Token导航 LogoToken导航TokenDH.com
Quant Framework MCP Server logo
金融服务stdio官方级别未说明来源级核验

Quant Framework MCP Server

MCP Server

一个开放、可插拔的量化工作流框架,支持组合式定量分析和扩展连接器,适用于金融数据建模和自主研究循环。

工具数

6

提示词数

0

GitHub Stars

4

资源数

0
PythonClaude金融数据Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Epsom700

提供方

Epsom700

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run quant --help

详细介绍

量化框架

一个开放、可插拔的框架,用于可组合的定量工作流程。从FRED开始。扩展到任何东西。

灵感源自 Karpathy的自我研究 --同样的三层契约(不可变评估器、代理沙箱、人为指导),作为一个可扩展的框架应用于定量金融。

这是一个框架,而不是一个产品。 FRED是hello world连接器。其他一切都是同一模式的延伸。

______________________________________________________________________

先决条件

______________________________________________________________________

安装

# Clone the repository
git clone 
cd quant_framework

# Install all dependencies
uv sync

______________________________________________________________________

配置

环境变量

创建一个 .env 项目根目录中的文件(或直接导出):

# .env
FRED_API_KEY=your_api_key_here

人物角色配置

编辑 configs/persona.yaml 控制MCP服务器公开的功能和连接器:

name: "Quant Research Agent"
description: "MCP server exposing quantitative research functions"
host: "127.0.0.1"
port: 8000

functions:
  - run_linear
  - run_random_forest
  - run_svr
  - run_xgboost
  - run_bayesian_ridge
  - run_hmm

connectors:
  - fred

护栏配置

编辑 configs/guardrails.yaml 定义函数输出的验证规则:

defaults:
  max_records: 10000

rules:
  run_linear:
    max_records: 5000
    required_fields: [model, r_squared, coefficients]
    roles:
      analyst:
        redacted_fields: [model]

______________________________________________________________________

用法

CLI--启动MCP服务器

# Show available commands
uv run quant --help

# Start the MCP server with SSE transport
uv run quant serve --persona configs/persona.yaml

# Use stdio transport instead
uv run quant serve --persona configs/persona.yaml --transport stdio

这将:

  1. 从注册所有建模功能 FunctionRegistry
  2. 初始化连接器(使用自动连接 $FRED_API_KEY)
  3. 启动MCP服务器 127.0.0.1:8000

从克劳德桌面连接

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "quant-framework": {
      "url": "http://localhost:8000/sse"
    }
  }
}

运行示例脚本

uv run python examples/basic_usage.py

这表明:

  1. 从FRED查询GDP数据
  2. 通过以下方式运行线性回归 FunctionRegistry
  3. 通过验证结果 GuardrailEngine

______________________________________________________________________

项目结构

quant_framework/
├── pyproject.toml                # Dependencies & CLI entry point
├── configs/
│   ├── persona.yaml              # MCP server persona config
│   └── guardrails.yaml           # Validation rules
├── examples/
│   └── basic_usage.py            # End-to-end demo script
├── experiments/                  # Autonomous research loop files
│   ├── evaluate.py               # Evaluation harness (scalar metric)
│   ├── prepare_snapshot.py       # Data snapshot caching script
│   └── strategy.py               # Editable strategy sandbox
├── program.md                    # Human-directed research agenda
└── quant_framework/              # Package root
    ├── cli.py                    # CLI (quant serve)
    ├── core/
    │   ├── function.py           # @register_function, FunctionRegistry, FunctionResult
    │   └── guardrail.py          # GuardrailEngine, GuardrailViolation
    ├── connectors/
    │   ├── connectors.py         # BaseConnector, ConnectorRegistry
    │   └── fred.py               # FREDConnector (with 24h file cache)
    ├── functions/
    │   └── modelling.py          # Registered modelling functions
    └── mcp/
        └── generator.py          # MCPServerGenerator

______________________________________________________________________

核心组件

连接器

连接器注册表名称描述
FREDConnectorfred基于24小时文件缓存的美联储经济数据
from quant_framework.connectors import FREDConnector

fred = FREDConnector()
fred.connect({"api_key": "your_key"})
df = fred.query("GDP", observation_start="2020-01-01")

建模功能

所有功能均已注册 @register_function 并返回a FunctionResult:

函数注册表名称型号类型键输出
run_linear_regressionrun_linear线性回归系数、截距、r²
run_random_forestrun_random_forest随机森林分类器功能_重要性,r²
run_svrrun_svrSVR
run_xgboostrun_xgboostXGBRegressor功能_重要性,r²
run_bayesian_ridgerun_bayesian_ridge贝叶斯海脊后角_std,alpha\_,lambda\_
run_hmmrun_hmm高斯HMM隐藏状态、转换矩阵、AIC、BIC
from quant_framework.functions.modelling import run_linear_regression

result = run_linear_regression(df, target="GDP", features=["UNRATE", "FEDFUNDS"])
print(result.output["r_squared"])   # 0.12
print(result.trace_id)              # unique trace ID

护栏发动机

from quant_framework.core import GuardrailEngine

engine = GuardrailEngine("configs/guardrails.yaml")
engine.validate("run_linear", result.output)           # passes
engine.validate("run_linear", result.output, role="analyst")  # applies role-specific rules
  • 热重载:对YAML的编辑立即生效(检查文件mtime)
  • 按角色覆盖:针对特定角色的更严格规则

函数注册表

from quant_framework.core import FunctionRegistry

# List all registered functions
FunctionRegistry.list()                        # ['run_linear', 'run_random_forest', ...]
FunctionRegistry.list_by_category("modelling") # filter by category

# Call by name
result = FunctionRegistry.call("run_linear", df=df, target="GDP")

______________________________________________________________________

自主研究循环

该框架包括一个完全自主的研究循环,旨在测试假设并逐步改进定量策略。

它建立在中概述的三层合同之上 program.md:

  1. 固定评估线束 (experiments/evaluate.py):在固定的历史数据集上对策略进行评分。
  2. 战略沙盒 (experiments/strategy.py):代理测试功能、模型选择和信号逻辑的单个文件。
  3. 人类方向 (program.md):定义代理的约束和高级研究议程。

运行循环

提供 program.md 将文件发送到任何自主编码代理(如Claude或内置系统),并指示其开始。代理人将阅读 program.md,修改 experiments/strategy.py,跑 evaluate.py,并使用保留/丢弃棘轮仅提交提高综合得分的更改。

______________________________________________________________________

扩展框架

添加连接器

from quant_framework.connectors.connectors import BaseConnector, ConnectorRegistry

@ConnectorRegistry.register("bloomberg")
class BloombergConnector(BaseConnector):
    def connect(self, config): ...
    def query(self, request, **kwargs): ...
    def get_schema(self): ...
    def health_check(self): ...

添加功能

from quant_framework.core import register_function, FunctionResult

@register_function(name="my_indicator", category="technical")
def my_indicator(df, window=14):
    result = ...  # your logic
    return FunctionResult(output={"value": result}, metrics={"window": window})

该功能在 FunctionRegistry 通过将其名称添加到您的角色YAML中,可以将其作为MCP工具公开。

______________________________________________________________________

设计原则

  • 连接器优先。 每个数据源都是一个 BaseConnector学习一个接口,连接任何东西。
  • 作为原子发挥作用。 修饰Python函数,通过MCP自动注册和自动公开。
  • 渐进式复杂性。 从FRED开始。添加你需要的东西,当你需要的时候。
  • 三层合同。 不可变评估器(护栏)、代理沙盒(功能存储)、人工指导(角色配置)。

______________________________________________________________________

贡献者

阿琼·辛格

许可证

麻省理工学院

目录标签

目录标签

PythonClaude金融数据量化分析本地部署金融建模自主研究可扩展框架数据连接器

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

部署方式(deploymentType,部署类型)

remote-capable

工具数量(toolCount,工具数)

6

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiononeremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP