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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"xml_content": "<xml_content>"
},
"name": "flex_analyze_portfolio_history"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| metric | No | total | |
| xml_content | Yes | ||
| return_method | No | twr |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |