Add Phase 2 trading rules documentation and data README

This commit is contained in:
root
2026-03-28 20:05:21 +04:00
parent c194755e26
commit 12bc699ddb
2 changed files with 109 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
# Data Directory
CSV files are not tracked in git (too large).
## Required files
```
EURUSD_5M.csv
GBPUSD_5M.csv
USDJPY_5M.csv
```
## How to obtain data
1. Download 1-minute data from [HistData.com](https://www.histdata.com/):
- EURUSD, GBPUSD, USDJPY
- Years 2024, 2025, and 2026 (Jan-Mar)
- 1-minute bar format (MetaTrader compatible)
2. Place `.zip` files in this directory
3. Run the resampling script:
```bash
python3 ../scripts/resample_to_5m.py
```
This produces the `*_5M.csv` files needed for training.
## Data format
CSV columns:
```
open,high,low,close,volume
1.07451,1.07481,1.07432,1.07465,12345
...
```
+74
View File
@@ -0,0 +1,74 @@
# Phase 2 Trading Rules
## Signal Generation
- Source: Genetic Programming tree evolved over 3000 individuals × 30 generations
- Input features: EURUSD, GBPUSD, USDJPY OHLC (12 inputs total)
- Output: Continuous signal -100 to +100
- Long entry: signal > +5.0
- Short entry: signal < -5.0
- Dead band: -5.0 to +5.0 (no trade)
## Per Trade Risk Management
| Parameter | Value |
|-----------|-------|
| Trade size (training) | $1,000 USD |
| Trade size (live) | $300 USD |
| Max concurrent (live) | 3 trades |
| Max exposure (live) | $900 USD |
| Initial SL | 1x ATR below/above entry |
| Trail trigger | 3x ATR profit from entry |
| Trail distance | 15% behind current price |
| Close condition | 15% reversal from peak/trough |
## Long Trade Example
```
Entry: 150.00 USDJPY
ATR: 0.30
SL initial: 149.70 (150.00 - 1×0.30)
Trail activates: 150.90 (150.00 + 3×0.30)
Price moves to: 151.00
New SL: 128.35 (151.00 × 0.85)
Price moves to: 152.00
New SL: 129.20 (152.00 × 0.85)
Price drops to: 129.20 → CLOSE
Profit: ~1:7 risk/reward
```
## Short Trade Example
```
Entry: 150.00 USDJPY
ATR: 0.30
SL initial: 150.30 (150.00 + 1×0.30)
Trail activates: 149.10 (150.00 - 3×0.30)
Price drops to: 149.00
New SL: 171.35 (149.00 × 1.15)
Price drops to: 148.00
New SL: 170.20 (148.00 × 1.15)
Price rises to: 170.20 → CLOSE
Profit: ~1:7 risk/reward
```
## Fitness Function
Win rate is PRIMARY objective (weight 6.0):
```python
win_bonus = (win_rate - 50.0) / 10.0
trade_penalty = max(0.0, (n_trades - 3000) / 10000.0)
fitness = -(6.0 * win_bonus) - (0.5 * sharpe) - (0.1 * total_ret / 10.0) + trade_penalty
```
- 80% win rate → win_bonus = +3.0 → strong reward
- 50% win rate → win_bonus = 0.0 → neutral
- 40% win rate → win_bonus = -1.0 → penalised
## Backtesting Configuration
- Library: vectorbt 0.28.5
- Train: Jan 2024 – Jun 2025 (44,310 bars)
- Validation: Jul 2025 – Oct 2025 (10,079 bars)
- Test: Nov 2025 – Mar 2026 (6,420 bars)
- Commission: 0.0015% per side
- Initial cash: $100,000