feat: net P&L after financing cost - #23
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
存在已确认的输入校验/语义一致性与测试断言不足问题,可能导致错误结果被静默接受并降低回归检测能力。
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
该 PR 扩展 position_pnl_estimate() 的输出,使其在原有换月收益 P&L 估算基础上,额外给出保证金资金成本与扣减后的净 P&L,以支持更贴近资金占用的持仓收益评估。
Changes:
- 在
position_pnl_estimate()中新增持有天数、资金成本估算与净 P&L 字段输出 - 补充单测对新增字段的基本断言
- 更新 CHANGELOG 与 ROADMAP,反映新增能力
File summaries
| File | Description |
|---|---|
| src/goratio/margin.py | 增加 holding_days、financing_cost_estimate、net_pnl_estimate 输出并参与净值计算 |
| tests/test_margin.py | 为 position_pnl_estimate() 新增字段增加断言 |
| CHANGELOG.md | 记录 position_pnl_estimate() 新增资金成本与净 P&L 估算 |
| .planning/ROADMAP.md | 勾选/记录“输出扣减资金成本后的净 P&L”里程碑 |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 5
- 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
+100
to
+101
| holding_days = max(0, (exit_date - entry_date).days) | ||
| financing = financing_cost_estimate(margin, holding_days) |
| "holding_days": holding_days, | ||
| "financing_cost_estimate": financing, | ||
| "pnl_estimate": pnl, | ||
| "net_pnl_estimate": net_pnl, |
Comment on lines
+73
to
+74
| self.assertGreater(result["holding_days"], 0) | ||
| self.assertIsNotNone(result["net_pnl_estimate"]) |
Comment on lines
+53
to
+54
| - `financing_cost_estimate()`:保证金资金成本估算; | ||
| - `position_pnl_estimate()` 增加资金成本与净 P&L 估算。 |
Comment on lines
+109
to
+113
| net_pnl = ( | ||
| pnl - financing | ||
| if pnl is not None | ||
| else None | ||
| ) |
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.
position_pnl_estimate 输出资金成本与扣费后净 P&L。