Skip to content

feat: net P&L after financing cost - #23

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

feat: net P&L after financing cost#23
XucroYuri merged 4 commits into
mainfrom
goratio-dev-net-pnl

Conversation

@XucroYuri

Copy link
Copy Markdown
Owner

position_pnl_estimate 输出资金成本与扣费后净 P&L。

Copilot AI lite review requested due to automatic review settings September 3, 2026 00:21
@XucroYuri
XucroYuri merged commit 453fdab into main Sep 3, 2026
11 checks passed
@XucroYuri
XucroYuri deleted the goratio-dev-net-pnl branch September 3, 2026 00:22

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

存在已确认的输入校验/语义一致性与测试断言不足问题,可能导致错误结果被静默接受并降低回归检测能力。

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_daysfinancing_cost_estimatenet_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 thread src/goratio/margin.py
Comment on lines +100 to +101
holding_days = max(0, (exit_date - entry_date).days)
financing = financing_cost_estimate(margin, holding_days)
Comment thread src/goratio/margin.py
"holding_days": holding_days,
"financing_cost_estimate": financing,
"pnl_estimate": pnl,
"net_pnl_estimate": net_pnl,
Comment thread tests/test_margin.py
Comment on lines +73 to +74
self.assertGreater(result["holding_days"], 0)
self.assertIsNotNone(result["net_pnl_estimate"])
Comment thread CHANGELOG.md
Comment on lines +53 to +54
- `financing_cost_estimate()`:保证金资金成本估算;
- `position_pnl_estimate()` 增加资金成本与净 P&L 估算。
Comment thread src/goratio/margin.py
Comment on lines +109 to +113
net_pnl = (
pnl - financing
if pnl is not None
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