版本: V3.5 发布日期: 2026-03-04 状态: 正式发布 适用范围: 所有 API 客户端(Python SDK、JavaScript SDK、第三方集成)
从 V3.5 版本开始,AgomTradePro 采用统一的 API 路由规范:/api/{module}/{resource}/
本次迁移旨在:
- 统一 API 路由结构,提升 RESTful 规范性
- 简化路由层级,便于理解和维护
- 宏观链路统一并入 data_center,避免双入口漂移
- 单一真源: 宏观正式入口只保留 data_center
- 渐进式迁移: 非宏观模块按 canonical 路径迁移
- 充分通知: 提前公告,明确时间表
- 有界兼容: 宏观旧路由已删除,其他模块按需保留短期兼容
| 模块 | 旧路由格式 | 新路由格式 | 状态 |
|---|---|---|---|
| account | /account/api/portfolios/ |
/api/account/portfolios/ |
兼容别名 |
| account | /account/api/positions/ |
/api/account/positions/ |
兼容别名 |
| regime | /api/regime/api/ |
/api/regime/ |
已废弃 |
| regime | /api/regime/api/current/ |
/api/regime/current/ |
已废弃 |
| signal | /api/signal/api/ |
/api/signal/ |
双轨 |
| signal | /api/signal/api/health/ |
/api/signal/health/ |
双轨 |
| macro | /macro/api/* |
/api/data-center/macro/series/ |
已移除,统一改走 data_center |
| policy | /policy/api/events/ |
/api/policy/events/ |
双轨 |
| realtime | /api/realtime/api/prices/ |
/api/realtime/prices/ |
双轨 |
| 模块 | 旧路由格式 | 新路由格式 | 状态 |
|---|---|---|---|
| alpha | /api/alpha/scores/ |
/api/alpha/scores/ |
无需迁移 |
| alpha | /api/alpha/coverage/ |
/api/alpha/coverage/ |
无需迁移 |
| factor | /factor/api/ |
/api/factor/ |
双轨 |
| rotation | /rotation/api/ |
/api/rotation/ |
双轨 |
| hedge | /hedge/api/ |
/api/hedge/ |
双轨 |
| 模块 | 旧路由格式 | 新路由格式 | 状态 |
|---|---|---|---|
| strategy | /strategy/api/ |
/api/strategy/ |
兼容别名 |
| simulated_trading | /simulated-trading/api/ |
/api/simulated-trading/ |
兼容别名 |
| decision_rhythm | /api/decision-rhythm/api/ |
/api/decision-rhythm/ |
双轨 |
| decision_workflow | /api/decision-workflow/api/ |
/api/decision-workflow/ |
双轨 |
| 模块 | 旧路由格式 | 新路由格式 | 状态 |
|---|---|---|---|
| equity | /equity/api/ |
/api/equity/ |
双轨 |
| fund | /fund/api/ |
/api/fund/ |
双轨 |
| sector | /sector/api/ |
/api/sector/ |
双轨 |
| sentiment | /api/sentiment/api/analyze/ |
/api/sentiment/analyze/ |
双轨 |
| 模块 | 旧路由格式 | 新路由格式 | 状态 |
|---|---|---|---|
| backtest | /backtest/api/ |
/api/backtest/ |
兼容别名 |
| audit | /audit/api/ |
/api/audit/ |
双轨,canonical 为 /api/audit/ |
| filter | /filter/api/ |
/api/filter/ |
兼容别名 |
| dashboard | /dashboard/api/v1/ |
/api/dashboard/v1/ |
兼容别名 |
| 阶段 | 日期 | 状态 | 说明 |
|---|---|---|---|
| Phase 1 | 2026-03-04 | 已完成 | 发布新路由,旧路由添加 Deprecation Header |
| Phase 2 | 2026-03-04 ~ 2026-04-01 | 进行中 | 客户端迁移,旧路由正常服务 |
| Phase 3 | 2026-04-01 ~ 2026-05-01 | 计划中 | 旧路由进入只读模式(仅支持 GET) |
| Phase 4 | 2026-06-01 | 计划中 | 移除旧路由支持 |
- 发布统一规范的新路由
- 旧路由添加 Deprecation HTTP Header
- SDK 同步更新(向后兼容)
- 文档更新完成
- 所有客户端更新到新路由
- 旧路由继续正常服务
- 每周监控迁移进度
- 旧路由限制为只读(仅 GET 请求)
- POST/PUT/PATCH/DELETE 请求将返回 410 Gone
- 强制剩余客户端迁移
- 完全移除旧路由支持
- 返回 404 Not Found
使用旧路由的请求将收到以下响应头:
X-Deprecated: true
X-Deprecation-Message: This endpoint is deprecated. Use /api/{module}/{resource}/ instead.
X-Sunset: 2026-06-01
Link: </api/{module}/{resource}/>; rel="alternate"
# 使用旧路由请求
curl -H "Authorization: Token xxx" \
http://api.example.com/api/regime/current/
# 响应头
HTTP/1.1 200 OK
Content-Type: application/json
X-Deprecated: true
X-Deprecation-Message: This endpoint is deprecated. Use /api/regime/current/ instead.
X-Sunset: 2026-06-01
Link: </api/regime/current/>; rel="alternate"pip install --upgrade agomtradepro-sdk无需修改代码! 新版 SDK 保持向后兼容:
# 旧版本(仍然有效)
from agomtradepro import AgomTradeProClient
client = AgomTradeProClient(
base_url="http://api.example.com",
api_token="your_token"
)
# 所有 API 调用自动使用新路由
regime = client.regime.get_current()
signals = client.signal.list()SDK 内部已更新为使用新路由,同时保留对旧路由的降级支持。
如果使用配置文件 (.agomtradepro.json),无需修改:
{
"base_url": "http://api.example.com",
"api_token": "your_token"
}如果使用环境变量,无需修改:
export AGOMTRADEPRO_BASE_URL="http://api.example.com"
export AGOMTRADEPRO_API_TOKEN="your_token"npm install @agomtradepro/sdk@latest
# 或
yarn upgrade @agomtradepro/sdk无需修改代码! 新版 SDK 保持向后兼容:
// 旧版本(仍然有效)
import { AgomTradePro } from '@agomtradepro/sdk';
const client = new AgomTradePro({
baseUrl: 'http://api.example.com',
apiToken: 'your_token'
});
// 所有 API 调用自动使用新路由
const regime = await client.regime.getCurrent();
const signals = await client.signal.list();MCP Server 无需升级,自动使用新路由。
如果使用环境变量配置,无需修改:
export AGOMTRADEPRO_BASE_URL="http://api.example.com"
export AGOMTRADEPRO_API_TOKEN="your_token"
agomtradepro-mcp如果您的代码直接调用 API(不使用 SDK),请按以下方式迁移:
import requests
# 旧路由(已废弃)
response = requests.get(
"http://api.example.com/api/regime/current/",
headers={"Authorization": "Token xxx"}
)
# 新路由(推荐)
response = requests.get(
"http://api.example.com/api/regime/current/",
headers={"Authorization": "Token xxx"}
)// 旧路由(已废弃)
fetch('http://api.example.com/api/regime/current/', {
headers: { 'Authorization': 'Token xxx' }
})
.then(r => r.json())
.then(data => console.log(data));
// 新路由(推荐)
fetch('http://api.example.com/api/regime/current/', {
headers: { 'Authorization': 'Token xxx' }
})
.then(r => r.json())
.then(data => console.log(data));# 旧路由(已废弃)
curl -H "Authorization: Token xxx" \
http://api.example.com/api/regime/current/
# 新路由(推荐)
curl -H "Authorization: Token xxx" \
http://api.example.com/api/regime/current//api/{module}/{resource}/
- 统一的
/api/前缀 - 简洁的模块路径
- RESTful 资源命名
-
双层 API 路径:
/api/{module}/api/{resource}/- 示例:
/regime/api/或/api/regime/api/→/api/regime/
- 示例:
-
模块级 API 路径:
/{module}/api/{resource}/- 示例:
/rotation/api/→/api/rotation/
- 示例:
- 更新 SDK 到最新版本
- 检查直接 HTTP 调用,更新为新路由
- 运行测试套件验证功能正常
- 监控日志中的 Deprecation 警告
- 查阅本迁移指南
- 更新 API 调用代码
- 在测试环境验证
- 部署到生产环境
- 更新 API 文档
- 配置监控告警(监控旧路由调用)
- 跟踪迁移进度
- 关注 Phase 3 只读模式通知
A: 2026-06-01 将完全移除旧路由支持。在此之前,旧路由会持续提供服务,但会收到 Deprecation Header。
A: 不必立即迁移。建议在 2026-04-01 前完成迁移,以避免只读模式限制。
A: 是的,SDK v1.2.0+ 自动使用新路由,无需修改代码。
A: 监控 HTTP 响应头中的 X-Deprecated 字段,或检查 SDK 日志。
A: 不会。路由迁移仅改变 URL 路径,API 请求和响应格式完全相同。
A: 可以临时回退到旧路由(在 2026-06-01 前)。同时提交问题报告。
A: 当前使用隐式 v1。未来计划支持 /api/v1/{module}/ 格式以支持多版本并存。
新路由通过 Django URL 配置实现:
# core/urls.py
# 新路由(推荐)
path('api/regime/', include('apps.regime.interface.api_urls')),
path('api/signal/', include('apps.signal.interface.api_urls')),
# 旧路由(兼容,已标记 deprecated)
path('regime/api/', include('apps.regime.interface.legacy_urls')),
path('signal/api/', include('apps.signal.interface.legacy_urls')),# core/middleware.py
class DeprecationMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
# 检测旧路由
if self.is_legacy_route(request.path):
response['X-Deprecated'] = 'true'
response['X-Deprecation-Message'] = (
f'This endpoint is deprecated. '
f'Use {self.get_new_route(request.path)} instead.'
)
response['X-Sunset'] = '2026-06-01'
return response| 日期 | 版本 | 变更说明 |
|---|---|---|
| 2026-03-04 | V3.5 | 初始版本,发布路由迁移指南 |
| 2026-02-20 | V3.4 | 完成路由一致性整改 |
| 2026-02-18 | V3.3 | 制定路由命名规范 |
文档维护: AgomTradePro Team 最后更新: 2026-03-04 联系方式: support@agomtradepro.com