RuntimeWarning: coroutine 'DhanFeed.connect' was never awaited
self.connect()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Connected to websocket
Connected to websocket
from dhanhq import marketfeed
import credentials
# Structure for subscribing is ("exchange_segment","security_id")
# Maximum 100 instruments can be subscribed, then use 'subscribe_symbols' function
instruments = [(0,"13")]
# Type of data subscription
subscription_code = marketfeed.Quote
# Ticker - Ticker Data
# Quote - Quote Data
# Depth - Market Depth
async def on_connect(instance):
print("Connected to websocket")
async def on_message(instance, message):
print("Received:", message)
# Received: {'type': 'Quote Data', 'exchange_segment': 0, 'security_id': 13, 'LTP': '22331.25', 'LTQ': 0, 'LTT': '14:56:38', 'avg_price': '0.00', 'volume': 0, 'total_sell_quantity': 0, 'total_buy_quantity': 0, 'open': '22048.30', 'close': '21982.80', 'high': '22348.40', 'low': '22047.75'}
print("Subscription code :", subscription_code)
feed = marketfeed.DhanFeed(credentials.client_id,
credentials.access_token,
instruments,
subscription_code,
on_connect=on_connect,
on_message=on_message)
feed.run_forever()
This code was working few days ago. But this code also gives same error:
RuntimeWarning: coroutine 'DhanFeed.connect' was never awaited
self.connect()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Connected to websocket
Connected to websocket
FYI: I have access to Data APIs from Dhan until 04 Apr 2024.
Request you guys to help me on this critical issue.
This is not an error but only warning, and this would not stop your code from running. If markets are live and you have subscribed to correct security ID, then you will receive data on the sockets as well.