问题描述
我需要获取最近的订单 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 (将#修改为@)