Fix MWR calculation, align TWR/MWR conventions, add portfolio Markdown export for AI - #20
Merged
Merged
Conversation
- New portfolio_markdown_export service: renders the Copilot portfolio
snapshot (summary, positions, Doctor health, Monte Carlo, target
drift, PAC) plus a TWR/MWR performance table as plain Markdown.
- New GET /portfolios/{id}/export/markdown endpoint returning
text/markdown with a Content-Disposition attachment filename.
- Frontend: 'Esporta per AI' menu in the Portfolio page header with
copy-to-clipboard and .md download actions.
- Unit tests for the renderer and integration tests for the endpoint.
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.
Summary
Nato da una verifica di correttezza del calcolo MWR, questo PR contiene tre blocchi di lavoro:
1. Fix del calcolo MWR (
performance_service.py)calculate_mwrincludeva come flusso a t=0 anche i movimenti datatistart, già compresi instart_value→ MWR sottostimato. Ora esclusi, coerentemente concalculate_twreget_mwr_timeseries.get_portfolio_value_at_datenon attribuisce alcun impatto cash ai trade, quindi le sottrazionicash_before/cash_in_periodtoglievano denaro mai presente nel valore (es. buy 1000 → 1200 dava MWR ≈ −93% invece di ≈ +20%). Rimosse.2. Allineamento convenzioni TWR ↔ MWR
MWRResult.mwr_pctè ora il rendimento di periodo cometwr_pct; il tasso annuo è esposto nel nuovo campomwr_annualized_pctsolo per periodi ≥ 365 giorni (specchio ditwr_annualized_pct).get_mwr_timeseriesriportano il rendimento cumulato da inizio periodo: grafico confrontabile con la serie TWR e stabile nei primi giorni.MWRResult, tooltip MWR aggiornato.3. Export Markdown del portafoglio per AI esterne
portfolio_markdown_export.py: renderizza lo snapshot del Copilot (riepilogo, posizioni, salute Doctor, Monte Carlo, target drift, PAC) più una tabella performance TWR/MWR in Markdown puro.GET /portfolios/{id}/export/markdown(text/markdown, filename di download, 404 uniforme)..md, pronto da incollare in ChatGPT/Claude/Gemini.Test
tsc --noEmit) pulito.🤖 Generated with Claude Code
https://claude.ai/code/session_01Dfocvsn4D46Kk3WRMeEeWY
Generated by Claude Code