Variation in total p&l

deeps123
Hi,

I an calculating intraday p&l for my algo. The steps are
1) get all positions
2) foreach (Position position in trades.Day)
{
totalProfit = totalProfit + position.PNL;

}

The problem is I am getting inconsistent results.
I have sold
NIFTY MAY 15250 CE and NIFTY MAY 15250 PE at 9:40 AM today (24-may-2021)
I have not seen a change in the market between 5/24/2021 10:04:21 AM and 5/24/2021 10:04:53 AM
But there is a variation in the total profit of more than 400% without any market movement.

Is the way I am calculating profit is correct?

Following is the log from my application

At
5/24/2021 10:03:49 AM
Total Profit
3142.5

At
5/24/2021 10:04:21 AM
Total Profit
3142.5

At
5/24/2021 10:04:53 AM
Total Profit
772.5

At
5/24/2021 10:05:25 AM
Total Profit
3288.75


  • sujith
    You can go through this thread.
  • deeps123
    Thanks! Sujith.
    pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);

    Can you please let me know what is this multiplier
  • sujith
    The multiplier value is provided in the positions call only. This is required for currency and commodities positions where the trading unit and the lot size are not the same. For example, the lot size of USDINR contracts is 1 but 1 lot refers to 1000 quantity of the trading unit.
  • deeps123
    Thanks!
  • deeps123
    It worked. But the only thing is we need to use quote.LastPrice instead of position.lastprice
  • sujith
    Yes, you are right. The last price should be updated from live market data.
Sign In or Register to comment.