主题
命令行用法(开发者)
目标读者:操作者 + 接入工程师 + CI 测试。不是 WeChat 投研同事。如果你是投研同事,请直接看 WeChat 使用。
安装
bash
git clone https://github.com/LaCatFly/twilight-drive.git
cd twilight-drive
bash install.shinstall.sh 会:
- 创建 Python 3.11+ venv
pip install -e ./core(核心包)- 在
~/.hermes/profiles/stock-research-agent/skills/research/stock-research/安装 skill scripts
配置
复制 .env.example 到 .env(profile 模板里有 profile/template-stock-research-pro/.env.example),填:
bash
TUSHARE_TOKEN=<your-tushare-pro-token>
# AKSHARE_ENABLE 默认 1,无需显式配置P1.0 backend 上线后(见 /status/),改成:
bash
TWILIGHT_SERVICE_URL=https://api.fsagent.cc
TWILIGHT_API_TOKEN=<your-bearer-token-from-issue-token-cli>
# TUSHARE_TOKEN 删除(中心化在 backend)跑
当前价 / 最近收盘
bash
./skill/stock-research/scripts/fetch_price.py 600519输出:
json
{
"value": 1371.05,
"metric": "close",
"code": "600519.SH",
"as_of": "2026-05-07",
"cite": {
"kind": "tool",
"source": "tushare",
"table": "daily",
"fetched_at": "2026-05-07T13:42:31.168+00:00",
"tool_call_id": "tc_fed71513e34b",
"served_by": "tushare"
}
}指定历史日期
bash
./skill/stock-research/scripts/fetch_price.py 600519 --trade-date 20260427基本面
bash
./skill/stock-research/scripts/fetch_fundamentals.py 600519 --period 20240331返回 P/E / P/B / ROE / 毛利率 / 净利率 / 资产负债率,每项带 cite。
退出码
| Code | 含义 |
|---|---|
| 0 | 成功 |
| 1 | 上游无数据(akshare + tushare 都返回空) |
| 2 | Tushare token 被拒(HTTP 401-ish) |
更多 envelope 形态见 skill/stock-research/references/tool-usage.md。
升级到 Service 模式
P1.0 backend 上线后(/status/ 跟踪进度),不需要改命令;只改 .env:
diff
- TUSHARE_TOKEN=<...>
+ TWILIGHT_SERVICE_URL=https://api.fsagent.cc
+ TWILIGHT_API_TOKEN=<bearer-from-scripts/issue-token.py>_client.py 自动检测两种 mode 并切换;输出 envelope 形状一致。