mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-14 16:26:57 +08:00
fix: Lighter CancelStopOrders now filters by TriggerPrice, proxyBinance checks upstream status
- CancelStopOrders: only cancel orders with non-empty TriggerPrice (was canceling ALL orders including regular limit orders — safety bug) - proxyBinance: return 502 when upstream returns non-200 instead of silently proxying error pages - Remove redundant CORS headers in agent/web.go (already handled by gin middleware)
This commit is contained in:
@@ -186,17 +186,22 @@ func (t *LighterTraderV2) CancelStopOrders(symbol string) error {
|
||||
}
|
||||
|
||||
canceledCount := 0
|
||||
skippedCount := 0
|
||||
for _, order := range orders {
|
||||
// TODO: Check order type, only cancel stop orders
|
||||
// For now, cancel all orders
|
||||
// Only cancel orders with a trigger price (stop-loss / take-profit)
|
||||
// Regular limit orders have empty or "0" trigger price
|
||||
if order.TriggerPrice == "" || order.TriggerPrice == "0" || order.TriggerPrice == "0.0" {
|
||||
skippedCount++
|
||||
continue
|
||||
}
|
||||
if err := t.CancelOrder(symbol, order.OrderID); err != nil {
|
||||
logger.Infof("⚠️ Failed to cancel order (ID: %s): %v", order.OrderID, err)
|
||||
logger.Infof("⚠️ Failed to cancel stop order (ID: %s): %v", order.OrderID, err)
|
||||
} else {
|
||||
canceledCount++
|
||||
}
|
||||
}
|
||||
|
||||
logger.Infof("✓ LIGHTER - Canceled %d stop orders", canceledCount)
|
||||
logger.Infof("✓ LIGHTER - Canceled %d stop orders (skipped %d regular orders)", canceledCount, skippedCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user