Hi guys, i'm currently using excel to record and keep track my stock counter trading. After multiple time of buying and selling of the stock, i like to find a way to check my balance stock average cost.

Below is the record:

------------------------------------------------------------------------------------------

Share trading record

Counter: Facebook

Record
Date transaction price unit amount type
2/1/2016 buy 110.00 50 5500 cost
3/1/2016 sell 120.00 30 3600 proceed
4/1/2016 buy 115.00 20 2300 cost
8/1/2016 buy 110.00 30 3300 cost
9/1/2016 sell 125.00 70 8750 proceed
10/1/2016 buy 120.00 50 6000 cost
15/1/2016 buy 125.00 20 2500 cost
16/1/2016 sell 140.00 40 5600 proceed

total buy = 170 unit
total sell = 140 unit
balance = 30 unit

Balance of 30 unit is consist of 20 unit bought on 15/01 @usd 120 and 10 unit bought on 10/01 @usd125.00

price units amount
120 10 1200
125 20 2500
30 3700

Average cost of Facebook share on hand = 3700/30
= 123.33


Possible to use excel formula to automated the calculation of the Average cost of Facebook?