Hello,
I am having a hard time creating a flow that has a running total of sorts. I essentially need a LIFO/FIFO flow, but instead of the first shares or last shares being closed first, I need to have the highest cost price closed first. I have sample data attached.
I have reviewed the other community posts on FIFO and LIFO, but I am still having trouble fitting those flows into my data.
Example:
724 & 91 shares are traded at the same price they can be group if its easier to calc
the 122 shares are at a new price --> the -14 shares need to be closed out at the 122 share price, leaving a balance of 108.
the -154 shares first must take the higher price of 21640.09 of the remaining 108 shares, and then the delta of -46 shares needs to be closed at 21375.19
etc, etc, etc all the way down to the final