side: "sell",
tdMode: "cross",
ordType: "post_only",
px: event.depth.asks[0].price.toFixed(4),
sz: "1",
}],
cancelOrders: order ? [{
instId: order.instId,
clOrdId: order.Id
}] : [] // 确保 order 存在,否则返回空数组
}
}
}
function main() { let instId = exchange.SetContractType(“swap”).InstrumentID;
let ctx = $.NewWSS(exchange, function(ws) {
let msg = null;
if (exchange.GetName() === 'Futures_OKCoin') {
msg = {
op: "subscribe",
args: [{
channel: "books5",
instId: instId,
}, {
channel: "trades",
instId: instId,
}]
};
} else {
let symbol = exchange.GetCurrency().replace('_', '').toLowerCase();
msg = {
method: "SUBSCRIBE",
params: [symbol + "@aggTrade", symbol + "@depth20@100ms"],
id: 1,
};
}
ws.write(JSON.stringify(msg));
Log("subscribe", msg, "channel");
LogStatus("Ready");
}, onTick, false);
while (true) {
ctx.poll();
EventLoop(1000);
}
}
Inventors quantify - small dreamsHello, error message says order is undefined. Changed if condition to true, but missing a sentence ``let order = event.orders && event.orders[0]; // Assuming to retrieve the first order from the event ``, order is undefined. In addition, the format of the code is: What's up? The Code What's up? 'Note the symbols, not the symbols'
EleutheromaniaThank you.