Binance contract websocket interface query holding account example

Author: The Little Dream, Date: 2020-12-15 15:21:45
Tags: ToolBinance

Binance contract websocket interface query holding account example

This is the first time that I've seen this video.https://binance-docs.github.io/apidocs/delivery/cn/#e3ee8329c9

Binance Futures Exchange objects added after configuration during testing.

img


function main() {
    LogReset(1)
    var ws = null
    exchange.IO("base", "https://dapi.binance.com")
    var obj = exchange.IO("api", "POST", "/dapi/v1/listenKey")
    Log(obj, typeof(obj))
    var listenKey = obj.listenKey
    Log("listenKey:", listenKey)
    var ts = new Date().getTime()
    ws = Dial("wss://dstream.binance.com/ws/" + String(listenKey))
    while (1) {
        var arr = ["balance", "account", "position"]
        for (var i in arr) {
            var info = {
                "method": "REQUEST",
                "params": [
                    listenKey + "@" + arr[i]
                ],
                "id": ts
            }
            ws.write(JSON.stringify(info))
            var ret = ws.read()
            Log(ret)
            Sleep(1000)
        }
        Sleep(1000)
    }
}

Related

More

liwenlueHi, how do you get the order update, you haven't received the order information.

fyrDo you need to write it yourself? /upload/asset/21b18cce8439c5312c140.png

Difficult to quantifyThe method in this example seems to be only applicable to a currency-based contract, right? I tried to change the contract address to a u-based contract, and found that I couldn't actively query "balance", "account", "position" and so on via websocket.

The Little DreamJust tested, this example can change the local address of the Rion to the local address of U, the order information is not required to subscribe, it will be pushed directly. Once tested, the cancellation of the re-order will be pushed an order change message.

liwenlueThe problem is at this point, the binary has a subscription method similar to @balance that includes transaction data, but the u subscription data is not subscribed, so I asked the binary service to let me directly use the wss://fstream.binance.com/ws/XaEAKTsQSRLZAGH9tuIu37plSRsdjmlAVBoNYPUITlTAko1WI22PgmBMpI1rS8Yh (listenKey) to get all the data re-processed, but I used this method that seems not to be available to the inventors, I don't know how to operate it, if there is a problem, try it, thank you, or I can give you an example code for subscribing to the u subscription.

The Little DreamHello, you need to subscribe to the corresponding channel to have push data, specifically you can see how to subscribe on the documentation of the exchange, in the example only these subscriptions: ``var arr = ["balance", "account", "position"] ```

The Little DreamIt's safe to say that it's at the bottom of the heartbeat, and you don't need a strategic level ```xxx.write (゚) ` (゚) to write messages.

The Little DreamAccording to the documentation of the exchange. Not necessarily the same as the U-bit. /upload/asset/17a3ea8b5fed6c2d05fd.png This is a list of all the different ways Upload/asset/17a3ea8b5fed6c2d05fd.png is credited in the database. /upload/asset/1699cb3f9cea6f9b2012.png This is a list of all the different ways Cb3f9cea6f9b2012.png is credited in the database.