Skip to content

Fix MWR calculation: start-day double counting and trade-fallback adjustments - #19

Merged
ascatox merged 2 commits into
mainfrom
claude/mwr-calculation-check-a2ahci
Jul 12, 2026
Merged

Fix MWR calculation: start-day double counting and trade-fallback adjustments#19
ascatox merged 2 commits into
mainfrom
claude/mwr-calculation-check-a2ahci

Conversation

@ascatox

@ascatox ascatox commented Jul 12, 2026

Copy link
Copy Markdown
Owner
  • calculate_mwr: skip cashflows dated on/before the period start, since
    get_portfolio_value_at_date(start) already includes them (consistent
    with calculate_twr and get_mwr_timeseries).
  • Remove the cash_before/cash_in_period value adjustments in the buy/sell
    fallback: portfolio value never tracks trade cash (buys only add
    holdings, sells only remove them), so the subtraction removed money
    that was never part of the value and produced wildly wrong IRRs.
  • Treat dividend/interest/fee as internal portfolio movements instead of
    investor cashflows in TWR/MWR: they stay in portfolio cash, so they are
    performance, not contributions. Investor flows are deposit/withdrawal,
    with buy/sell as fallback.
  • In the fallback, count buy/sell amounts as real external flows for TWR
    too (portfolio value changes when assets are bought/sold).
  • Add unit tests for start-day deposits, fallback buys, internal
    dividends, TWR fallback flows, and timeseries/point MWR consistency.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01Dfocvsn4D46Kk3WRMeEeWY

claude added 2 commits July 12, 2026 19:47
…ustments

- calculate_mwr: skip cashflows dated on/before the period start, since
  get_portfolio_value_at_date(start) already includes them (consistent
  with calculate_twr and get_mwr_timeseries).
- Remove the cash_before/cash_in_period value adjustments in the buy/sell
  fallback: portfolio value never tracks trade cash (buys only add
  holdings, sells only remove them), so the subtraction removed money
  that was never part of the value and produced wildly wrong IRRs.
- Treat dividend/interest/fee as internal portfolio movements instead of
  investor cashflows in TWR/MWR: they stay in portfolio cash, so they are
  performance, not contributions. Investor flows are deposit/withdrawal,
  with buy/sell as fallback.
- In the fallback, count buy/sell amounts as real external flows for TWR
  too (portfolio value changes when assets are bought/sold).
- Add unit tests for start-day deposits, fallback buys, internal
  dividends, TWR fallback flows, and timeseries/point MWR consistency.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dfocvsn4D46Kk3WRMeEeWY
… rate

- MWRResult.mwr_pct is now the period return like twr_pct; the annual
  IRR is exposed as mwr_annualized_pct only for periods >= 365 days,
  mirroring twr_annualized_pct.
- MWR timeseries points now report the cumulative return since the
  period start instead of the annualized IRR, making the chart
  comparable with the TWR series and stable in the first days.
- Frontend: add mwr_annualized_pct to the MWRResult type and clarify
  the MWR tooltip in the performance KPI card.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dfocvsn4D46Kk3WRMeEeWY
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
valore365 Ready Ready Preview, Comment Jul 12, 2026 8:00pm

@ascatox
ascatox merged commit dc9d34e into main Jul 12, 2026
3 checks passed
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