No option to find LTP of a stock in Dhan API

First of all, Dhan api looks simple compared to other broker API. Under one account we can have multiple APIs and that is really a lifesaver.

But,

All my strategies are required to fetch the LTP of a stock. And after 2 days of exploring API, I came to know that API does not have a function to fetch LTP. And your current documentation is really useless. Please create a new and useful documentation.

1 Like

Hello @Dhanu

We are coming up with Live Market Feed soon. It is already #4 on Upcoming Features on Dhan: For Feb & Mar 2023.

We have maintained all standard documentation practices. Would love to hear your approach too. Is it possible for you to drop a note at api@dhan.co regarding the same and we will go through it.

1 Like

Cant fetch LTP via API ?!?!?
And here I was looking to move some to Dhan.

Hi @VijayNair

Welcome to the Dhan community

Our team is already working on it, and we will keep you updated as soon as possible.

Any chance of this getting implemented in June 2023 ?

Hi @VijayNair, yes we hope to bring this up soon.

1 Like

@Divyesh @PravinJ

This is actually a very important missing link. Even all my trading through algo or my custom ordering application depends on fetching LTP of stock or index to pick the appropriate option before order is placed. Hence I’m unable to trade effectively with Dhan. I don’t want to integrate other broker’s API to fetch LTP to make it work with Dhan.

Please add LTP feature ASAP in a simple manner. I’m told you’re working on webhooks for LTP? Why can’t there be a simple function to get LTP?

Hello @Djain

We are working on websockets and not webhooks to provide you with Market Data as part of our API offering. Yes, there has been delay in the development of the same, but we are committed to deliver the best.

The reason for developing Websocket and not LTP over API calls, is because websocket helps providing a continuous connection, where your system can receive price feed continuously, without you having to poll data at specific interval. This helps you receive market feed data streaming enabling your system to trade better.

Hello Hardik,
Thanks for the update! But I hope Dhan team understands that all other brokers provide LTP through APIs. All our codes are designed to work with those. For order placing a stream of LTP is not required, only a quick hit to API to get latest LTP of a stock/index is needed to decide which option we need to buy/sell, and then the order is placed.

While I agree websockets may provide continuous stream of LTP data, it also adds new complication to existing codes and may require a lot of rework. Additionally despite the best of efforts, websockets can loose reliability at times. Websocket is also not ideal in cases we pick an option and place order, but need that option’s LTP to set SL or target. Having websocket open for multiple options is not ideal.

Can Dhan team please try to provide a simple API call function for LTP in orders API in addition to websockets that you are already developing? May be put a limit on LTP API calls in case you are worried about server load or misuse.

Thanks,
DJ

Hello @Djain

Yes, I can understand your use case. But at the same time, a websocket connection can help you handle these very same use cases as well. In addition to this, it is also more stable and updates realtime, making it easier for your strategy to get edge.

In addition to this, there is always rate limiting in APIs which might hinder your deployed strategy, in case where your polling rates are not within limits. We will explore this moving forward, to deliver market quotes over API. But currently, we are focused on providing Live Market Feed first.

Thanks!
I hope to see LTP web sockets soon so that I can start my full fledged trading journey with Dhan!

I agree with @Djain . Many of us like to poll ltp only every 30 sec - 1 to 5 minutes - and for that websocket may not be the best way or atleast not how many programmers like to work.
I am surprised you guys are doing websockets without providing a basic simple way of querying ltp.

Let me explain the main options use case again for LTP via API calls.

Lets say NIFTY is at 18120. So to get the index LTP may be we can use websockets and they are even better! But lets say at this level algo decides to buy an ATM option. So based on the latest NIFTY LTP, the option chosen is 18100 CE. This is the first decision algo has to make based on LTP data.

Now the second decision is to decide the Stop Loss and Target values for the chosen option. Since these values must be given at the time of order placement, the LTP data of the 18100 CE option will also be needed. Now it is impractical to have a websocket open in advance for this particular option. Are we suppose to open tens of websockets for different options in advance? The algo will pick a particular option instantaneously and would seek the LTP after that choice, hence opening a websocket at that point will cause delays.

THIS IS WHERE the websocket concept for LTP fails as we cannot have websockets open for the entire option chain without straining our and Dhan’s systems. A simple solution is to allow LTP through API calls. Total of 2 calls will be made, one to NIFTY Index LTP and the other for the chosen option LTP! This also prevents us from added unwanted complexities in existing algos!

I know Dhan team may look into this in future, but please understand IT IS A MAJOR GAP in your APIs right now. I literally have custom built scalp ordering systems that I cannot use with Dhan and I am certain there are many more traders like me.

Attaching a screenshot of one of my custom ordering software to help you understand that I am bringing this issue up as a serious trader! This system is modified for Dhan and places instant option buying orders on user input and picks the option itself based on parameters and NIFTY/BNF LTP. Also allows instant covering of last order in partial or complete basis. Ideal for scalpers! Currently I have to use a 3rd party API to get Nifty/BNF LTP which causes delays and I am unable to implement SL/Target or BO orders due to missing LTP for options.

1 Like

Hello @VijayNair and @Djain,

On websockets, you can subscribe and unsubscribe to as many instruments as you want. This will become more clear once the same has been released.

Especially, in the example highlighted by @Djain where one needs to constantly monitor their position and take trades via Algo, it is beneficial to have continuous stream of data rather than polling at intervals to capture market trends.

Not always, especially with Options. Infact I prefer polling less frequently. I have also seen reports of frequent disconnects with other brokers and some then use ‘polling ltp via api calls’ as a fall back.

Anyways, I’ll wait till you are able to facilitiate ltp via api calls.

True.

Polling each option is highly inefficient (even if we poll 3 ITM and 7 OTM each of PE and CE, i.e. 20 scrips for one index).

So if we are tracking NIFTY, BNF and FNIFTY, we will have up to 60 open websockets? Not at all a good solution.

I guess I will also put on hold trading and my algo modifications with Dhan till an effective LTP API call functionality is available.

@Djain

Over here, one aspect that is being overlooked is that you only need one websocket connection wherein you can have multiple scrips/instruments subscribed. So, there will not be 60 open websockets, but 1 single websocket with 60 instruments subscribed.

I believe it will be best if you try out the websocket first once it is released, and then you can let us know your feedback.

Oh cool. Let’s see when it rolls out. Any tentative date?
Thanks!

I just explored the dhan API for making youtube videos and also for my algo shifting, I didn’t find ltp(), it’s a basic thing, I read all the above questions and replies, and I wondered, the discussion started Feb 8, 2023, now Jun 13, 2023, I don’t know what they are planing really but really its too late. and also security symbols data is a bit raw, but that’s ok, I managed to clean it.

without ltp(), what’s the use of this API, is it just for placing the order not tracking the order? @Divyesh @Hardik @PravinJ @dhan

2 Likes