Dhan API - Live M2M

So I have been using Dhan’s API only for a week or so and while working on an algo I kind of wanted the live M2M/PnL of my current positions, so I expected to fetch those using the get current position from the API methods, but the value of the key ‘unrealizedProfit’ seems to be ‘0’? I request the appropriate team to look into this, I don’t know if API’s are actually supposed to provide live M2M/PnL but it’d just be great to have it.

Thanks and Regards

Hi @ayan, welcome to Dhan community.

Trading APIs usually do not provide M2M / PnL. This is a derived number, which is sum of all your positions at that time and it can be easily calculated.

Even in our apps, this is derived as a sum from open positions, not passed over via API. If it is done via API - this may actually be a delayed P&L by some micro seconds.

Thanks @PravinJ for the reply, had already written the code for that, was just looking for a way to reduce my system’s latency further, thanks for the reply though, really appreciate it.

Most welcome Ayan, and see writing code for that is much faster :slight_smile: