ranjanrak / optionchainstream

Live streaming option chain for equity derivatives using Kite connect Websocket based on redis.
MIT License
145 stars 69 forks source link

Unable to live stream the bank nifty data #10

Closed srinivasraja54 closed 1 year ago

srinivasraja54 commented 1 year ago

Dear @ranjanrak

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?

[{'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

import platform
if platform.system() != "Linux":
    from multiprocessing import set_start_method
    set_start_method("fork")