Factor Miner MCP
Provides integration with Redis for caching and storing computed factor snapshots, including daily factor values written to dfactor:{symbol} keys with a 48-hour TTL, and using cached factor snapshots to support ML predictions.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Factor Miner MCPRun the OOS admission check on my new momentum factor"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Factor Miner MCP
A 股量化因子挖掘工具集的独立 MCP(Model Context Protocol)服务。从 Athena 的 py-sidecar 中抽取 factor 域,让任何 MCP 客户端(Claude Desktop、Kimi Code、Cursor、自研 Agent)都能直接驱动完整的「因子挖掘 → 评估 → 回测 → 上线巡检」流水线。
工具清单(15 个)
因子挖掘
工具 | 说明 | 负载 |
| 沙箱执行 factor.py(import 白名单 + rlimit + 120s 超时),跑评估电池 | 重(异步) |
| 全量 qlib 回测:SOTA 因子 + 新因子对齐 Alpha20 baseline,qrun 出指标 | 重(异步) |
| 生产准入 OOS 检查:挖掘窗口 vs 纯样本外窗口,报告 IC/年化/回撤 + 衰减 | 重(异步) |
| 每日收盘后计算在线因子,写 Redis | 重(异步) |
| 衰减巡检:近 N 交易日截面 IC(纯 pandas,无需 qlib) | 轻 |
| 从 OHLCV K线计算 Alpha158 风格因子(纯 pandas) | 轻 |
| 因子值 → ML 信号预测 | 轻 |
ML
工具 | 说明 | 负载 |
| 滚动 LGBM 训练:K线 → Alpha158 因子 + 次日收益标签 → 扩张窗训练,输出 IC/RankIC/Sharpe | 重(异步) |
| 用滚动模型出次日收益预测(优先 Redis 因子快照,回退实时计算) | 轻 |
| 训练器状态:最近训练日、逐日指标、模型是否存在、特征清单 | 轻 |
因子评估与组合
工具 | 说明 | 负载 |
| Alphalens 式因子完整评估:分位数组收益、多空价差、IC 序列(均值/IR/衰减)、换手率(手写 pandas) | 轻 |
| 组合优化:HRP / 等权 / 最小方差内置;装 pypfopt 后支持 | 轻 |
| 牛/熊/震荡识别:规则状态机(动量 + 已实现波动率阈值)内置;装 hmmlearn 走 GaussianHMM | 轻 |
| 结构突变检测:CUSUM + 二分分割(水平 + 漂移两路)内置;装 ruptures 走 PELT | 轻 |
| 波动率预测:EWMA(λ=0.94)+ Parkinson 高低价参考内置;装 arch 走 GARCH(1,1) | 轻 |
重负载工具提交即入队返回 job_id,轮询 GET /jobs/<id> 拿结果,
不占 HTTP 连接。
实现说明与算法出处
factor_tearsheet手写 pandas 而非依赖 alphalens 本体:alphalens 已半停维护(上游多年无实质更新),其依赖链与 pandas>=2 冲突频发; 分位数收益 / IC / 换手率逻辑本身很短,手写可控、可测、零额外依赖。HRP — López de Prado (2016), Building Diversified Portfolios that Outperform Out-of-Sample(相关距离 → 层次聚类 → 拟对角化 → 递归二分)。
EWMA — RiskMetrics (1996), J.P. Morgan Technical Document,λ=0.94, 多期预测平坦外推。
PELT — Killick et al. (2012), Optimal Detection of Changepoints With a Linear Computational Cost, JASA(可选增强,内置为 CUSUM(Page 1954)
二分分割)。
HMM — GaussianHMM(收益率 + 滚动波动率两特征,可选增强,内置为规则 状态机)。
全部 5 个工具:纯 numpy/pandas/scipy 路径开箱可用,重库 (pypfopt / hmmlearn / ruptures / arch)惰性导入做可选增强,输出
method字段标注实际实现。
Related MCP server: FactorHub MCP Server
快速开始
pip install -r requirements.txt
python3 server.py --port 50053验证:
curl http://127.0.0.1:50053/health
curl http://127.0.0.1:50053/tools接入 MCP 客户端(以 Claude Desktop / Kimi Code 为例):
# mcp 配置
factor:
url: http://127.0.0.1:50053/mcpDocker 部署
无需本地 Python 环境,一条命令起服务:
docker compose up -d # 构建镜像 + 启动容器(首次构建约 3-5 分钟)
docker compose ps # 查看状态
docker compose logs -f # 跟踪日志验证:
curl http://127.0.0.1:50053/health
curl http://127.0.0.1:50053/tools # 应返回 15 个工具说明与限制:
镜像不含
pyqlib(PyPI 无 linux/aarch64 wheel,arm64 需源码编译), 因此factor_backtest/gen_data/update_data等回测/数据工具 在容器内不可用;纯 pandas 工具(compute_factors/predict/factor_recent_ic等)开箱即用。h5 数据集可通过 volume 挂载:- ./data:/app/data并设FACTOR_MINER_DATA_DIR=/app/data/factor_mining。lightgbm已随镜像安装(linux wheel 自带 OpenMP 运行时),ml_train_rolling/ml_predict可用。Redis 缓存(
dfactor:*写入)可选:设置REDIS_URL指向可达的 Redis,缺失时自动降级跳过缓存写入。
license 鉴权(可选):在 docker-compose.yml 中取消注释,把宿主机
licenses.json 挂进容器并设置 MCP_LICENSE_FILE:
environment:
MCP_LICENSE_FILE: /app/licenses/licenses.json
volumes:
- ./licenses.json:/app/licenses/licenses.json:ro数据准备(回测类工具需要)
factor_execute / factor_backtest / factor_oos_check 依赖 qlib
cn_data 导出的日频量价 h5 数据集:
pip install pyqlib # arm64 Linux 需从 GitHub 源码编译,见 requirements.txt 注释
python3 -m factor_miner.update_data # qlib cn_data 增量更新
python3 -m factor_miner.gen_data --debug # 调试集(100 股 × 2 年)
python3 -m factor_miner.gen_data --full # 全量(回测用)factor_recent_ic / compute_factors / predict 纯 pandas 实现,
不依赖 qlib,开箱即用。
鉴权与额度(可选)
默认开放模式(本地/内网)。设置环境变量后强制 license key 鉴权:
export MCP_LICENSE_FILE=/path/to/licenses.json
python3 server.py --port 50053
# 客户端请求头:X-License-Key: <key>license JSON 格式与额度语义见 mcp_gateway.py docstring。GET /quota
查余量,GET /queue-stats 看队列。
端点一览
GET /health 健康检查
GET /tools 工具 JSON schema 列表
POST /mcp MCP JSON-RPC(initialize / tools/list / tools/call)
GET /jobs/<id> 异步任务状态/结果
GET /quota license 额度余量(鉴权模式)
GET /queue-stats 队列概况沙箱安全模型
factor_execute 等执行用户提交的 factor.py 时在子进程沙箱中运行:
AST import 白名单(仅 pandas/numpy 等)、rlimit 资源限制、120s 超时、
隔离工作目录。实现见 factor_miner/sandbox.py。
致谢
factor_miner/gen_data.py移植自 microsoft/RD-Agent(MIT)factor_miner/qlib_dump_bin.py裁剪自 microsoft/qlib v0.9.6(MIT)本项目主体来自 Athena
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Related MCP Connectors
China A-share market data for research, backtesting and AI agents via MCP.
MCP server giving AI agents one-connection access to China A-share market intelligence: financials,
Research-only MCP server: turn your AI into a quant research desk — backtests, no trades.
7-factor stock scoring MCP server. US/HK/CN, 74 stocks. Free + Premium (USDC/Base). x402 ready.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceMCP server that wraps SFC financial data API into 32 tools for comprehensive A-share market data, including real-time quotes, rankings, limit-up statistics, news, themes, financials, charts, research reports, and watchlists.-
- AlicenseBqualityDmaintenanceA China A-share market data MCP server that enables AI agents to query factor data, market quotes, valuations, and run strategy backtests.114MIT
- AlicenseAqualityAmaintenanceProvides point-in-time financial data access and an honest backtesting engine via MCP, enabling users to research restated fundamentals, run backtests with deflated Sharpe metrics, and benchmark returns against published factors.8MIT
- FlicenseNot gradedqualityBmaintenanceProvides deterministic A-share market snapshots and immutable strategy versions for short-term review, exposing verified daily reports via MCP without order or account management.-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/JingxuanC/factor-miner-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server