fix: 删除多定义的方法 (#528)

This commit is contained in:
ERIC LEUNG
2025-11-05 20:11:50 +08:00
committed by GitHub
parent 80b09f0982
commit 2d084f373c
5 changed files with 2 additions and 136 deletions

View File

@@ -549,39 +549,8 @@ func (t *HyperliquidTrader) CloseShort(symbol string, quantity float64) (map[str
return result, nil
}
// CancelStopOrders 取消该币种的止盈/止损单
func (t *HyperliquidTrader) CancelStopOrders(symbol string) error {
coin := convertSymbolToHyperliquid(symbol)
// CancelStopOrders 取消该币种的止盈/止
// 获取所有挂单
openOrders, err := t.exchange.Info().OpenOrders(t.ctx, t.walletAddr)
if err != nil {
return fmt.Errorf("获取挂单失败: %w", err)
}
// 注意Hyperliquid SDK 的 OpenOrder 结构不暴露 trigger 字段
// 因此暂时取消该币种的所有挂单(包括止盈止损单)
// 这是安全的,因为在设置新的止盈止损之前,应该清理所有旧订单
canceledCount := 0
for _, order := range openOrders {
if order.Coin == coin {
_, err := t.exchange.Cancel(t.ctx, coin, order.Oid)
if err != nil {
log.Printf(" ⚠ 取消订单失败 (oid=%d): %v", order.Oid, err)
continue
}
canceledCount++
}
}
if canceledCount == 0 {
log.Printf(" %s 没有挂单需要取消", symbol)
} else {
log.Printf(" ✓ 已取消 %s 的 %d 个挂单(包括止盈/止损单)", symbol, canceledCount)
}
return nil
}
// CancelStopLossOrders 仅取消止损单Hyperliquid 暂无法区分止损和止盈,取消所有)
func (t *HyperliquidTrader) CancelStopLossOrders(symbol string) error {