style: convert Traditional Chinese comments to Simplified Chinese (#662)

## Problem

The codebase contains mixed Traditional Chinese (繁體中文) and Simplified Chinese (简体中文)
in comments and error messages, causing:
- Inconsistent code style
- Reduced readability for mainland Chinese developers
- Maintenance overhead when reviewing diffs

### Affected Files
- **trader/hyperliquid_trader.go**: 8 occurrences
- **trader/binance_futures.go**: 2 occurrences

## Solution

Convert all Traditional Chinese characters to Simplified Chinese to unify code style.

### Conversion Map

| Traditional | Simplified | Context |
|-------------|-----------|---------|
| 處理 | 处理 | "正確處理" → "正确处理" |
| 總資產 | 总资产 | "總資產" → "总资产" |
| 餘額 | 余额 | "可用餘額" → "可用余额" |
| 實現 | 实现 | "未實現盈虧" → "未实现盈亏" |
| 來 | 来 | "僅來自" → "仅来自" |
| 現貨 | 现货 | "現貨餘額" → "现货余额" |
| 單獨 | 单独 | "單獨返回" → "单独返回" |
| 開倉 | 开仓 | "開倉金額" → "开仓金额" |
| 數量 | 数量 | "開倉數量" → "开仓数量" |
| 過 | 过 | "過小" → "过小" |
| 為 | 为 | "後為" → "后为" |
| 後 | 后 | "格式化後" → "格式化后" |
| 建議 | 建议 | "建議增加" → "建议增加" |
| 選擇 | 选择 | "選擇價格" → "选择价格" |
| 幣種 | 币种 | "幣種" → "币种" |

## Changes

### trader/hyperliquid_trader.go (8 locations)

**Line 173-181**: Balance calculation comments
```diff
-//  Step 5: 正確處理 Spot + Perpetuals 余额
-// 重要:Spot 只加到總資產,不加到可用餘額
+//  Step 5: 正确处理 Spot + Perpetuals 余额
+// 重要:Spot 只加到总资产,不加到可用余额

-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 现货余额(单独返回)
```

**Line 189-191**: Log output messages
```diff
-log.Printf("  • Perpetuals 可用余额: %.2f USDC (可直接用於開倉)", availableBalance)
-log.Printf("  • 總資產 (Perp+Spot): %.2f USDC", totalWalletBalance)
+log.Printf("  • Perpetuals 可用余额: %.2f USDC (可直接用于开仓)", availableBalance)
+log.Printf("  • 总资产 (Perp+Spot): %.2f USDC", totalWalletBalance)
```

### trader/binance_futures.go (2 locations)

**Line 301, 355**: Error messages for insufficient quantity
```diff
-return nil, fmt.Errorf("开倉數量過小,格式化後為 0 (原始: %.8f → 格式化: %s)。建議增加開倉金額或選擇價格更低的幣種", quantity, quantityStr)
+return nil, fmt.Errorf("开仓数量过小,格式化后为 0 (原始: %.8f → 格式化: %s)。建议增加开仓金额或选择价格更低的币种", quantity, quantityStr)
```

## Testing

-  Compilation: Passes `go build`
-  Verification: No Traditional Chinese characters remain in trader/*.go
-  Functionality: No logic changes, only text updates

## Impact

-  Unified code style (100% Simplified Chinese)
-  Improved readability and maintainability
-  Easier code review for Chinese developers
-  No functional changes or behavior modifications

---

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
0xYYBB | ZYY | Bobo
2025-11-07 08:36:14 +08:00
committed by GitHub
parent 12512ff7f3
commit 4d7b28a600
2 changed files with 11 additions and 11 deletions

View File

@@ -298,7 +298,7 @@ func (t *FuturesTrader) OpenLong(symbol string, quantity float64, leverage int)
// ✅ 检查格式化后的数量是否为 0防止四舍五入导致的错误
quantityFloat, parseErr := strconv.ParseFloat(quantityStr, 64)
if parseErr != nil || quantityFloat <= 0 {
return nil, fmt.Errorf("开倉數量過小,格式化後為 0 (原始: %.8f → 格式化: %s)。建增加開倉金額或選擇價格更低的幣種", quantity, quantityStr)
return nil, fmt.Errorf("开仓数量过小,格式化后为 0 (原始: %.8f → 格式化: %s)。建增加开仓金额或选择价格更低的币种", quantity, quantityStr)
}
// ✅ 检查最小名义价值Binance 要求至少 10 USDT
@@ -352,7 +352,7 @@ func (t *FuturesTrader) OpenShort(symbol string, quantity float64, leverage int)
// ✅ 检查格式化后的数量是否为 0防止四舍五入导致的错误
quantityFloat, parseErr := strconv.ParseFloat(quantityStr, 64)
if parseErr != nil || quantityFloat <= 0 {
return nil, fmt.Errorf("开倉數量過小,格式化後為 0 (原始: %.8f → 格式化: %s)。建增加開倉金額或選擇價格更低的幣種", quantity, quantityStr)
return nil, fmt.Errorf("开仓数量过小,格式化后为 0 (原始: %.8f → 格式化: %s)。建增加开仓金额或选择价格更低的币种", quantity, quantityStr)
}
// ✅ 检查最小名义价值Binance 要求至少 10 USDT

View File

@@ -170,15 +170,15 @@ func (t *HyperliquidTrader) GetBalance() (map[string]interface{}, error) {
}
}
// ✅ Step 5: 正確處理 Spot + Perpetuals 余额
// 重要Spot 只加到總資產,不加到可用餘額
// 原因Spot 和 Perpetuals 是獨立帳戶,需手 ClassTransfer 才能轉帳
// ✅ Step 5: 正确处理 Spot + Perpetuals 余额
// 重要Spot 只加到总资产,不加到可用余额
// 原因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)
@@ -186,9 +186,9 @@ func (t *HyperliquidTrader) GetBalance() (map[string]interface{}, error) {
accountValue,
walletBalanceWithoutUnrealized,
totalUnrealizedPnl)
log.Printf(" • Perpetuals 可用余额: %.2f USDC (可直接用於開倉", availableBalance)
log.Printf(" • Perpetuals 可用余额: %.2f USDC (可直接用于开仓", availableBalance)
log.Printf(" • 保证金占用: %.2f USDC", totalMarginUsed)
log.Printf(" • 總資產 (Perp+Spot): %.2f USDC", totalWalletBalance)
log.Printf(" • 总资产 (Perp+Spot): %.2f USDC", totalWalletBalance)
log.Printf(" ⭐ 总资产: %.2f USDC | Perp 可用: %.2f USDC | Spot 余额: %.2f USDC",
totalWalletBalance, availableBalance, spotUSDCBalance)