QuantContext

行业场景

by zomma-dev

为 AI trading agents 提供确定性股票筛选、回测与因子分析能力,支持稳定复现的量化研究与策略评估。

什么是 QuantContext

为 AI trading agents 提供确定性股票筛选、回测与因子分析能力,支持稳定复现的量化研究与策略评估。

README

QuantContext

QuantContext is an MCP server that turns plain-English strategy descriptions into executable quant research: screen stocks by any criteria, backtest over historical data, and run factor analysis to see where the returns come from. Every number is computed from real market data, not generated by an LLM. Results are fully reproducible.

Works with Claude, Codex, OpenCode, or any other MCP-compatible coding agent.

Install

bash
pip install quantcontext-mcp

Claude Code:

bash
claude mcp add quantcontext -- quantcontext

Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):

json
{
  "mcpServers": {
    "quantcontext": {
      "command": "quantcontext"
    }
  }
}

No API keys. No configuration.

Tools

Three tools that compose into a full research workflow:

code
screen_stocks -> backtest_strategy -> factor_analysis
ToolWhat it does
screen_stocksFilter S&P 500, Nasdaq 100, or Russell 2000 by fundamentals, momentum, quality, technical signals, or a multi-factor blend. Returns ranked candidates.
backtest_strategyTest a strategy over history with a rebalance-loop engine. Returns CAGR, Sharpe, max drawdown, equity curve, and trade log.
factor_analysisDecompose strategy returns into Fama-French factors (market, size, value, momentum). Returns alpha with t-statistic, factor loadings, and R-squared.

Sample Prompts

Stock screening:

code
Screen S&P 500 for value stocks: PE under 15, ROE above 12%
code
Find the top 20% momentum stocks in the Nasdaq 100 over the last 200 days
code
Rank S&P 500 stocks by a blend of value, momentum, and quality, equal weight each factor
code
Find S&P 500 stocks with RSI under 40 and price above the 200-day moving average

Backtesting:

code
Backtest a top-20% momentum strategy on Nasdaq 100, monthly rebalance, last 2 years
code
How would a value screen (PE under 15, ROE above 12%) have performed on S&P 500 over the last 3 years?
code
Test a momentum strategy with a 15% stop loss and 20% max portfolio drawdown circuit breaker

Full research workflow:

code
Screen S&P 500 for cheap, high-quality stocks. Backtest monthly over 3 years,
then run factor analysis. Is the return real alpha or just factor exposure?

Screen Types

ScreenDescriptionKey parameters
fundamental_screenFilter by PE, ROE, leverage, revenue growthpe_lt, roe_gt, debt_equity_lt, revenue_growth_gt
quality_screenProfitability and balance sheet healthroe_gt, debt_equity_lt, profit_margin_gt
momentum_screenRank by N-day price momentumlookback_days, top_pct
value_screenCheapest stocks by valuationpe_lt, top_n
factor_modelMulti-factor composite scoreweights (value/momentum/quality/volatility), top_n
technical_signalRSI and SMA crossover signalsrsi_period, sma_short, sma_long
mean_reversionStocks below z-score thresholdlookback_days, z_threshold

Use from Python

The tools are also importable directly — no agent required. Useful if you have an existing script and want to plug in backtesting or factor analysis.

python
from quantcontext.server import screen_stocks, backtest_strategy, factor_analysis
import asyncio, json

# Screen
result = json.loads(asyncio.run(screen_stocks(
    universe="sp500",
    screen_type="fundamental_screen",
    config={"pe_lt": 15, "roe_gt": 12},
)))

# Backtest
bt = json.loads(asyncio.run(backtest_strategy(
    stages=[{"order": 1, "type": "screen", "skill": "fundamental_screen", "config": {"pe_lt": 15, "roe_gt": 12}}],
    universe="sp500",
    rebalance="monthly",
    start_date="2022-01-01",
)))
print(bt["metrics"])

# Factor analysis — pipe the equity curve straight in
fa = json.loads(asyncio.run(factor_analysis(
    equity_curve=bt["full_equity_curve"]
)))
print(fa["alpha_annualized"], fa["alpha_tstat"])

Strategies are expressed using the built-in screen types from the table above. All functions are async and return JSON strings.

Data

All public data, no API keys required.

DataSourceCache
Daily OHLCV pricesYahoo Finance (yfinance)~/.cache/quantcontext/prices.parquet
Fundamentals (PE, ROE, margins, etc.)Yahoo Finance~/.cache/quantcontext/financials/, 24h TTL
Fama-French factors (Mkt-RF, SMB, HML, Mom)Kenneth French Data Library~/.cache/quantcontext/ff_factors.parquet
Universe lists (S&P 500, Nasdaq 100)Wikipedia~/.cache/quantcontext/sp500_tickers.json

The first tool call downloads and caches data (10-30 seconds). All subsequent calls use the local cache: screening under 1s, backtesting 3-8s.

To skip the cold start, run once after install:

bash
quantcontext-warmup --url https://quantcontext.ai/api/data

Links

  • Docs — full reference, examples, methodology
  • PyPI

License

MIT

<!-- mcp-name: io.github.zomma-dev/quantcontext -->

常见问题

QuantContext 是什么?

为 AI trading agents 提供确定性股票筛选、回测与因子分析能力,支持稳定复现的量化研究与策略评估。

相关 Skills

面试体系设计

by alirezarezvani

Universal
热门

按岗位、级别和团队设计面试流程,生成能力矩阵、题库与评分标准,分析面试官偏差并校准招聘门槛,适合搭建或优化企业招聘体系。

团队招人没章法时,用它快速搭建岗位化面试流程、题库与评分标准,还能兼顾校准面试偏差,招聘更稳更准。

行业场景
未扫描18.2k

期权交易

by binance-skills-hub

热门

Binance Derivatives-trading-options request using the Binance API. Authentication requires API key and secret key. Supports testnet and mainnet.

行业场景
未扫描4.5k

A股交易助手

by alvisdunlop

热门

A股股票智能交易助手,专服务中国大陆股票市场。当用户询问A股股票行情、个股分析、大盘情绪、热点板块、交易策略、价格预警、涨跌幅、成交量、技术面或基本面分析时触发。只处理沪深A股(代码�?/00/30/68开头),自动忽略港股和美股。所有数据实时从东方财富、新浪财经、同花顺、雪球抓取。Use when: user asks about Chinese A-share stocks, 股票行情, 个股分析, 大盘分析, 板块热点, 买卖�? 止盈止损, 仓位建议, or any A-share trading-related query.

行业场景
未扫描4.5k

相关 MCP Server

by boosted-chat

热门

Flight search & booking for AI agents. 400+ airlines, $20-50 cheaper than OTAs.

行业场景
1.2k

Search company disclosures and financial statements from the Korean market. Retrieve stock profiles, market classifications, and historical trading data across major exchanges. Accelerate equity research with accurate, date-specific insights for Korean securities.

做韩国股研时,用它能一站查公司披露、财报和历史行情,按日期精确追溯关键信息,比手动翻交易所高效太多。

行业场景
146

检索韩国市场公司的披露文件与财务报表,并获取股票概况等关键信息。

想研究韩股公司时,它能一站式拉取披露、财报和股票概况,省去跨站查资料的麻烦,对跨境投研尤其省时。

行业场景
146

评论