如何解决在网络套接字流中获取最近的交易订单信息 binance api(node js)
我需要获取最近的订单 vie websocets 当前看到了这个,这不是使用 node-binance-api
// The only time the user data (account balances) and order execution websockets will fire,is if you create or cancel an order,or an order gets filled or partially filled
function balance_update(data) {
console.log("Balance Update");
for ( let obj of data.B ) {
let { a:asset,f:available,l:onOrder } = obj;
if ( available == "0.00000000" ) continue;
console.log(asset+"\tavailable: "+available+" ("+onOrder+" on order)");
}
}
function execution_update(data) {
let { x:executionType,s:symbol,p:price,q:quantity,S:side,o:orderType,i:orderId,X:orderStatus } = data;
if ( executionType == "NEW" ) {
if ( orderStatus == "REJECTED" ) {
console.log("Order Failed! Reason: "+data.r);
}
console.log(symbol+" "+side+" "+orderType+" ORDER #"+orderId+" ("+orderStatus+")");
console.log("..price: "+price+",quantity: "+quantity);
return;
}
//NEW,CANCELED,REPLACED,REJECTED,TRADE,EXPIRED
console.log(symbol+"\t"+side+" "+executionType+" "+orderType+" ORDER #"+orderId);
}
binance.websockets.userData(balance_update,execution_update);
但我只需要获取最近的订单数据,订单状态如未结、部分成交或完全成交。 无论如何这是可能的 - 就像在 ws 流上获取这些数据
我目前使用
const WS = require('ws');
const ws = new WS('wss://stream.binance.com:9443/ws/shibusdt@bookTicker');
ws.on('message',function incoming(sdata) {}
像这样,所以对于订单信息,我可以创建其他 ws 变量并从那个或类似的东西中获取传入数据。标识可能的。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。