Skip to content

feat: T+1 net episode backtest summary - #30

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

feat: T+1 net episode backtest summary#30
XucroYuri merged 4 commits into
mainfrom
goratio-dev-net-backtest

Conversation

@XucroYuri

Copy link
Copy Markdown
Owner

新增 run_contract_episode_net_backtest,基于 T+1 open/settle 净收益与成本。

Copilot AI lite review requested due to automatic review settings September 3, 2026 00:38
@XucroYuri
XucroYuri merged commit 39201f6 into main Sep 3, 2026
11 checks passed
@XucroYuri
XucroYuri deleted the goratio-dev-net-backtest branch September 3, 2026 00:39

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

新增 backtest 摘要的测试断言与分支覆盖不足,且返回字段/文档与错误信息需补强以避免 API 使用歧义。

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

Pull request overview

该 PR 新增合约 episode 的“净收益(T+1 open/settle 执行缺口)+ 成本”回测摘要入口,用于在合约 CSV 数据上快速汇总净收益表现,配合现有 contract_episode_return_summary() 的口径输出。

Changes:

  • 新增 run_contract_episode_net_backtest():按 execution=open/settle 选择净收益口径并扣减成本后汇总统计。
  • 新增对应单元测试用例,并更新 Changelog/Roadmap 记录。
File summaries
File Description
tests/test_contracts.py 增加 run_contract_episode_net_backtest() 的基础用例覆盖
src/goratio/contracts.py 新增净收益回测摘要函数(基于 episode summary 的 open/settle 口径)
CHANGELOG.md 记录新增 backtest 摘要入口
.planning/ROADMAP.md Roadmap 勾选完成项并更新测试数
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 4
  • 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 tests/test_contracts.py
Comment on lines +347 to +354
result = run_contract_episode_net_backtest(
records, [episode], execution="open", cost_bps=10.0
)

self.assertEqual(result["execution"], "open")
self.assertEqual(result["episode_count"], 1)
self.assertIsNotNone(result["mean_net_after_cost_return"])

Comment thread src/goratio/contracts.py
Comment on lines +541 to +545
"""基于合约 CSV 的 episode 净收益回测摘要(T+1 open/settle 默认成交模型)。

execution="open" 使用扣减 T+1 open gap 后的真实换月净收益;
execution="settle" 使用扣减 T+1 settle gap 后的真实换月净收益。
"""
Comment thread src/goratio/contracts.py
Comment on lines +546 to +547
if execution not in ("open", "settle"):
raise ValueError("execution 必须是 open 或 settle")
Comment thread src/goratio/contracts.py
Comment on lines +569 to +576
return {
"method": "contract_episode_net_backtest",
"execution": execution,
"cost_bps": cost_bps,
"episode_count": len(net_rows),
"mean_net_after_cost_return": (
sum(returns) / len(returns) if returns else None
),
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