flex_analyze_portfolio_history
Analyze portfolio NAV changes over time and compute returns using time-weighted (TWR) or money-weighted (MWR) methods from Interactive Brokers Flex XML data.
Instructions
Show how the portfolio NAV changed over time and compute a return figure.
Return methods
twr (default) — Time-Weighted Return via daily chain-linking. Eliminates the timing/size effect of external cash flows. Use this to evaluate the strategy independent of cash-flow decisions.
mwr — Money-Weighted Return via Modified Dietz. Reflects the investor's actual experience: large deposits before a rally boost the return; large withdrawals before a rally reduce it. Use this to evaluate overall portfolio performance.
Args: xml_content: Raw Flex XML string. metric: Which equity component to track — "total", "cash", "stock", "options", "futures", "bonds" (default "total"). return_method: "twr" (default) or "mwr".
Returns JSON with a time-series, annualised and period returns, and the total net external cash flow over the period.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| metric | No | total | |
| xml_content | Yes | ||
| return_method | No | twr |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |