mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 09:18:08 +00:00
feat: 更新订单处理逻辑,将价格类型改为字符串以避免精度问题,并添加价格格式化函数
This commit is contained in:
@@ -2,7 +2,7 @@ import type { AsterOrder } from "../../exchanges/types";
|
||||
|
||||
export interface OrderTarget {
|
||||
side: "BUY" | "SELL";
|
||||
price: number;
|
||||
price: string; // 改为字符串避免精度问题
|
||||
amount: number;
|
||||
reduceOnly: boolean;
|
||||
}
|
||||
@@ -15,18 +15,14 @@ export function makeOrderPlan(
|
||||
const toCancel: AsterOrder[] = [];
|
||||
|
||||
for (const order of openOrders) {
|
||||
const price = Number(order.price);
|
||||
if (!Number.isFinite(price)) {
|
||||
toCancel.push(order);
|
||||
continue;
|
||||
}
|
||||
const orderPrice = String(order.price);
|
||||
const reduceOnly = order.reduceOnly === true;
|
||||
const matchedIndex = targets.findIndex((target, index) => {
|
||||
return (
|
||||
unmatched.has(index) &&
|
||||
target.side === order.side &&
|
||||
target.reduceOnly === reduceOnly &&
|
||||
price === target.price
|
||||
orderPrice === target.price // 直接使用字符串比较
|
||||
);
|
||||
});
|
||||
if (matchedIndex >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user