robertmartin8 / PyPortfolioOpt

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

Optimizing for max sortino #401

Closed cemozerr closed 1 year ago

cemozerr commented 2 years ago

What are you trying to do? I'm trying to optimize for max sortino using PyPortfolioOpt.

What have you tried? I've gone through the EfficientSemivariance docs, but could not find a function to optimize for max sortino.

Is there a simple way to do this?

robertmartin8 commented 2 years ago

Hi @cemozerr,

I'm not sure how one might do that (apart from looping through a range of returns, using efficient_returns, then selecting the max).

Even max sharpe requires a nontrivial variable transformation to make it convex – it's not obvious to me how to do this transformation for Sortino.

Maybe @phschiele has come across some technique for it?

Best, Robert

phschiele commented 2 years ago

This would definitely require some work to get it right using the "exact" formulation of the efficient semivariance. For now, looping over the returns or maximizing the Sharpe ratio using the semi covariance matrix (i.e., Estrada's method) seem like good approaches. Seems like a fun project to dig into the details, though, so perhaps I'll look into it at some point.

brettelliot commented 2 years ago

I like this idea too. I think the use case for the sortino is crypto... the sharpe penalizes big upsides (though im probably butchering that explanation) but thats kinda what some people want outta crypto :)

@phschiele listed two workarounds so ill give at least one of them a try (probably maximizing the Sharpe ratio using the semi covariance matrix).

Thanks!