LLM-driven A-share (Shanghai/Shenzhen main board) stock screening CLI
Project description
DeepTrade
本地运行的 A 股(沪深主板)选股 CLI 工具:tushare 行情 + OpenAI 兼容 LLM(DeepSeek / Qwen / Kimi …)+ DuckDB 单机仓库 + 插件式 CLI 框架。
✨ 主要特性
- 轻量本地化:单文件 DuckDB + uv,一条命令跑完,无需服务进程或容器。
- 纯透传式插件 CLI:框架命令面封闭——只管
init / config / plugin / data;其余命令一律按deeptrade <plugin_id> <argv...>透传给插件,插件自管--help、子命令、参数、持久化。新增插件类型(皮肤、新数据源、回测、IM 渠道……)零框架改动。 - 数据隔离(Plan A):每个插件在自己的 migrations 里声明并拥有自己的表(含 tushare 派生数据),框架不持有任何业务表。
tushare_sync_state/tushare_calls/llm_calls都按plugin_id维度隔离。 - 顶层通知 API:
from deeptrade import notify, notification_session一行发推送;框架根据已安装的 channel 插件自动路由,无 channel 时自动 noop。 - 多 LLM Provider 共存:
llm.providers字典化配置,多个 OpenAI 兼容服务并存;插件通过LLMManager.get_client(name=...)按名取用,单次 run 内可调多家。 - LLM 强约束:JSON 模式 + Pydantic 双层校验;永远不传 tools / function calls。
- 盘中数据隔离:
--allow-intraday模式下同步的不完整数据写入data_completeness='intraday',日终模式严格拒绝命中。
🚀 5 分钟上手
安装
# 推荐
uv sync --all-extras
uv run pre-commit install
# 兜底(无 uv)
python -m venv .venv && source .venv/bin/activate # Windows: .\.venv\Scripts\activate
pip install -e ".[dev]"
初始化与配置
deeptrade init # 建库 + 应用 core migrations
deeptrade config set-tushare # 交互式输入 tushare token
deeptrade config set-llm # 交互式增/改/删 LLM provider(deepseek / qwen / kimi …)
deeptrade config list-llm # 列出已配置且可用的 provider
deeptrade config test-llm # 对所有 provider 做连通性自检(也可加 <name> 单测)
deeptrade config show # 表格展示当前配置(密钥脱敏)
安装内置插件并运行
# 安装一个 strategy 插件 + 一个 channel 插件
deeptrade plugin install ./deeptrade/strategies_builtin/limit_up_board -y
deeptrade plugin install ./deeptrade/channels_builtin/stdout -y
deeptrade plugin list # 查看已安装
# 运行打板策略(CLI 由插件自管,--help 由插件渲染)
deeptrade limit-up-board --help
deeptrade limit-up-board run # 默认日终模式
deeptrade limit-up-board run --allow-intraday --force-sync
# 运行成交量异动策略(三模式)
deeptrade volume-anomaly screen # 异动筛选 → upsert va_watchlist
deeptrade volume-anomaly analyze # LLM 主升浪启动预测
deeptrade volume-anomaly prune --days 30 # 剔除追踪 ≥30 日的标的
# 推送链路自检
deeptrade stdout-channel test
报告产出在 ~/.deeptrade/reports/<run_id>/。
📦 命令矩阵
框架命令(封闭集合)
| 命令 | 用途 |
|---|---|
deeptrade --version / -V |
显示版本 |
deeptrade --help / -h |
框架命令清单(不枚举插件子命令) |
deeptrade init [--no-prompts] |
建库 + 应用 core migrations |
deeptrade config {show, set, set-tushare, set-llm, list-llm, test-llm} |
全局配置 |
deeptrade plugin install <path> [-y] |
本地路径安装(绝不联网) |
deeptrade plugin list / info <id> |
列表 / 详情 |
deeptrade plugin enable <id> / disable <id> |
启 / 停 |
deeptrade plugin uninstall <id> [--purge] |
卸载(--purge 才 DROP 表) |
deeptrade plugin upgrade <path> |
升级(增量 migrations) |
deeptrade data sync ... |
(暂停用,下版本恢复) |
保留字(不可作为 plugin_id):init / config / plugin / data。
插件命令(按 plugin_id 透传,插件自管)
| 命令 | 来源 |
|---|---|
deeptrade limit-up-board {run, sync, history, report} |
内建打板策略插件 |
deeptrade volume-anomaly {screen, analyze, prune, history, report} |
内建成交量异动插件 |
deeptrade stdout-channel {test, log} |
内建 stdout 通知插件 |
deeptrade <你的-plugin-id> ... |
你自己写的任何插件 |
任意插件子命令的 --help 都由插件自身渲染——框架不感知动词语义。
🧱 架构
┌──────────────────────── deeptrade CLI (custom click.Group) ────────────────────────┐
│ │
│ framework commands (closed): │
│ init │ config │ plugin │ data │
│ │
│ plugin pass-through (open): │
│ <plugin_id> ──argv──→ Plugin.dispatch(argv) → int (plugin owns the rest) │
└──────────────────────────────────┬─────────────────────────────────────────────────┘
│
┌──────────────────────┼──────────────────────────┐
▼ ▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌────────────────────┐
│ Core services │ │ deeptrade.notify │ │ Plugins (any type)│
│ DuckDB · Config │ │ → routes to all │ │ • metadata │
│ Tushare · LLM │ │ enabled │ │ • validate_static │
│ Notifier │ │ channel plugins│ │ • dispatch(argv) │
└─────────────────┘ └──────────────────┘ │ (channel: + push) │
└────────────────────┘
设计决策见 docs/plugin_cli_dispatch_evaluation.md。
📖 文档
- DESIGN.md — 设计文档
- docs/plugin_cli_dispatch_evaluation.md — 当前架构的评估与决策记录(v0.3)
- docs/quick-start.md — 上手指南
- docs/plugin-development.md — 写一个新插件
- docs/limit-up-board.md — 打板策略说明
- CHANGELOG.md — 版本变更
⚖️ 免责声明
本工具仅用于策略研究、数据整理与候选标的分析,不构成投资建议,不进行自动交易。所有 LLM 输出基于提交的结构化数据,不引用任何外部信息源;用户应自行核验候选标的的最新状态后再做决策。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deeptrade_quant-0.0.2.tar.gz.
File metadata
- Download URL: deeptrade_quant-0.0.2.tar.gz
- Upload date:
- Size: 208.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd68b458993a7b56f6abc57a55362c5123b6312cb97760c086418b383ff32b04
|
|
| MD5 |
ce0ec4409c13f2deb2cdcb817d27a01a
|
|
| BLAKE2b-256 |
d1ef52b2c352bd5234edde36226b4a13c4b25ee2195d08f8228b3b3833e8fe4c
|
Provenance
The following attestation bundles were made for deeptrade_quant-0.0.2.tar.gz:
Publisher:
release.yml on ty19880929/DeepTrade
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deeptrade_quant-0.0.2.tar.gz -
Subject digest:
bd68b458993a7b56f6abc57a55362c5123b6312cb97760c086418b383ff32b04 - Sigstore transparency entry: 1485574176
- Sigstore integration time:
-
Permalink:
ty19880929/DeepTrade@b900760c7f2cae128ab6ec4feefbe4a19a61d414 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/ty19880929
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b900760c7f2cae128ab6ec4feefbe4a19a61d414 -
Trigger Event:
push
-
Statement type:
File details
Details for the file deeptrade_quant-0.0.2-py3-none-any.whl.
File metadata
- Download URL: deeptrade_quant-0.0.2-py3-none-any.whl
- Upload date:
- Size: 207.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
568852951bc02bc94b467b39e1b6579633ab0fe0cc24228a4a0a2d33abc8ca15
|
|
| MD5 |
f2800219ea051fef5af011cd65fc44c3
|
|
| BLAKE2b-256 |
0ab7314e6f4215b559915f4f1c0d64e9d2f1997b89ed1da784921f21719784c7
|
Provenance
The following attestation bundles were made for deeptrade_quant-0.0.2-py3-none-any.whl:
Publisher:
release.yml on ty19880929/DeepTrade
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deeptrade_quant-0.0.2-py3-none-any.whl -
Subject digest:
568852951bc02bc94b467b39e1b6579633ab0fe0cc24228a4a0a2d33abc8ca15 - Sigstore transparency entry: 1485574209
- Sigstore integration time:
-
Permalink:
ty19880929/DeepTrade@b900760c7f2cae128ab6ec4feefbe4a19a61d414 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/ty19880929
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b900760c7f2cae128ab6ec4feefbe4a19a61d414 -
Trigger Event:
push
-
Statement type: