Market Regime Oracle

Market Regime Oracle

Classifies BTC market into 5 regimes (Risk-On, Range-Bound, Risk-Off, Capitulation, Euphoria) with target exposure and posture, enabling risk management decisions.

Category
Visit Server

README

<div align="center">

šŸ“Š Market Regime Oracle

A 5-signal → 5-state BTC market-regime classifier with posture mapping, backtested vs buy-and-hold.

Fuses momentum, sentiment, volatility, funding & flow into one explainable regime — and a documented risk posture per regime.

Python License: MIT Tests Track MCP

</div>


What It Does

Ask "What kind of BTC market is this, and how much risk should I take?"

The oracle answers with one of 5 regimes + a documented posture:

Regime Target Exposure Posture
🟢 RISK_ON 100% Uptrend — full exposure
🟔 RANGE_BOUND 40% Sideways — light exposure
šŸ”µ RISK_OFF 20% Downtrend — defensive
šŸ”“ CAPITULATION 10% Panic — max defensive
🟣 EUPHORIA 30% Blow-off — take profit

Built as an MCP Strategy Skill for the CoinMarketCap Agent Hub (BNB AI Trading — Track 2). Any MCP-compatible client (Claude Desktop, Cursor, CMC Agent Hub) calls get_market_regime to get a deterministic, no-look-ahead risk posture.


šŸ“ˆ Headline Result

In a down year for BTC (āˆ’37%), the regime strategy did āˆ’12.7% — halving drawdown (āˆ’24% vs āˆ’51%) and halving volatility (19% vs 43%), outperforming buy-and-hold by ~25 points while still going long in uptrends.

Metric Regime Strategy Buy & Hold
Total return āˆ’12.7% āˆ’37.4%
Max drawdown āˆ’24.2% āˆ’51.2%
Annualized volatility 19.3% 43.1%
Sharpe (rf 4%) āˆ’0.82 āˆ’0.97
Sortino āˆ’1.01 āˆ’1.32

Data: CoinGecko BTC daily (2025-06-19 → 2026-06-17, 364 days). Start $10,000. 10 bps/turnover cost.


šŸ–¼ļø Visual Results

Equity Curve — Regime Strategy vs Buy & Hold

<img src="results/equity_curve.png" alt="Equity curve" width="760">

Drawdown — Strategy Stays Shallower

<img src="results/drawdown.png" alt="Drawdown" width="760">

BTC Price with Regime Overlay

<img src="results/regime_overlay.png" alt="Regime overlay" width="760">

Regime Distribution & Target Exposure

<img src="results/regime_summary.png" alt="Regime summary" width="760">


šŸ—ļø Architecture

  CoinGecko (BTC OHLCV)         alternative.me (Fear & Greed)
         │                              │
         ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                        ā–¼
             ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
             │   data/loader.py    │  aligned daily features
             ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                       ā–¼
  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
  │     5 independent signal modules         │  each → score in [-1, +1]
  │  momentum(0.30)  fear_greed(0.25)        │
  │  funding(0.15)   flows(0.15)   vol(0.15) │
  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                         ā–¼ weighted fusion
                  composite score
                         ā–¼ priority rules
  ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
  │   5-state regime classifier              │  CAPITULATION > EUPHORIA >
  │   (deterministic, no look-ahead)         │  RISK_OFF   > RISK_ON >
  ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜                          > RANGE_BOUND
                         ā–¼
                target exposure + action
           ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
           ā–¼                               ā–¼
    vectorized backtest                MCP tool: get_market_regime
    (no look-ahead, w/ costs)          (stdio, Agent Hub skill)

🧩 The 5 Signals

Signal Source Weight
RSI / MACD momentum CoinGecko price 0.30
Fear & Greed Index alternative.me 0.25
Volatility regime CoinGecko price 0.15
Funding rate proxy derived from price 0.15
Exchange flow proxy derived from volume 0.15

Each signal outputs a normalized bullishness score in [-1, +1]. All 5 are independently unit-tested.

Transparency: Funding rate and exchange flows have no free public feed. We reconstruct them from price/volume data as clearly-labeled proxies. Drop in real feeds anytime — the fusion layer is signal-agnostic.


šŸš€ Quick Start

git clone https://github.com/aggreyeric/bnb-market-regime-oracle.git
cd bnb-market-regime-oracle
pip install -r requirements.txt

# Run full pipeline: fetch → classify → backtest → charts
python main.py

# Run tests (offline, no network needed)
PYTHONPATH=src python -m pytest tests/

# Run as MCP server
PYTHONPATH=src python -m market_regime_oracle.mcp_server

# Live MCP demo (30 seconds)
./scripts/demo.sh

Docker

docker compose up --build run    # full pipeline
docker compose up --build server # MCP server

šŸ“ Project Layout

market_regime_oracle/
ā”œā”€ā”€ src/market_regime_oracle/
│   ā”œā”€ā”€ data/          # CoinGecko + alternative.me loaders
│   ā”œā”€ā”€ signals/       # 5 signal modules (unit-tested)
│   ā”œā”€ā”€ classifier/    # fusion → regime mapping
│   ā”œā”€ā”€ backtest/      # vectorized engine, no look-ahead
│   ā”œā”€ā”€ viz/           # equity/drawdown/regime charts
│   └── mcp_server.py  # MCP stdio server
ā”œā”€ā”€ tests/             # 24/24 passing
ā”œā”€ā”€ results/           # CSVs, metrics.json, PNG charts
ā”œā”€ā”€ scripts/demo.sh    # live MCP round-trip
ā”œā”€ā”€ Dockerfile
ā”œā”€ā”€ docker-compose.yml
└── README.md

šŸ“š Data Sources

  • CoinGecko v3 free API — BTC daily close + volume
  • alternative.me — Fear & Greed Index

Both public, both free. No API keys required.


šŸ“œ License

MIT Ā© 2026

šŸ¤– AI Assistants

→ See CLAUDE.md for AI coding assistant context.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured