fix:完善aster账户净值和盈亏计算|Improve the calculation of the net value and profit/loss of the aster account (#695)

Co-authored-by: LindenWang <linden@Lindens-MacBookPro-2.local>
This commit is contained in:
Linden
2025-11-07 13:38:39 +08:00
committed by GitHub
parent eb16882282
commit f1f24ad1fa
8 changed files with 88 additions and 71 deletions

View File

@@ -175,10 +175,10 @@ func (t *HyperliquidTrader) GetBalance() (map[string]interface{}, error) {
// 原因Spot 和 Perpetuals 是独立帐户,需手动 ClassTransfer 才能转账
totalWalletBalance := walletBalanceWithoutUnrealized + spotUSDCBalance
result["totalWalletBalance"] = totalWalletBalance // 总资产Perp + Spot
result["availableBalance"] = availableBalance // 可用余额(仅 Perpetuals不含 Spot
result["totalUnrealizedProfit"] = totalUnrealizedPnl // 未实现盈亏(仅来自 Perpetuals
result["spotBalance"] = spotUSDCBalance // Spot 现货余额(单独返回)
result["totalWalletBalance"] = totalWalletBalance // 总资产Perp + Spot
result["availableBalance"] = availableBalance // 可用余额(仅 Perpetuals不含 Spot
result["totalUnrealizedProfit"] = totalUnrealizedPnl // 未实现盈亏(仅来自 Perpetuals
result["spotBalance"] = spotUSDCBalance // Spot 现货余额(单独返回)
log.Printf("✓ Hyperliquid 完整账户:")
log.Printf(" • Spot 现货余额: %.2f USDC (需手动转账到 Perpetuals 才能开仓)", spotUSDCBalance)
@@ -551,7 +551,6 @@ func (t *HyperliquidTrader) CloseShort(symbol string, quantity float64) (map[str
// CancelStopOrders 取消该币种的止盈/止
// CancelStopLossOrders 仅取消止损单Hyperliquid 暂无法区分止损和止盈,取消所有)
func (t *HyperliquidTrader) CancelStopLossOrders(symbol string) error {
// Hyperliquid SDK 的 OpenOrder 结构不暴露 trigger 字段