Update scoring system

This commit is contained in:
2025-07-11 20:58:28 +07:00
parent 8a2b0ba323
commit 754a21da69
6 changed files with 304 additions and 95 deletions

109
README.md
View File

@@ -381,6 +381,115 @@ This configuration allows for more aggressive trading strategies while maintaini
- **Initial Balance**: Starting capital for backtest
- **Advanced Config**: All bot parameters (time limits, profit control, etc.)
### Backtest Scoring System
The backtest scoring system evaluates strategy performance using a comprehensive multi-factor approach with weighted components and dynamic penalties. The final score ranges from 0-100, where 100 represents optimal performance.
#### Scoring Components (Weighted Distribution)
| Component | Weight | Description |
|-----------|--------|-------------|
| **Growth Percentage** | 25% | Primary performance metric based on total return |
| **Sharpe Ratio** | 15% | Risk-adjusted return measure |
| **Max Drawdown (USD)** | 12% | Maximum capital loss in absolute terms |
| **Win Rate** | 15% | Percentage of profitable trades (weighted by trade count) |
| **Profitability Bonus** | 8% | Additional reward for positive returns |
| **Hodl Comparison** | 5% | Performance vs buy-and-hold strategy |
| **Trade Count** | 5% | Sufficient trading activity validation |
| **Recovery Time** | 2% | Time to recover from maximum drawdown |
| **Test Duration** | 3% | Adequate testing period validation |
| **Fees Impact** | 2% | Trading cost efficiency |
#### Component Scoring Details
**Growth Percentage (25%)**
- **Negative Returns**: Linear penalty (20 + growth% × 1.5)
- **0-5%**: Linear scale (0-40 points)
- **5-10%**: Accelerated scale (40-100 points)
- **10%+**: Full score (100 points)
**Sharpe Ratio (15%)**
- **Negative**: 0 points
- **0-4**: Linear scale (0-100 points)
- **4+**: Full score (100 points)
**Max Drawdown USD (12%)**
- **0-30%**: Exponential penalty (100 - (drawdown%/30 × 100)^1.5)
- **30%+**: 0 points
**Win Rate (15%)**
- **Base Score**: Win rate percentage
- **Trade Count Factor**: Full significance at 55+ trades, reduced for fewer trades
- **Minimum Trade Penalty**: 50% penalty for <10 trades
**Profitability Bonus (8%)**
- **Positive Returns**: Logarithmic bonus (50 × (1 - 1/(1 + growth%/30)))
- **Negative Returns**: 0 points
**Hodl Comparison (5%)**
- **Outperforms Hodl**: 0-80 points based on margin
- **Underperforms Hodl**: 0-20 points based on underperformance
**Trade Count (5%)**
- **<5 trades**: 0 points
- **5-10 trades**: Linear scale (0-50 points)
- **10-50 trades**: Linear scale (50-100 points)
- **50+ trades**: 100 points
**Recovery Time (2%)**
- **Timeframe-adjusted expectations**:
- 5m: 3 days max recovery
- 15m: 5 days max recovery
- 30m: 10 days max recovery
- 1h: 15 days max recovery
- 4h: 30 days max recovery
- 1d: 90 days max recovery
**Test Duration (3%)**
- **Timeframe-adjusted minimums**:
- 5m: 14 days minimum
- 15m: 28 days minimum
- 30m: 56 days minimum
- 1h: 84 days minimum
- 4h: 120 days minimum
- 1d: 90 days minimum
- **Optimal duration**: 3× minimum duration
**Fees Impact (2%)**
- **0-2% fees**: Linear penalty (100-50 points)
- **2-5% fees**: Linear penalty (50-0 points)
- **5%+ fees**: 0 points
- **Fees > PnL**: 0 points
#### Dynamic Penalty System
The scoring system applies dynamic penalties based on performance thresholds:
**Profitability Rules**
- **Negative Growth**: 10% penalty per 1% loss
- **Negative Absolute PnL**: 70% penalty
- **Low Win Rate**: 50% penalty per 10% below 30% (for 10+ trades)
- **Low Profit**: 10% penalty per 1% below 2% (for 5+ trades)
- **High Drawdown**: 2% penalty per 1% above 20%
- **Short Test Duration**: 2% penalty per day below 30 days
**Special Rules**
- **No Positions**: Automatic 0 score
- **Score Clamping**: Final score clamped between 0-100
- **Error Handling**: Returns 0 for any calculation errors
#### Scoring Philosophy
The system prioritizes:
1. **Consistent profitability** over high-risk gains
2. **Risk management** through drawdown control
3. **Statistical significance** through adequate trade counts
4. **Timeframe-appropriate** expectations for recovery and duration
5. **Cost efficiency** through fee management
6. **Realistic performance** through dynamic penalties
This comprehensive approach ensures that high-scoring strategies demonstrate robust, sustainable performance across multiple dimensions rather than relying on single metrics or short-term luck.
### RunBacktestRequest Structure
The backtest request supports both saved and dynamic configurations: