Skip to content

Fix CLA max_sharpe with equal expected returns#740

Open
anmol0705 wants to merge 1 commit into
PyPortfolio:mainfrom
anmol0705:fix-738-cla-equal-returns
Open

Fix CLA max_sharpe with equal expected returns#740
anmol0705 wants to merge 1 commit into
PyPortfolio:mainfrom
anmol0705:fix-738-cla-equal-returns

Conversation

@anmol0705

Copy link
Copy Markdown

Description

Fixes #738.

This fixes a TypeError in CLA.max_sharpe() when all expected returns are equal.

In this edge case, _compute_lambda() can return None for lam, but _solve() later compares lam against floats. This PR applies the existing CLA._infnone() helper consistently in the lambda comparison path, allowing the algorithm to fall through deterministically to the minimum-volatility solution.

Changes

Validation

  • uv run --extra dev pytest tests/test_cla.py
  • uv run --with ruff ruff check pypfopt/cla.py tests/test_cla.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CLA crashes with TypeError and produces non-deterministic results when expected returns are equal

1 participant