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

Any way to suppress warnings from CVXPY re: ECOS solver? #565

Closed wayner9 closed 1 year ago

wayner9 commented 1 year ago

What are you trying to do? When using PyPortolioOpt I get the following warning: Python311\site-packages\cvxpy\reductions\solvers\solving_chain.py:336: FutureWarning: Your problem is being solved with the ECOS solver by default. Starting in CVXPY 1.5.0, Clarabel will be used as the default solver instead. To continue using ECOS, specify the ECOS solver explicitly using the ``solver=cp.ECOS`` argument to the ``problem.solve`` method.

What have you tried? I posted in the CVXPY Github issues area and they said to come here. see: https://github.com/cvxpy/cvxpy/issues/2281

I believe that this could be fixed by explicitly using the solver=cp.ECOS argument to the problem.solve method or solver=cp.CLARABEL . But I don't know where you would do this.

phschiele commented 1 year ago

@wayner9 Which optimizer are you using? You should be able to specify the solver when instantiating the optimizer. See this test case here: https://github.com/robertmartin8/PyPortfolioOpt/blob/30ab57147ba61eddc8301294a5b1c5ef260b23fa/tests/test_efficient_frontier.py#L101

wayner9 commented 1 year ago

I am not explicitly specifying an optimizer. Presumably whatever is the default optimizer is what I am using.

I am calling the optimizer with:

ef = EfficientFrontier(mu, S,weight_bounds=bounds)
raw_weights = ef.efficient_risk(vol)

Right now I am just setting up code to pull in my data and run the optimizer so I haven't been too concerned on exactly what Optimizer I am using. Once I get a bit further along I will worry about that more. But it is kind of a pain to get all of these warning lines in my output.

phschiele commented 1 year ago

Just do

ef = EfficientFrontier(mu, S,weight_bounds=bounds, solver="CLARABEL")

and you should be good.

wayner9 commented 1 year ago

Perfect that works!