# QuantContext:Deterministic Quant Tools for AI Trading Agents QuantContext is an MCP (Model Context Protocol) server that gives AI agents real quantitative computation for trading research. Works with Claude, Codex, Opencode, and any MCP client. Every number is computed from actual market data, not generated by an LLM. ## Install pip install quantcontext-mcp ## Tools ### screen_stocks Screen a stock universe (S&P 500, Russell 2000, Nasdaq 100) with quantitative filters. Screen types: fundamental_screen, quality_screen, momentum_screen, value_screen, factor_model, technical_signal, mean_reversion Returns: ranked candidates with scores and fundamental/technical metrics (capped at 30 results) ### backtest_strategy Run a historical backtest on a stock screening strategy using a rebalance-loop engine. Supports: multi-stage pipelines, equal_weight or inverse_volatility sizing, daily/weekly/monthly/quarterly rebalance, stop_loss, max_position_size, max_drawdown circuit breaker Returns: CAGR, Sharpe ratio, max drawdown, Calmar ratio, win rate, turnover, equity curve, trade log ### factor_analysis Decompose strategy returns into Fama-French four-factor model (market, size, value, momentum) using OLS regression. Returns: alpha with t-statistic, factor loadings with t-statistics, R-squared, residual volatility, interpretation ## Composing Tools screen_stocks → backtest_strategy → factor_analysis Pass full_equity_curve from backtest_strategy directly into factor_analysis. ## Data Sources - yfinance: daily OHLCV prices and fundamentals (no API key required) - Kenneth French Data Library: Fama-French factors (no API key required) - Cache: ~/.quantcontext/cache/ (~50MB for full S&P 500 coverage) ## Performance - First call: ~10s (downloads market data) - Screening: under 1s (cached) - Backtesting: 3–8s (cached) ## Links - Docs: https://quantcontext.ai/docs - GitHub: https://github.com/zomma-ai/quantcontext-mcp-server - PyPI: https://pypi.org/project/quantcontext-mcp/