Files
nofx/logger
tinkle a3f896d3b3 Fix: Correct PnL calculation in trade history analysis
Fixed critical issues in historical trade record and performance analysis:

1. PnL Calculation: Changed from percentage-only to actual USDT amount
   - Now correctly calculates: positionValue × priceChange% × leverage
   - Previously: 100U@5% and 1000U@5% both showed 5.0
   - Now: Properly reflects different position sizes and leverage

2. Position Tracking: Added quantity and leverage to open position records
   - Store complete trade data for accurate PnL calculation
   - Previously only stored: side, openPrice, openTime
   - Now includes: quantity, leverage for proper accounting

3. Position Key: Fixed to distinguish long/short positions
   - Changed from symbol to symbol_side (e.g., BTCUSDT_long)
   - Prevents conflicts when holding both long and short positions

4. Sharpe Ratio: Replaced custom Newton's method with math.Sqrt
   - Simplified standard deviation calculation
   - More reliable and maintainable

Impact: Win rate, profit factor, and Sharpe ratio now based on accurate USDT amounts

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 15:30:32 +08:00
..