Binance のトランザクションをリアルタイムで WeChat にプッシュする (wss プロトコルの実践)
3
Follow
1503
Followers
websocketプロトコルで,ビットコインの取引情報を微信に送信することは,wssプロトコルでの演習として使用できます.
基本的には 30分ごとにlistenKeyを更新し,その後,アカウントに登録したデータストリームに登録する.
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

