Describe the bug
I am trying to track my order status using websocket,but once connected , the websocket shuts down immediately, and it's getting this error:
Error: Connection to remote host was lost.
To Reproduce
import numpy as np
import pandas as pd
from binance.client import Client
from binance.enums import HistoricalKlinesType
import datetime
api_key = ''
api_secret = ''
client = Client(api_key, api_secret)
def on_open(ws):
print("opened connection to Binance streams")
def on_error(ws, error):
print(f"Error: {error}")
def on_close(ws,close_status_code,close_msg):
print("closed connection to Binance streams")
def on_message(ws, message):
print(f"Message: {message}")
event_dict = json.loads(message)
if event_dict["e"] == "executionReport": # event type
order_status = event_dict["X"]
if order_status == "NEW": # order fill
symbol = event_dict["s"]
id = event_dict["i"] # int
price = event_dict["L"] # float as string
side = event_dict["S"] # "BUY" or "SELL"
qty = event_dict["l"] # float as string
fee = event_dict["n"] # float as string
print(f"{symbol}: FILL {side} {qty} at {price}; fee {fee}")
listenkey = get_listen_key_by_REST(api_key)
websocket.enableTrace(True)
SOCKET = "wss://fstream-auth.binance.com/ws/"+listenkey
import rel
ws = websocket.WebSocketApp(SOCKET, on_open=on_open, on_close=on_close,
on_message=on_message,on_error=on_error)
ws.run_forever(dispatcher=rel,reconnect=5)
rel.signal(2,rel.abort)
rel.dispatch()
Expected behavior
IF connected , it should return my future account status.
Environment (please complete the following information):
Describe the bug I am trying to track my order status using websocket,but once connected , the websocket shuts down immediately, and it's getting this error: Error: Connection to remote host was lost.
To Reproduce
Expected behavior IF connected , it should return my future account status.
Environment (please complete the following information):