Skip to content

交易 - 快速开始

jh_quant.trading 是交易运行层,负责把选股、策略信号、组合优化、风险规则、订单执行、持久化、API 和 Dashboard 串成一个可运行的模拟盘或实盘服务。

模拟盘

Terminal window
uv run python run_paper.py

默认会启动两个并行模拟场景:

  • paper-turtle:海龟策略,作为保底基准。
  • paper-momentum:默认用户策略场景。

API 启动后会自动打开 trading Dashboard。只想启动 API 时可以加:

Terminal window
uv run python run_paper.py --no-dashboard

常用示例:

Terminal window
uv run python run_paper.py --strategy turtle --backend tushare
uv run python run_paper.py --strategy rsi --symbols 688041,688256,688981
uv run python run_paper.py --strategy turtle,momentum --no-dashboard

实盘

Terminal window
uv run python run_live.py

运行前需要设置 MiniQMT / xtquant broker 环境变量:

Terminal window
set MINIQMT_USERDATA_DIR=D:\path\to\userdata
set MINIQMT_STOCK_ACCOUNT=你的资金账号

常用示例:

Terminal window
uv run python run_live.py --strategy turtle
uv run python run_live.py --backend xquant --strategy turtle,momentum
uv run python run_live.py --no-dashboard

策略参数

--strategy 接收一个或多个注册策略名,多个策略用英文逗号分隔:

Terminal window
--strategy turtle,momentum

当前注册策略会在 --help 中完整列出:

bollinger_bands, breakout, buy_and_hold, dual_thrust, mean_reversion,
momentum, moving_average_crossover, rsi, turtle, volume_divergence, volume_trend

paper-compare 模板会自动把 turtle 作为保底 scenario。如果你传入 --strategy rsi,最终会创建 paper-turtlepaper-rsi 两个模拟场景。

下一步