交易 - 快速开始
jh_quant.trading 是交易运行层,负责把选股、策略信号、组合优化、风险规则、订单执行、持久化、API 和 Dashboard 串成一个可运行的模拟盘或实盘服务。
模拟盘
统一 CLI 入口 jh-quant paper:
jh-quant paper默认使用 paper-compare 模板,自动创建两个并行模拟场景:
paper-turtle:海龟策略基准场景。paper-momentum:默认用户策略场景。
API 启动后会自动打开 trading Dashboard。只想启动 API 时:
jh-quant paper --no-dashboard查看完整参数说明:
jh-quant paper --help常用示例:
jh-quant paper --strategy turtle --backend tusharejh-quant paper --strategy rsi --symbols 688041,688256,688981jh-quant paper --strategy turtle,momentum --no-dashboard默认行为:
- backend:
tushare - template:
paper-compare - strategy:
momentum - 默认股票池: 半导体 / AI 芯片链观察池
- API 地址:
http://127.0.0.1:8000/docs - 初始资金: 100,000 元
实盘
jh-quant live运行前需要设置 MiniQMT / xtquant broker 环境变量:
set MINIQMT_USERDATA_DIR=D:\path\to\userdataset MINIQMT_STOCK_ACCOUNT=你的资金账号查看完整参数说明:
jh-quant live --help常用示例:
jh-quant live --strategy turtlejh-quant live --backend xquant --strategy turtle,momentumjh-quant live --no-dashboard注意:
live模式没有--initial-capital(资金以 broker 查询为准),不支持回填(始终保持realtime时钟)。
数据同步
将本地 SQLite 交易数据增量同步到远程 Postgres / Neon:
jh-quant sync --from trade_paper.db详见 数据同步。
策略参数
--strategy 接收一个或多个注册策略名,多个策略用英文逗号分隔:
--strategy turtle,momentum当前注册策略会在 --help 中完整列出,共 11 种:
bollinger_bands, breakout, buy_and_hold, dual_thrust, mean_reversion,momentum, moving_average_crossover, rsi, turtle, volume_divergence, volume_trendpaper-compare 模板会自动把 turtle 作为保底 scenario。如果你传入 --strategy rsi,最终会创建 paper-turtle 和 paper-rsi 两个模拟场景。