Ethereum: Binance Futures Account_update Stress Store via WebSockets
As a programmer for the construction of a developer on Ethereum Blockchain, you are probably familiar with work with web sockets and interaction with API -JAM Exchange. However, when it comes to electricity trading using Binance Futures, things can become a little more complex. In this article, we will question the answer from API -ja Binance for trade during Account_update
through WebSocket.
Problem: Lack of Reply
Suppose you have successfully set up a websocket connection with Binance and try to make the currents of the Account_update '. Use the following code:
Python
Imports Json
Imports of websocket
Socket = 'WSS: //fstream.binance.com/ws'
Stream_endPoint = 'Olympus'
WS = WebSocket.create_Connection (socket)
msg = {
"JSONRPC": "2.0",
"Method": "Eth_Getaccountupdate,"
"Params": ["0x ..."],
"ID": 1
Iche
Ws.Send (Json.dumps (MSG))
While the truth is:
try:
data = ws.Recv ()
If the 'result' is in data and data ['result'] == 'OK':
Print (data)
Elif 'Error' in data and data ['Error'] ['Code'] == 1000:
Print ('Account Update Error:', Data ['Error'] ['Message'])
else:
break
Apart from webSocket.exception.ConnectionClused:
break
ws.Close ()
`
As you can see, this code sends an update request to the end pointETH_GETACCOUNTUPDATEwith your account address as a parameter. However, it does not seem to receive any response from the server.
Possible causes:
Invalid final point API -JA : Make sure you use the correct endpoint of API for computers_update (olympus) and whether the end point is properly shaped.
Missing authentication : Binance requires authentication when creating API requests. Make sure you have added your account credentials toJSONRPCheader with the following format:
Python
{"JSONRPC": "2.0", "Method": "ETH_GETACCOUNTUPDATE", "Auth": {"Address": "0x ..."}, "ID": 1}
`
Time checking with this : If you have problems with time or connections, try to increase the parametertimeoutin your website request:
Python
ws = websocket.create_Connection (socket, timeout = 30)
`
Errors on the server side : There are mistakes that there are mistakes on the server side for which API does not return the answer. Check Binance's documentation for all known problems or updates relating to PCs_update.
Examples of Cases of Use:
Stream Testing : You can use this code as a starting point to test the current with Binance Futures.
Development and Error Removal : This example shows how to send an update request to the end pointeth_getaccountUpdate` for test purposes.
Conclusion:
In conclusion, when it comes to electricity trading on Binance using WebSockets, the response from the server may be challenging. You must properly place the end point of API and credentials to authenticate. In addition, keep in mind potential problems such as time, problems with relationships or errors on the server side. With some problem solving, you should be able to solve this question and successfully receive answers from Binance for the purpose of trading in electricity.
References:
- Binance Futures API Documentation: [ Html )
- Documentation of Ethereum: [