I would like to ask everyone how to implement some basic functions of Websocket with python.

Hello everyone, I am a beginner in programming, I have been using REST API before, but recently I want to do high-frequency trading and need to switch to Websocket. I am suffering from the lack of example code in the official documentation, and the example code I can find online is also full of errors, and I have not been able to succeed. So please give me a python example code that can run normally, thank you very much! I want to subscribe to the 1-minute BTCTUSD kline, account balance, and store the return results in variables. In addition, I want to implement leverage borrowing and repayment and buying and selling operations through webSocket, as well as the function of automatic reconnection when disconnected. Thank you again!

Hi there,

You can have a look at the Websocket Stream/Websocket API examples folder on the Python Connector’s Github Repo. There it has Python examples on how to use each Websocket endpoint.