mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 09:58:22 +08:00
fd8b1477e7
Major fixes: 1. Trade History data loss issue - Root cause: Open records outside analysis window caused close matching failures - Solution: Pre-populate position state by reading 3x window of historical records - Ensures long-term positions (>5 hours) generate correct trade records 2. P&L calculation errors - Remove incorrect leverage multiplication from absolute P&L - Correct calculation: Futures P&L = quantity × price difference - Leverage only affects P&L percentage (relative to margin) 3. Other fixes - Break-even trades (pnl=0) no longer misclassified as losses - Perfect strategy shows Profit Factor as 999.0 instead of 0.0 - Expand analysis window from 20 to 100 cycles (5 hours) Files changed: - logger/decision_logger.go: Core matching and calculation logic - api/server.go: API analysis window - trader/auto_trader.go: AI decision analysis window Co-Authored-By: tinkle-community <tinklefund@gmail.com>