资源加载中... loading...

o(╥﹏╥)o

Author: Eleutheromania, Created: 2024-08-08 16:20:45, Updated: 2024-08-10 18:47:09

            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);
}

}


More

发明者量化-小小梦 您好,报错说 order 没定义。把if条件改成true了,但是少了一句```let order = event.orders && event.orders[0]; // 假设从事件中获取第一个订单```,order就成没定义的了。 另外发代码的格式: \`\`\` 代码 \`\`\` 注意是符号` 不是符号 '

Eleutheromania 好的感谢