mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-04 11:30:58 +08:00
## Problem (Issue #592) risk_usd formula incorrectly multiplies leverage twice: - Incorrect: risk_usd = |Entry - Stop| × Position Size × Leverage ❌ This causes AI to calculate risk as 10x (or leverage倍) higher than actual. ## Root Cause Position Size already includes leverage effect: - Position Size (coins) = position_size_usd / price - position_size_usd = margin × leverage - Therefore: Position Size = (margin × leverage) / price Multiplying leverage again amplifies risk calculation by "leverage" times. ## Example Scenario: $100 margin, 10x leverage, 0.02 BTC position, $500 stop distance **Correct calculation:** risk_usd = $500 × 0.02 = $10 ✅ Risk % = 10% of margin (reasonable) **Incorrect calculation (current):** risk_usd = $500 × 0.02 × 10 = $100 ❌ Risk % = 100% of margin (completely wrong!) ## Impact - AI miscalculates risk as "leverage" times higher - May refuse valid trades thinking risk is too high - Risk control logic becomes ineffective - Potential for position sizing errors ## Solution Correct formula: risk_usd = |Entry - Stop| × Position Size (coins) Added warnings: - CN: ⚠️ 不要再乘杠杆:仓位数量已包含杠杆效应 - EN: ⚠️ Do NOT multiply by leverage: Position Size already includes leverage effect ## Modified Files - prompts/adaptive.txt (line 404) - prompts/nof1.txt (line 104) Closes #592