Interpolation with non-linear information... FIFO

C

Chris

I am trying to interpolate between data. Imagine the following situation:

Stock trade: Trade Price: Consideration: FIFO Cash:
+100,000 2.50 250,000 0
+50,000 2.75 137,500 0
+225,000 3.00 675,000 0

Then I sell: -184,250 @ 3.40
The resultant cash that is due from these trades is calculated on a FIFO
basis (First In First Out). So the calculation would be (100,000
*(3.40-2.50) + 50,000 *(3.40-2.75) + 34,350 * (3.40-3.00)) = 136,240. But I
want to add a column that does this automatically. I.e.:
Stock trade: Trade Price: Consideration: FIFO Cash:
+100,000 2.50 250,000 0
+50,000 2.75 137,500 0
+225,000 3.00 675,000 0
-184,250 3.40 626,450 +136,240
The cash line would also need to be able to go the other way... i.e. if had
sold first and then hit a buy, what is the cash flow on a FIFO basis.

Any ideas how I can do this??
 
Top