from option_chain import OptionChain
import json
OptionStream = OptionChain("BANKNIFTY", "2022-12-04", "xxxxxx", access_token="xxxxxx", underlying=True)
# This sync is required only once daily at initial run
OptionStream.sync_instruments()
# Stream option chain data in real-time
StreamData = OptionStream.create_option_chain()
for data in StreamData:
print(data)
content=json.dumps(data[0])
with open("./optiondata.json", "w") as outfile:
outfile.write(content)
It prints only one token data in loop. Am I doing any mistake here?
Dear @ranjanrak
It prints only one token data in loop. Am I doing any mistake here?
[{'token': 260105, 'symbol': 'NIFTY BANK', 'last_price': 43332.95, 'change': 0.5317402778180486}]
if I pass underlying value as False, it returns empty value
2022-12-05 22:08:42+0100 [-] Log opened. 2022-12-05 22:08:43+0100 [-] Connection error: 0 - error parsing tokens. 2022-12-05 22:08:43+0100 [-] ERROR:root:closed connection on error: 0 error parsing tokens. [] Traceback (most recent call last):
I have come across other issue in GitHub about TypeError: cannot pickle '_thread.lock' object #5". I have fixed it by below code snippet in websocket.py. it happens on windows and macOS