portfolio
Build and analyze a multi-ticker portfolio: compute optimal weights (minimum variance, maximum Sharpe, risk parity, Black-Litterman), risk contributions, stress tests, and Brinson attribution.
Instructions
Portfolio construction and analysis for the given tickers (at least two). Optimal weights: get_minimum_variance_weights, get_maximum_sharpe_weights, get_mean_variance_weights (target_return= or risk_aversion=), get_risk_parity_weights (risk_budget={'AAPL': 0.5, ...} optional), get_hierarchical_risk_parity_weights, get_inverse_volatility_weights, get_minimum_cvar_weights (confidence_level=) and get_black_litterman_weights (views={'AAPL': 0.10, 'AAPL-MSFT': 0.02}, optional view_confidences= and market_weights=; market capitalizations by default). Each returns per ticker and for the Portfolio the Weight, annualized Expected Return, Volatility, Sharpe Ratio and Risk Contribution. minimum_weight=/maximum_weight= bound the weights (a negative minimum allows shorting). get_efficient_frontier (points=) returns portfolios from the lowest risk to the highest return. For given weights (weights={'AAPL': 0.6, 'MSFT': 0.4}, equal weights when omitted): get_risk_contributions, get_stress_test (returns in the Dot-com Crash, Global Financial Crisis, Euro Area Debt Crisis, 2015-2016 and 2018 Q4 sell-offs, COVID-19 Crash and 2022 Rate Shock next to the benchmark, or scenarios={'name': ['start', 'end']}), get_look_through_exposure (by='sector'|'country'|'holdings', looks through ETFs to their holdings, with the benchmark's exposure next to it) and get_brinson_attribution (allocation, selection and interaction effects by sector against the benchmark over start_date/end_date). Expected returns are historical averages; period= sets the return frequency (daily by default). Weights, returns and volatilities are decimals.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | No | What to look through to: "sector", "country" or "holdings". | sector |
| tau | No | The uncertainty of the implied returns relative to the covariance matrix. | |
| limit | No | The rows to return, like head and tail: 5 for the first five, -5 for the last five (the most recent of a time series). A table with its periods as columns (financial statements, ratios) keeps its first or last periods instead. For ETF holdings the largest (or, negative, the smallest) by weight, and for a list (e.g. news or a screener) its length. | |
| views | No | The annualized views, absolute views as total returns. | |
| period | No | Observation frequency, e.g. 'daily', 'weekly', 'monthly', 'quarterly', or 'annual' (supported values differ per method). | daily |
| points | No | The number of portfolios on the frontier. | |
| tickers | No | Comma-separated ticker symbols, e.g. 'AAPL,MSFT,GOOGL'. | |
| weights | No | For get_brinson_attribution: The weight per asset at the start of the date range. For get_look_through_exposure, get_risk_contributions, get_stress_test: The weight per asset. | |
| end_date | No | End of the date range in YYYY-MM-DD format. | 2026-10-27 |
| indicator | Yes | Name of the specific metric to calculate, one of the listed values. Required — search_metrics finds the indicator (and its tool) for a metric by name. | |
| quarterly | No | Return quarterly data instead of annual when True. | |
| scenarios | No | Custom scenarios as {"name": ("start date", "end date")}. | |
| start_date | No | Start of the date range in YYYY-MM-DD format. | 2021-10-28 |
| risk_budget | No | The share of the risk per asset, e.g. {"AAPL": 0.4, "MSFT": 0.2, ...}; it is scaled to sum to one. | |
| show_columns | No | Comma-separated names to filter the output. For historical data use the key names visible in any response record (e.g. 'Close,Volume,Return'). For financial statements use the 'metric' field values from the response (e.g. 'Revenue,Net Income,EBITDA'). Call the tool once without this parameter to see all available names, then repeat with show_columns to reduce response size and token usage. | |
| risk_aversion | No | For get_black_litterman_weights: The risk aversion δ of the market. For get_mean_variance_weights: The investor's risk aversion λ; higher values give less risky portfolios. | |
| target_return | No | The annualized return the portfolio must expect, e.g. 0.12 for 12%. | |
| linkage_method | No | The linkage of the hierarchical clustering: "single", "complete", "average" or "ward". | single |
| market_weights | No | The market weight per asset. | |
| maximum_weight | No | The highest weight an asset may have. | |
| minimum_weight | No | For get_black_litterman_weights, get_efficient_frontier, get_mean_variance_weights, get_minimum_cvar_weights: The lowest weight an asset may have. For get_maximum_sharpe_weights, get_minimum_variance_weights: The lowest weight an asset may have; a negative value allows short positions. | |
| benchmark_ticker | No | Ticker used as the market benchmark, e.g. 'SPY' or '^GSPC'. | SPY |
| confidence_level | No | The confidence level of the CVaR, e.g. 0.95 for the average of the worst 5% of periods. | |
| view_confidences | No | The confidence per view, between 0 and 1. | |
| include_benchmark | No | Whether to include the benchmark as an asset. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |