mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-09 08:18:07 +00:00
fix: improve order price comparison logic in makeOrderPlan function for better precision
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user