performance
Calculate risk-adjusted investment metrics such as Sharpe, Sortino, beta, alpha, CAPM, Treynor, and tracking error for selected tickers, periods, and benchmarks.
Instructions
Pre-computed risk-adjusted performance metrics (Sharpe ratio incl. standard/lo/adjusted/probabilistic/deflated methods, Sortino ratio, Alpha, Jensen's Alpha, Beta, CAPM, Treynor ratio, M2 ratio, Tracking Error, Information Ratio, Fama-French factors, period Returns, Excess Returns — get_beta takes method='blume' (Bloomberg adjusted), 'vasicek', 'dimson' (lags=), 'scholes_williams', 'upside' or 'downside' besides the default 'ols'; Returns/Excess Returns support cumulative=true for the compounded growth of 1 from the start of the date range, so the first value includes the first period's return; returns start from the first close on or after start_date, so for a year-to-date return set start_date to the last trading day of the previous year). Beta, CAPM, Alpha, Jensen's Alpha, Treynor, Sortino, M2, Tracking Error and Information Ratio support rolling=N for a rolling N-period value spanning the full history instead of one value per period (e.g. period='monthly', rolling=6 for a rolling 6-month figure). Sharpe ratios are per observation (e.g. per day within the period) unless annualize=true; method='lo' is Lo's (2002) annualized Sharpe ratio corrected for autocorrelated returns (lags= autocorrelation lags); it needs 30 or more returns per period, so use quarterly or yearly periods or rolling= of 30 or more. get_sharpe_ratio_standard_error (method='iid', 'non_normal' for skewed and fat-tailed returns, or 'gmm' for autocorrelated returns too) is on the per-observation scale. get_minimum_track_record_length is the number of return observations (trading days per period, or periods with rolling=) needed before the Sharpe ratio is significantly above benchmark_sharpe_ratio (0 by default, per observation) at confidence_level (0.95); empty when the Sharpe ratio is not above it. get_coskewness and get_cokurtosis measure how each ticker moves with the squared and cubed moves of the benchmark (method='standardized' or 'residual', Harvey-Siddique). Requires tickers='AAPL' — use comma-separated values for multiple tickers. Supports period='daily' only together with rolling=N (e.g. period='daily', rolling=60 for a rolling 60-day figure); per-period results use weekly, monthly, quarterly, or yearly. get_style_analysis and get_return_statistics also take period='daily' without rolling. get_beta_implied_return splits each period's return into Beta × Benchmark Return (the Implied Return) and the Residual, the asset's own part, with the Beta estimated from the beta_window (252 by default) daily returns before the period; it is daily by default (limit=-1 for the latest day's move) and also takes weekly, monthly, quarterly or yearly. Residual Value is the Residual in money (times the market cap at the previous close, in the ticker's trading currency; empty for ETFs and indices), Residual Percentile the share of earlier residuals that were smaller in size and Residual Largest Since the date of the last residual as large in the same direction ('the largest stock-specific fall since'), so limit=-1 judges the latest move against the whole history from start_date (two or more years back: a year for the Beta and a year of residuals for the Percentile). The factor models (get_fama_and_french_model, get_carhart_four_factor_model, get_factor_asset_correlations, get_factor_correlations) take region='United States' (default), 'Developed', 'Developed ex US', 'Europe', 'Japan', 'Asia Pacific ex Japan' or 'North America' for Ken French's regional factors. get_style_analysis is Sharpe's returns-based style analysis: every ticker gets its weights in the style indices, by default IWD, IWF, IWN, IWO (US large and small cap value and growth), AGG (bonds) and BIL (cash), or those of style_tickers= (e.g. style_tickers='IWF,IWD,AGG'; tickers outside the call are retrieved), with its in-sample R Squared, selection return and tracking error; window= for rolling weights, which adds Sharpe's out-of-sample selection return per period. get_factor_analysis: factor analysis (predictive power) of the performance metrics across tickers: do the tickers that score high on one go on to return more than those that score low? Needs tickers= with at least ten, preferably twenty or more tickers. metrics= a performance metric name, a comma-separated list, or 'all' (the default: returns, excess return, beta, Sharpe, Sortino, Treynor, information ratio, tracking error, Jensen's alpha, Calmar, Omega, win rate); each is measured within every period. Returns a row per metric and horizon: the mean information coefficient (IC, the Spearman rank correlation between the metric and the later returns), its standard deviation, IC information ratio, t-statistic, p-value, share of positive periods, number of periods, the Top Minus Bottom quantile spread, quantile turnover and rank autocorrelation. detail='information_coefficient', 'quantile_returns', 'quantile_turnover' or 'rank_autocorrelation' returns that part per period (or per quantile) for a single metric. period= sets how often it is evaluated (monthly by default), horizons= the periods ahead (e.g. 12 or [1, 12]), quantiles= the number of quantiles (5). Other parameters pass to the metrics. The IC is reported as measured: a negative IC for get_returns is short-term reversal. get_kelly_criterion is the share of capital to risk that maximizes log growth: method='discrete' (default; win rate - loss rate / payoff ratio) or 'continuous' (average excess return / variance), fraction=0.5 for half Kelly; per period, within_period=false over the whole history, or rolling=N. get_return_statistics (daily returns over the whole range by default; within_period=true per year) gives the absolute win rate, average win and loss, payoff ratio, profit factor, expectancy, longest winning and losing streaks, recovery factor and common sense ratio. get_morningstar_risk_adjusted_return (MRAR, the certainty-equivalent return Morningstar ranks funds on, gamma=2) and get_morningstar_risk (Morningstar Return minus MRAR) use monthly total returns in excess of the risk-free rate (risk_free_rate='13w' for the Treasury bill rate Morningstar uses), per calendar year (period='yearly' or 'quarterly'), over the whole range with within_period=false, or rolling=36, 60 or 120 for Morningstar's three, five and ten year figures at every month end.
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": {
"indicator": "<indicator>"
},
"name": "performance"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lag | No | Number of periods to lag when computing growth rates. | |
| lags | No | The number of lags (past periods) the test or model uses, e.g. 1 or 5. Leave unset to use the default of the indicator you selected. Defaults are None for get_sharpe_ratio, get_sharpe_ratio_standard_error; 1 for get_beta. | |
| rank | No | true ranks the tickers (or countries) within every period, from the highest value (rank 1) to the lowest, and compares each with its neighbour toward the middle of the ranking: the Difference (in points for returns) and the Multiple (only when both have the same sign), so the first and last rank show how far the best and the worst stand apart, e.g. a fall more than twice as large as the next one. Needs a value per period and ticker; pick one field with show_columns where there are more. | |
| alpha | No | For get_rachev_ratio: The confidence level used for both tails (e.g. 0.05 for the best/worst 5% of outcomes). For get_starr_ratio: The confidence level used for the CVaR calculation (e.g. 0.05 for the worst 5% of outcomes). | |
| gamma | No | The risk aversion, 0 or higher. | |
| 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, and rows per ticker (an earnings calendar) are selected per ticker. For ETF holdings the largest (or, negative, the smallest) by weight, and for a list (e.g. news or a screener) its length. 0 returns every row. | |
| order | No | The order of the lower partial moment used in the denominator. | |
| column | No | The price column to use, e.g. 'Close' or 'Adj Close'; for get_factor_analysis the output of a metric with several, e.g. 'Signal Line'. | |
| detail | No | get_factor_analysis only: 'information_coefficient', 'quantile_returns', 'quantile_turnover' or 'rank_autocorrelation' returns that part for a single metric instead of the summary. | |
| growth | No | Return period-over-period growth rates instead of absolute values. | |
| method | No | "standardized" or "residual". Leave unset to use the default of the indicator you selected. Defaults are 'standardized' for get_cokurtosis, get_coskewness; 'discrete' for get_kelly_criterion; 'iid' for get_sharpe_ratio_standard_error; 'multi' for get_fama_and_french_model; 'ols' for get_beta; 'standard' for get_sharpe_ratio. | |
| period | No | Observation frequency, e.g. 'daily', 'weekly', 'monthly', 'quarterly', or 'annual' (supported values differ per method). Leave unset to use the default of the indicator you selected. Defaults differ between indicators. | |
| region | No | The region whose factors to use: "United States", "Developed", "Developed ex US", "Europe", "Japan", "Asia Pacific ex Japan" or "North America" (the factors of Ken French's library for that region's stocks). Every region's factors are U.S. dollar returns with the U.S. one-month Treasury bill as... | United States |
| window | No | The number of periods the indicator looks back over, e.g. 14 or 20. | |
| metrics | No | get_factor_analysis only: the metric(s) to analyse, a method name such as 'get_price_to_earnings_ratio', a comma-separated list, or a collection of the tool (see the tool description), e.g. 'profitability'. | all |
| rolling | No | Rolling window size in number of periods. When set, the metric is computed over a smoothly overlapping trailing window across the full history (e.g. period='monthly' and rolling=6 gives a rolling 6-month value) instead of one value per period, or (for economics indicators) a simple moving average used to smooth the raw series. Leave unset to use the default of the indicator you selected. Defaults differ between indicators. | |
| tickers | No | Comma-separated ticker symbols, e.g. 'AAPL,MSFT,GOOGL'. | |
| end_date | No | End of the date range in YYYY-MM-DD format; left empty, today (or the indicator's own window). | |
| fraction | No | The share of the full Kelly bet, e.g. 0.5 for half Kelly. | |
| horizons | No | The number of periods the forward returns cover. | |
| n_trials | No | The number of independent (or effectively independent) strategy variations, parameter combinations, or lookback windows tried before arriving at the reported Sharpe ratio. Only used when method="deflated". Pass this explicitly whenever the actual number of trials is known. | |
| annualize | No | Set to true to annualize a Sharpe ratio (by default it is per observation, e.g. per day, so roughly sqrt(252) smaller than the annualized figure). | |
| 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. | |
| quantiles | No | The number of quantiles the tickers are sorted into per period. | |
| quarterly | No | Return quarterly data instead of annual when True. | |
| adjustment | No | The fixed adjustment added to the Average Drawdown, conventionally 0.1 (10%). | |
| cumulative | No | Return the cumulative value compounded over time instead of the discrete value per period. Always rebased to start at 1 at the beginning of the selected date range. | |
| start_date | No | Start of the date range in YYYY-MM-DD format; left empty, five years before today (or the indicator's own window). | |
| beta_window | No | The number of daily returns the Beta is estimated on. | |
| standardize | No | Return the Z-Score (standard score) instead of the raw values, i.e. how many standard deviations each value is from the mean of its own series. When combined with growth=True, the growth values are standardized instead of the raw values. | |
| 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. | |
| periods_apart | No | The number of periods between the dates the quantile turnover and the rank autocorrelation compare. | |
| style_tickers | No | The tickers of the style indices, as a list or a comma-separated string. | |
| trials_window | No | The window size of the auxiliary rolling Sharpe ratio series that approximates `Var[SR_trials]` and the default `n_trials`. Only used when method="deflated". It counts observations of the returns the Sharpe ratio is computed from: daily (or intraday) observations for the Sharpe ratio per period,... | |
| within_period | No | Whether to calculate the risk of the months within each period or of all months in the range. Leave unset to use the default of the indicator you selected. Defaults are True for get_burke_ratio, get_calmar_ratio, get_gain_to_pain_ratio, get_kelly_criterion, get_morningstar_risk, get_morningstar_risk_adjusted_return, get_omega_ratio, get_rachev_ratio, get_starr_ratio, get_sterling_ratio; False for get_return_statistics. | |
| risk_free_rate | No | The US Treasury yield used as the risk-free rate: '13w' (the 13-week bill), '5y', '10y' (default) or '30y'. | 10y |
| benchmark_ticker | No | Ticker used as the market benchmark, e.g. 'SPY' or '^GSPC'; 'None' for no benchmark. | SPY |
| confidence_level | No | The confidence level. | |
| exclude_risk_free | No | Whether to exclude the risk-free rate from the results. | |
| show_full_results | No | Whether to show the actual and benchmark returns next to the Alpha. | |
| factors_to_calculate | No | Comma-separated factor names to include in the calculation. | |
| benchmark_sharpe_ratio | No | For get_minimum_track_record_length: The benchmark Sharpe ratio SR*, on the scale of one observation (e.g. 1 / SQRT(252) for an annualized benchmark of 1 on daily returns). For get_sharpe_ratio: The hypothesized or benchmark Sharpe ratio (SR*) to test the observed Sharpe ratio against. Only used when method="probabilistic". | |
| include_daily_residuals | No | Whether to also return the pointwise (daily) regression residuals as a second DataFrame. | |
| minimum_acceptable_return | No | The minimum acceptable return (MAR) threshold below which returns are considered downside, e.g. 0.0 for downside relative to a zero return. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |