# Understanding Cover's Universal Portfolio Algorithm

I am trying to implement the Universal Portfolio algorithm strategy inspired by the paper by Professor Cover from Stanford.

At the moment I am trying to understand the underlying logic of the algorithm. My goal is to implement the algorithm using 8 ETFs (classified into 3 categories: Equities, Fixed Income and Commodities), to represent the "market".

My understanding is that the strategy, based on historical returns, evaluates every possible portfolio with every possible combination of weights and calculates the return of each.

Then the universal portfolio is the portfolio that is the weighted average of all these possible portfolios, weighted by their performance.

To implement this, here is a summary of my steps:

• Gather 1-year worth (252 trading days) worth of historical prices
• Calculate percentage returns
• At this stage, I would compute the integral of wealth across all portfolios to generate the weight

At this stage, I am a bit lost - How would I derive the weights for each asset for rebalancing the portfolio?

Is there any statight forward shortcut to compute the weights? (For reference, I am planning on implementing this in Python

Thanks :)

Paper for reference:

• Interesting question. Another, related, question is "how much data do you need". I suspect (though I have never seen it discussed) that 1 year is far too little. – Alex C Apr 1 '18 at 22:04
• @AlexC Per my understanding, the algorithm uses the past years data to select the initial asset weights. After that, it periodically rebalanced based on the new price movements. So I think one year's worth of data might be enough for initial set up – Guest Apr 1 '18 at 22:10

The weights can be naive or optimized for some metric or your choosing. If your weighting methodology is arbitrary/naive, then one year of data may be sufficient. The example below in the link uses a 40/40/20 weighting of equity/bond/gold respectively.

However, if you are optimizing for something (Omega, Sortino, Sharpe or any other metric) you probably want to come to the weighting conclusion using far more than one year of data--as hinted at by @AlexC in the comments.

The link below should help out with the Python implementation. The code is not mine and I have not tested the code at all but it is well marked-up, and there is some useful info in the comments below it.

https://www.quantopian.com/posts/universal-portfolios

The "magic" in Cover is the rebalancing effect across all of the multiplicities of all the possible portfolios. At least, assuming, or at least allowing for, infinite time.

In its presented form, take 2 securities and construct 101 portfolios, each containing 0-100% integer proportions of either. AND REBALANCE ALL OF THOSE MINUTELY / HOURLY / DAILY / MONTHLY /WEEKLY / MONTHLY etc. to always hold the same fixed proportion. That's really the "secret sauce". It really is.

To understand the intuition behind this, you need to revisit a couple of vanilla concepts in traditional portfolio maths, and combine them. Move it from the discrete case of an infinite number of infinitely-small portfolios to a continuous curve. That is no different to the Markowitz frontier between the two.

Cover simply proved that, with enough time, with a LOT of time, the rebalancing effect across the curve would end up generating an average return across the curve in excess of the return of the better single asset.

This is neither a simple "mean-reversion" nor a "momentum" effect. Aĺl of your portfolios are mean-reverting; but you're running with their momentum.

The intuition is the arithmetic vs geometric half-variance drag and rebalancing effect. Whatever the two assets's true return, vol, and correlation, the rebalancing portfolios will be biased to having a better risk-reward than their naked equivalent all across the curve. Cover' s insight was proving that letting the winning (rebalancing) portfolios run would, in the end, guarantee performance better than the winning asset. In the (VERY) long-run.

If you don't understand the central anomaly here, ask yourself what is the probability that any market will be X% up before being X% down? If you want to teĺl me it's a 50:50, then the theoretically optimal bet is to stake a quarter of my wealth it's down :-) Yes, that's crazy; but it's not wrong... market doubles or zeroes every day, buy or sell to hold? The same is true to diminished degrees with "fair bets" in general.

Any fair investment, ie zero long-term expected return, therefore has to have a (SMALL) positive expected return in the short-term.

Cover' s "Universal Portfolio" is simply an algorithm that exploits this effect it's "proof" is simply that , with infinite time, the rebalancing gains across the spectrum of weights will end up surpassing the performance differential between the sample assets.

That's the logic (and proven, assuming traditional assumptions with respect to normality hold true).

Best, W

My understanding is that it is effectively a Gibbs distribution over the portfolio actions with temperature 1 and the energy being the portfolio wealth under a given portfolio action. Some folks in ML might think of this as the mean of a softmax distribution.

It is not obvious to me yet why the mean of the distribution and not the mode or the max is the action.

I think this book has something about this in Ch 9 or 10. Something about equivalence in some sense to a mixture prediction https://www.amazon.co.uk/Prediction-Learning-Games-Nicolo-Cesa-Bianchi/dp/0521841089