Binance 거래를 WeChat으로 실시간으로 푸시(WSS 프로토콜 연습)
3
Follow
1503
Followers
websocket 프로토콜을 통해 BTC 거래 정보를 위키백과에 전송하는 것은 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

