From 8d79ace8b31db92fdae6bc507674eec151370184 Mon Sep 17 00:00:00 2001 From: discountry Date: Sun, 1 Feb 2026 11:15:00 +0800 Subject: [PATCH] Refactor triggerType handling in order placement logic - Updated the triggerType assignment in placeStopLossOrder and related functions to default to "STOP_LOSS" instead of conditionally setting it based on the order side. - This change simplifies the logic for stop market orders across the order coordinator and GRVT exchange gateway, ensuring consistent behavior. --- src/core/order-coordinator.ts | 2 +- src/exchanges/grvt/gateway.ts | 2 +- src/exchanges/grvt/order.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/order-coordinator.ts b/src/core/order-coordinator.ts index 253bd21..91ad13e 100644 --- a/src/core/order-coordinator.ts +++ b/src/core/order-coordinator.ts @@ -296,7 +296,7 @@ export async function placeStopLossOrder( timeInForce: "GTC", reduceOnly: true, closePosition: true, - triggerType: side === "BUY" ? "TAKE_PROFIT" : "STOP_LOSS", + triggerType: "STOP_LOSS", }); pendings[type] = String(order.orderId); log("stop", `挂止损单: ${side} STOP_MARKET @ ${normalizedStop}`); diff --git a/src/exchanges/grvt/gateway.ts b/src/exchanges/grvt/gateway.ts index afb2a0f..733f018 100644 --- a/src/exchanges/grvt/gateway.ts +++ b/src/exchanges/grvt/gateway.ts @@ -1337,7 +1337,7 @@ function buildUnsignedOrder(params: { function buildTriggerMetadata(params: CreateOrderParams): GrvtUnsignedOrder["metadata"]["trigger"] | undefined { if (params.type === "STOP_MARKET") { - const triggerType = params.triggerType ?? (params.side === "BUY" ? "TAKE_PROFIT" : "STOP_LOSS"); + const triggerType = params.triggerType ?? "STOP_LOSS"; const stopPrice = params.stopPrice ?? params.activationPrice; if (!stopPrice) { throw new Error("GRVT stop orders require a stopPrice or activationPrice"); diff --git a/src/exchanges/grvt/order.ts b/src/exchanges/grvt/order.ts index ac875b3..ad6488b 100644 --- a/src/exchanges/grvt/order.ts +++ b/src/exchanges/grvt/order.ts @@ -62,7 +62,7 @@ export async function createStopOrder(intent: StopOrderIntent): Promise