From c852b1d871182d00a1fce0cbf282c3e6b021b215 Mon Sep 17 00:00:00 2001 From: fish Date: Sun, 3 May 2026 22:31:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=89=B9=E9=87=8F=E6=89=93?= =?UTF-8?q?=E5=88=86=E6=8E=A5=E5=8F=A3=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLAUDE.md | 5 ++++- README.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index a918d70..504a17a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -26,6 +26,9 @@ docker-compose -f docker-compose.trade.yml run --rm tushare python -m src.main - curl -X POST http://localhost:4001/api/v1/run -H "Content-Type: application/json" \ -d '{"symbol":"FG"}' +# 批量触发所有固定品种今日打分 +curl -X POST http://localhost:4001/api/v1/run/batch + # 查询打分列表 curl "http://localhost:4001/api/v1/scores?limit=5" @@ -42,7 +45,7 @@ docker-compose -f docker-compose.trade.yml exec postgres psql -U trade -d future **单进程串行流水线**:`src.main.main()` 先按命令行参数(显式 `ts_code` 优先,否则 `contracts.active_contract(symbol)` 按当月主力自动选)定下合约,再调 `run()` 顺序执行 `fetcher → storage(candles) → scorer → storage(scores)`。无后台任务、无队列,每次 CLI 调用处理一个合约一日。 -**FastAPI 服务**(`src.api`):容器默认以 `uvicorn src.api:app` 启动,暴露 `/api/v1/run`(触发流水线)、`/api/v1/scores`、`/api/v1/scores/{id}`、`/api/v1/contracts`、`/api/v1/candles` 等端点。启动时自动 `storage.init_db()` 建表。API 与 CLI 共用同一套 `fetcher/storage/scorer` 逻辑。 +**FastAPI 服务**(`src.api`):容器默认以 `uvicorn src.api:app` 启动,暴露 `/api/v1/run`(触发流水线)、`/api/v1/run/batch`(批量打分)、`/api/v1/scores`、`/api/v1/scores/{id}`、`/api/v1/contracts`、`/api/v1/candles` 等端点。启动时自动 `storage.init_db()` 建表。API 与 CLI 共用同一套 `fetcher/storage/scorer` 逻辑。 **主力轮换规则**(`contracts.py`):每个品种在 `ROLLOVER_RULES` 中维护 `month -> (主力月, 年份偏移)` 表。FG 当前规则:1-3/12 月→05、4-7 月→09、8-11 月→01,其中 8-11 月与 12 月跨年(`year_offset=1`)。新增品种(如 RB、I)只需在该 dict 里加一条,无需改 main 流程。 diff --git a/README.md b/README.md index e348c12..9fbad6c 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,9 @@ docker-compose -f docker-compose.trade.yml run --rm tushare python -m src.main curl -X POST http://localhost:4001/api/v1/run -H "Content-Type: application/json" \ -d '{"symbol":"FG"}' +# 批量触发所有固定品种今日打分 +curl -X POST http://localhost:4001/api/v1/run/batch + # 查询最新打分 curl "http://localhost:4001/api/v1/scores?limit=5" @@ -214,7 +217,7 @@ A: 郑商所用 `.ZCE` 后缀(如 `FG2609.ZCE`),上期所用 `.SHF`,大 **Q: 如何定时自动跑?** -A: 通过宿主机 cron / launchd 等定时器调用 `docker-compose -f docker-compose.trade.yml run --rm tushare ...`。也可直接调用 API: `curl -X POST http://localhost:4001/api/v1/run ...`。 +A: 通过宿主机 cron / launchd 等定时器调用 `docker-compose -f docker-compose.trade.yml run --rm tushare ...`。也可直接调用 API: `curl -X POST http://localhost:4001/api/v1/run ...` 或批量接口 `curl -X POST http://localhost:4001/api/v1/run/batch`。 ## Web 报表(浏览端)