Fix MWR calculation: start-day double counting and trade-fallback adjustments - #19
Merged
Merged
Conversation
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
get_portfolio_value_at_date(start) already includes them (consistent
with calculate_twr and get_mwr_timeseries).
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.
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.
too (portfolio value changes when assets are bought/sold).
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