This folder (Live/) contains everything needed to run the A+B+Diversifier Sleeves strategy live with Alpaca. Nothing else is used for implementation; all production code lives here.
Combine two equity dual-momentum engines (A and B) with three truly diversifying sleeves to build a robust, non-overfit, live-tradeable portfolio.
| Sleeve | Weight | Description |
|---|---|---|
| Strategy A | 20% | Phase 3 mom_corr: momentum + correlation, top 5 |
| Strategy B | 20% | Top-3 Dual-Momentum: pure momentum, top 3 |
| Rates sleeve | 20% | Bond trend: TLT / IEF / BIL |
| Bear sleeve | 20% | SH when SPY < SMA200, otherwise BIL |
| CTA proxy | 20% | PDBC / DBMF / KMLM in uptrend, otherwise BIL |
- A and B are highly correlated, so switching rules between them add no OOS value.
- C (Triple EMA + Macro + Kurt) was discarded as a primary engine due to look-ahead and overfit risk.
- The three sleeves (Rates, Bear, CTA proxy) break correlation and approximately double Sharpe and triple Calmar in backtest.
- Gold is omitted because it degrades Calmar in the OOS sample.
- Momentum signal: RSI(14) on adaptive cumulative return over 63/126/252 days, blended by VIX percentile.
- Slow filter: price above 252-day SMA.
- Fast filter: EMA 8/21/50 + MACD 12/26/9 aligned bullish.
- Selection: every Friday, pick the top-N assets by composite score.
- Risk overlay: if VIX is above its 70th percentile (last 252 days), cut exposure by half.
- Base frequency: annual (first 5 trading days of January).
- Drift threshold: if any sleeve deviates more than ±10% from its target weight, rebalance.
- Execution: sells first, then buys, to free buying power.
- 10 bps one-way in backtest (adjust with observed real slippage in paper trading).
- Alpaca ETFs are commission-free, but SH/PSQ/VIXY may have wider spreads.
A = 20%
B = 20%
rates = 20%
bear = 20%
cta = 20%
- A and B: equal-weight within their selected top-N.
- Rates: 100% in the best of TLT / IEF / BIL based on SMA200.
- Bear: 100% in SH if SPY < SMA200, otherwise BIL.
- CTA proxy: equal-weight among PDBC / DBMF / KMLM in uptrend, otherwise BIL.
- The runner reads Alpaca account equity and allocates dollars proportionally.
- Fractional shares are supported by default; if unavailable, it rounds to whole lots.
The strategy is a fixed-weight ensemble at the sleeve level, not dynamic. Research showed that A/B/C switching rules added overfit and failed to beat A or B alone OOS.
- A and B are two implementations of the same dual-momentum engine with different scoring and concentration.
- Each contributes 20% of NAV.
- The diversifier sleeves contribute 60% of NAV.
Live/
├── README.md
├── pyproject.toml # Project metadata + deps + pytest config
├── requirements.txt # `pip install -r requirements.txt`
├── .env.example # Template; copy to .env (gitignored)
├── live/ # Strategy package
│ ├── __init__.py
│ ├── core_signals.py # Point-in-time engines A and B
│ ├── data_feed.py # Alpaca + yfinance + cache
│ ├── alpaca_executor.py # Order placement
│ ├── portfolio.py # Sleeve construction and targets
│ ├── risk.py # Safety guardrails
│ ├── state.py # Peak equity / weights persistence
│ └── monitor.py # Live vs backtest monitoring
├── scripts/
│ └── rebalance.py # Daily entry point (was live_runner.py)
├── notebooks/
│ └── A_B_Diversifier_Analytics.ipynb
├── tests/
│ ├── __init__.py
│ └── test_live_pipeline.py # Smoke tests
└── logs/ # Runtime artifacts (gitignored): state.json, orders_*.csv, target_weights.jsonl
└── .gitkeep
cd Live
pip install -r requirements.txtCreate a .env file inside Live/ with:
ALPACA_API_KEY=PK...
ALPACA_API_SECRET=...
ALPACA_LIVE=falseNever commit .env to Git. It is already in .gitignore.
cd Live
python scripts/rebalance.py --date 2025-06-27 --dry-run --prefer-yfinanceThis uses yfinance, simulates a $100,000 account, and prints the orders it would send.
- Make sure
ALPACA_LIVE=false. - Remove
--dry-run:
cd Live
python scripts/rebalance.py --prefer-yfinance- Validate several months in paper.
- Set
ALPACA_LIVE=true. - Run without
--dry-run.
Run once per day after market close. Example cron on Linux/macOS:
35 16 * * 1-5 cd /path/to/Live && python scripts/rebalance.pyOn Windows use Task Scheduler or Git Bash cron.
The runner automatically blocks execution if:
- Price data is more than 2 days stale.
- Any target ticker is missing from the price panel.
- A single position exceeds 50% of NAV.
- A+B combined exceeds 70% of NAV.
- Live drawdown exceeds -10% from peak equity.
- It is a weekend or fixed US holiday (1/1, 7/4, 12/25).
Also, the code only trades in paper unless ALPACA_LIVE=true is explicitly set.
cd Live
python -m live.monitorShows:
- Latest run date.
- Account equity.
- Number of orders and turnover.
- Sleeve-level weights.
cd Live
python -m pytest tests/ -qSmoke tests do not call Alpaca; they use cached yfinance data.
| Period | CAGR | Vol | Sharpe | Max DD | Calmar |
|---|---|---|---|---|---|
| 2015-2025 | 16.5% | 7.5% | 2.20 | -7.18% | 2.30 |
| OOS 2020-2025 | 20.6% | - | 2.36 | -7.18% | 2.87 |
Historical results do not guarantee future performance.