Skip to content

[Alerts] 持仓权重提醒在缺少折算值时混用币种并误报 #130

Closed

Description

@wxrbyte

问题与复现

position_weight 提醒使用 marketValueBase ?? marketValue 除以 totalAssets。Holding.currency 表示持仓计价币种,PortfolioSnapshot.baseCurrency 表示总资产币种;缺少 marketValueBase 时,直接使用外币 marketValue 会比较不同单位。

例如 USD 总资产 1000、HKD 持仓市值 400、marketValueBase 未提供,maxWeight=0.3:当前直接得到 weight=0.4 并生成超限提醒,实际没有足够数据计算美元权重。该错误也会经 AlertEngine 发送通知并写入事件日志。

预期与修复方向

优先使用供应商提供的 marketValueBase;只有持仓币种和组合基币都已知且相同时,才允许使用原始 marketValue。缺失折算或币种信息时保持未知,不猜测汇率、不发错误提醒。保留真实零值和正常同币种行为。

复现证据

Windows 11 / Bun 1.4.2,main ff3ed3d。新增 5 个测试:修复前 2 pass / 3 fail;修复后 alerts 47 pass / 0 fail,shared 1000 pass / 0 fail。包含真实 AlertEngine→通知回调→事件文件保存/重载,以及折算数据恢复后的行为。

范围仅 position_weight 提醒,不声称修改了其他组合风险报表或供应商汇率转换。

Activity

  1. wxrbyte commented on Sep 20, 2026

    @wxrbyte
    ContributorAuthor

    /claim

  2. added
    claimed
    on Sep 20, 2026
  3. github-actions commented on Sep 20, 2026

    @github-actions

    @wxrbyte 已认领该 Issue,并已自动设为 Assignee。提交 PR 时请在描述中写 Closes #130。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

claimed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions