Closed PraveenChordia closed 1 year ago
Hi please share the on message and on error functions, also which tokens you are subscribing for, please share the request.
Hi, Below is the code which is working most of the time. But sometimes i get below message after 2-3 minutes of calling quote API
[OnClose]: Function is running HSWebsocket 1000
I run this code in a loop for every 5 milli second and I get this message in live trading ~3 times in 2 hours.
I guess this should not stuck for ~3minutes instead it should return error.
''' from neo_api_client import NeoAPI
def on_message(message): print('[Res]: ', message)
def on_error(message): result = message print('[OnError]: ', result)
ks_client = NeoAPI(consumer_key=consumer_key,consumer_secret=secretkey,environment="prod",on_message=on_message, on_error=on_error)
inst_tokens = [{"instrument_token": "BANKNIFTY23SEP44400CE", "exchange_segment": "nse_fo"}]
dat = ks_client.quotes(instrument_tokens = inst_tokens, quote_type="ltp", isIndex=False)
print (float(dat['message'][0]['ltp'])) '''
Thanks and Regards, Keerthi
You must pass the instrument token for the options contract, not the trading symbol. If you refer to the scrip-master file for nse_fo, the first column, "pSymbol," contains the instrument token of the respective option and future contracts.
when I try to access quote, I get the following:
[OnClose]: Function is running HSWebsocket 1000
Any suggestions why I am getting this message?