Hello,
I have data from stock exchange, all my data is in a single file, I have data about purchases and sales. I want to associated on my sales data the date of purchase.
Example to illustrate what I want to realize : I have in my data.
Date | Purchase/Sales | Quantity |
01/10/2011 | P | 24 |
27/02/2012 | P | 28 |
24/08/2012 | S | -15 |
05/02/2013 | S | -8 |
12/02/2013 | S | -27 |
Sales Data (Purchase/Sales = S), I have for sale 24/08/2012 15 titles, its corresponds to purchases of 01/10/2011 because it is the earliest date.
Then I sold 8 titles on 05/02/2013 , as I sold 15 titles before , in the purchase of 01/10/2011 , I have 9 titles ( 24-15 = 9) , so for sales of 05/02/2013 , I make the date 01/10/2011 .
I dont know if I'm clear, but here the result i want :
date | Sales | Quantity | Date Purchase |
24/08/2012 | V | -15 | 01/10/2011 |
05/02/2013 | V | -8 | 01/10/2011 |
12/02/2013 | V | -27 | 27/02/2012 |
Thank you in advance for your help.