Let's assume below as my transactions:
bought 10 at 120 bought 20 at 150 sold 15 at 170
What will be the average price of my holdings i.e., for 18 shares.
Is it 110 ?
Your sheet shows math. OK math, but probably not good accounting for taxes. You can set up your account for FIFO (first in first out) LIFO (last in first out) or specific shares identified by lot. Average cost basis is available, and you did the math right, but it is less common, and not a default broker choice. Some also offer a tax optimized sale choice, which would choose higher cost lots for short term gain, or longer term lots to capture long term cap gains.
Note: The choice has to be made with the broker prior to the sales. You don't get to choose after the fact.