Dhan_TradeHull Data API Rate Limit

Hi @Tradehull_Imran

I started watching the Dhan TradeHull algo trading series/playlist on YouTube.
Great Series! Great Work!!

As we were trying to fetch data using, Dhan API, data retrieval was taking time as mentioned in the video => https://youtu.be/Lb70i1zdolw?list=PL9XPiw_IKs3bpAHD9lhSMXBZV_RBwkqui&t=1748

One thing, I noticed is that time.sleep is added at several places in Dhan_TradeHull.py file. Could that be slowing down the data retrieval from Dhan? For example, get_historical_data method has 2 seconds delay added before fetching the data.

Can we use something like below in Dhan_TradeHull library?

data_api_frequency_per_second = 10
data_api_delay_between_calls = 1/data_api_frequency_per_second
data_api_last_call_time = None

method =>get_historical_data:
while( (current time - data_api_last_call_time) < data_api_delay_between_calls ):
time.sleep(data_api_delay_between_calls)

data_api_last_call_time = current time
#fetch and return historical data

OR

may be if this delay is removed from Dhan_TradeHull codebase, it could be handled in framework code as well (may not be a clean approach)

Hi @TradingHuman ,

yes we were using time.sleep() explicitly it older codebase versions… now in newer versions this has been fixed.
see : Dhan-Tradehull · PyPI

Great!