PnL & other fields way off

I am comparing some values from an overnight option long position “API Response vs Upstox pro” platform.

Many parameters look just way too off? Could you please take a look.

Response from (portfolio/short-term-positions) API:

{
    "status": "success",
    "data": [
        {
            "exchange": "NFO",
            "multiplier": 1.0,
            "value": 522.5,
            "pnl": 435.0,
            "product": "D",
            "instrument_token": "NSE_FO|61566",
            "average_price": 10.45,
            "buy_value": 0.0,
            "overnight_quantity": 50,
            "day_buy_value": 0.0,
            "day_buy_price": 0.0,
            "overnight_buy_amount": 969822.5,
            "overnight_buy_quantity": 50,
            "day_buy_quantity": 0,
            "day_sell_value": 0.0,
            "day_sell_price": 0.0,
            "overnight_sell_amount": 0.0,
            "overnight_sell_quantity": 0,
            "day_sell_quantity": 0,
            "quantity": 50,
            "last_price": 8.7,
            "unrealised": -969387.5,
            "realised": -0.0,
            "sell_value": 0.0,
            "tradingsymbol": "NIFTY23AUG19800CE",
            "close_price": 8.65,
            "buy_price": 19396.45,
            "sell_price": 0.0
        }
    ]
}

Questions:

  1. Upstox Pro website shows correct pnl of -87.50. API showing different value ("pnl": 435.0)?
  2. Upstox Pro website shows correct unrealised pnl of -87.50. API showing very large number ("unrealised": -969387.5)?
  3. Upstox Pro website shows correct overnight buy amount (50 * 10.45 = 522.50). API showing something else ("overnight_buy_amount": 969822.5)?
  4. Upstox Pro website shows correct overnight buy price (10.45). API showing something else ("buy_price": 19396.45)?

These are very basic fields & I expect them to be correct. So I am not sure whether it is a bug or my lack of understanding of what these numbers mean???

2 Likes

Any update? This pnl fields are critical.

I have passed on your query to the concerned team and will get back to you soon.

Thanks.

Thank you so much @Pradeep_Jaiswar

Please note that intraday position pnl is correct. However, all pnl values seem to be calculated on a little delayed LTP. This is just by a visual comparison of pnls.
If possible, please use the latest ltp for pnl calc.

realized_pnl value is also wrong for overnight positions.

We were planning to add Upstox in our system & this one issue affecting many of our Upstox users to switch to the APIs.

Having wrong pnl is extremely critical issue & needs to be addressed on priority.

Understood. We appreciate you bringing this matter to our notice.

As previously mentioned, we are actively addressing this issue with our technical team as a top priority. We will provide you with an update as soon as possible.

@Pradeep_Jaiswar Any expected timeline for this? How come such a basic bug remained unnoticed for so long & why is this not being taken on priority?

I hope the team understands the importance of PnL numbers?

We understand the significance of PnL figures.

At the moment, PnL numbers are calculated using the LTP cache, which has a 1-minute delay. We are planning to decrease this cache duration, with the ultimate goal of bringing it much closer to real-time.

We will be prioritizing this with our internal team and be assured that once we implement this adjustment, we will promptly notify you and continue to provide timely updates based on priority.

@Pradeep_Jaiswar It is okay, take your own time…

Looks like I am the only one pushing for this. None of my clients even bothered to put a comment on this.

It is not affecting me, it is only affecting the clients using our app & they do not seem to care !

Hi @priteshmhatre,

We assure you that our team is actively working on a resolution for this.

However, we request a bit of patience as this will take a reasonable amount of time to fix it.

Thanks.

Almost 2 months & you still expect me to keep patience.

I am putting this on social media now, this is absolute unprofessionalism.

Hi @priteshmhatre,

First of all, thank you your patience and brining this to our attention.

We had released updates to our Positions API a couple of weeks back, which we would recommend you to test again at your end.

However, having said that we would like to address the point that there will be a cache of upto 1 minute for response from Positions API so you might see a slightly outdated P&L for your positions

To get the current and real-time P&L, you can get LTP of the instrument via websockets and use the below formula to compute your current P&L
pnl = (buy_value - sell_value) + (quantity * multiplier * ltp)
(All fields are available in the response of the API)

Hope this helps.
Let us know in case of any other queries or if you would like to connect with our team.

Any update on this? I am noticing it even now and just came across this thread. It’s been more than 8 months now and it’s hard time there should be a timeline to fix this critical issue.

Let me know if I’m missing anything.

Agreed, but this computation must be at the API end. Client applications must not have computation logic.

@Agent007, We’ve cleared the LTP cache and switched to real-time processing. Could you please check and confirm from your end?