Kotak-Neo / kotak-neo-api

120 stars 112 forks source link

what is right way to use call back function for Client.quotes and client.subscribe #181

Open Hari3115 opened 5 months ago

Hari3115 commented 5 months ago

Both Client.quotes and client.subscribe returning None after updating to Python SDK v1.2, issue was not there in previous version. Anyone was able to solve this? #157

AaryaNaik321 commented 5 months ago

same issues is happing with me related to the client.quotes i was try to abstract the ATM value when i assing the variable to the client.quotes it gives none as an input if anyone has solution then let me know

AaryaNaik321 commented 5 months ago

my code ltp = client.quotes(instrument_tokens=inst_tokens, quote_type="ltp", isIndex=False) atm = str(round(float(ltp['message'][0]['last_traded_price'])/50)*50)

sudhanshupati commented 5 months ago

have you checked the "client.on_message = on_message". For me if I call Client.quote , i get the ltp in on_message method

Hari3115 commented 5 months ago

can you share your on_message method code

sudhanshupati commented 5 months ago

inside on_message I am storing the data in a dictionary

Hari3115 commented 4 months ago

anyone able to actually get a response from the call back function? what is the method that works?

sudhanshupati commented 4 months ago

below mention a sample code from on_message method def on_message(message): if message['type'] == 'quotes': print(message)

do your operation

When you call the quote method it will return None but the result will be print inside on_message

Hari3115 commented 2 months ago

The problem was launching jupyter from anaconda, when i launched the jupyter notebook directly, the callback function worked fine. I m not sure why, but it worked.