0
donuts
4y

Anyone know how to fix this efficiently? I'm calculating Realized gains but the output is ~ $120.

Because it's using the avg cost as the sales price of each share.

However what it should do sell the shares using FIFO.

But I can't think of how to efficiently track the purchase prices to use without replaying all the trades and tracking every single share that is bought and sold.

Like:
B1 100
S1 50
B2 100
B3 40
S2 70 (50 B1 20 B2)

Comments
  • 1
    I'm having trouble here.

    Mostly because the coords don't explain themselves (B - Buy, S - Sales?) and look like a coordinate system.

    Otherwise. Your plan sounds foolproof.

    Unless you do it over and over again, that seems to be the plan.

    If you do it again and again, tracking changes will be helpful
  • 0
    @IntrusionCM buy sell yes.

    So when reading in, start at the beginning. And I guess like you said can save the current positions using like X shares, Y price, Z date so when reloading can skip all the older ones at least for committing the current position
Add Comment