Appearance
Learn Backtesting
Everything you need to get started with professional strategy testing.
Quick Start - Get your first backtest running in under 60 seconds
Option 1: Try Without Signup (Recommended)
The fastest way to get started is with guest mode - no signup required!
What You Get:
- ✅ 3 free backtests
- ✅ Popular symbols (SPY, AAPL, GOOGL, MSFT)
- ✅ 30 days of historical data
- ✅ Core technical indicators
- ✅ Full results and metrics
Your First Strategy
Once you're in the app, you'll see a pre-loaded demo strategy. Here's what it does:
python
BACKTEST_CONFIG = {
'start_date': '20240101',
'end_date': '20240201',
'initial_capital': 10000
}
def on_bar_close(data_contexts, portfolio, state):
"""Simple moving average crossover"""
data = data_contexts['SPY']
# Calculate moving averages
sma_fast = data.sma(10) # 10-day average
sma_slow = data.sma(20) # 20-day average
# Skip if not enough data
if sma_fast is None or sma_slow is None:
return
# Buy when fast crosses above slow
if sma_fast > sma_slow and portfolio.position('SPY') == 0:
shares = int(portfolio.cash * 0.5 / data.close)
if shares > 0:
buy('SPY', shares)
# Sell when fast crosses below slow
elif sma_fast < sma_slow and portfolio.position('SPY') > 0:
sell('SPY', portfolio.position('SPY'))
Steps:
- Review the Strategy - The code is already loaded
- Click "Run Backtest" - See results in seconds
- Modify and Experiment - Try changing parameters
- Sign Up When Ready - Get unlimited backtests
Option 2: Create a Free Account
Want to save strategies and get more features? Create a free account:
- Visit app.backtestingengine.com
- Click "Sign Up" - Use email or Google
- Verify Email - Check your inbox
- Start Testing - 480 compute minutes free/month
Free Account Benefits:
- 💾 Save unlimited strategies
- 📊 Access all symbols
- 📈 Full historical data
- 🔧 Advanced indicators
- 📤 Export results
Understanding the Interface
Editor Panel (Left)
- Strategy Code: Write your Python strategy here
- Syntax Highlighting: Automatic Python highlighting
- Auto-Save: Changes saved as you type (logged-in users)
- Examples Menu: Load pre-built strategies
Results Panel (Right)
- Metrics Tab: Key performance indicators
- Trades Tab: Individual trade details
- Chart Tab: Equity curve visualization
- Logs Tab: Debug output from your strategy
Key Concepts
1. Strategy Structure
Every strategy needs:
- BACKTEST_CONFIG: Define dates and capital
- on_bar_close(): Main logic executed each bar
2. Data Access
python
data = data_contexts['SPY'] # Get symbol data
price = data.close # Current close price
sma = data.sma(20) # 20-day moving average
3. Order Execution
python
buy('SPY', 100) # Buy 100 shares
sell('SPY', 50) # Sell 50 shares
sell_all('SPY') # Close entire position
4. Portfolio Info
python
cash = portfolio.cash # Available cash
position = portfolio.position('SPY') # Current shares
equity = portfolio.equity # Total value
Common Patterns
Pattern 1: Momentum Strategy
python
if data.close > data.sma(50):
# Uptrend - go long
if portfolio.position('SPY') == 0:
buy('SPY', 100)
elif portfolio.position('SPY') > 0:
# Exit position
sell_all('SPY')
Pattern 2: Mean Reversion
python
rsi = data.rsi(14)
if rsi < 30 and portfolio.position('SPY') == 0:
# Oversold - buy
buy('SPY', 100)
elif rsi > 70 and portfolio.position('SPY') > 0:
# Overbought - sell
sell_all('SPY')
Pattern 3: Risk Management
python
# Position sizing based on portfolio
position_size = int(portfolio.equity * 0.02 / data.close)
# Stop loss
if portfolio.position('SPY') > 0:
entry_price = state.get('entry_price', data.close)
if data.close < entry_price * 0.95: # 5% stop loss
sell_all('SPY')
What Just Happened?
When you run a backtest:
- Historical Data Loaded - Real market data from the date range
- Strategy Executed - Your code runs on each trading day
- Orders Simulated - Buys and sells executed at market prices
- Performance Calculated - Metrics computed from results
Common Questions
Q: Is this using real money? A: No! This is a simulation using historical data. No real money involved.
Q: Why start with guest mode? A: You can test immediately without signup. Perfect for learning.
Q: What symbols can I trade? A: Guest mode: SPY, AAPL, GOOGL, MSFT. Free account: All US stocks.
Q: How accurate is the simulation? A: We use real historical data with realistic execution modeling.
Next Steps
Learning Paths
📚 Complete Beginner
- What is Backtesting? - Core concepts
- First Strategy Tutorial - Build from scratch
- Example Library - Study working strategies
🔧 Ready to Code
- API Reference - All available functions
- Strategy Development - Advanced patterns
- Best Practices - Professional techniques
💡 Strategy Ideas
- Basic Strategies - Start with simple concepts
- Advanced Examples - Complex implementations
- Risk Management - Protect your capital
Tips for Success
- Start Simple - Master basic strategies before complex ones
- Test Thoroughly - Try different time periods and market conditions
- Manage Risk - Always include stop losses and position sizing
- Keep Learning - Markets evolve, so should your strategies