OpenBB 项目介绍
OpenBB 项目介绍
项目定位
OpenBB(OpenBB Data Platform,ODP)是一个开源金融数据平台,通过标准化数据模型(Standard Models)与可插拔 Provider 架构,将来自数十个数据源(Yahoo Finance、FMP、Benzinga、SEC 等)的金融数据统一接入,并通过 Python SDK、REST API、CLI 和 MCP Server 等多种接口对外输出。
一句话:金融数据领域的”Connect Once, Consume Everywhere”——一次接入数据,多处消费(Python 量化、Excel 分析师、AI Agent、REST API)。
核心能力
- 标准化数据模型(Standard Models):为每个金融数据域(Equity、Crypto、Economy 等)定义统一的
QueryParams+Data模型,Provider 通过继承与扩展接入 - 可插拔 Provider 架构:35+ 数据提供商通过 Python entry points 动态注册,支持热插拔
- OBBject 统一输出:所有命令返回
OBBject[T]泛型对象,支持to_dataframe()/to_polars()/to_numpy()/to_llm()多种格式转换 - Provider Interface 动态聚合:运行时自动合并所有 Provider 的字段,生成
StandardParams+ExtraParamsdataclass,注入 FastAPI 依赖 - MCP Server 原生支持:内置 Model Context Protocol 服务器,AI Agent 可直接调用所有 OpenBB 数据端点
- 三层扩展体系:Core(路由/功能)、Provider(数据源)、OBBject(输出后处理)通过 entry points 解耦
- 多消费端:Python SDK(
obb.equity.price.historical("AAPL"))、REST API(FastAPI)、CLI(openbb-cli)、Excel 插件、Workspace - 缓存与异步:内置 LRU 缓存、
asyncio异步管线、maybe_coroutine兼容同步/异步 Fetcher
技术栈
| 维度 | 选择 |
|---|---|
| 语言 | Python 3.10 ~ 3.12 |
| 数据验证 | Pydantic v2 |
| 包管理 | Poetry |
| Web 框架 | FastAPI + Uvicorn |
| 测试 | pytest |
| Lint | Ruff |
| 数据处理 | Pandas, Polars, NumPy |
| 图表 | Plotly |
| 扩展注册 | importlib_metadata entry_points |
| MCP | MCP SDK |
架构概览
快速体验
# 1. 安装包pip install openbb
# 2. 最简示例python -c "from openbb import obboutput = obb.equity.price.historical('AAPL')df = output.to_dataframe()print(df.head())"教程导读
本教程分为 AI 应用 和 开发工程 两部分:
AI 教程(ai/)
聚焦 OpenBB 在 AI/Agent 场景下的设计,从金融数据接入到 AI Agent 集成的最佳实践:
| 章节 | 知识点 |
|---|---|
| 01 | OBBject 与 LLM 数据管道(to_llm() 设计) |
| 02 | MCP Server 与 Agent 工具调用 |
| 03 | TET 管线与 AI 数据质量保障 |
| 04 | 标准化数据模型对 AI 推理的影响 |
| 05 | 多 Provider 路由与 Agent 决策 |
| 06 | OBBject Extension 与 AI 输出增强 |
Dev 教程(dev/)
聚焦 OpenBB 的工程实践与架构决策:
| 章节 | 知识点 |
|---|---|
| 01 | Entry Points 驱动的插件化架构 |
| 02 | Provider Interface 动态类型聚合 |
| 03 | TET(Transform-Extract-Transform)数据管线 |
| 04 | Router 与 FastAPI 深度集成 |
| 05 | CommandRunner 执行管线与上下文注入 |
| 06 | OBBject 泛型结果模型设计 |
| 07 | Monorepo 与扩展开发模式 |