The function `conditional_value_at_risk` in `stats` seems to have two errors. - The way `c_var` is calculated seems to always make it NaN and thus the function always returns `var` - Shouldn't it be `returns[returns > var]` instead of `returns[returns < var]`? Now this might be entirely wrong - I'm just looking at the german wiki https://de.wikipedia.org/wiki/Conditional_Value_at_Risk which states $CVaR_{\alpha }(X)= E [X|X> VaR _{\alpha }(X)]$ citing https://sci-hub.st/https://doi.org/10.1111/1467-9965.00068.
The function
conditional_value_at_riskinstatsseems to have two errors.c_varis calculated seems to always make it NaN and thus the function always returnsvarreturns[returns > var]instead ofreturns[returns < var]? Now this might be entirely wrong - I'm just looking at the german wiki https://de.wikipedia.org/wiki/Conditional_Value_at_Risk which states