Add JoinQuant browser backtest automation
This commit is contained in:
@@ -12,6 +12,11 @@ from click.testing import CliRunner
|
||||
|
||||
from cli import cli
|
||||
from pipeline.common.schema import FILL_COLUMNS, PNL_COLUMNS, POSITION_COLUMNS
|
||||
from plugins.joinquant.browser import (
|
||||
default_browser_config,
|
||||
resolve_template,
|
||||
write_browser_config_template,
|
||||
)
|
||||
from plugins.joinquant.export_targets import export_targets
|
||||
from plugins.joinquant.ingest import (
|
||||
ingest_joinquant_outputs,
|
||||
@@ -530,3 +535,42 @@ def test_build_fixed_share_positions_excludes_final_executionless_date():
|
||||
]
|
||||
assert positions["position_shares"].tolist() == [1000, 1000]
|
||||
assert positions["target_value"].tolist() == [10_000.0, 10_500.0]
|
||||
|
||||
|
||||
def test_browser_config_template_and_placeholder_resolution(tmp_path):
|
||||
config_path = write_browser_config_template(
|
||||
tmp_path / "browser_config.json",
|
||||
strategy_url="https://www.joinquant.com/example",
|
||||
)
|
||||
config = json.loads(config_path.read_text())
|
||||
assert config["strategy_url"] == "https://www.joinquant.com/example"
|
||||
assert config["actions"][0]["type"] == "goto"
|
||||
|
||||
context = {
|
||||
"wrapper_path": "/tmp/wrapper.py",
|
||||
"target_csvs": ["/tmp/20240110.csv", "/tmp/20240111.csv"],
|
||||
"expected_joinquant_csvs": {"fills": "/tmp/jq_fills.csv"},
|
||||
}
|
||||
assert resolve_template("{wrapper_path}", context) == "/tmp/wrapper.py"
|
||||
assert resolve_template("{target_csvs}", context) == [
|
||||
"/tmp/20240110.csv",
|
||||
"/tmp/20240111.csv",
|
||||
]
|
||||
assert resolve_template("save:{expected_joinquant_csvs.fills}", context) == "save:/tmp/jq_fills.csv"
|
||||
|
||||
|
||||
def test_joinquant_cli_browser_config_smoke(tmp_path):
|
||||
runner = CliRunner()
|
||||
config_path = tmp_path / "browser_config.json"
|
||||
result = runner.invoke(cli, [
|
||||
"joinquant",
|
||||
"write-browser-config",
|
||||
"--out-path",
|
||||
str(config_path),
|
||||
"--strategy-url",
|
||||
"https://www.joinquant.com/example",
|
||||
])
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
assert config_path.exists()
|
||||
assert default_browser_config()["actions"]
|
||||
|
||||
Reference in New Issue
Block a user