Ethereum: Binance Future Account_update Les Websocets
As a developer Bilding Applications on Ethereum blockchain, you are like familiar with a whole web prayer and interaction with an exchange in the API. Howver, with regard to streaming trading that makes binance furs, things can become a little more complex. In this article, we will immerse ourselves in the responsibilities of the API Binance API streaming trade via Websocks.
The problem: lack of answer
Suppose you have managed to configure your Websocket connection to exempt to execute a business of Account_Update. You use the following code:
Python
Import json
Import weboct
Configure Concononect Websocket
socket = 'wss: //fstream.binnance.com/ws'
Define the termination point of the API
stream_endpoint = 'Olympus'
Create a new WebSocket object
WS = Websocket.create_Connection (socket)
Send an update of requests to have a point of ending the flow
msg = {
"JSONRPC": "2.0",
"Method": "Eth_Getaccountupdate",
"Params": ["0x ...."],
Replace with your accounting
"ID": 1
}
WS.SEND (JSON.DUMPS (MSG))
Wait for an answer
Although true:
to try:
Receive JSON data on the server
Data = WS.Recv ()
If "result" of data and data ["result"] == "OK":
Print (data)
Elif 'error' in data and data ['error'] ['code'] == 1000:
account on different
print ('Account on the distinction:', data ['error'] ['mess'])))))
other:
to break
Except WebSacket.Exception.ConnectionCloseed:
to break
Close the Consocial Websocket
WS.CLOSE ()
re
Assessed by this code sends an update of reindeerETH_GetacCountadupdate. Howver, that does not seem to be rewritten by any response from the server.
Possible cause:
- Termination point of the non-valid API : Make sure you are correct API Endpoint for the_update account flows (“Olympus”) and that them are correctly formatted.
- Myming authentication
: Binance requires authentication when making API proposals. Make sure you have accounting them “JSONRPC”
`Python
{"Ysonrpc": "2.0", "Method": "Eth_Getaccountupdate", "Auth":
re
- Problems of delay or connection : If your experience is the problem of the expiration time, try to increase the "Timeout" parameter in
Python
WS = Websocket.Create_Connection (socket, timeout = 30)
` re
- Equipment on the server side : It is possible that the ear is the server which causes the API of your response. Check Binance documentation for known problems or updates concerning_update account flows.
Example of use cases:
- Test streaming trading : You can have a stop on the binance fur.
- Development and debugging : This is the request for updating “ETH_GetaccountuPdate for testing purposes.
Conclusion:
Integrations, when it comes to streaming trading on Binance using websocets, obtaining an arupse from the server can be difficult. Make sure you correctly configure your API termination point and authentication information. In addition, keep the potential means such as expiration times, connection problems or the ears on the server side. With a certain troubleshooting, you are a white bed to solve this successful transmitter and reception for the ends of Binance Binance for purposes.
References:
- API documentation of binance furs: HTML)
- Ethereum documentation: