How is STT calculated?

In this case, Average Price = [First Buy (500*100) + Second Buy (200*110) + Sell (500*105)] / [First Buy (500) + Second Buy (200) + Sell (500)] = 50000 + ...