From db7b24e2e0278b66284b61c7f57d53d599213a12 Mon Sep 17 00:00:00 2001 From: ZhouYongyou <128128010+zhouyongyou@users.noreply.github.com> Date: Tue, 4 Nov 2025 10:44:15 +0800 Subject: [PATCH] style: apply go fmt to fix indentation and alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix formatting issues across multiple files: - logger/decision_logger.go: correct if statement indentation - main.go: fix DataKLineTime field tab alignment - trader/auto_trader.go: align struct field comments and code blocks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- logger/decision_logger.go | 2 +- main.go | 2 +- trader/auto_trader.go | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/logger/decision_logger.go b/logger/decision_logger.go index 842783ba..e12fd1dc 100644 --- a/logger/decision_logger.go +++ b/logger/decision_logger.go @@ -349,7 +349,7 @@ func (l *DecisionLogger) AnalyzePerformance(lookbackCycles int) (*PerformanceAna symbol := action.Symbol side := "" - if action.Action == "open_long" || action.Action == "close_long" || action.Action == "partial_close" || action.Action == "auto_close_long" { + if action.Action == "open_long" || action.Action == "close_long" || action.Action == "partial_close" || action.Action == "auto_close_long" { side = "long" } else if action.Action == "open_short" || action.Action == "close_short" || action.Action == "auto_close_short" { side = "short" diff --git a/main.go b/main.go index 4864f2ad..51152554 100644 --- a/main.go +++ b/main.go @@ -37,7 +37,7 @@ type ConfigFile struct { StopTradingMinutes int `json:"stop_trading_minutes"` Leverage LeverageConfig `json:"leverage"` JWTSecret string `json:"jwt_secret"` - DataKLineTime string `json:"data_k_line_time"` + DataKLineTime string `json:"data_k_line_time"` News []config.NewsConfig `json:"news"` } diff --git a/trader/auto_trader.go b/trader/auto_trader.go index 94e83348..28df5979 100644 --- a/trader/auto_trader.go +++ b/trader/auto_trader.go @@ -113,11 +113,11 @@ type AutoTrader struct { lastResetTime time.Time stopUntil time.Time isRunning bool - startTime time.Time // 系统启动时间 - callCount int // AI调用次数 - positionFirstSeenTime map[string]int64 // 持仓首次出现时间 (symbol_side -> timestamp毫秒) + startTime time.Time // 系统启动时间 + callCount int // AI调用次数 + positionFirstSeenTime map[string]int64 // 持仓首次出现时间 (symbol_side -> timestamp毫秒) lastPositions map[string]*PositionSnapshot // 上一个周期的持仓快照 (symbol_side -> snapshot) - newsProcessor []news.Provider // 新闻 + newsProcessor []news.Provider // 新闻 } // NewAutoTrader 创建自动交易器 @@ -343,7 +343,7 @@ func (at *AutoTrader) runCycle() error { for _, action := range autoClosedActions { log.Printf("[AUTO-CLOSE] 检测到自动平仓: %s %s (价格: %.4f)", action.Symbol, action.Action, action.Price) record.Decisions = append(record.Decisions, action) - record.ExecutionLog = append(record.ExecutionLog, + record.ExecutionLog = append(record.ExecutionLog, fmt.Sprintf("[AUTO-CLOSE] 自动平仓: %s %s (止损/止盈触发)", action.Symbol, action.Action)) } @@ -502,7 +502,7 @@ func (at *AutoTrader) runCycle() error { if lev, ok := pos["leverage"].(float64); ok { leverage = int(lev) } - + snapshots = append(snapshots, PositionSnapshot{ Symbol: symbol, Side: side, @@ -1461,7 +1461,7 @@ func (at *AutoTrader) detectAutoClosedPositions(currentPositions []decision.Posi } autoClosedActions = append(autoClosedActions, autoClosedAction) - log.Printf("[AUTO-CLOSE] 检测到自动平仓: %s %s @ %.4f (可能由止损/止盈触发)", + log.Printf("[AUTO-CLOSE] 检测到自动平仓: %s %s @ %.4f (可能由止损/止盈触发)", lastPos.Symbol, action, closePrice) } }