Need help with code .. seeing connection closed after every 5 minutes.

msangani
Hi Guys,

I need help please.

I've the following code wherein I'm getting historical data of 5 minute and then converting them in DataFrame.
What I'm observing is every 5 minute, I get "Connection error: 1006 - connection was closed uncleanly (None)" and then it reconnects successfully. If I remove the historical_data and DataFrame line, then the entire code works fine for the entire day.
Any guidance where I might be going wrong?


# You have to use the pre-defined callbacks to manage subscriptions.
kws.connect(threaded=True)

while True:
def on_ticks(ws, ticks):
helper_method(ticks)

def helper_method(ticks):
now = datetime.datetime.now()
if (not(now.minute % 5 == 0 and now.second < 3)): return

# Below 2 lines if removed works flawlessly.
data = kite.historical_data(256265, start, end, "5minute", continuous=False, oi=False)
data = pd.DataFrame(data)
:
:
  • SRIJAN
    SRIJAN edited January 2022
    The above code is working for me. The problem is 'return'. Remove it.
Sign In or Register to comment.