Ethereum: Binance SpotWebsocketClient not sending responses for a subscribed symbol

Here are the maintenance on the specified code of the code:

Ethereum: Binance SpotwebSockClient does not drop out the eaten on the subscribed symbol

As a trader of cryptocurrency, the reality of the renewal from the renewal source has an important value for the basic decrees. One of these signs is an api binance spot webSocket, which gives you the opportunity to connect to the blockchain ethereum and to make market data in the regional time. However, at the point of the catalog “BinanceSpotwebsketClient” the problem can be made, which can interfere with the signatures on the signatures.

Problem: Subcribe without registration

Ethereum: Binance SpotWebsocketClient not sending responses for a subscribed symbol

In the children’s children, a new copy of the “SpotwebSketClient” is assembled and the sub -signs give. However, if you subscribe to a full symbol, using the “Subscription” method, you can not be signed in the following. If this is a proof, the client will be extended to the data in the sign -signed symbol, even if you have made from the record.

Resolution: Uspolza Method “Otkaz from Subscription”

To solve the problem, you always have to summarize the method “Do not pinch”, when you discard the subscription on the subscription. Here is a coded version of the code with this remont:

`Python

JSON IMport

Datetime

binance.websket.spot.websket_Client Import SpotwebsketClient

De Safe_json_load (Data):

return the data

Def Safe_json_dump (Data):

Will return to json.dumps (data)

Class BinancespotwebskketClient:

Def __init __ (you, Simvol, Secretism, APREDPOINT):

Self.symbol = symbol

Self.secretKey = secretkey

Self.apiendPoint = APIENDPOINT

Self.subscriptions = {}

Subcribe (I, Simvol, Unders = No):

If the symbol is not on the sow.

Self.subscripts [symbol] = no

Answer = safe_json_load (Return)

If the answer is not:

Raise Valueerror ("Weeking Subscribe")

Self._subscribe (Simvol, Answer)

DEF USOUBScribe (Self, Symbol):

If the symbol is not on the sow.

Retrieve

Del Self.Subscripts [Simvol]

Calling the Function Function to free the no -lane

If the symbol is in the self.

Self.callbackfunctions [symbol] ()

Def _subscribe (you, Simvol, Data):

This method is caused by when you are sustaining the subscription

PRINT (F "Subcribe on {Simvol} for real")

Def Sendrealtimedata (you, Simvol):

This method can be used for a reaal data for a concrete symbol

pass

Use Primer:

Client = BinanceSpotwebsketClient (

"Е",

symbol

"Your_secret_key",

secret key

"

API Endpoint

)

Def Onrealtimedatareced (Data):

Print (F "{Data ['Symbol']} Updated {Data ['NewPrice']}"

Client.Subscribe ("ETH", Onrealtimedatare)

verify code

You can protest this code, laptop jupyter. Receive that you have installed the Binance catalog and shut up that you replace “Your_secret_key” on the factory secret key.

After creation of the copy “BinancespotwebsketClient” you can sign on a given symbol, using the “Subscription” method, which triggers the data for this for a full signal. You can get out of the subscription, call the method “upset”, when you read the accumulation.

The following is a trace, you have to do the opportunity to solve the problem with the code and to punch the fact that you set aside the units to the subscribed symbols.

metamask appearing

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *