Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Integrating Price Predictions with Portfolio Optimization

I've recently been reading/learning about developing quantitative trading algorithms, and found this platform (and Zipline) to be an awesome place to get started. In my reading, I've seen lots of methods explored for how one would predict price movements for a specific time series - for example many of the example algorithms on this platform are intended to do this, and then implement a simple buy-when-going-up/sell-when-going-down strategy for executing orders. However, I've also learned a bit about portfolio optimization techniques - how to maintain a portfolio that lies on the efficient frontier, maximizing return for a given risk level (or the other way around, same thing). I've seen a few examples for doing this floating around in this forum, but so far haven't seen any good examples for combining these two parts (price prediction of a basket of equities, and portfolio optimization). Is this a standard thing to do in creating trading algorithms? And if so, does someone have an example of this being done? Alternatively a link to a book covering these topics would be awesome also. I can imagine how it would work, and could probably hack something together - but I'd rather use known-good practices if possible.

TLDR: I have a basket of N stocks, and have direction predictions for each. How do I construct an optimal portfolio from these predictions, and then update this portfolio as the predictions are updated?

6 responses

Hello Zack,

When you say "direction predictions" I'm thinking it is a vector of length N, with +1 for a prediction that a given stock will go up, and -1 if it is expected to go down. Or are you also able to predict what the expected return will be (i.e. how much each security will go up/down)?

One way to start thinking about it is that you want to decide how to minimally rotate the portfolio allocation vector in its multidimensional space, subject to one or more constraints. It's a bit mired in mathematical formalism, but this paper gives a formulation (see Section 4.2):

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

It does "price prediction of a basket of equities, and portfolio optimization" and has been explored extensively on Quantopian (do a google search on 'quantopian olmar'). The approach is to make as small of a change (rotation) as possible, while satisfying the constraint of having the expected return be greater than a specified value, based on the assumption of reversion to the mean.

There are numerical solvers available on Quantopian:

http://docs.scipy.org/doc/scipy/reference/optimize.html#module-scipy.optimize
http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
http://cvxopt.org/ (not yet available in the backtester, but working in the research platform)

So, you could look into these to solve your optimization problem, once it is formulated.

Grant

My first stop would be implementing Black-Litterman, with the Idzorek view confidence optimization. But I did it once already in the CQF program so I have it lying around somewhere. :)

@Zack, are you a stat quant like Grant and Simon? Or are you a street quant like me? You can probably get the gist of what a stat quant is from their replies. They understand and follow the math behind quantitative reasoning and algo building. Me? I'm too dense to follow the math so I muddle through with crude facsimiles of algorithms. If you tend to the latter (not saying you're dense like me though) then this might be of help...

Combining portfolio rebalancing with alpha techniques might be though of as a contradiction, that is, if you use reversion portfolio style. When securities are gaining momentum, above the mean, a mean reversion portfolio technique would have you sell them. The exact opposite of what a momentum alpha strategy would have you do. The same goes for the downside; buy the losers in a mean reversion portfolio rather than eliminate them.

If, on the other hand, you prefer the inverted portfolio rebalancing technique of adding winners and trimming losers then you could effectively focus on your alpha algo, ignore your portfolio algo, but trade a best of breed sub-selection of your larger group and achieve the desired combination of techniques. You'd favor the alpha winners, cull the alpha losers, and have both a winning alpha strategy as well as a winning portfolio strategy.

It's also worth pointing out that a lot of the portfolio optimization algorithms are based on the assumption of normality of returns. It's not clear how much portfolio optimization strategies theoretically apply to combining trading strategies.

I also vaguely recall that most of them have trouble beating equal-weight anyway, so I doubt there's a great reason to spend a lot of time on it until you have nothing better to do...?

Simon.

Following Simon's first comment, I'm directing you to Black-Litterman implementaion on Quantopian.
Like Simon, I implemented Black-Litterman in my CQF. I now wonder how Zack would blend his models.
My guess is that he will use BL to build his prior portfolio. Then he will run his model to predict the moves (new views) and re-run BL to find his posterior allocations. After that he will be rebalancing his portfolio until his views change.

I guess it depends if we are talking about optimizing a basket of equities given per-equity predictions from the alpha model, in which case I suspect you'd just take the historical returns and shrunken covariance as your prior, and update using your signal strength as the Idzorek view. If you're trying to allocate fixed capital between various entire strategies, your prior would be the historical returns and shrunken covariance of those strategies, and you'd update with some measure of the strategies' current strength of signal, if there is one.

A trick with this stuff (which I haven't worked through at all) is how to project performance attribution back through to the strategies with fills and slippage of the aggregated orders of the portfolio system?