Skip to content

Migrate backend to cvxpy #77

Description

@robertmartin8

In general, PyPortfolioOpt receives positive feedback from users, professional and retail alike. The main plus is an intuitive interface that is quite easy to get up and running with.

However, I receive repeated (constructive) criticism on one area in particular – the use the scipy optimiser on the backend. This is a generic nonlinear constrained optimiser – so in theory it should be able to make progress on any combination of objective functions and constraint. The truth is that it doesn't – optimisation is generally a difficult computational problem, and it is easy for the optimiser to get stuck in local minima (see #75 for a reproducible example).

The decision to use a scipy backend, in some ways, was "lazy development" – I hadn't started my undergrad when I first built PyPortfolioOpt and didn't have the technical ability to properly implement convex optimisation "by hand". However, I think I am now intellectually capable of rebuilding the backend properly.

cvxpy is a modelling language for convex optimisation problems – essentially, if you frame your convex opt problem in their language, they provide strong guarantees about the resulting solution. I want to shift the majority of the optimisation from scipy to cvxpy. Scipy will still remain as an alternative if people want to use nonconvex objective functions, but the standard efficient frontier stuff should use cvxpy.

I anticipate that this will result in breaking changes, though I will try to minimise this. I currently like the end-user API of PyPortfolioOpt, even if it was heavily inspired by the scipy optimiser. Note: this will not affect HRP, Black-Litterman, etc.

Happy to discuss this further and receive feedback, since it is quite a major undertaking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions