hey @vive1101011, this is not a bug. We don’t provide this data on APIs, most users who consume APIs can simply add P&L on all individual positions and get this with a simple query. We do the same and render combined P&L on the fly on Dhan platforms - you will see this is much much faster than all other platforms out there.
Why we don’t provide this - to get collective P&L from all positions on LTP that is changing dynamically and then streaming it - will result in lag & performance issues if we start streaming this.
Actually the problem is if quote api(getting LTP) not available to the individual investors then the only option left to calculate p&l is using /charts/intraday 1min candle close, which is delayed.
My two cents:
- Having an unrealised P&L (or even realised P&L) seem like a first class entity for any Position, and hence even at cost of some performance, the preference would be to have it coming from source rather than the clients getting LTP separately for each stock having a position and computing it. Majority of clients can bear a lag of ~1 second as they won’t be having an HFT use-case. Those having one would anyways fetch LTP themselves.
- I would feel the central source would be more optimised in terms of lag because of multiple requests coming in which can be pooled. It might be suboptimal if each of us client does it individually.
(Btw, if the proposal is to not provide unrealised or realised profits in the Positions API, why even keep those empty fields there, and leave room for confusion?)
Hoping the team would accommodate the above request
Fair point you have on this… and we did speak with many users while building APIs. Most, and when I say most its very high calculate this by themselves.
If you will see our implementation of P&L in any of Dhan’s platforms - App or Web, we render P&L much much faster than anyone else would, and we do it on the fly there itself. When we give P&L to users via APIs, it comes live from our trading systems and that basically will take it down (by load and hamper performance) as we will have to calculate this and transmit.
Additionally, many API users we have interacted with have their own source of LTP / Live Prices. So their use-case of trading is just resolved with trading APIs. Also our infrastructure cost of trading APIs is significantly lower than data broadcast APIs (live P&L). That helps us give Trading APIs for free.
We recently made Trading APIs of Dhan free: DhanHQ Superfast Trading APIs Update: Trading APIs are now FREE for all
Thank you @PravinJ for the prompt response
Sure, I can understand. Anyways, its not a burning problem for me, and can live without it.
I do feel that if any fields are not being populated, why to pass them unnecessary
Increases the payload and processing on client end.
Maybe the fields not being populated/used can be removed, also to remove any confusion and expectations
Hi @vive1101011 , were u able to calculate live pnl using positions and candles data?
I was not able to implement instant pnl as tick data is still not available on Dhan.
Algo Trader’s like us are Facing issues as
Ticker data is not available. We are unable to calculate PNL and SET SL in system.
Relying on Ohlc data of 1 minute candles will effect our system considerably.
Pls consider websocket a Priority.