Live Trading
Moving from backtest to live trading is a significant step. This guide covers the process and best practices.
The Transition
Backtest → Paper Trading → Live Trading
↓ ↓ ↓
Theoretical Simulated Real
Why Paper Trade First?
Before risking real capital:
- Verify behavior - Does the strategy trade as expected?
- Test infrastructure - Are systems reliable?
- Build confidence - Gain experience without risk
- Compare metrics - Validate backtest assumptions
Pre-Launch Checklist
Strategy Ready
- Backtest Sharpe > 1.0 over 3+ years
- Max drawdown < 20%
- Passed walk-forward analysis
- Paper traded for 2-4 weeks
- Performance tracks backtest within 20%
Infrastructure Ready
- API keys configured and tested
- Error notifications set up
- Kill switch accessible
- Monitoring dashboard ready
- Emergency contact list prepared
Risk Management Set
- Maximum position size defined
- Maximum drawdown limit set
- Daily loss limit configured
- Correlation limits in place
Paper Trading
Setup
from vecalpha import PaperTrading
paper = PaperTrading(
strategy=MyStrategy,
symbols=['AAPL', 'MSFT', 'GOOGL'],
initial_capital=100000,
commission=0.001
)
paper.start()
Monitoring
Track key metrics daily:
| Metric | Check |
|---|---|
| Number of trades | Expected range? |
| Win rate | Similar to backtest? |
| Slippage | Within assumptions? |
| Latency | Acceptable delays? |
Comparison Framework
# Compare paper vs backtest
comparison = paper.compare_to_backtest(backtest_results)
print(f"Return difference: {comparison.return_diff:.2%}")
print(f"Trade count ratio: {comparison.trade_ratio:.2f}")
print(f"Win rate difference: {comparison.win_rate_diff:.2%}")
if comparison.return_diff > 0.20:
print("WARNING: Significant divergence from backtest")
Going Live
Gradual Scaling
Don't deploy full capital immediately:
Week 1-2: 25% of target capital
Week 3-4: 50% of target capital
Week 5+: 100% of target capital
Risk Limits
risk_config = {
'max_position_pct': 0.10, # Max 10% in single position
'max_sector_pct': 0.30, # Max 30% in single sector
'max_daily_loss': 0.02, # Stop if down 2% in a day
'max_drawdown': 0.10, # Stop if drawdown hits 10%
'max_trades_per_day': 20, # Limit trading frequency
}
strategy.set_risk_config(risk_config)
Kill Switch
Emergency stop capability:
# Immediate halt
strategy.emergency_stop()
# Scheduled pause
strategy.pause(duration='24h')
# Reduce positions
strategy.reduce_positions(target_pct=0.50)
Live Monitoring
Daily Checks
| Check | What to Look For |
|---|---|
| Positions | Expected sizes and directions |
| P&L | Within normal variance |
| Orders | Filled correctly, no rejects |
| Errors | System errors, API issues |
Performance Tracking
# Real-time metrics
dashboard = LiveDashboard(strategy)
dashboard.show_metrics()
# Periodic reports
report = strategy.generate_report(period='weekly')
report.email_to('[email protected]')
Alert Configuration
alerts = {
'drawdown_alert': {'threshold': 0.05, 'action': 'notify'},
'loss_alert': {'threshold': 0.02, 'action': 'notify'},
'error_alert': {'threshold': 1, 'action': 'notify + pause'},
'position_alert': {'threshold': 0.15, 'action': 'notify'},
}
strategy.configure_alerts(alerts)
Live vs Backtest Divergence
Common Causes
| Divergence | Likely Cause |
|---|---|
| Fewer trades | Stricter fill conditions |
| Lower returns | Slippage, missed opportunities |
| Higher variance | Market regime change |
| Different signals | Data feed differences |
How to Handle
- Document differences - Track when and where divergence occurs
- Investigate root cause - Is it infrastructure, market, or strategy?
- Adjust expectations - Live performance is usually 10-30% lower
- Consider re-optimization - If divergence is systematic
# Track divergence over time
divergence_log = []
def track_divergence(live_result, backtest_result):
div = {
'date': datetime.now(),
'live_return': live_result.return,
'backtest_return': backtest_result.return,
'divergence': live_result.return - backtest_result.return
}
divergence_log.append(div)
# Alert if significant
if abs(div['divergence']) > 0.10:
send_alert(f"Large divergence detected: {div['divergence']:.2%}")
Operational Best Practices
Regular Reviews
| Frequency | Review Content |
|---|---|
| Daily | Positions, P&L, errors |
| Weekly | Performance metrics, risk exposure |
| Monthly | Strategy effectiveness, market regime |
| Quarterly | Full strategy review, optimization |
Documentation
Maintain a trading log:
## [Date] Trading Log
### Market Conditions
- Trend: Bullish/Bearish/Sideways
- Volatility: High/Normal/Low
- Key Events: [Earnings, Fed, etc.]
### Strategy Performance
- Trades: X
- P&L: X%
- Issues: [Any problems]
### Notes
- [Observations, adjustments needed]
Contingency Plans
| Scenario | Action |
|---|---|
| API failure | Switch to backup, manual review |
| Unexpected loss > 5% | Pause, investigate |
| Market circuit breaker | Halt all strategies |
| Strategy bug | Immediate stop, fix, paper test |
When to Stop
Red Lines
Stop trading if:
- Max drawdown exceeded
- Live Sharpe < 0 for extended period
- Systematic divergence from backtest
- Market regime fundamentally changed
- Strategy logic proven flawed
Post-Mortem
After stopping, analyze:
- What went wrong? - Strategy, execution, or market?
- What assumptions failed? - Backtest missed something?
- What can be improved? - For next iteration
Scaling Up
When Ready to Increase Capital
Criteria for scaling:
- 3+ months of profitable live trading
- Risk metrics within targets
- Consistent execution
- Comfortable with drawdowns
- Adequate capital reserves
Multi-Strategy Portfolio
portfolio = Portfolio([
{'strategy': TrendStrategy, 'allocation': 0.40},
{'strategy': MeanReversionStrategy, 'allocation': 0.30},
{'strategy': MomentumStrategy, 'allocation': 0.30},
])
portfolio.set_correlation_limit(0.6) # Max correlation
portfolio.set_max_drawdown(0.15) # Portfolio-level limit
Summary
| Phase | Duration | Key Actions |
|---|---|---|
| Paper Trading | 2-4 weeks | Validate behavior |
| Initial Live | 1-2 months | Scale up gradually |
| Full Deployment | Ongoing | Monitor and iterate |
Next Steps
- Risk Management - Protect your capital
- Advanced Topics - Multi-asset strategies