Skip to content

Commit

Permalink
better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tschm committed Dec 18, 2024
1 parent 89e9e0e commit c8b4715
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cvx/random/rand_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 2 additions & 5 deletions cvx/risk/bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
5 changes: 5 additions & 0 deletions cvx/risk/cvar/cvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit c8b4715

Please sign in to comment.