feat: margin utilization summary - #16
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
变更范围小且自包含,新增功能具备明确输入校验并有对应单元测试覆盖,文档/路线图同步更新一致。
Pull request overview
本 PR 增加了一个用于批量持仓模拟结果的保证金占用率统计摘要函数 margin_utilization_summary,用于在研究/回测场景下快速汇总逐笔近似的保证金占用水平,并补齐对应的单元测试与变更记录。
Changes:
- 在
goratio.margin中新增margin_utilization_summary(),基于rows[*].margin_estimate计算 mean/max utilization(相对initial_capital)。 - 新增单元测试覆盖
valid_margin_count、均值与最大占用率计算。 - 更新 CHANGELOG 与 ROADMAP,记录新 API 与测试数量变化。
File summaries
| File | Description |
|---|---|
| tests/test_margin.py | 增加 margin_utilization_summary() 的单测用例与断言。 |
| src/goratio/margin.py | 新增保证金占用率摘要函数实现与输入校验。 |
| CHANGELOG.md | 在 Unreleased 新增项中补充新函数条目。 |
| .planning/ROADMAP.md | 将新函数标记为已完成,并更新当前测试数量说明。 |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
新增 margin_utilization_summary,统计批量持仓保证金占用率。