Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

I am using quadprog in MATLAB for very simple mean-variance optimization, with less than 100 assets.

It is quite fast but if I run a strategy with daily rebalancing, the execution time can add up very quickly.

Does anyone know any faster solver, particularly in MATLAB?

share|improve this question
    
How long does it take now to optimize? For daily mean-variance rebalancing you shouldn't need more than the standard optimizer I guess, even with 100 assets. In short, define better your problem (the size of your constraint set and the optimizing method you use, ..), we might help you from there already. –  SRKX Sep 27 '12 at 18:52
    
The optimization itself is very simple, just standard mean-variance optimization with standard nonnegativity and full investment constraints. The only problem is that I need to do this daily for say 30 different portfolios each with 100 assets. So it could take hours in aggregate. I have been using quadprog in Matlab with interior-point-convex algorithm. It is very possible that there is nothing I can do to speed it up, but I thought I tried my luck by asking here. –  ezbentley Sep 27 '12 at 19:29
1  
I take it you mean you want to do a backtest that looks over the past n years using 30 different strategies. You might want to look to parallel processing. That tends to work well in this sort of situation. –  John Sep 27 '12 at 19:59
    
I forgot to mention that I was already using parallel processing. I ran the profiler on my code an quadprog is the one taking the most time simply because it gets called so many times. So anything to speed it up will be very valuable. –  ezbentley Sep 27 '12 at 22:06
    
How long does a single mean-variance run take in Matlab on 100 assets? –  Marc Shivers Sep 28 '12 at 2:21
add comment

4 Answers

up vote 6 down vote accepted

I believe there are several ways you can tackle your problems.

First, you mentioned that your perform several optimizations. One solution that comes to mind instead of speeding up the optimization itself is to perform the optimizations in parallel, so you could look at Mathwork's Parallel Computing Toolbox.

Second, providing the optimizer with a good initial guess reduces the execution time, by how much depends on the problem. In this case the optimal weights for the previous day can be such a guess.

Third, if you want to speed up the optimization, you have basically two approaches.

Either you can use the same method but with a package that is implement in a more optimal fashion, and you could look at packages such as NAG's.

Otherwise, you believe that there is another method that would be better at finding a solution. I've seen people use Conic Optimization for this kind of problems and I know that MOSEK have a MATLAB package for that method. You can also have a look at their white paper for more details about this approach.

For more theory on numerical optimizations such as quadratic programming you could take a look at Numerical Optimization by Nocedal and Wright.

share|improve this answer
2  
I don't know whether this applies in this scenario but another idea is seeding the solver with a good initial guess. In this case a good guess could be obtained by using the portfolio weights of the previous day. –  Bob Jansen Sep 28 '12 at 5:31
    
@BobJansen oh yeah I forgot about that, although if it is convex it should quickly converge shouldn't it? –  SRKX Sep 28 '12 at 15:13
add comment

I'd suggest checking out MOSEK, I used it at my last firm (medium frequency stat arb) and I also know it's used at another large hedge fund.

share|improve this answer
add comment

I would suggest Ipopt, it is a very robust quadratic and non-linear solver and has matlab interface:

https://projects.coin-or.org/Ipopt/wiki/MatlabInterface

share|improve this answer
    
I have successfully used Ipopt to minimize cost and tracking error of a basket of stocks replicating an index for our automated arbitrage strategies and highly recommend it as well. –  pavy bez Mar 18 '13 at 12:05
add comment

Pyalogtrade pyalgotrade.optimizer.local module: http://gbeced.github.com/pyalgotrade/docs/v0.9/html/tutorial.html

The main idea is to take advante of Google’s cloud computing services to optimize your strategies, which is specially helpful when you don’t have access to a cluster of computers to optimize your strategies in parallel.

Note that you should run only one server and one or more workers in different computers.

Google App Engine support http://gbeced.github.com/pyalgotrade/docs/v0.9/html/googleappengine.html

Pyalogtrade Down Load Here: http://gbeced.github.com/pyalgotrade/downloads/index.html

Google App Engine SDK for Python https://developers.google.com/appengine/downloads

Related topic: Switching from Matlab to Python for Quant Trading and Research

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.