**Equation solving problem - Post trade allocation**
HI everybody.
for my job i need to set up and solve an equation. I need to allocate trades to multiple account with the same average buy price. For example.
I bought 100 shares: 2 at 2.50 37 at 2.54 41 at 2.56 and 30 at 2.60. Then i need to allocate, out of the 100 shares, 40 shares to account1, 33 shares to account2, 7 shares to account3 and 20 shares to account4. - all of the account must have the same average buy price (2 to 3 digits must me equal, after it can vary.) - you can not divide a share, so only plain numbers. - all the shares must be allocated. - the algorithm should work with 10+ accounts and 50+ different shares prices.
it's 2 weeks I work on this, have approximate solutions, but the the correct equation and integration in matlab, I don't! see some help!
Thank you!!
Matgoo |