diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-01 18:25:29 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-01 18:25:29 +0900 |
| commit | 5cee0686e421b1f21484c23e413692616e9e2ffa (patch) | |
| tree | 0a6343ebeca158d5881c57cb71e9f67800fda535 /services/backtester/tests/test_walk_forward.py | |
| parent | 7bfdf07dccb09a613f66f63d1513b80f167a3881 (diff) | |
feat(backtester): Phase 1 complete — realistic backtesting engine
- Slippage modeling (configurable per-trade, buy higher/sell lower)
- Trading fee deduction (maker/taker configurable)
- Stop-loss and take-profit auto-execution per position
- Short selling support (allow_short flag)
- Walk-forward analysis engine (in-sample/out-of-sample, efficiency ratio)
- Daily equity curve Sharpe/Sortino with risk-free rate adjustment
- Recovery factor, consecutive win/loss streaks, fee-aware PnL
- 312 tests passing
Diffstat (limited to 'services/backtester/tests/test_walk_forward.py')
| -rw-r--r-- | services/backtester/tests/test_walk_forward.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/services/backtester/tests/test_walk_forward.py b/services/backtester/tests/test_walk_forward.py index e672dac..5ab2e7b 100644 --- a/services/backtester/tests/test_walk_forward.py +++ b/services/backtester/tests/test_walk_forward.py @@ -1,10 +1,10 @@ """Tests for walk-forward analysis.""" + import sys from pathlib import Path from decimal import Decimal from datetime import datetime, timedelta, timezone -import pytest sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src")) sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "strategy-engine")) @@ -19,15 +19,18 @@ def _generate_candles(n=100, base_price=100.0): for i in range(n): # Simple oscillating price price = base_price + (i % 20) - 10 - candles.append(Candle( - symbol="BTCUSDT", timeframe="1h", - open_time=datetime(2025, 1, 1, tzinfo=timezone.utc) + timedelta(hours=i), - open=Decimal(str(price)), - high=Decimal(str(price + 5)), - low=Decimal(str(price - 5)), - close=Decimal(str(price)), - volume=Decimal("100"), - )) + candles.append( + Candle( + symbol="BTCUSDT", + timeframe="1h", + open_time=datetime(2025, 1, 1, tzinfo=timezone.utc) + timedelta(hours=i), + open=Decimal(str(price)), + high=Decimal(str(price + 5)), + low=Decimal(str(price - 5)), + close=Decimal(str(price)), + volume=Decimal("100"), + ) + ) return candles |
