Using Backtest

Master the Backtest tool to validate your pairs trading strategies using historical data.

🚀 Quick Start Guide

1Select two stocks for your trading pair
2Choose your date range for historical testing
3Configure entry/exit parameters and risk management
4Run backtest and analyze performance results

1. Understanding Backtesting

Backtesting is a powerful method to test trading strategies using historical data before risking real money.

📊 What Backtesting Does:
  • Strategy Validation: Test your trading logic on historical data
  • Performance Measurement: Quantify returns, risk, and drawdowns
  • Parameter Optimization: Find optimal settings for your strategy
  • Risk Assessment: Understand potential losses and volatility
🎯 Backtesting Benefits:
  • Risk-Free Testing: No real money at risk during testing
  • Data-Driven Decisions: Base strategies on historical evidence
  • Strategy Refinement: Identify and fix strategy weaknesses
  • Confidence Building: Trade with proven strategy performance

2. Setting Up Your Backtest

Configure your backtest parameters to match your trading strategy and risk tolerance.

📈 Stock Pair Selection:
  • Stock A & Stock B: Choose from available stocks in your database
  • Data Availability: Ensure both stocks have sufficient historical data
  • Correlation: Select pairs that historically move together
  • Liquidity: Consider trading volume and bid-ask spreads
📅 Date Range Selection:
  • From Date: Start of your testing period (default: 2021-01-01)
  • To Date: End of your testing period (default: today)
  • Recommended Duration: At least 1-2 years for reliable results
  • Market Cycles: Include both bull and bear market periods

3. Configuring Strategy Parameters

Fine-tune your trading strategy parameters for optimal performance and risk management.

⚙️ Core Strategy Parameters:
Lookback Period:

Days for calculating Z-scores (default: 60)

Entry Z-Score:

Threshold for opening trades (default: 2.5)

Exit Z-Score:

Threshold for closing trades (default: 1.5)

🛡️ Risk Management Parameters:
Time Stop:

Maximum days to hold a trade (default: 15)

Loss Stop:

Maximum loss percentage (default: -10%)

Target Profit:

Profit target percentage (default: 10%)

4. Running Your Backtest

Execute your backtest and monitor the simulation process to generate performance results.

▶️ Execution Steps:
  1. 1. Verify all parameters are set correctly
  2. 2. Ensure both stocks have data for the selected date range
  3. 3. Click the "Run Backtest" button
  4. 4. Wait for the analysis to complete
  5. 5. Review the generated results and trade history
📊 What Happens During Backtest:
  • Data Processing: Historical prices are aligned and processed
  • Z-Score Calculation: Rolling Z-scores computed for each day
  • Trade Simulation: Entry/exit signals trigger virtual trades
  • Performance Tracking: P&L, drawdowns, and statistics calculated

5. Understanding Backtest Results

Learn how to interpret the backtest results to evaluate strategy performance and make improvements.

📈 Performance Metrics:
Total Return:

Overall strategy performance percentage

Win Rate:

Percentage of profitable trades

Average Trade:

Mean profit/loss per trade

Max Drawdown:

Largest peak-to-trough decline

📋 Trade History:
  • Entry/Exit Dates: When trades were opened and closed
  • Trade Type: LONG (buy ratio) or SHORT (sell ratio)
  • Entry/Exit Z-Scores: Z-score values at trade points
  • Exit Reason: Why the trade was closed (target, stop, time)
  • Trade P&L: Profit or loss for each individual trade
6

Strategy Optimization

Use backtest results to refine your strategy parameters and improve performance.

🔧 Parameter Tuning:
  • Entry Thresholds: Adjust Z-score levels for better entry timing
  • Exit Thresholds: Optimize profit taking and loss cutting
  • Lookback Periods: Test different calculation windows
  • Risk Parameters: Fine-tune stops and targets
📊 Performance Analysis:
  • Identify Patterns: Look for common exit reasons
  • Risk Assessment: Evaluate drawdown patterns
  • Market Conditions: Analyze performance in different periods
  • Strategy Validation: Confirm strategy works across time

💡 Best Practices & Tips

🎯 Backtesting Strategy:
  • • Test strategies across multiple market cycles
  • • Use out-of-sample data for final validation
  • • Consider transaction costs and slippage
  • • Avoid overfitting to historical data
⚡ Performance Optimization:
  • • Focus on risk-adjusted returns, not just total returns
  • • Monitor drawdowns and recovery periods
  • • Test parameter sensitivity and robustness
  • • Consider market regime changes
🔄 Continuous Improvement:
  • • Regularly re-run backtests with new data
  • • Document successful parameter combinations
  • • Compare performance across different pairs
  • • Integrate backtest results with live trading

🎯 What's Next?

Now that you understand how to use the Backtest tool, validate your strategies and optimize your trading approach.