Estimation Uncertainty
Calculate how uncertain the estimates of the expected returns and the covariance matrix are.
Both are estimated again on many simulated histories of the same length, and the spread of those estimates gives a confidence interval for every expected return and covariance and a standard error for every expected return. These are the box uncertainty sets of robust (worst-case) mean-variance optimization.
- The stationary bootstrap of Politis and Romano (1994), blocks of a random length with a geometric distribution of mean block_size, wrapping from the last period to the first.
- The circular block bootstrap: blocks of block_size periods that wrap around.
- The moving block bootstrap: blocks of block_size periods that start where a whole block fits (Künsch, 1989).
- The normal distribution: histories drawn from a multivariate normal distribution with the average returns and the sample covariance.
Block bootstraps keep the dependence between consecutive returns, such as volatility clustering, that drawing single periods would break.
Also known as: bootstrapped expected returns, uncertainty set, estimation error, block bootstrap.
Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_estimation_uncertainty:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "JNJ", "XOM"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.portfolio.get_estimation_uncertainty()
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
How uncertain are the expected returns of Apple, Microsoft, Johnson & Johnson and ExxonMobil estimated from 2021 to 2025?
Which returns:
| Item | Expected Return | Lower | Upper | Standard Error |
|---|---|---|---|---|
| AAPL | 0.1932 | -0.0568 | 0.4194 | 0.1207 |
| MSFT | 0.2017 | -0.0032 | 0.3985 | 0.1045 |
| JNJ | 0.0987 | -0.0518 | 0.2328 | 0.0756 |
| XOM | 0.2911 | 0.0630 | 0.5191 | 0.1179 |
4 rows
Parameters
get_estimation_uncertainty accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
method | str | How the histories are simulated. Options are: “stationary” (stationary bootstrap), “circular” (circular block bootstrap), “moving” (moving block bootstrap), “normal” (multivariate normal draws). Defaults to “stationary”. | "stationary" |
period | str | The frequency of the returns. Options are: “daily” (daily returns), “weekly” (weekly returns), “monthly” (monthly returns), “quarterly” (quarterly returns), “yearly” (yearly returns). Defaults to “daily”. | "weekly" |
n_bootstrap | int | The number of simulated histories. Defaults to 1000 (as skfolio; Riskfolio-Lib draws 6000). | 1000 (as skfolio; Riskfolio-Lib draws 6000) |
block_size | int | The (average) number of periods in a block. Defaults to 3 (as Riskfolio-Lib’s window). | 3 (as Riskfolio-Lib's window) |
confidence_level | float | The confidence level of the bounds, the (1 - c) / 2 and (1 + c) / 2 percentiles of the estimates. Defaults to 0.95. | 0.95 |
seed | int | None | The seed of the random draws, so the result repeats; None draws a new one every time. Defaults to 0. | 42 |
output | str | Options are: “expected_returns” (the Expected Return, Lower, Upper and Standard Error per asset), “covariance” (the Lower and Upper bound of every covariance). Defaults to “expected_returns”. | "expected_returns" |
include_benchmark | bool | Whether to include the benchmark as an asset. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the Toolkit’s rounding. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Paper Politis, D. N. and Romano, J. P. (1994). “The Stationary Bootstrap.” Journal of the American Statistical Association, 89(428), 1303-1313.
- Paper Künsch, H. R. (1989). “The Jackknife and the Bootstrap for General Stationary Observations.” The Annals of Statistics, 17(3), 1217-1241.
- Paper Tütüncü, R. H. and Koenig, M. (2004). “Robust Asset Allocation.” Annals of Operations Research, 132, 157-187.
- Library Shares similar logic as Riskfolio-Lib’s bootstrapping
- Library Shares similar logic as Riskfolio-Lib’s normal_simulation (normal distribution)
- Library Shares similar logic as skfolio’s BootstrapMuUncertaintySet