Backtesting Engine
Detailed documentation of the backtesting system: methodology, assumptions, and implementation details.
Overview
The backtesting engine is built in Python using pandas and numpy for efficient data processing. It simulates trading strategies on historical data to evaluate their performance before live deployment.
Key Features
- Vectorized backtesting for fast execution
- Walk-forward optimization
- Out-of-sample testing
- Realistic transaction costs and slippage
- Multiple performance metrics
- Risk-adjusted returns analysis
Methodology
Data Requirements
- Historical Period: 5 years of daily OHLCV data
- Data Source: yfinance API
- Symbols: 21 global market indices
- Frequency: Daily bars
Execution Logic
- Calculate technical indicators for each symbol
- Generate trading signals based on strategy rules
- Simulate order execution with realistic assumptions
- Track portfolio value and positions over time
- Calculate performance metrics and risk statistics
Trading Assumptions
Costs & Slippage
- • Commission: $0 (zero-commission brokers)
- • Slippage: 0.1% per trade
- • Spread: Included in slippage
Position Sizing
- • Initial Capital: $100,000
- • Position Size: 100% of capital
- • No leverage
Order Execution
- • Entry: Next day's open price
- • Exit: Next day's open price
- • Market orders only
Risk Management
- • Stop-loss: Strategy-dependent
- • Take-profit: Strategy-dependent
- • Max position: 100%