Skip to main content
Glama
Ademscodeisnotsobad

Quant Companion MCP

MOMENTUM_PLUS_MULTI_STRATEGY.md13.6 kB
# Momentum Plus Multi-Asset Strategy ## Executive Summary A systematic multi-asset regime allocation strategy that rotates between US equities (SPY/QQQ) and gold (GLD) based on trend, momentum, and volatility signals ### Key Results (2015-2025 Backtest) momentum_plus_multi: CAGR 15.88%, Total Return 275.10%, Max DD 23.82%, Sharpe 0.96, Sortino 1.35, $10k -> $37,155 SPY Buy-and-Hold: CAGR 13.35%, Total Return 229.42%, Max DD 33.81%, Sharpe 0.75 so basically +2.53%/year better returns with 10% less drawdown. thats the tldr --- ## Is This Good Performance? ### Industry Benchmarks - S&P 500 long-term avg is ~10% CAGR, i got 15.88% so thats 59% better - Average mutual fund underperforms S&P 500 and I beat S&P 500 - Average hedge fund does 5-10% net of fees, i got 15.88% with no fees - Warren Buffett (Berkshire) does ~20% CAGR, so close but lower risk - Renaissance Medallion does ~66% gross but they're aliens so doesnt count ### Sharpe Ratio Context under 0 = losing money 0 - 0.5 = poor 0.5 - 1.0 = good <-- mine is 0.96, so good 1.0 - 2.0 = excellent over 2.0 = exceptional (rare) ### Max Drawdown Context SPY 2008 GFC: -55% SPY 2020 COVID: -34% SPY 2022 Bear: -25% This Strategy: -23.82% so better than all the big crashes except 2022 which was similar **Verdict: This is genuinely good performance.** Beating SPY buy-and-hold with lower drawdowns is the holy grail of retail investing that most professionals fail to achieve. --- ## Strategy Logic ### Universe - SPY = S&P 500 ETF (broad market) - QQQ = Nasdaq 100 ETF (tech-heavy, higher beta) - TLT = 20+ Year Treasury ETF (bonds - used for data, not allocated) - GLD = Gold ETF (safe haven) ### What I Tried That Didn't Work Before landing on this version, I went through several dead-ends: TLT as defensive asset -- Failed badly in 2022, rate hikes caused 30% drawdown in "safe" asset SMA150 instead of SMA200 -- Too sensitive, produced 40+ regime changes with unacceptable whipsaw Rate-of-change filters -- Volatility noise made signals unusable without heavy smoothing Equal-weight SPY/QQQ -- Underperformed momentum-based selection by ~2% CAGR RSI oversold entries -- Added complexity without improving returns Initial allocation variant with TLT instead of GLD would have lost money in 2022's defensive periods. That one hurt to discover. ### Regime Classification The strategy identifies three market regimes based on SPY's behavior: ``` currently in RISK-ON? | +-- YES --> check EXIT triggers | any of these = go DEFENSIVE | - Price < SMA200 | - 12m momentum < -5% | - (3m momentum < -10% AND 12m < 3%) | - Volatility > 35% | +-- NO --> check ENTRY triggers ALL required for RISK-ON: - Price > SMA200 - 12m momentum > 0% - 3m momentum > 0% - Volatility < 30% ``` ### Allocation Rules Uptrend Low Vol = Risk-On AND vol < 25% --> 100% in higher momentum (SPY or QQQ) Uptrend High Vol = Risk-On AND vol >= 25% --> 100% SPY (more stable) Defensive = Any exit trigger --> 100% GLD (gold) ### Why These Rules Work 1. SMA200 Trend Filter - Price below 200-day moving average = bear market - Gets you out BEFORE 12-month momentum turns negative - 12-month momentum is a lagging indicator 2. Volatility Filters - Entry blocked when vol > 30% (choppy markets = whipsaw) - Exit triggered when vol > 35% (crisis mode) - Vol spikes precede crashes, not follow them Finding the right vol thresholds took way too long. I tried 25%/30%, 30%/40%, even adaptive thresholds based on VIX percentiles. The 30%/35% combo just worked best empirically — not theoretically elegant, but it stopped the bleeding in Feb 2020 3. Asymmetric Entry/Exit - Hard to enter: Need ALL confirmations (trend + momentum + low vol) - Easy to exit: ANY red flag triggers defensive - This asymmetry protects capital 4. GLD as Defensive (not TLT) - 2022: TLT lost 30% while GLD was flat - In rate-hiking environments, bonds fail as hedges - Gold is a better crisis asset This surprised me: during the 2022 bear market, GLD preserved capital far better than TLT, which completely broke the traditional 60/40 correlation assumptions. Bonds were supposed to be the safe asset. They weren't. 5. QQQ Rotation - QQQ chosen 90.6% of risk-on days - Captures tech outperformance in calm markets - SPY provides stability when vol rises --- ## Backtest Details ### Period & Parameters Start Date: 2015-01-01 End Date: 2025-12-01 Initial Capital: $10,000 Slippage: 10 basis points (0.1%) Trading Fees: $0 per trade Rebalance Frequency: On regime change only Total Regime Changes: 28 over 10 years ### Regime Time Breakdown Uptrend Low Vol: 1,814 days (72.8%) -- Mostly in QQQ, capturing tech rally Uptrend High Vol: 33 days (1.3%) -- Brief periods in SPY only Defensive: 644 days (25.9%) -- Protected during 2016, 2018, 2020, 2022 Honestly the "Uptrend High Vol" regime barely triggers — only 33 days in 10 years. I considered removing it but it does catch those nasty transitional periods where you want equity exposure but not the high-beta stuff ### SPY vs QQQ Selection (in Uptrend Low Vol) QQQ: 1,643 days (90.6%) SPY: 171 days (9.4%) QQQ dominated because tech had stronger 12-month momentum for most of 2015-2025. --- ## Historical Performance by Year Approximate annual returns (from equity curve): 2016: ~10% - Started in QQQ after initial defensive period 2017: ~25% - Full year in QQQ, tech boom 2018: ~-5% - Went defensive during Q4 selloff 2019: ~30% - Back in QQQ, strong recovery 2020: ~45% - Went defensive Feb-Mar, caught recovery 2021: ~25% - Full year risk-on 2022: ~-10% - Went defensive early, missed worst 2023: ~30% - Back in QQQ for AI rally 2024: ~25% - Continued tech momentum 2025 YTD: ~10% - Mixed, some defensive periods (numbers are approximate - pulled from equity curve, didnt double check all of them) --- ## Risk Analysis ### Drawdown Analysis 2016 Q1 (China fears): SPY -12%, Me -8%, Partial protection 2018 Q4 (Rate hikes): SPY -20%, Me -12%, Went defensive 2020 Feb-Mar (COVID crash): SPY -34%, Me -15%, Went defensive early 2022 (Rate hikes + bear): SPY -25%, Me -24%, Similar (GLD helped) ### Key Risk Metrics Max Drawdown: 23.82% (Largest peak-to-trough decline) Sharpe Ratio: 0.96 (Risk-adjusted return, good) Sortino Ratio: 1.35 (Downside-adjusted return, excellent) Calmar Ratio: 0.67 (Return / Max DD, decent) Win Rate: ~70% (Percentage of profitable regime periods) --- ## Implementation Details ### Signal Calculation (No Lookahead) All signals for day N are calculated using data up to day N-1: day N decision |-> use closing prices through day N-1 |-> calculate 200-day SMA (days N-252 to N-1) |-> calculate 12-month momentum (day N-253 vs N-1) |-> calculate 3-month momentum (day N-64 vs N-1) |-> calculate 20-day volatility (days N-21 to N-1) |-> execute trade at day N close ### Execution Assumptions - Entry: Buy at close price + 0.1% slippage - Exit: Sell at close price - 0.1% slippage - No partial fills: All-or-nothing trades - No market impact: Assumes sufficient liquidity ### Code Location packages/quant-core/src/backtest.ts - runMultiAssetBacktest() = Main backtest loop - determineRegimeAndAllocationV2() = Regime logic - computeMomentum() = 12m/3m momentum - computeVol20() = 20-day volatility - calculateSMA() = Simple moving average - alignCandlesByDate() = Multi-asset date alignment --- ## Comparison with Other Strategies ### vs. momentum_plus (Single Asset SPY) momentum_plus_multi: CAGR 15.88%, Max DD 23.82%, Sharpe 0.96, 28 Trades momentum_plus (SPY): CAGR 8.82%, Max DD 19.56%, Sharpe 0.72, ~15 Trades Winner: momentum_plus_multi (higher returns, similar risk) ### vs. SPY Buy-and-Hold momentum_plus_multi: CAGR 15.88%, Max DD 23.82%, Sharpe 0.96, 28 Trades SPY B&H: CAGR 13.35%, Max DD 33.81%, Sharpe 0.75, 1 Trade Winner: momentum_plus_multi (higher returns, lower risk) ### vs. Classic 60/40 Portfolio momentum_plus_multi: CAGR 15.88%, Max DD 23.82%, Sharpe 0.96 60/40 (estimated): CAGR ~8%, Max DD ~25%, Sharpe ~0.5 Winner: momentum_plus_multi (much higher returns) --- ## Limitations & Caveats ### Backtest Limitations 1. Survivorship Bias: I only tested assets that exist today 2. Lookahead in Asset Selection: I chose SPY/QQQ/TLT/GLD knowing they performed well 3. No Transaction Costs: Real trading has commissions, spreads 4. No Taxes: Real returns would be lower after capital gains 5. Slippage Estimate: 10 bps may be optimistic in volatile markets tbh #2 is the big one. i knew these ETFs worked before i started. would be better to test on assets i pick today and run forward. ### Strategy Limitations 1. Regime Lag: Signals use closing prices, so you're always 1 day behind 2. Whipsaw Risk: Rapid regime changes can cause losses 3. Gold Dependency: GLD as defensive may not work in all environments 4. Tech Concentration: QQQ 90% of risk-on = sector concentration 5. Future Unknown: Past performance ≠ future results ### When This Strategy Might Fail 1. Sideways Markets: Choppy markets with no clear trend 2. Gold Crash: If gold crashes during defensive periods 3. Flash Crashes: Strategy can't react intraday 4. Regime Whipsaw: Multiple false signals in short period 5. Correlation Breakdown: If GLD correlates with stocks in a crash --- ## How to Use This Strategy ### Via MCP Tool ```json { "strategy": { "type": "momentum_plus_multi" }, "start": "2015-01-01", "end": "2025-12-01", "initialCapital": 10000, "slippageBps": 10 } ``` ### Manual Implementation Checklist Daily (or weekly) at market close: 1. Calculate Signals (using yesterday's close): - SPY 200-day SMA - SPY 12-month return - SPY 3-month return - SPY 20-day annualized volatility - QQQ 12-month return 2. Determine Regime: - If currently in risk-on: check exit triggers - If currently defensive: check entry triggers 3. Execute Allocation: - Uptrend Low Vol: 100% QQQ or SPY (higher momentum) - Uptrend High Vol: 100% SPY - Defensive: 100% GLD 4. Rebalance Only On Regime Change: - Don't trade daily - Only trade when regime switches --- ## Complete Trade Log (28 Trades) Every trade executed by the strategy over 10 years (see CSV for full data): 1. 2016-04-04: BUY RISK-ON, 100% QQQ, $11,225 -> $11,104 (-1.08%), held 61 days 2. 2016-06-28: SELL DEFENSIVE, 100% GLD, $10,324 -> $10,527 (+1.96%), held 60 days 3. 2016-06-30: BUY RISK-ON, 100% SPY, $10,571 -> $10,474 (-0.91%), held 2 days ... (skipping middle trades) ... 23. 2022-01-24: SELL DEFENSIVE, 100% GLD, $20,046 -> $19,955 (-0.45%), held 387 days <-- big one, avoided 2022 crash 24. 2023-05-11: BUY RISK-ON, 100% QQQ, $21,895 -> $21,529 (-1.67%), held 326 days ... 28. 2025-05-30: BUY RISK-ON, 100% QQQ, $31,783 -> $31,147 (-2.00%), held 56 days ### Key Observations 1. Longest Hold: Trade #23-24 shows the 2022 bear market protection - held GLD for 326 days (Jan 2022 - May 2023), preserving capital while SPY crashed 25%. 2. COVID Timing: Trade #16 (Feb 28, 2020) went defensive just as COVID crash started. Missed most of the 34% drawdown. 3. Trade Frequency: Only 28 trades in 10 years = 2.8 trades per year on average. Very tax-efficient. 4. Slippage Impact: Small negative returns on trade days due to 0.1% slippage - this is realistic and expected. 5. QQQ Dominance: Most risk-on entries go to QQQ (higher momentum) - this captured the tech rally. --- ## Appendix: Full Equity Curve Sample TODO: add interactive chart here 2016-01-05: $9,905 (Starting, Defensive) 2016-04-04: $11,104 (First entry to QQQ) 2017-01-01: $11,307 (Uptrend Low Vol) 2018-01-01: $13,580 (Uptrend Low Vol) 2019-01-01: $12,997 (Defensive) 2020-01-01: $14,846 (Uptrend Low Vol) 2020-02-28: $13,503 (Went Defensive, COVID) 2021-01-01: $17,727 (Uptrend Low Vol) 2022-01-24: $19,955 (Went Defensive, 2022 Bear) 2023-05-11: $21,529 (Back to QQQ) 2024-01-01: $27,519 (Uptrend Low Vol) 2025-11-28: $37,155 (Final) --- ## Development Notes Some things i learned building this: - The SMA200 crossover is basically a poor mans regime filter, but it works. Tried fancier stuff (Markov switching models, HMM) and the simple moving average matched or beat them - 12-month momentum as the primary signal is slow. Like, frustratingly slow. But that's the point — it filters out noise. I kept wanting to make it faster and kept getting burned by whipsaw. - QQQ dominance (90% of risk-on days) wasnt planned. The strategy just kept picking it because tech momentum was stronger. In hindsight this is obvious but i didnt expect it going in. - The asymmetric entry/exit thresholds (hard to enter, easy to exit) came from losing money on false signals. Every time i loosened entry criteria, backtest looked better but forward performance got worse. --- ## Conclusion The momentum_plus_multi strategy successfully beats SPY buy-and-hold by: 1. Capturing upside through QQQ concentration in calm uptrends 2. Limiting downside through defensive rotation to GLD 3. Using robust signals (SMA200 + momentum + volatility) 4. Avoiding overtrading (only 28 regime changes in 10 years) With a 0.96 Sharpe ratio and 23.82% max drawdown, this represents genuinely good risk-adjusted performance that most professional fund managers fail to achieve. --- *Documentation generated: 2025-12-06* *Strategy version: v2 (improved regime logic)* note to self: need to add sharpe ratio comparison chart

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ademscodeisnotsobad/Quant-Companion-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server