mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-15 16:56:56 +08:00
fix: Lighter stop/take-profit orders must use TimeInForce=0 (ImmediateOrCancel)
Lighter SDK validates that StopLossOrder (type=2) and TakeProfitOrder (type=4) must have TimeInForce=0 (ImmediateOrCancel), not TimeInForce=1 (GoodTillTime). This was causing stop-loss and take-profit orders to fail validation and not be submitted to Lighter exchange.
This commit is contained in:
@@ -626,7 +626,8 @@ func (t *LighterTraderV2) CreateStopOrder(symbol string, isAsk bool, quantity fl
|
|||||||
priceValue = uint32(triggerPrice * 1.05 * 1e2)
|
priceValue = uint32(triggerPrice * 1.05 * 1e2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop orders use GoodTillTime with expiry
|
// Stop orders MUST use ImmediateOrCancel (0) with expiry set
|
||||||
|
// Lighter SDK validates: StopLossOrder/TakeProfitOrder require TimeInForce=0 (ImmediateOrCancel)
|
||||||
orderExpiry := time.Now().Add(30 * 24 * time.Hour).UnixMilli() // 30 days
|
orderExpiry := time.Now().Add(30 * 24 * time.Hour).UnixMilli() // 30 days
|
||||||
|
|
||||||
txReq := &types.CreateOrderTxReq{
|
txReq := &types.CreateOrderTxReq{
|
||||||
@@ -636,7 +637,7 @@ func (t *LighterTraderV2) CreateStopOrder(symbol string, isAsk bool, quantity fl
|
|||||||
Price: priceValue,
|
Price: priceValue,
|
||||||
IsAsk: boolToUint8(isAsk),
|
IsAsk: boolToUint8(isAsk),
|
||||||
Type: orderTypeValue,
|
Type: orderTypeValue,
|
||||||
TimeInForce: 1, // GoodTillTime
|
TimeInForce: 0, // ImmediateOrCancel - REQUIRED for stop/take-profit orders!
|
||||||
ReduceOnly: 1, // Stop orders should be reduce-only
|
ReduceOnly: 1, // Stop orders should be reduce-only
|
||||||
TriggerPrice: triggerPriceValue,
|
TriggerPrice: triggerPriceValue,
|
||||||
OrderExpiry: orderExpiry,
|
OrderExpiry: orderExpiry,
|
||||||
|
|||||||
Reference in New Issue
Block a user