Marginal Value at Risk (mVaR)
Calculate the Marginal Value at Risk (Marginal VaR) of each asset in a portfolio.
Ordinary VaR (see get_value_at_risk) treats each asset in isolation. Marginal VaR instead measures how much the portfolio’s VaR would change for an infinitesimal increase in a given asset’s portfolio weight - i.e. the sensitivity of portfolio risk to each holding, not the risk of the holding on its own:
- Portfolio Return = SUM(weight_i * Return_i)
- Beta_i = Cov(Return_i, Portfolio Return) / Var(Portfolio Return)
- Marginal VaR_i = Beta_i * Portfolio VaR
An asset with Beta_i > 1 contributes disproportionately to portfolio risk, while Beta_i < 1 (and especially Beta_i < 0) indicates a diversifying holding.
For more information about the method, see the following sources:
- Garman, M.B. (1997). “Taking VaR to Pieces.” Risk, 10(10), 70-71.
- Litterman, R. (1996). “Hot Spots and Hedges.” Goldman Sachs Risk Management Series.
- Jorion, P. (2006). “Value at Risk: The New Benchmark for Managing Financial Risk.” 3rd ed., McGraw-Hill, Chapter 7.
Also known as: Marginal VaR, MVaR.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Marginal Value at Risk (mVaR) for you. Just ask in plain English.
Calculate the Marginal Value at Risk (mVaR) in Python
The Marginal Value at Risk (mVaR) is available in the Risk module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_marginal_value_at_risk as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AMZN", "TSLA", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.risk.get_marginal_value_at_risk(weights={"AMZN": 0.5, "TSLA": 0.3, "MSFT": 0.2})
Which returns:
| Marginal VaR | |
|---|---|
| AMZN | -0.0512 |
| TSLA | -0.0698 |
| MSFT | -0.0331 |
Parameters
get_marginal_value_at_risk accepts the following parameters:
- weights (dict[str, float] | None, optional): Portfolio weights keyed by ticker. Normalized internally to sum to 1. Defaults to None, which uses equal weights across every ticker in the Toolkit instance (excluding the “Portfolio” and “Benchmark” pseudo-tickers, if present).
- period (str, optional): The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”.
- column (str, optional): The historical data column to use. Defaults to “Return”.
- alpha (float, optional): The confidence level (e.g., 0.05 for 95% confidence). Defaults to 0.05.
- distribution (str, optional): The distribution to use for the underlying portfolio VaR calculation (historic, gaussian, cornish-fisher or studentt). Defaults to “historic”.
- rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.
Related Risk Metrics
The Risk module page introduces the module, and the sidebar lists all of its functions.