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

Help with Gross and Net Exposure Constraints #460

Closed codearmo closed 1 year ago

codearmo commented 2 years ago

Hi I am trying to find a way to optimize a long-short portfolio, the aim is to have control over a) the gross exposure b) the net exposure

So let's say I want to have a gross exposure of 150% I have tried: ef.add_constraint(lambda w: cvxpy.sum(cvxpy.abs(w)) <= 1.5)

I am little stuck as to how I could do something like: Target a long allocation of 100% which building on the example above, would mean 50% absolute value of short positions.

Great package and hope you can point me in the right direction.

robertmartin8 commented 1 year ago

As I recall, it's actually quite difficult to add exposure constraints (L1 norms) in the context of portfolio optimisation.

Check out #133 for some ideas