Getting the following RuntimeWarning while subscribing to the FyresSocket and no data is received

Access_token = ENV_DATA.get('CLIENT_ID')+":"+access_token
data_type = "symbolData"
symbol=["MCX:CRUDEOIL21SEPFUT", "NSE:INFY-EQ"]
def custom_message(self):
print(self)
ws.FyersSocket.websocket_data = custom_message
fyersSocket = ws.FyersSocket(access_token=Access_token, data_type=data_type,symbol=symbol)
fyers-apiv2 version 2.0.4
any help is appreciated
add fyersSocket.subscribe() at bottom and try once.
Hi @immaturetrader
Thank you for the reply, when calling the subscribe method I am getting RuntimeWarning.
https://stackoverflow.com/questions/54088263/runtimewarning-enable-tracemalloc-to-get-the-object-allocation-traceback-with-a
Does this make any sense to you,
asyncio
Package is a Dependency for the Fyres websocket, so probably I am messing with some dependency. Not able to find it though@Arun Babu
I hope below stuff works:
Are you running socket connection in an async mode. If so change it to run on main thread and use threading instead of async.
As in fyers_api -> ws.py file they have created a new event_loop to parse message(binary to str, using asyncio). You cant create multiple loops within, so try threading instead.
I have spent 2 days on this issue and couldn't resolve, lets wait for a rollout update clearing all boiler plate code.
Try printing self.response and not self in socket connection, self acts as a pointer.
Hi Arun I am guessing you are using jupyter notebooks, please try it in nomal .py file.... if you really want to use it in .ipynb files, you have to add another dependency, nest_asyncio.
try this...this works on my computer..
###############---- WEBSOCKET Stuff-------------
data_type = 'symbolData' #(for symbol websocket the data_type has to be “symbolData”)
symbol =['NSE:SBIN-EQ']
access_token=client_id + ':' + ac_t
# (This is the custom message function which we need to have in order to receive the Symbol/order update and accordingly you can manipulate the data you receive through this function )
def custom_message(self):
print ("Custom " + str(self.response))
ws.FyersSocket.websocket_data = custom_message
fyersSocket = ws.FyersSocket(access_token=access_token, data_type=data_type,symbol=symbol)
fyersSocket.subscribe()
time.sleep(60)
@TH3 PIRAT3 Thanks man. I am not using jupyter notebook but using spyder in a conda env
I was able to connect to socket and get data, by running it as a plain py file from the terminal, but still having the same issue if I try to run it from spyder in my conda env
list the imports please...
Use this code for the Websocket
https://github.com/SHIVANIUM-GIT/fyer_api_websocket