How to Backtest Crypto Strategies by Market Regime (With Real Data)
How to Backtest Crypto Strategies by Market Regime (With Real Data) Your backtest says Sharpe 2.0. You deploy. It immediately starts losing money. Sound familiar? The problem isn't your strategy. It's your backtest. Specifically: it averaged across multiple market regimes, hiding where your edge actually lives. A strategy that returns 40% in bull markets and -20% in bear markets will show a healthy positive backtest if your sample is 60% bull. Deploy it into a bear market and it looks like the signal "decayed." It didn't decay. You were never testing what you thought you were testing. Here's what regime-split backtesting reveals: Strategy Bull Sharpe Bear Sharpe Chop Sharpe Aggregate Sharpe SMA 50/200 2.4 -0.3 0.1 1.1 Mean Reversion 0.4 1.8 1.2 1.0 Momentum 3.1 -1.2 -0.5 0.9 The aggregate Sharpe looks similar across strategies. The regime-split view tells a completely different story: SMA crossover only works in trends, mean reversion works everywhere except bull, momentum is great in bull and terrible otherwise. This is the insight most traders miss. Before you can split backtest results by regime, you need regime labels for every historical period. You have three options: The /intelligence/regime-history endpoint returns timestamped regime classifications going back to the start of the dataset. Each classification includes regime (bull/bear/chop), subtype, and confidence. import requests API_KEY = "your_api_key" headers = {"Authorization": f"Bearer {API_KEY}"} # Get regime history history = requests.get( "https://getregime.com/api/v1/intelligence/regime-history", headers=headers ).json() # Each transition includes start time, end time, and average confidence for transition in history["transitions"]: print(f"{transition['regime']} from {transition['started_at']} " f"to {transition['ended_at']} " f"(confidence: {transition['avg_confidence']:.0%})") For point-in-time queries (what was the regime at any specific timestamp): # What regime was it on March 15, 2026? regime_at = requests.get( "https://getregime.com/api/v1/intelligence/regime-at", params={"ts": "2026-03-15T00:00:00Z"}, headers=headers ).json() print(f"Regime: {regime_at['regime']} ({regime_at['confidence']:.0%})") If you want to roll your own, the minimum viable regime detector uses 3-4 uncorrelated signals: Trend: BTC price vs 200-day SMA Volatility: ATR(20) / ATR(90) ratio Sentiment: Fear & Greed Index Macro: DXY direction (optional) Classify as "bull" when 3+ signals agree bullish, "bear" when 3+ agree bearish, "chop" otherwise. This won't be as accurate as a 10-signal weighted classifier, but it avoids overfitting and is simple to implement. Hidden Markov Models with 2-3 states are popular in academic literature. They work well in-sample but watch out for: Transition probability drift out-of-sample Sensitivity to initialization Overfitting on the training regime distribution Regime's API includes an HMM endpoint trained on 8,000+ snapshots if you want to compare against your own implementation. Once you have regime labels, tag every trade in your backtest with the regime that was active when the trade was opened. import pandas as pd # Your trades dataframe trades = pd.DataFrame({ 'entry_time': [...], 'exit_time': [...], 'pnl_pct': [...], 'symbol': [...], }) # Regime transitions from API transitions = pd.DataFrame(history['transitions']) transitions['started_at'] = pd.to_datetime(transitions['started_at'], unit='ms') transitions['ended_at'] = pd.to_datetime(transitions['ended_at'], unit='ms') def get_regime_at(ts): for _, t in transitions.iterrows(): if t['started_at'] 0).mean() avg_pnl = subset['pnl_pct'].mean() max_dd = subset['pnl_pct'].cumsum().cummax() - subset['pnl_pct'].cumsum() print(f"\n{regime.upper()}") print(f" Trades: {len(subset)}") print(f" Sharpe: {sharpe:.2f}") print(f" Win Rate: {win_rate:.1%}") print(f" Avg PnL: {avg_pnl:.2%}") print(f" Max DD: {max_dd.max():.2%}") Once you know which regimes your strategy works in, the fix is straightforward: import requests def should_trade(): """Check regime before entering any position.""" regime = requests.get( "https://getregime.com/api/v1/market/regime" ).json() current = regime['regime'] confidence = regime['confidence'] # Only trade in regimes where backtest shows positive Sharpe if current == 'chop' and confidence > 0.6: return False # Our strategy loses in chop if current == 'bear' and confidence > 0.7: return 'short_only' # Flip to short-only in bear return True # Full trading in bull # Position sizing by regime REGIME_SIZE = { 'bull': 1.0, # Full size 'bear': 0.6, # Reduced 'chop': 0.4, # Minimal } Our track record page shows live, verifiable results from applying regime-based position sizing to BTC: Regime-following: +7.59% Buy-and-hold: -1.89% Alpha: +9.48% This is from 4,941 market snapshots over 29 days. Not a backtest — real data, real classifications, verifiable on-chain. Never report aggregate backtest Sharpe. Always split by regime. A "Sharpe 2.0" strategy might be a "Sharpe 3.5 in bull, -0.5 in everything else" strategy. Regime detection doesn't need to be fast — it needs to be right. A 2-day lag on detecting a regime change costs a few percent. A false regime flip costs much more. Use multiple uncorrelated signals. Single-indicator regime detectors (just RSI, just SMA) overfit. Require supermajority agreement across 4+ signals before reclassifying. Size by regime, not just signal. Even if you trade in all regimes, reduce position size in regimes where your strategy has low Sharpe. Track regime-adjusted Sharpe in production. If rolling 30-trade Sharpe drops below 0.5 for the current regime, that's a yellow flag. Try It Get regime-classified historical data for your own backtests: # No auth needed for current regime curl https://getregime.com/api/v1/market/regime # Full history requires Pro ($49/mo) or Institutional ($149/mo) curl -H "Authorization: Bearer YOUR_KEY" \ https://getregime.com/api/v1/intelligence/regime-history Free tier: 500 calls/day, regime + market overview. Start here. Regime is a real-time crypto market regime detection API. One endpoint tells you if the market is bull, bear, or chop — so your bot only trades when conditions match your strategy. Free API access → | See pricing → | API docs →
