Appearance
API调用说明
导航
正文
量化接口学习文档
本文档说明 WorldQuant BRAIN 平台量化相关接口的 URL、可加参数 以及 使用示例。
基础地址:
- API 根地址:
https://api.worldquantbrain.com - 平台页地址:
https://platform.worldquantbrain.com(用于在浏览器中打开 alpha 详情页等)
一、接口列表
1. 认证
| 项目 | 说明 |
|---|---|
| URL | POST https://api.worldquantbrain.com/authentication |
| 参数 | 无 URL 参数;Body 使用 Basic Auth(email + password),或按平台要求传认证信息 |
| 说明 | 登录获取 session,后续请求依赖此 session |
使用示例
text
POST https://api.worldquantbrain.com/authentication
Authorization: Basic <base64(email:password)>2. 检查 Session 是否超时
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/authentication |
| 参数 | 无;依赖当前 session |
| 说明 | 返回中包含 token.expiry,表示剩余有效秒数 |
使用示例 在已登录 session 下请求:
text
GET https://api.worldquantbrain.com/authentication3. 创建模拟(单条或批量)
| 项目 | 说明 |
|---|---|
| URL | POST https://api.worldquantbrain.com/simulations |
| 参数 | 无 URL 参数;Body 为 JSON:单条为一条模拟配置对象,批量为模拟配置对象数组 |
| Body 示例(单条 REGULAR) | type, settings(region, universe, delay, decay, neutralization, truncation 等), regular(alpha 表达式) |
| Body 示例(SUPER) | type, settings(同上 + selectionHandling, selectionLimit), selection, combo |
| 说明 | 响应头 Location 为模拟进度查询地址 |
使用示例 创建一条普通 alpha 模拟:
json
POST https://api.worldquantbrain.com/simulations
Body: {
"type": "REGULAR",
"settings": {
"instrumentType": "EQUITY",
"region": "USA",
"universe": "TOP3000",
"delay": 1,
"decay": 0,
"neutralization": "INDUSTRY",
"truncation": 0.08,
"pasteurization": "ON",
"testPeriod": "P0Y0M0D",
"language": "FASTEXPR"
},
"regular": "rank(ts_delta(close, 1))"
}4. 查询模拟进度
| 项目 | 说明 |
|---|---|
| URL | 由创建模拟接口响应头 Location 给出,形如 https://api.worldquantbrain.com/simulations/{simulation_id} 或平台约定路径 |
| 参数 | 无;需带 session |
| 说明 | 若响应头有 Retry-After,需等待后再次请求;返回中有 status、完成时可能有 alpha(alpha_id)或 children(多模拟子任务 id 列表) |
使用示例 创建模拟后用返回的 Location 轮询:
text
GET https://api.worldquantbrain.com/simulations/xxxxx5. 获取单个子模拟状态(多模拟时)
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/simulations/{child_id} |
| 参数 | 路径参数 child_id:多模拟进度返回的 children 中的 id |
| 说明 | 用于多模拟场景下查看每个子任务的进度与结果,返回中可有 alpha(对应 alpha_id) |
使用示例
text
GET https://api.worldquantbrain.com/simulations/{child_id}6. 获取 Alpha 完整模拟结果
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/alphas/{alpha_id} |
| 参数 | 路径参数 alpha_id:alpha 的 id;若响应有 Retry-After 需等待后重试 |
| 说明 | 返回该 alpha 的完整配置、train/test、is 统计等 |
使用示例
text
GET https://api.worldquantbrain.com/alphas/abc123xyz7. 获取 Alpha 生产相关性
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/alphas/{alpha_id}/correlations/prod |
| 参数 | 路径参数 alpha_id |
| 说明 | 返回中有 schema、records、max、min 等,用于生产相关性分析 |
使用示例
text
GET https://api.worldquantbrain.com/alphas/abc123xyz/correlations/prod8. 获取 Alpha 自相关性
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/alphas/{alpha_id}/correlations/self |
| 参数 | 路径参数 alpha_id |
| 说明 | 返回中有 schema、records、max、min 等,用于自相关检验 |
使用示例
text
GET https://api.worldquantbrain.com/alphas/abc123xyz/correlations/self9. 获取 Alpha 提交检查结果
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/alphas/{alpha_id}/check |
| 参数 | 路径参数 alpha_id |
| 说明 | 返回中 is.checks 为各项检查结果列表 |
使用示例
text
GET https://api.worldquantbrain.com/alphas/abc123xyz/check10. 更新 Alpha 属性
| 项目 | 说明 |
|---|---|
| URL | PATCH https://api.worldquantbrain.com/alphas/{alpha_id} |
| 参数 | 路径参数 alpha_id;Body 为 JSON,可选键:name, color, category, tags, osmosisPoints, regular.description, selection.description, combo.description;不传的键表示不修改 |
| 说明 | 用于修改 alpha 的名称、颜色、分类、标签、描述等 |
使用示例
json
PATCH https://api.worldquantbrain.com/alphas/abc123xyz
Body: { "name": "My Alpha", "category": "PRICE_MOMENTUM" }11. 获取 Alpha PnL(累计 / 日度)
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/alphas/{alpha_id}/recordsets/{pnl_type} |
| 参数 | 路径参数:alpha_id;pnl_type 取 pnl(累计)或 daily-pnl(日度) |
| 说明 | 返回中有 schema、records,按日期与收益 |
使用示例
text
# 累计 PnL
GET https://api.worldquantbrain.com/alphas/abc123xyz/recordsets/pnl
# 日度 PnL
GET https://api.worldquantbrain.com/alphas/abc123xyz/recordsets/daily-pnl12. 获取 Alpha 年度统计
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/alphas/{alpha_id}/recordsets/yearly-stats |
| 参数 | 路径参数 alpha_id |
| 说明 | 返回中有 schema、records,按年汇总统计 |
使用示例
text
GET https://api.worldquantbrain.com/alphas/abc123xyz/recordsets/yearly-stats13. 获取数据集列表
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/data-sets |
| 参数 | Query:instrumentType(如 EQUITY), region(如 USA), delay(如 1), universe(如 TOP3000); 可选 theme(true/false,是否仅主题相关) |
| 说明 | 返回可用数据集列表,用于查数据源与字段 |
使用示例
text
GET https://api.worldquantbrain.com/data-sets?instrumentType=EQUITY®ion=USA&delay=1&universe=TOP3000
GET https://api.worldquantbrain.com/data-sets?instrumentType=EQUITY®ion=USA&delay=1&universe=TOP3000&theme=true14. 获取数据字段列表
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/data-fields |
| 参数 | Query:instrumentType, region, delay, universe;可选 search(关键词), limit(如 50), offset(如 0) |
| 说明 | 返回可用数据字段,带 search 时常用 limit+offset 做分页 |
使用示例
text
GET https://api.worldquantbrain.com/data-fields?instrumentType=EQUITY®ion=USA&delay=1&universe=TOP3000
GET https://api.worldquantbrain.com/data-fields?instrumentType=EQUITY®ion=USA&delay=1&universe=TOP3000&limit=50&search=close&offset=015. 获取操作符列表
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/operators |
| 参数 | 无 |
| 说明 | 返回 alpha 表达式可用操作符及 scope 等信息 |
使用示例
text
GET https://api.worldquantbrain.com/operators16. 获取模拟配置选项(Instrument Type / Region / Delay 等)
| 项目 | 说明 |
|---|---|
| URL | OPTIONS https://api.worldquantbrain.com/simulations |
| 参数 | 无 |
| 说明 | 返回中 actions.POST.settings.children 包含 Instrument type、Region、Universe、Delay、Neutralization 等可选值与依赖关系 |
使用示例
text
OPTIONS https://api.worldquantbrain.com/simulations17. 绩效对比(合并前后表现)
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/{part_url}/alphas/{alpha_id}/before-and-after-performance |
| 参数 | 路径:part_url 取 users/self(当前用户)、teams/{team_id}(指定团队)或 competitions/{competition}(指定竞赛);alpha_id 为 alpha id |
| 说明 | 返回合并前后绩效对比数据,需在 part_url 对应维度有权限 |
使用示例
text
GET https://api.worldquantbrain.com/users/self/alphas/abc123xyz/before-and-after-performance
GET https://api.worldquantbrain.com/teams/team_001/alphas/abc123xyz/before-and-after-performance
GET https://api.worldquantbrain.com/competitions/comp_001/alphas/abc123xyz/before-and-after-performance18. 运行 Super Selection(筛选 alpha 数量)
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/simulations/super-selection |
| 参数 | Query:settings.instrumentType, settings.region, settings.delay, selection(表达式), limit, selectionLimit, selectionHandling 等 |
| 说明 | 根据 selection 表达式返回符合条件的 alpha 数量等信息 |
使用示例
text
GET https://api.worldquantbrain.com/simulations/super-selection?settings.instrumentType=EQUITY&settings.region=USA&settings.delay=1&selection=...&selectionLimit=1000&selectionHandling=POSITIVE19. 提交 Alpha
| 项目 | 说明 |
|---|---|
| URL | POST https://api.worldquantbrain.com/alphas/{alpha_id}/submit |
| 参数 | 路径参数 alpha_id;无 Body |
| 说明 | 提交该 alpha 参与评估;若响应有 Retry-After,可用 GET 同路径轮询提交状态 |
使用示例
text
POST https://api.worldquantbrain.com/alphas/abc123xyz/submit20. 查询 Alpha 提交状态
| 项目 | 说明 |
|---|---|
| URL | GET https://api.worldquantbrain.com/alphas/{alpha_id}/submit |
| 参数 | 路径参数 alpha_id |
| 说明 | 在 POST submit 返回 Retry-After 时用于轮询当前提交状态 |
使用示例
text
GET https://api.worldquantbrain.com/alphas/abc123xyz/submit二、Alpha 详情页链接
在浏览器中查看某个 Alpha 的详情时,可使用以下地址:
| 项目 | 说明 |
|---|---|
| URL 形式 | https://platform.worldquantbrain.com/alpha/{alpha_id} |
| 说明 | 将 {alpha_id} 替换为具体 Alpha 的 id,即可在平台打开该 Alpha 的详情页 |
| 示例 | https://platform.worldquantbrain.com/alpha/abc123xyz |
三、通用说明
- 除认证、操作符、数据集、数据字段、super-selection 等少数接口外,多数接口需要先通过 POST /authentication 完成登录,并在后续请求中携带该 session(如 Cookie 或 Authorization)。
- 部分接口在响应头中返回 Retry-After,表示需等待指定秒数后再重试。
- 速率限制相关响应头:
x-ratelimit-limit-minute、x-ratelimit-remaining-minute、x-ratelimit-limit-second、x-ratelimit-remaining-second,可根据这些头控制请求频率。