robertmartin8 / PyPortfolioOpt

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

Minimum optimal weight #466

Closed amos-peter closed 1 year ago

amos-peter commented 2 years ago

Hi, could you please check how to set the minimum optimal weight of an asset? For example, if the optimized assets are 90 out of 100. the minimum weight of the 90 assets should be 0.0025.

robertmartin8 commented 2 years ago

Hi, could you clarify what you mean? You can set a minimum weight threshold in the EfficientFrontier constructor, or you can add weight constraints by asset using ef.add_constraint(w[7] >0.00025.

amos-peter commented 2 years ago

Hi Robert. Could you please suggest any way to prevent the optimizer to produce very small weight like 0.001?

robertmartin8 commented 2 years ago

Adding constraints is generally the best way of doing this