feat: attach stress note to backtest reports - #33
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
attach_stress_note() 中事件序列化方式与文案范围表述存在可改进点,建议修正以避免后续兼容性与语义误导。
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
本 PR 新增 attach_stress_note(),用于将原始数据中的非正价格(负/零价)压力事件与说明附加到回测(backtest)报告中,避免负油价等尾部事件在报告层被“静默消失”,并同步补充了测试与文档记录。
Changes:
- 在
goratio.stress中新增attach_stress_note(raw, backtest_report),输出stress_events与stress_note。 - 增加对应单元测试覆盖回测报告附加字段的行为。
- 更新
CHANGELOG.md与.planning/ROADMAP.md记录新增能力与测试数量。
File summaries
| File | Description |
|---|---|
| tests/test_stress.py | 新增测试用例验证回测报告可附加压力事件与说明。 |
| src/goratio/stress.py | 新增 attach_stress_note() 将非正价格事件与提示信息注入回测报告。 |
| CHANGELOG.md | 记录新增 attach_stress_note() 能力。 |
| .planning/ROADMAP.md | 路线图勾选该能力并更新测试数量统计。 |
Review details
Suppressed comments (1)
src/goratio/stress.py:55
scan_non_positive_events()scans both gold and oil; wording here currently singles out oil. Consider using a generic phrase like “非正价格事件” to match the actual data attached instress_events.
"负油价/零价事件未进入正价格回测样本;如需压力测试请使用合约级原始数据单列场景"
- Files reviewed: 4/4 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 on lines
+49
to
+53
| events = scan_non_positive_events(raw) | ||
| report = dict(backtest_report) | ||
| report["stress_events"] = [ | ||
| event.__dict__ for event in events | ||
| ] |
|
|
||
|
|
||
| def attach_stress_note(raw: RawMarketData, backtest_report: dict) -> dict: | ||
| """把负油价压力事件状态附加到 backtest 报告中。""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
新增 attach_stress_note,把负油价事件与说明附加到回测报告。