바이낸스 체결 내역을 위챗으로 실시간 푸시 (WSS 프로토콜 연습)
3
Follow
1508
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

