Phase 3: TP/SL Optimization Analytics API

- Created /api/analytics/tp-sl-optimization endpoint
- Analyzes historical trades using MAE/MFE data
- Calculates optimal TP1/TP2/SL levels based on percentiles
- Provides win rate, profit factor, and hit rate analysis
- Shows money left on table (MFE - realized P&L)
- Projects impact of optimal levels on future performance

Analytics calculated:
- MAE analysis: avg, median, percentiles, worst
- MFE analysis: avg, median, percentiles, best
- Current level performance: TP1/TP2/SL hit rates
- Optimal recommendations: TP1=50% of avg MFE, TP2=80%, SL=70% of avg MAE
- Projected improvements: win rate change, profit factor, total P&L

Requires 10+ closed trades with MAE/MFE data to generate recommendations
Test script: scripts/test-analytics.sh

Next: Phase 4 (visual dashboard) or wait for trades with MAE/MFE data
This commit is contained in:
mindesbunister
2025-10-29 21:11:23 +01:00
parent e068c5f2e6
commit da72b5de04
2 changed files with 334 additions and 0 deletions

15
scripts/test-analytics.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Test TP/SL Optimization Analytics Endpoint
# Usage: ./scripts/test-analytics.sh
echo "🔍 Testing TP/SL Optimization Analytics..."
echo ""
RESPONSE=$(curl -s http://localhost:3001/api/analytics/tp-sl-optimization)
# Pretty print JSON response
echo "$RESPONSE" | jq '.' || echo "$RESPONSE"
echo ""
echo "✅ Test complete"