diff --git a/src/core/lib/order-plan.ts b/src/core/lib/order-plan.ts index 3e3d7c2..a321447 100644 --- a/src/core/lib/order-plan.ts +++ b/src/core/lib/order-plan.ts @@ -18,11 +18,18 @@ export function makeOrderPlan( const orderPrice = String(order.price); const reduceOnly = order.reduceOnly === true; const matchedIndex = targets.findIndex((target, index) => { + const targetPrice = String(target.price); + const orderPriceValue = Number(orderPrice); + const targetPriceValue = Number(targetPrice); + const priceMatches = + Number.isFinite(orderPriceValue) && Number.isFinite(targetPriceValue) + ? Math.abs(orderPriceValue - targetPriceValue) <= 1e-8 + : orderPrice === targetPrice; return ( unmatched.has(index) && target.side === order.side && target.reduceOnly === reduceOnly && - orderPrice === target.price // 直接使用字符串比较 + priceMatches ); }); if (matchedIndex >= 0) { @@ -39,4 +46,3 @@ export function makeOrderPlan( return { toCancel, toPlace }; } -