Tolak transaksi Binance ke WeChat dalam masa nyata (amalan protokol wss)
3
Follow
1503
Followers
Melalui protokol websocket, maklumat urus niaga Bitcoin boleh dihantar ke WeChat sebagai latihan untuk protokol WSS.
Prinsipnya adalah untuk mengemas kini listenKey setiap 30 minit, dan kemudian melanggan aliran data yang telah didaftarkan oleh akaun tersebut.
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
Related strategies
Comment
All comments (3)
- 1

