Back to Community
Request for CVXPY in Quantopian

Can we have this module please? It makes optimization so much easier.

17 responses

Noted! Thanks for the module request, we'll add CVXPY to the request list :)

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thanks Alisa. Do you have an ETA? I want to try something that requires cvxpy and cannot be done (extremely difficult) with cvxopt.

Hello Pravin (correct shortening?),

I have an application for CVXOPT, but it sounds like CVXPY is better. Is it a matter of ease of use, or are there optimizations that just can't be done in CVXOPT, that CVXPY will handle?

I'd like to try the so-called OLMAR algorithm with CVXOPT / CVXPY. The core of the algorithm is the optimization problem set up in Section 4.2 of this paper:

http://arxiv.org/ftp/arxiv/papers/1206/1206.4626.pdf

It minimizes the squared Euclidean distance between a new portfolio allocation and the present one, subject to the inequality constraint that the projected overall return of the portfolio be greater than or equal to a fixed limit. I gather that CVXOPT / CVXPY would be ideally suited, correct?

Grant

Hi Grant,

You got my name correct. It is a matter of use because anything with CVXPY can be done with CVXOPT but requires reformulation and gets very complex. CVXPY makes it so much easier. If you cannot wait, here is problem similar to OLMAR optimization using CVXOPT. The objective function is in similar form.

http://cvxopt.org/examples/book/cvxfit.html

Thanks Pravin,

That's what I thought, regarding CVXPY. Thanks for the example.

Grant

Pravin, your request is in the queue, though it's not on our immediate radar. Currently we're focused on: https://www.quantopian.com/posts/how-to-build-a-stat-arb-strategy-on-quantopian

That being said, when the module is available in the IDE, I'll post back here!

Hi Alisa,

I'm no expert, but I suspect that the class of optimization problems solvable by CVXPY are directly applicable to problems encountered in the domain of building stat-arb strategies. If the objective function can be formulated as quadratic and compatible with the optimizer, then equality and inequality constraints can be applied to optimize returns of a trading basket, for example (I know it applies to long-only strategies, but should generalize to hedged ones). I see that Pravin has also been applying it to screening of securities that mean revert.

Might be worth a head-scratch...

Grant

Thanks Grant. What I am trying to solve is this code from matlab:

cvx_begin quiet  
     variable X(n,n) symmetric  
     variable t(p)  

     minimize sum_square(t)  
     subject to  
        for i=1:p  
             t(i)==trace(A{i}*X)  
        end  
        trace(C*X)>=sigma_threshold  
        trace(X)==1  
        X==semidefinite(n)  
  cvx_end

I have no clue how to convert this into a format that CVXOPT understands. I can do it with CVXPY easily.

That doesn't look like standard MATLAB code. Did you leave out some % signs to indicate comments?

@Grant,

That's syntax of CVX package. Check out http://cvxr.com/cvx/

Pravin

Technically, given time, I could copy the entire source of CVXPY into my algorithm but unfortunately it uses inheritance everywhere and Q does not like it.

Hi all, and sorry for the zombie thread revival. I'm one of the authors of [ECOS][1], one of the mixed integer convex solvers used by cvxpy. I'd be happy to contribute time to make ECOS Quantopian compatible if the underlying solvers are the issues for CVXPY integration.

Any luck with this module. Its been more than a year.

Hi Pravin,

Just curious...do you have a problem that can't be solved with scipy.optimize? It has bounds, equality and inequality constraints? Other bells and whistles. What's missing? Or is it just not efficient enough? Or doesn't converge properly?

Grant

Hi Quantopian,

Can we please please have CVXPY integrated?

+1

What is the timeframe for integrating CVXPY? It would make my life much easier.