diff --git a/cvx/random/rand_cov.py b/cvx/random/rand_cov.py index dadbef1f..783e9408 100644 --- a/cvx/random/rand_cov.py +++ b/cvx/random/rand_cov.py @@ -17,5 +17,8 @@ def rand_cov(n): + """ + Construct a random covariance matrix of size n x n + """ a = np.random.randn(n, n) return np.transpose(a) @ a diff --git a/cvx/risk/bounds.py b/cvx/risk/bounds.py index add18bca..6effe383 100644 --- a/cvx/risk/bounds.py +++ b/cvx/risk/bounds.py @@ -50,16 +50,13 @@ def __post_init__(self): ) def update(self, **kwargs): - # lower = kwargs.get("lower", np.zeros(self.m)) lower = kwargs[self._f("lower")] self.parameter[self._f("lower")].value = np.zeros(self.m) self.parameter[self._f("lower")].value[: len(lower)] = lower - upper = kwargs[self._f("upper")] # .get("upper", np.ones(self.m)) + upper = kwargs[self._f("upper")] self.parameter[self._f("upper")].value = np.zeros(self.m) - self.parameter[self._f("upper")].value[ - : len(upper) - ] = upper # kwargs.get("upper", np.ones(m)) + self.parameter[self._f("upper")].value[: len(upper)] = upper def constraints(self, weights, **kwargs): return [ diff --git a/cvx/risk/cvar/cvar.py b/cvx/risk/cvar/cvar.py index bf087fa5..12d97c32 100644 --- a/cvx/risk/cvar/cvar.py +++ b/cvx/risk/cvar/cvar.py @@ -27,8 +27,13 @@ class CVar(Model): """Conditional value at risk model""" alpha: float = 0.95 + """alpha parameter to determine the size of the tail""" + n: int = 0 + """number of samples""" + m: int = 0 + """number of assets""" def __post_init__(self): self.k = int(self.n * (1 - self.alpha))