In your script, create a stock movements table based on the rows you specified in the first list. The movements table has a single date column, a single movement quantity column and a single product column.
First store the stock additions in this table (only rows with Item, Quantity and Purchased Date), like:
Item
Apples
Mvt Qty
100
Mvt Date
01/01/2015
Oranges
50
03/01/2015
Pears
25
02/01/2015
Apples
200
02/01/2015
Then add the stock subtractions (only rows with Item, Quantity and Sales Date). Negate the Quantity.
Item
Apples
Mvt Qty
-100
Mvt Date
03/01/2015
The order is unimportant. Showing stock levels on a certain date now becomes very simple.