Hi team, I have been trying to subscribe 200 instruments, but can not. Somehow dhanhq python library throws an error. I have tried with multiple instruments list and can not find any solution… Can you please help me resolve this. Thanks in advance.
My code -
# More basic code here, main code starts below
async def on_connect(instance):
print("Connected!")
async def on_message(instance, message):
print(message)
feed = marketfeed.DhanFeed(client_id=client_id,
access_token=access_token,
instruments=instruments[:100],
subscription_code=subscription_code,
on_connect=on_connect,
on_message=on_message
)
print(f'Total subscribed instruments right now: {len(feed.instruments)}. Subscribing more...')
feed.subscribe_symbols(subscription_code, instruments[99:200])
print(f'Total subscribed instruments right now: {len(feed.instruments)}. Going to run feed now.')
feed.run_forever()
My error:
C:\___DHANHQ_PACKAGE_LOCATION_HERE___\dhanhq\marketfeed.py:79: RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Total subscribed instruments right now: 100. Subscribing more...
Total subscribed instruments right now: 200. Going to run feed now.
Connected!
Connected!
Connection has been closed
Yes, just reviewing this. There are open PRs for this, will merge from the same post testing and update. I will post it here as soon as it is reviewed and merged.
Also, could you confirm what is the max limit (if any) that would be supported? Suppose I want to track all f&o stocks (~ 200) + their futures and ATM options, that means approx 1k-2k stocks. Will the websockets be the right choice?
Or are you guys also working on a polling mechanism for getting a large number of LTP and OI data since not everyone will need the whole stream and some may only need the data on on-demand basis when their script runs.
Yes, on the websockets, you can get live data stream of upto 5000 instruments on a single websocket, which is an efficient way when you are trying to poll data for large number of instruments at a single time.
On the LTP API, we are looking into feasibility of delivering data via this method.
Thanks @Hardik, look forward to the library update.
for the polling api, you could keep a very small rate limit (e.g. 10 times per minute), so that people don’t misuse it when the streaming api was a better choice.
Hi @Hardik , it’s been a week, is there any ETA for this? I’m paying monthly charges for the data api but it doesn’t work as advertised (yet). Hope you understand.