robertmartin8 / PyPortfolioOpt

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

Constraint on position change #452

Closed bruppfab closed 2 years ago

bruppfab commented 2 years ago

What are you trying to do? I am trying to limit the transaction costs by limiting how frequent switches in and out from positions.

Consider the portfolio on t-1 is invested 50% in stock A and 50% in stock B. On T-0 the optimizer would rebalance to 40% in stock A and 60% in stock B. However, I would like to add a constraint, that the positions on T-0 can only be T-1 positions +/-7% on total assets, i.e. both stocks can only be between 43% and 57% on T-0.

Any ideas how to solve this?

robertmartin8 commented 2 years ago

Yup, that's doable. This issue might help!