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
访问服务器

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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选