Skip to main content

Reconnect

The following is a simple demonstration that automatically reconnects the trading socket when a disconnection event is detected using a callback:

# A callback to receive event 
def on_event(code, content):
print("===event=====")
print(code)
print(content)
if code == "300":
print("Reconnect")
try:
accounts = sdk.login("Your ID","Your password", "Your cert path", "Your cert password")
print("Reconnect successs")
except Exception as e:
print("Reconnect failed")
print(e)
print("========")

sdk.set_on_event(on_event)