Sensitivity of Portfolio’s Annualized Volatility to Shocks¶
-
perfana.monte_carlo.sensitivity.
sensitivity_vol_m
(cov_or_data, weights, freq=None, shock=0.05, names=None, leveraged=False, distribute=True)[source]¶ Calculates the sensitivity of a shock to the annualized volatility of the portfolio
- Parameters
cov_or_data (
ndarray
) – Monte carlo simulation data or covariance matrix. If simulation cube, this must be 3 dimensional with the axis representing time, trial and asset respectively and frequency will also need to be specified.weights (array_like) – Weights of the portfolio. This must be 1 dimensional and must match the dimension of the data’s last axis.
freq (Frequency) – Frequency of the data. Can either be a string (‘week’, ‘month’, ‘quarter’, ‘semi-annual’, ‘year’) or an integer specifying the number of units per year. Week: 52, Month: 12, Quarter: 4, Semi-annual: 6, Year: 1.
shock (float) – The amount to shock each asset class by. A positive number represents adding to the asset class by proportionately removing from the other asset class. A negative number represents removing from the asset class and adding to the other asset class proportionately.
names (list of str) – Asset class names
leveraged (bool) – If True, asset weights are allowed to go below 0 and above 1. This represents that the asset class can be shorted or levered.
distribute (bool) – If True, asset value changes are distributed proportionately to all other asset classes. See Notes for more information.
- Returns
A series with asset names as the index and annualized volatility as its value
- Return type
Series
Examples
>>> from perfana.datasets import load_cube >>> from perfana.monte_carlo import sensitivity_vol_m >>> data = load_cube()[..., :7] >>> weights = [0.25, 0.18, 0.13, 0.11, 0.24, 0.05, 0.04] >>> freq = 'quarterly' >>> shock = 0.05 # 5% absolute shock >>> sensitivity_vol_m(data, weights, freq, shock) Asset_1 0.113284 Asset_2 0.121786 Asset_3 0.113964 Asset_4 0.109301 Asset_5 0.104626 Asset_6 0.106652 Asset_7 0.106140 Name: vol, dtype: float64