Chapter 7: Going to Production¶
Deploy strategies from research to live trading.
The Production Journey¶
Each stage requires different considerations.
Pre-Production Checklist¶
Strategy Validation¶
- Walk-forward Sharpe > 0.5
- Degradation < 50%
- Positive after realistic costs
- Stable parameters
- Reasonable turnover
Infrastructure¶
- Data pipeline operational
- Broker connection tested
- Alerting configured
- Monitoring in place
- Backup procedures documented
Risk Controls¶
- Position limits set
- Exposure limits configured
- Circuit breakers enabled
- Maximum loss defined
From Research to Production¶
Research Code¶
Text Only
// research/momentum.sig
data:
source = "historical_prices.parquet"
params:
lookback: range(40, 100, 20) // Optimize
signal momentum:
emit zscore(ret(prices, lookback))
portfolio research:
weights = rank(momentum).long_short(top=0.2, bottom=0.2)
backtest walk_forward(...) from 2010-01-01 to 2024-12-31
Production Code¶
Text Only
// production/momentum_live.sig
config: "config/production.yaml"
data:
source = "s3://mybucket/live_prices/"
format = parquet
// Fixed parameters (from optimization)
signal momentum:
emit zscore(ret(prices, 60))
portfolio live:
weights = rank(momentum).long_short(
top = 0.2,
bottom = 0.2,
cap = 0.03
)
constraints:
gross_exposure = 2.0
net_exposure = 0.0
max_sector = 0.20
max_position = 0.03
costs = tc.bps(10)
Key Differences¶
| Aspect | Research | Production |
|---|---|---|
| Parameters | Optimized | Fixed |
| Data Source | Historical | Live feed |
| Execution | Simulated | Real orders |
| Monitoring | Manual | Automated |
| Error Handling | None | Comprehensive |
Production Configuration¶
Main Config File¶
YAML
# config/production.yaml
# Environment
environment: production
log_level: info
# Data
data:
source: "s3://mybucket/prices/"
refresh_interval: 1h
cache_dir: "/var/cache/sigc"
# Strategy parameters
params:
lookback: 60
top_pct: 0.20
position_cap: 0.03
# Risk limits
risk:
max_position: 0.03
max_sector: 0.20
max_daily_loss: 0.03
max_drawdown: 0.15
gross_exposure: 2.0
net_exposure_range: [-0.1, 0.1]
# Transaction costs
costs:
commission_bps: 5
spread_bps: 5
market_impact_bps: 2
# Execution
execution:
broker: alpaca
order_type: limit
limit_offset_bps: 5
max_order_size: 0.02
Daemon Mode¶
Setup¶
YAML
# config/daemon.yaml
daemon:
enabled: true
pid_file: "/var/run/sigc/strategy.pid"
log_file: "/var/log/sigc/strategy.log"
schedule:
# Compute weights before market close
- cron: "30 15 * * 1-5"
action: compute_weights
timezone: "America/New_York"
# Execute trades
- cron: "55 15 * * 1-5"
action: execute_trades
timezone: "America/New_York"
Start Daemon¶
Bash
# Start in paper mode first
sigc daemon start \
--strategy production/momentum_live.sig \
--config config/production.yaml \
--paper
# Check status
sigc daemon status
Paper Trading¶
Why Paper Trade First?¶
- Verify execution logic
- Test broker integration
- Validate data pipeline
- Check alerting
- Build confidence
Duration¶
Minimum 2-4 weeks of paper trading before going live.
What to Check¶
- Trades execute correctly
- Position sizes match targets
- Transaction costs reasonable
- No unexpected errors
- Performance tracks expectations
Going Live¶
Final Pre-Live Checklist¶
Text Only
Pre-Flight Checks
=================
[✓] Strategy file valid
[✓] Data source accessible
[✓] Broker connection OK
[✓] Account has sufficient capital
[✓] Risk limits configured
[✓] Alerting configured
[✓] Logging enabled
Ready for live trading.
Start Live Trading¶
Bash
# Start live
sigc daemon start \
--strategy production/momentum_live.sig \
--config config/production.yaml \
--live
Monitoring¶
Key Metrics¶
| Metric | Monitor | Alert |
|---|---|---|
| Daily P&L | Continuous | >2% loss |
| Positions | Every trade | Divergence >10% |
| Exposure | Hourly | Outside limits |
| Data freshness | Hourly | >2h stale |
| System health | Continuous | Any failure |
Dashboard Example¶
Text Only
MOMENTUM STRATEGY - LIVE
========================
Status: RUNNING
Positions:
Long: 50 stocks, $500,000
Short: 50 stocks, $500,000
Net: $0 (0.0%)
Gross: $1,000,000 (200%)
Performance (Today):
P&L: +$1,234 (+0.12%)
vs SPY: +0.08%
Performance (MTD):
P&L: +$8,456 (+0.85%)
Sharpe: 1.2
Risk Metrics:
Daily VaR: $15,000
Current DD: -2.3%
Beta: 0.05
Alerting¶
YAML
alerting:
slack:
webhook: ${SLACK_WEBHOOK}
channel: "#trading"
rules:
- name: "Large Loss"
condition: daily_loss > 0.02
severity: warning
- name: "Circuit Breaker"
condition: daily_loss > 0.03
severity: critical
action: halt_trading
- name: "Trade Failure"
condition: trade_failed
severity: critical
Daily Operations¶
Morning Routine¶
- Check overnight status
- Verify positions match targets
- Review any alerts
- Check data freshness
- Review broker account
End of Day¶
- Review today's trades
- Check P&L
- Verify reconciliation
- Note any issues
Weekly Review¶
- Performance analysis
- Compare to backtest
- Check parameter drift
- Review any incidents
Error Handling¶
Common Issues¶
Data Stale:
Trade Rejected:
Text Only
Alert: Order rejected - insufficient buying power
Action: Check account balance, reduce position sizes
Connection Lost:
Recovery Procedures¶
YAML
recovery:
auto_retry:
max_attempts: 3
delay_seconds: 60
failover:
enabled: true
backup_broker: "backup_config.yaml"
manual_intervention:
- circuit_breaker_triggered
- large_position_divergence
Best Practices¶
1. Start Small¶
YAML
# Week 1-2
max_position: 0.01
gross_exposure: 1.0
# Week 3-4
max_position: 0.02
gross_exposure: 1.5
# Month 2+
max_position: 0.03
gross_exposure: 2.0
2. Monitor Everything¶
Log all: - Trades executed - Signals computed - Data received - Errors encountered
3. Have Kill Switches¶
Bash
# Emergency stop
sigc daemon stop --immediate
# Reduce exposure
sigc reduce-exposure --target 0.5
4. Document Everything¶
Maintain: - Run books - Incident reports - Parameter change log - Performance records
5. Regular Reviews¶
- Daily: Quick health check
- Weekly: Performance review
- Monthly: Deep analysis
- Quarterly: Strategy review
Exercises¶
- Create a production configuration file
- Set up paper trading for your strategy
- Configure alerting for key metrics
- Create morning and EOD checklists
Next Chapter¶
Continue to Chapter 8: Advanced Analytics for factor models and attribution.