Type/to search

Envio em tempo real de negociações da Binance para o WeChat (prática do protocolo wss)

Binance
3
Follow
1508
Followers

Através do protocolo websocket, é possível enviar as informações de negociação da Binance para o WeChat, servindo como um exercício do protocolo wss. O princípio específico é renovar o listenKey a cada 30 minutos e, em seguida, inscrever-se no datastream ao qual a conta está inscrita.

Source
JavaScript
function main() {
    var listenKey = JSON.parse(HttpQuery('https://api.binance.com/api/v1/userDataStream','',null,'X-MBX-APIKEY:'+APIKEY)).listenKey;
    HttpQuery('https://api.binance.com/api/v1/userDataStream', {method:'DELETE',data:'listenKey='+listenKey}, null,'X-MBX-APIKEY:'+ APIKEY);
    listenKey = JSON.parse(HttpQuery('https://api.binance.com/api/v1/userDataStream','',null,'X-MBX-APIKEY:'+ APIKEY)).listenKey;
    var datastream = Dial("wss://stream.binance.com:9443/ws/"+listenKey, 100);
    var update_listenKey_time =  Date.now()/1000;
    while (true){
        if (Date.now()/1000 - update_listenKey_time > 1800){
            update_listenKey_time = Date.now()/1000;
            HttpQuery('https://api.binance.com/api/v1/userDataStream', {method:'PUT',data:'listenKey='+listenKey}, null,'X-MBX-APIKEY:'+ APIKEY);
Strategy parameters
Strategy parameters
your binance API Key (Optional)
Comment
All comments (3)

    不能支持其他交易所吗?

    8 years ago

    思路类似

    8 years ago

    从中学习HttpQuery函数的用法,以及币安user data stream使用技巧

    8 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)