- Fix external closure P&L using tp1Hit flag instead of currentSize - Add direction change detection to prevent false TP1 on signal flips - Signal flips now recorded with accurate P&L as 'manual' exits - Add retry logic with exponential backoff for Solana RPC rate limits - Create /api/trading/cancel-orders endpoint for manual cleanup - Improves data integrity for win/loss statistics
24 lines
758 B
Bash
Executable File
24 lines
758 B
Bash
Executable File
#!/bin/bash
|
|
# Run optimal exit analysis and save results
|
|
# Usage: ./run_exit_analysis.sh
|
|
|
|
OUTPUT_FILE="exit_analysis_results_$(date +%Y%m%d_%H%M%S).txt"
|
|
|
|
echo "🔍 Running optimal exit level analysis..."
|
|
echo "Results will be saved to: $OUTPUT_FILE"
|
|
echo ""
|
|
|
|
# Run the SQL analysis
|
|
docker exec trading-bot-postgres psql -U postgres -d trading_bot_v4 -f scripts/analyze_optimal_exits.sql | tee "$OUTPUT_FILE"
|
|
|
|
echo ""
|
|
echo "✅ Analysis complete!"
|
|
echo "📊 Results saved to: $OUTPUT_FILE"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Review the output above"
|
|
echo "2. Look for patterns in MFE/MAE distribution"
|
|
echo "3. Check if quality score correlation is strong"
|
|
echo "4. Decide on optimal TP1/TP2/SL levels"
|
|
echo "5. Update config/trading.ts with new settings"
|