IBKR 订单提交总是以错误 10244: UNSET_DECIMAL 信标泄露而被拒绝,原因是 decimal.js 文件复制不正确
1. The persisted operation carries no cashQty. From data/trading/<account>/commit.json:
operations[0].order.totalQuantity = '1'
operations[0].order.orderType = 'LMT'
operations[0].order.lmtPrice = '14'
operations[0].order.tif = 'DAY'No cashQty key — so the application layer never sets it. TradingGit.rehydrateOrder correctly skips it (if (order.cashQty != null) is false), leaving the new Order() class default cashQty = UNSET_DECIMAL.
2. Two independent decimal.js instances. The broker pack resolves [email protected] from its own runtime/broker-packs/ibkr/releases/<rel>/node_modules/, while app.asar bundles its own copy. Decimals created by the app are therefore not instanceof the pack's Decimal.
3. The encoder gates the sentinel conversion behind instanceof. Broker pack dist/index.js:1676:
function makeFieldHandleEmpty(val) {
if (val === null || val === void 0) throw new Error("Cannot send None to TWS");
if (val instanceof Decimal3) { // <-- fails for a foreign Decimal
if (val.equals(UNSET_DECIMAL)) return makeField(""); // <-- the sentinel -> empty conversion
return makeField(val);
}
if (val === UNSET_INTEGER || val === UNSET_DOUBLE) return makeField("");
if (val === DOUBLE_INFINITY) return makeField(INFINITY_STR);
return makeField(val); // <-- falls through to String(val)
}A foreign Decimal misses both the instanceof branch and the primitive === checks, so it reaches makeField(val), which likewise tests instanceof Decimal3 and ends at String(val).
Reproduced in isolation with two copies of the same decimal.js:
same-copy sentinel -> "" (correct: TWS reads it as unset)
foreign-copy sentinel ->
…内容来源: TraderAlice/OpenAlice