Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Every two minute i got this error - Connection error: 1006 - connection was closed uncleanly (None) #88

Closed
karthickbala123 opened this issue Aug 14, 2020 · 5 comments

Comments

@karthickbala123
Copy link

I read previous discussions about this error but am not resolve this issue
am also not using any computation inside on_ticks(). kindly help me

susbcription_list = [int(x) for x in trd_portfolio]
def getticks(ticks):
for tick in ticks:
ticks_token = tick['instrument_token']
push_tick_values_to_trd_portfolio(tick, ticks_token)

push_value_to_excel()
def on_ticks(ws, ticks):
# Todo: "On_ticks"
getticks(ticks)

def on_connect(ws, response):
ws.subscribe(susbcription_list)
ws.set_mode(ws.MODE_FULL, susbcription_list)


# Assign the callbacks.
kws.on_ticks = on_ticks
kws.on_connect = on_connect


kws.connect(threaded=True)

count = 0
while True:
count += 1
if count % 2 == 0:
if kws.is_connected():
kws.set_mode(kws.MODE_FULL, susbcription_list)
else:
if kws.is_connected():
kws.set_mode(kws.MODE_FULL, susbcription_list)

time.sleep(5)

image

@vijaykz
Copy link

vijaykz commented Aug 15, 2020

push_tick_values_to_trd_portfolio(tick, ticks_token)
push_value_to_excel()

By looks, these seem to be time consuming operations. Try doing only in-memory operations in on_ticks() and offload other functionalities to a separate thread.

@karthickbala123
Copy link
Author

Thank you for your reply @vijaykz can you send some exapmle code for memory operations bcoz am basic python user only. kindly help me

@vijaykz
Copy link

vijaykz commented Aug 20, 2020

Refer to this example. This shows how to fetch & store ticks. Instead of database, you can simply maintain candles in list of list, for example.

@sachin2404
Copy link

Hi Vijaykz , In your example, you said you are sending ticks in celery taske queue where ticks are inserted into DB. But what if I want to do operation on latest ticks not on previous ticks. I want to compute on instant basis while getting ticks.

@vijaykz
Copy link

vijaykz commented Apr 30, 2021

I do not have a need to save in DB. I create candlesticks in a list of lists like this:

ticks = [ [Date, O, H, L, C, V], [Date, O, H, L, C, V], .... [Date, O, H, L, C, V] ]

In order to perform operations on the latest bar, you can fetch it just by using ticks[-1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants