In the Position tab, the P&L is updated based on the average buy and average sell prices, including open positions. However, the P&L in the Trader’s Diary is updated based on closed positions (using FIFO and/or speculation basis).
Lets understand with an example shared below :
#1 Scenario
On 1st Jan, you bought 10 quantities of ABC scrip at ₹20 = ₹200 (buy value).
On 2nd Jan, you have again bought 10 quantities of ABC scrip at ₹30 = ₹300 (buy value).
On 5th Jan, you sold only 10 quantities at ₹35 = ₹350 (sell value).
Here, as per FIFO method, your first purchase at ₹20 will be netted-off against the sell order placed on 5th Jan showing a gross profit of ₹150.
#2 Scenario
On 1st Jan, you bought 15 quantities of option contract at a premium of ₹100 = ₹1500 (buy value).
On 2nd Jan, you closed the same position at ₹120 = ₹1800 (sell value), and booked a gross profit of ₹300.
On 2nd Jan, you have again bought the same quantities and same contract at ₹200 = ₹3000 (buy value).
Here, as per multiple trade in same scrip on same day, the Trader's diary will considered the speculation/intraday trades first and reflect a loss of ₹1200 (₹1800-₹3000=1200), and your first purchase of ₹100 will be carry forwarded until closed.
Please note in the above scenario, the system will display the average price of the last bought order i.e ₹200 in the position tab. However, your actual buying average will be ₹100.
We have shared a detailed explanation on how Trader's diary works here.