Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8554343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:51:40+00:00 2026-06-11T14:51:40+00:00

I have a problem where I have multiple (few thousand) quantities that I need

  • 0

I have a problem where I have multiple (few thousand) quantities that I need to split between a set number of recipients such that each quantity must be split into whole numbers and using the same proportion.
I need to find an algorighm that implements this reliably and efficiently (dont we all ?:-) )

This is to solve a problem in financial markets (stock exchange orders) where an order might get thousands of “fills” and at the end of the day must be distributed to a few clients while maintaining the order’s average price. Here’s an example:

Total Order Quantity 37300

Quantities filled by the Stock Exchange

Execution 1. 16700 shares filled at price 75.84

Execution 2. 5400 shares filled at price 75.85

Execution 3. 4900 shares filled at price 75.86

Execution 4. 10300 shares filled at price 75.87

Total 37300 shares filled at average price = (16700*75.84 + 5400*75.85 + 4900*75.86 + 10300*75.87) / 37300 = 75.85235925

Suppose I need to split these quantities between 3 clients such that :

Client1: 15000 shares

Client2: 10000 shares

Client3: 12300 shares

Each execution must be split individually (I can’t just take each clients requested quantity priced at average price)

My first thought was to split each proportionately :

Client 1 gets 15000/37300=0.402144772

Client 2 gets 10000/37300=0.268096515

Client 3 gets 12300/37300=0.329758713

Which would lead to

Client1 – 15000 Client2 – 10000 Client3 – 12300
Ratio : 0.402144772 Ratio : 0.268096515 Ratio : 0.329758713

Splits (Sorry about the formatting – this was the best I could do in the Post editor)

+-------------+-------------+-------------+
| Client 1    | Client 2    | Client 3    | 
+-------------+-------------+-------------+ 
| 6715.817694 | 4477.211796 | 5506.970509 | 
| 2171.581769 | 1447.72118  | 1780.697051 |
| 1970.509383 | 1313.672922 | 1615.817694 |
| 4142.091153 | 2761.394102 | 3396.514745 |
+-------------+-------------+-------------+
| Totals:     |             |             |
|       15000 |       10000 |       12300 | 
+-------------+-------------+-------------+

The problem with this is that I can’t assign fractional quantities to clients so I need a smart algorithm which adjusts the quantities such that the fractional part of these splits is 0. I understand that this may be impossible in many scenarios so this requirement can be relaxed a little bit so that a certain client gets a little more (or less).

Does anybody know of an algorithm that I can use as a starting point for this problem ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:51:41+00:00Added an answer on June 11, 2026 at 2:51 pm

    You can round all the numbers (ratio[n] * totalQuantity) except the last one (possibly the smallest) The last one must be the totalQuantity – sum of the others. This will give you whole number quantities while having a correct total as close to the ratios you choose.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem is this: I have multiple competing threads (100+) that need to access
Hi The problem am having is that I have multiple TreeView control and each
i have a problem calling multiple instance of a class that i have coded
I have a few separate application projects (EARs) with multiple EJBs that I want
I have a very annoying problem that I've been struggling with for a few
I have multiple sections... within these sections there are few child elements... I need
Here's the situation: I have a web-based ticket application, multiple users. One problem that
I have a problem conserning uploading multiple files to my ftp server and I
I have segmentation fault problem with my multiple class files project. Without making empty
i have a problem with triggering the multiple alarm at first time , here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.