robertmartin8 / PyPortfolioOpt

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

criteria for "AssertionError: Unexpectedly insufficient funds." may be wrong #383

Closed sourabhvjha closed 2 years ago

sourabhvjha commented 2 years ago

Describe the bug AssertionError: Unexpectedly insufficient funds. is thrown even when cost == available_funds in pypfopt/discrete_allocation.py line 200

Expected behavior AssertionError should be thrown only when cost < available_funds Code sample assert cost < available_funds, "Unexpectedly insufficient funds."

Operating system, python version, PyPortfolioOpt version MacOS 11.6, python 3.7.5, PyPortfolioOpt 1.4.2

sourabhvjha commented 2 years ago

The issue is happening because the sum of weights is > 1