mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-03 19:11:02 +08:00
## 🎯 修復核心問題:保證金摘要選擇邏輯 ### 問題根源 **4db1a3a (henrylab)** 和 **d062126 (icy)** 的矛盾: 1. **henrylab** 將 CrossMarginSummary → MarginSummary(逐倉) - 邏輯:V1 設定逐倉,所以改查詢逐倉摘要 - 問題:方向錯了,Hyperliquid 應該預設全倉 2. **icy** 添加 isCrossMargin 配置,預設全倉 - 邏輯:添加配置,SetLeverage 使用配置 - 問題:忘記修改 GetBalance,仍硬編碼 MarginSummary - 結果:設定全倉,查詢逐倉摘要 → 又不一致了 ### 修復方案 根據 `isCrossMargin` 動態選擇正確的摘要: ```go if t.isCrossMargin { // 全倉模式:使用 CrossMarginSummary accountValue, _ = strconv.ParseFloat(accountState.CrossMarginSummary.AccountValue, 64) } else { // 逐倉模式:使用 MarginSummary accountValue, _ = strconv.ParseFloat(accountState.MarginSummary.AccountValue, 64) } ``` ### 修復前後對比 | 版本 | 設定模式 | 查詢摘要 | 邏輯一致 | 方向正確 | |------|---------|---------|---------|---------| | V1 (nobody) | 逐倉 | CrossMargin | ❌ | ❌ | |4db1a3a(henrylab) | 逐倉 | Margin | ✅ | ❌ | |d062126(icy) | 全倉 | Margin | ❌ | ⚠️ | | **此次修復** | 全倉 | CrossMargin | ✅ | ✅ | ### 清理混亂註釋 修復前: ```go // 🔍 调试:打印API返回的完整CrossMarginSummary结构 summaryJSON, _ := json.MarshalIndent(accountState.MarginSummary, ...) // 註釋說 CrossMarginSummary,代碼用 MarginSummary ❌ ``` 修復後: ```go log.Printf("🔍 [DEBUG] Hyperliquid Perpetuals %s 完整数据:", summaryType) // 根據實際使用的摘要類型動態輸出 ✅ ``` ## 相關分析 詳見:/tmp/core_problem_analysis.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>