From e28240e7991cd3c9f8cc0df05fe7fd2d9898f338 Mon Sep 17 00:00:00 2001 From: discountry Date: Mon, 6 Oct 2025 18:44:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=8D=8F=E8=B0=83=E5=99=A8=E5=92=8C=20GRVT=20=E9=80=82?= =?UTF-8?q?=E9=85=8D=E5=99=A8=E9=80=BB=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=AD=A2=E6=8D=9F=E5=8D=95=E7=9A=84=20reduceOnly=20=E5=92=8C?= =?UTF-8?q?=20closePosition=20=E5=8F=82=E6=95=B0=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=BB=98=E8=AE=A4=E4=BB=B7=E6=A0=BC=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E5=99=A8=E4=B8=BA=20LAST?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/order-coordinator.ts | 1 + src/exchanges/grvt/gateway.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/order-coordinator.ts b/src/core/order-coordinator.ts index a415938..e56e603 100644 --- a/src/core/order-coordinator.ts +++ b/src/core/order-coordinator.ts @@ -238,6 +238,7 @@ export async function placeStopLossOrder( side, type, stopPrice: roundDownToTick(stopPrice, priceTick), + reduceOnly: "true", closePosition: "true", timeInForce: "GTC", quantity: roundQtyDownToStep(quantity, qtyStep), diff --git a/src/exchanges/grvt/gateway.ts b/src/exchanges/grvt/gateway.ts index 922d73c..cd4fff1 100644 --- a/src/exchanges/grvt/gateway.ts +++ b/src/exchanges/grvt/gateway.ts @@ -73,7 +73,7 @@ const ENVIRONMENT_ALIASES: Record = { production: "prod", }; -const DEFAULT_MARK_PRICE_TRIGGER = "MARK"; +const DEFAULT_MARK_PRICE_TRIGGER = "LAST"; const DEFAULT_TIME_IN_FORCE: GrvtTimeInForce = "GOOD_TILL_TIME"; const TRAILING_NOT_SUPPORTED_ERROR = "GRVT exchange adapter does not yet support trailing stop orders"; @@ -1097,12 +1097,16 @@ function mapOrder(order: IOrder, symbol: string): AsterOrder { const avgFillPrice = Array.isArray(state?.avg_fill_price) ? state?.avg_fill_price?.[0] ?? undefined : state?.avg_fill_price ?? undefined; + const hasTrigger = Boolean(trigger?.tpsl?.trigger_price); + const derivedType = hasTrigger + ? (order.is_market ? "STOP_MARKET" : "LIMIT") + : (order.is_market ? "MARKET" : "LIMIT"); return { orderId: order.order_id ?? metadata?.client_order_id ?? cryptoRandomId(), clientOrderId: metadata?.client_order_id ?? "", symbol, side: leg?.is_buying_asset ? "BUY" : "SELL", - type: order.is_market ? "MARKET" : "LIMIT", + type: derivedType, status: state?.status ?? "NEW", price: leg?.limit_price ?? "0", origQty: leg?.size ?? "0",