roll_cvar¶
Defined in fynance.metrics
- roll_cvar(X, alpha=0.05, w=252, method='historical')[source]
Rolling Conditional Value-at-Risk of a price/equity curve.
Causal trailing estimate of
cvar: each output point uses only thewreturns observed up to and including that point, so the output has aw-point NaN head.- Parameters:
- Xarray_like
Time-series of price, performance or index (a single curve), shape
(T,).- alphafloat, optional
Tail probability, in
(0, 1). Default is 0.05.- wint, optional
Size of the trailing window, in number of returns. Default is 252.
- method{‘historical’, ‘gaussian’, ‘cornish_fisher’}, optional
Estimation method, see
cvar. Default is ‘historical’.
- Returns:
- np.ndarray[np.float64, ndim=1] of shape (T,)
Rolling Conditional Value-at-Risk; the first
wvalues are NaN.
See also
cvar,roll_var,roll_mdd
Examples
>>> import numpy as np >>> X = np.array([100., 99., 103., 95., 101., 98., 104., 90., 108., 97., ... 102.]) >>> out = roll_cvar(X, alpha=0.4, w=5, method='historical') >>> np.isnan(out[:5]).all() True >>> round(out[5], 4) 0.0537