Holding price and partial stock selling esp when stock price is falling

Hello Team,

Apologies for the naive question. I did see avg holding price calculations examples in forum but I am specific to the share price when its falling.

I have a clarificaiton regarding the holding avg price calculation in case of delivery product type / CNC. Would like to understand related to the partial selling when the stock price is esp falling. Checked in internet that FIFO is been used, when trying to sell stock, so would like to understand it with example

Buy 10 @ 100
Buy 10 @ 90
Buy 10 @ 80

based on the above, the holding price is calculated as
(100x10 + 90x10 + 80x10 ) / ( 10 + 10 + 10 ) = 90

holding avg price = 90
holding qty = 30

now if the current price is 95 and if i sell as below

Sell 10 @ 95

below are the clarifications related to the PnL

Q: when 10 qty its sold, does it get calcualted like below,

= ( sell price - holding avg price ) x 10
= ( 95 - 90 ) x 10
= 50

in this case i am getting profit of 50

Q: or does it get caluclated using FIFO method

= ( sell price - last old trade price ) x 10
= ( 95 - 100 ) x 10
= -50

in this case I am incurring a loss of -50

Pls help me understand which approach its followed and what is my PnL calculations

Regards,
Kartik

It works on a FIFO basis, so the sell is matched against your first buy (10 @ ₹100), giving you a −₹50 loss on that trade.

Your fresh buy average after selling will be: (90×10 + 80×10) / 20 = ₹85 with 20 qty remaining.

Thank you @Adarsh_Patil

Q : but in the zerodha holding page, for every LTP in real time, the unrealised profit and loss values is shown based on the average holding price

Correct. When you sell part of your holdings, the average price changes based on the remaining quantity in your portfolio. Your unrealized P&L will then be calculated using the new average buy price.

Thank you @Adarsh_Patil