Add JoinQuant simulated trading automation

This commit is contained in:
Yuxuan Yan
2026-07-04 18:12:01 +08:00
parent 39a93259e1
commit d05931f41a
5 changed files with 311 additions and 72 deletions
+48 -3
View File
@@ -7,6 +7,7 @@ import click
from plugins.joinquant.browser import (
browser_snapshot,
run_browser_backtest,
run_browser_sim_trade,
save_login_state,
write_browser_config_template,
)
@@ -258,10 +259,17 @@ def browser_login_cmd(storage_state, login_url, headless, wait_seconds):
@joinquant.command("write-browser-config")
@click.option("--out-path", required=True, help="Path for JSON browser automation config")
@click.option("--strategy-url", default="", help="JoinQuant strategy edit/backtest URL")
def write_browser_config_cmd(out_path, strategy_url):
@click.option("--strategy-url", default="", help="JoinQuant strategy edit/backtest/模拟盘 URL")
@click.option(
"--flow",
type=click.Choice(["backtest", "sim-trade"]),
default="backtest",
show_default=True,
help="Browser automation template to write",
)
def write_browser_config_cmd(out_path, strategy_url, flow):
"""Write a browser automation selector/action config template."""
path = write_browser_config_template(out_path, strategy_url=strategy_url)
path = write_browser_config_template(out_path, strategy_url=strategy_url, flow=flow)
click.echo(f"Saved JoinQuant browser config template: {path}")
@@ -323,3 +331,40 @@ def run_browser_backtest_cmd(
click.echo(f" {key}: {path}")
if report["reconcile_paths"]:
click.echo(f"Saved reconciliation summary: {report['reconcile_paths']['summary_md']}")
@joinquant.command("run-browser-sim")
@click.option("--manifest-path", required=True, help="Manifest from target preparation")
@click.option("--config-path", required=True, help="JSON simulated-trading browser config")
@click.option(
"--storage-state",
default="~/.config/chinese-equity-quant/joinquant_storage_state.json",
show_default=True,
)
@click.option("--out-dir", default=None, help="Browser-run artifact directory")
@click.option("--headed", is_flag=True, help="Run with a visible browser")
@click.option("--no-auto-reconcile", is_flag=True, help="Skip ingest/reconcile after downloads")
def run_browser_sim_cmd(
manifest_path,
config_path,
storage_state,
out_dir,
headed,
no_auto_reconcile,
):
"""Run JoinQuant 模拟盘 browser automation from manifest and config."""
report = run_browser_sim_trade(
manifest_path=manifest_path,
config_path=config_path,
storage_state=storage_state,
out_dir=out_dir,
headless=not headed,
auto_reconcile=not no_auto_reconcile,
)
click.echo(f"Saved browser sim-trade report: {report['report_path']}")
if report["downloaded"]:
click.echo("Downloaded JoinQuant CSVs:")
for key, path in report["downloaded"].items():
click.echo(f" {key}: {path}")
if report["reconcile_paths"]:
click.echo(f"Saved reconciliation summary: {report['reconcile_paths']['summary_md']}")