Skip to content

feat: contracts net-backtest CLI - #31

Merged
XucroYuri merged 5 commits into
mainfrom
goratio-dev-net-backtest-cli
Sep 3, 2026
Merged

feat: contracts net-backtest CLI#31
XucroYuri merged 5 commits into
mainfrom
goratio-dev-net-backtest-cli

Conversation

@XucroYuri

Copy link
Copy Markdown
Owner

新增 contracts net-backtest,从合约 CSV 运行 T+1 open/settle 净收益回测。

Copilot AI lite review requested due to automatic review settings September 3, 2026 00:40
@XucroYuri
XucroYuri merged commit 8ebf3b3 into main Sep 3, 2026
11 checks passed
@XucroYuri
XucroYuri deleted the goratio-dev-net-backtest-cli branch September 3, 2026 00:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

新增命令路径存在可避免的重复 CSV 解析开销且测试未覆盖 settle/文本输出分支,建议补齐后再合并。

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

本 PR 为 goratio contracts 增加 net-backtest 子命令,使用户可以从合约 CSV 直接运行基于 T+1 open/settle 净收益口径 的 episode 回测摘要输出(支持 JSON 或文本)。

Changes:

  • 在 CLI 中新增 contracts net-backtest 子命令与参数(horizon/cost-bps/execution/json)。
  • 增加对应 CLI 单测,验证从合约 CSV 运行并产出可解析的 JSON。
  • 更新 README/CHANGELOG/ROADMAP 文档,补充命令用法与版本记录。
File summaries
File Description
tests/test_cli.py 新增 contracts net-backtest 的 CLI 回归测试用例。
src/goratio/cli.py 增加 contracts net-backtest 子命令解析与执行逻辑,并接入 run_contract_episode_net_backtest
README.md 补充 contracts net-backtest 的示例用法。
CHANGELOG.md 记录新增 CLI 能力的变更条目。
.planning/ROADMAP.md 更新 roadmap 勾选项与测试数量统计。
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/goratio/cli.py
Comment on lines +466 to +468
records = read_contract_csv(args.csv)
raw = contract_csv_to_raw_market_data(args.csv)
prepared = prepare_market_data(
Comment thread tests/test_cli.py
Comment on lines +411 to +425
output = io.StringIO()
exit_code = main(
[
"contracts", "net-backtest", "--csv", str(csv_path),
"--horizon", "63", "--json",
],
today=lambda: date(2024, 1, 4),
stdout=output,
stderr=io.StringIO(),
)

payload = json.loads(output.getvalue())
self.assertEqual(exit_code, 0)
self.assertEqual(payload["execution"], "open")
self.assertEqual(payload["episode_count"], 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants