robertmartin8 / PyPortfolioOpt

Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
https://pyportfolioopt.readthedocs.io/
MIT License
4.55k stars 957 forks source link

efficient_return raises an unnecessary value error in the long/short case #606

Open jgerlach93 opened 3 weeks ago

jgerlach93 commented 3 weeks ago

Describe the bug when passing a vector of expected returns with possibly negative values, as desired for the long short case, i guess max_return_value is still wrongly computed as the max(expected_returns), but, should be computed as max(weight_bounds[0] neg_expected_returns) and max(weight_bounds[1]) pos_expected_returns) for the differently signed parts of the expected_returns vector

    399 if target_return > self._max_return_value:
--> 400     raise ValueError(
    401         "target_return must be lower than the maximum possible return"
    402     )
    404 update_existing_parameter = self.is_parameter_defined("target_return")
    405 if update_existing_parameter:

ValueError: target_return must be lower than the maximum possible return

Expected behavior A clear and concise description of what you expected to happen.

Code sample Add a minimal reproducible example (see here).

Operating system, python version, PyPortfolioOpt version e.g MacOS 10.146, python 3.7.3, PyPortfolioOpt 1.2.6

Additional context Add any other context about the problem here.