Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pypfopt/cla.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ def _solve(self):
self.w[-1][i],
)
if (
self.ls[-1] is None or lam < self.ls[-1]
) and lam > CLA._infnone(l_out):
self.ls[-1] is None or CLA._infnone(lam) < self.ls[-1]
) and CLA._infnone(lam) > CLA._infnone(l_out):
l_out, i_out = lam, i
if (l_in is None or l_in < 0) and (l_out is None or l_out < 0):
# 3) compute minimum variance solution
Expand Down
13 changes: 13 additions & 0 deletions tests/test_cla.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ def test_cla_max_sharpe_short():
assert sharpe > long_only_sharpe


def test_cla_max_sharpe_equal_returns_matches_min_volatility():
mu = np.array([0.1, 0.1])
S = np.array([[0.01, 0.01], [0.01, 0.02]])

cla = CLA(mu, S)
w = cla.max_sharpe()

min_vol_cla = CLA(mu, S)
min_vol_w = min_vol_cla.min_volatility()
assert w == min_vol_w
np.testing.assert_allclose(cla.weights, min_vol_cla.weights)


def test_cla_custom_bounds():
bounds = [(0.01, 0.13), (0.02, 0.11)] * 10
cla = setup_cla(weight_bounds=bounds)
Expand Down