feat: batch portfolio summary - #24
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
新增测试目前断言过弱且 Changelog 条目格式不一致,建议补强断言与统一文档格式后再合入。
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
该 PR 在 goratio.margin 中新增一个高层封装函数,用于将批量 episode 的持仓模拟结果汇总为资金曲线与保证金占用统计,便于研究调用方一次性获取核心摘要输出。
Changes:
- 新增
summarize_batch_portfolio():封装run_position_simulation+batch_equity_summary+margin_utilization_summary的批量汇总返回结构 - 新增对应单元测试用例并更新 Changelog/Roadmap 记录
File summaries
| File | Description |
|---|---|
| tests/test_margin.py | 增加 summarize_batch_portfolio 的测试用例入口 |
| src/goratio/margin.py | 新增批量持仓汇总函数,返回 simulation/equity/margin_utilization 组合结果 |
| CHANGELOG.md | 记录新增 API 条目 |
| .planning/ROADMAP.md | 勾选完成项并更新测试数量 |
Review details
- 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
+54
to
+55
| - `position_pnl_estimate()` 增加资金成本与净 P&L 估算; | ||
| - `summarize_batch_portfolio()`:批量 episode → 持仓模拟 → 资金/保证金高层汇总。 |
Comment on lines
+300
to
+305
| summary = summarize_batch_portfolio(records, [episode]) | ||
|
|
||
| self.assertIn("simulation", summary) | ||
| self.assertIn("equity", summary) | ||
| self.assertIn("margin_utilization", summary) | ||
|
|
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.
新增 summarize_batch_portfolio,汇总批量持仓模拟、资金曲线与保证金占用。