Market depth in algo trading

@Tradehull_Imran Hi Imran,

The New feature of Full market depth in dhan is great. However, for my algo needs, I want to have a display on my terminal the Bid (min) and Ask (max) values.
Example: if Stock A LTP is 100, the BUILD UP at BID (min) may be at 90, and Ask (max) may be at 102. I want to display BID (min) of 90 and ask (max) of 102 through my algo. what command needs to be used. please do let me know. This would be of help in getting to know the trade direction for intraday. Basically, i should get the Spread of Depth on my algo terminal, is the requirement.

Hi @Anil_kumar18 ,

refer the below code:

quote_data = tsl.get_quote(names = 'ACC')
bid = quote_data['ACC']['depth']['buy'][0]['price']
ask = quote_data['ACC']['depth']['sell'][0]['price']

ok. @Tradehull_Imran . Thanks… i will look into this…

@Tradehull_Imran , Hi Imran, I did implement the code provided by you. Thanks. Here is the result…

My requirement is as follows:

BIOCON is trading at LTP : 390.6, Max/Highest Ask value is at 395, and Min/Lowest Bid value is at 385.7 I want these values to be captured on my terminal. Also, the Total Buy Quantity and Total Sell Quantity displayed on terminal doesnot match with the BID/ASK display from tv.dhan.co . Please suggest.

do we need to subscribe to data api to get market depth? @Tradehull_Imran

Hi @Tradehull_Imran , Please reply at the earliest… Thanks

Hi @lotus ,

Yes, you need to subscribe to data api.

Tagging @Hardik and @Dhan for the same.

Hello @Anil_kumar18

Over here, are you looking for Bid/Ask total quantity or best bid/ best ask quantity. It is a bit unclear over here.

Also, which field are you referring for total buy/sell quantity.

Hello @Hardik ,

 This is in reference to the New updated BID/ASK menu feature available in tv.dhan.co. 

Here , Biocon is trading at LTP 390… as per the BID/ASK menu, there are several BIDS below the ltp and several ASK above the ltp. i want to capture Lowest BID from this menu and the highest ASK from this menu in real time in my algo.
Additionally, the Total BID/BUY Quantity and Total ASK/SELL Quantity should be captured in realtime in my also.
My algo code is as below for reference:

Please suggest…

Hi @Hardik

I am looking for the Lowest Bid, and Highest Ask (spread) , in real time to be used in my algo.
Along with this, i want the Total Bid/Buy qty and Total Ask / Sell qty. in realtime to be used in my algo

Hello @Anil_kumar18

You need a working code for this here?
I can see the values already printed in code screenshot. What is the issue that you are facing with this?

Hi @Hardik

I am looking for the Lowest Bid, and Highest Ask (spread) , in real time to be used in my algo.
Along with this, i want the Total Bid/Buy qty and Total Ask / Sell qty. in realtime to be used in my algo

Hey @Anil_kumar18

I got this. If you are using Dhan Python library, it has 5 level market depth added and we will be soon adding 20 level depth as well.

You can sort bid/ask at your end to get these values. Coming to total bid/ask, you can use the fields available in Full Packet of Live Market Feed.

hi @Tradehull_Imran is full market depth available through API ? currently i can see 20 market depth. when can this be available. Thanks

Hello @dhimanvikas

Full market depth is not available on APIs as of now. The data packets are too large for us to stream. Will keep you updated in case we bring this up on DhanHQ.

Hi @Tradehull_Imran ,
Thru the api, is it possible to have historical monthly candlestick data. If so, pls. give the subprogram or command line.

:joy: :joy: :joy:

Hi @Anil_kumar18 ,

refer the below code:

    data = tsl.get_historical_data('NIFTY', 'INDEX', 'Day')

@Tradehull_Imran Hi Imran,

In the Trade hull _ V2, Program,

the current code provides historical CANDLESTICK data upto the previous day. i.e. yesterday. what change needs to be done so that i need to get the current day candle stick data aswell.