feat: backtesting engine — historical replay with shared strategies
This commit is contained in:
parent
1d9900838d
commit
5e5425a0f7
8 changed files with 1242 additions and 1 deletions
42
backtester/config.py
Normal file
42
backtester/config.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
"""Backtest configuration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
@dataclass
|
||||
class BacktestConfig:
|
||||
"""Configuration for a single backtest run.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
start_date:
|
||||
Inclusive start of the replay window.
|
||||
end_date:
|
||||
Inclusive end of the replay window.
|
||||
initial_capital:
|
||||
Starting cash balance in USD.
|
||||
commission_per_trade:
|
||||
Fixed commission charged per order (Alpaca is commission-free,
|
||||
so the default is 0.0).
|
||||
slippage_pct:
|
||||
Simulated slippage as a fraction of price (0.001 = 0.1%).
|
||||
strategy_weights:
|
||||
Mapping of strategy name to weight. If empty, strategies
|
||||
receive equal weight (0.333...).
|
||||
max_position_pct:
|
||||
Maximum fraction of equity per position (default 5%).
|
||||
signal_threshold:
|
||||
Minimum combined signal strength to trigger a trade (default 0.3).
|
||||
"""
|
||||
|
||||
start_date: datetime
|
||||
end_date: datetime
|
||||
initial_capital: float = 100_000.0
|
||||
commission_per_trade: float = 0.0
|
||||
slippage_pct: float = 0.001
|
||||
strategy_weights: dict[str, float] = field(default_factory=dict)
|
||||
max_position_pct: float = 0.05
|
||||
signal_threshold: float = 0.3
|
||||
Loading…
Add table
Add a link
Reference in a new issue