Master equity backtesting with dividend adjustments, stock splits, corporate actions, market hours, and sector rotation strategies.
| Category | Examples | Volatility | Best For |
|---|---|---|---|
| Large Cap (>$10B) | AAPL, MSFT, GOOGL | Low-Moderate | Long-term, swing trading |
| Mid Cap ($2-10B) | CRWD, NET, DDOG | Moderate | Growth, momentum |
| Small Cap ($300M-2B) | Micro software/biotech | High | Aggressive growth |
| Penny Stocks (<$5) | OTC, pink sheets | Extreme | Speculation (risky) |
Start backtesting with liquid large caps (SPY, QQQ components) for most reliable data and execution assumptions.
Unadjusted prices make splits look like crashes and miss dividend returns. Your backtest will be wildly inaccurate without proper adjustments.
Example: AAPL Stock Split
Aug 27, 2020: 4:1 split announced
Unadjusted: $500 → $125 (looks like -75% crash!)
Adjusted: Historical prices divided by 4, chart continuous
Result: Accurate returns, no false signals
| Adjustment Type | What It Fixes | Formula | Example |
|---|---|---|---|
| Split Adjustment | Stock splits/reverse splits | Price / Split Ratio | 2:1 split: $100 → $50 |
| Dividend Adjustment | Dividend payments | Price - Dividend | $2 div: $100 → $98 |
| Merger Adjustment | Acquisitions | Buyout Price | Acquired at $50/share |
| Spinoff Adjustment | Company splits into 2 | Complex (varies) | Parent + new entity |
Most data providers offer "Adjusted Close" column. This is the gold standard for backtesting.
Only use unadjusted prices for:
Quarterly cash payments to shareholders. Critical for buy-and-hold strategies.
Ex-Dividend Date: Last day to buy to receive dividend
Payment Date: Cash hits your account
Yield: Annual dividend / stock price
Increases shares outstanding, decreases price proportionally. No change in market cap.
| Split | Shares | Price |
|---|---|---|
| Before | 100 | $500 |
| 2:1 Split | 200 | $250 |
Value unchanged: 100 × $500 = 200 × $250 = $50,000
Many stocks go to zero (bankruptcies, delistings). Backtesting only survivors inflates results.
| Session | Time (EST) | Liquidity | Characteristics |
|---|---|---|---|
| Pre-Market | 4:00am - 9:30am | Low | News reactions, wide spreads |
| Regular Hours | 9:30am - 4:00pm | High | 🔥 Best execution, tight spreads |
| After-Hours | 4:00pm - 8:00pm | Low | Earnings releases, volatile |
Most retail backtesting should focus on regular hours (9:30am-4pm) for realistic fill prices and liquidity assumptions.
Stocks gap overnight (close $50, open $52) due to after-hours news. This creates opportunities but also risk. Backtest with realistic gap assumptions - you can't buy at yesterday's close if it gaps up at open.
| Sector | Examples | Cycle Phase | Characteristics |
|---|---|---|---|
| Technology (XLK) | AAPL, MSFT, NVDA | Growth | High growth, rate-sensitive |
| Financials (XLF) | JPM, BAC, GS | Expansion | Rate increases benefit banks |
| Healthcare (XLV) | JNJ, UNH, PFE | Defensive | Stable, recession-resistant |
| Energy (XLE) | XOM, CVX, COP | Late cycle | Commodity-driven, cyclical |
| Consumer Staples (XLP) | PG, KO, WMT | Defensive | Recession-proof, low vol |
Different sectors outperform at different economic stages:
Test sector rotation by comparing sector ETFs (XLK, XLF, XLV) performance vs SPY. Switch to outperforming sectors monthly or quarterly. This often beats buy-and-hold with similar risk.
Stocks move 5-15% on earnings (sometimes 20-30%). This creates both opportunity and risk for your backtest.
| Scenario | Stock Reaction | Typical Move |
|---|---|---|
| Beat + Guidance Raise | Gap up | +5 to +15% |
| Beat + Guidance Lower | Mixed | -2 to +3% |
| Meet Expectations | Flat | -2 to +2% |
| Miss Earnings | Gap down | -8 to -20% |
Include earnings dates in your backtest. Test two versions: 1) Exit before earnings, 2) Hold through earnings. The first usually has lower returns but much lower risk (Sharpe ratio often better).
To backtest stocks: 1) Use adjusted prices for accurate returns (accounts for dividends and splits), 2) Test during market hours (9:30am-4pm EST) for realistic fills, 3) Include corporate actions (splits, dividends, mergers), 4) Account for pattern day trader rules if under $25K, 5) Use at least 10 years of data covering bull/bear markets. Always backtest with realistic slippage and commissions.
Always use adjusted prices for backtesting. Adjusted prices account for dividends and stock splits to show true returns. Without adjustments, a 2:1 split looks like a -50% crash. Most data providers offer "adjusted close" which is the standard for backtesting. Use unadjusted prices only for analyzing actual entry/exit price levels.
Use split-adjusted data from your provider. Modern backtesting platforms automatically adjust historical prices for splits. For manual adjustments: multiply all prices before the split by the split ratio (e.g., 2:1 split means divide all prior prices by 2). This ensures chart continuity and accurate return calculations.