Skip to content

feat: daily position mark-to-market - #18

Merged
XucroYuri merged 4 commits into
mainfrom
goratio-dev-daily-mark
Sep 3, 2026
Merged

feat: daily position mark-to-market#18
XucroYuri merged 4 commits into
mainfrom
goratio-dev-daily-mark

Conversation

@XucroYuri

Copy link
Copy Markdown
Owner

新增 run_daily_position_mark,输出逐日盯市 P&L 与保证金占用。

Copilot AI lite review requested due to automatic review settings September 3, 2026 00:09
@XucroYuri
XucroYuri merged commit 466d84e into main Sep 3, 2026
11 checks passed
@XucroYuri
XucroYuri deleted the goratio-dev-daily-mark branch September 3, 2026 00:11

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

run_daily_position_mark() 目前存在输入校验与返回结构一致性问题(无数据/日期区间边界与 margin_rate 判定),需要先修正以避免调用方在边界条件下出现不一致或隐式错误。

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

新增 run_daily_position_mark(),用于基于真实主力合约链输出单笔持仓的逐日盯市 P&L 与保证金占用估算,并补充相应单元测试与文档记录,完善保证金/换月研究工具链。

Changes:

  • margin.py 新增 run_daily_position_mark(),逐日输出 realized/unrealized/cumulative P&L 与保证金估算,并在换月时按旧合约结算、按新合约重开仓。
  • 新增单测覆盖换月场景下的 P&L 计算与保证金字段输出。
  • 更新 CHANGELOGROADMAP 记录新增能力与测试数量。
File summaries
File Description
tests/test_margin.py 增加逐日盯市换月场景的单元测试用例
src/goratio/margin.py 新增 run_daily_position_mark() 逐日盯市与保证金估算逻辑
CHANGELOG.md 记录新增 run_daily_position_mark() 能力
.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 thread src/goratio/margin.py
Comment on lines +243 to +250
calendar = report["series"][instrument]["calendar"]
daily = [
point
for point in calendar
if entry_date <= date.fromisoformat(point["date"]) <= exit_date
]
if not daily:
return {"rows": [], "final_pnl": None}
Comment thread src/goratio/margin.py
Comment on lines +251 to +254
multiplier = 100 if instrument == "gold" else 1000
rate = margin_rate or DEFAULT_MARGIN_RATES.get(
"GC" if instrument == "gold" else "CL", 0.1
)
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