removed CVaR entirely

This commit is contained in:
robertmartin8
2020-03-16 11:26:56 +00:00
parent eaae099efc
commit d9e93d64e7
8 changed files with 19 additions and 221 deletions

View File

@@ -23,7 +23,6 @@ Currently implemented:
- Sharpe ratio
- L2 regularisation (minimising this reduces nonzero weights)
- Quadratic utility
# - negative CVaR (expected shortfall). Caveat emptor: this is very buggy.
"""
import numpy as np
@@ -151,34 +150,3 @@ def quadratic_utility(w, expected_returns, cov_matrix, risk_aversion, negative=T
utility = mu - 0.5 * risk_aversion * variance
return _objective_value(w, sign * utility)
# def negative_cvar(weights, returns, s=10000, beta=0.95, random_state=None):
# """
# Calculate the negative CVaR. Though we want the "min CVaR portfolio", we
# actually need to maximise the expected return of the worst q% cases, thus
# we need this value to be negative.
# :param weights: asset weights of the portfolio
# :type weights: np.ndarray
# :param returns: asset returns
# :type returns: pd.DataFrame or np.ndarray
# :param s: number of bootstrap draws, defaults to 10000
# :type s: int, optional
# :param beta: "significance level" (i. 1 - q), defaults to 0.95
# :type beta: float, optional
# :param random_state: seed for random sampling, defaults to None
# :type random_state: int, optional
# :return: negative CVaR
# :rtype: float
# """
# import scipy.stats
# np.random.seed(seed=random_state)
# # Calcualte the returns given the weights
# portfolio_returns = (weights * returns).sum(axis=1)
# # Sample from the historical distribution
# dist = scipy.stats.gaussian_kde(portfolio_returns)
# sample = dist.resample(s)
# # Calculate the value at risk
# var = portfolio_returns.quantile(1 - beta)
# # Mean of all losses worse than the value at risk
# return -sample[sample < var].mean()