Artificial Intelligence

Stochastic portfolio theory, revisited!

P. López

26/07/2017

No Comments

The Stochastic portfolio theory (SPT), a relatively new portfolio management theory, was first introduced in 1999 by Robert Fernholz. It can be combined with Machine Learning and Bayesian statistics. This allows the investor to generate trading strategies. It’s a very attractive theory for several reasons: it’s theoretical, it’s not very well known and, most importantly, it’s cool.

Let’s begin this post with a gentle introduction to the topic.

This theory is all about defining and studying investment strategies from the perspective of stochastic calculus. This branch of mathematics studies the characteristics of stochastic processes. So a good starting point is:

What’s a stochastic process?

A stochastic process, as fancy as it sounds, is just a collection of random variables, usually indexed in a certain way, (frequently, by time). So at each point of time we have a realisation of a random variable. As an example, a geometric Brownian motion is a stochastic process widely used in finance. Under this model, asset returns are a normal random walk. As such, the dynamics of the process can by specified by the following stochastic differential equation:

\( dS = \mu S dt +  \sigma S dX \)

Where \(S\) is the stock price process with mean return \(\mu\) and volatility \(\sigma\).

If we simulate several realisations of this process, we get:

Geometric brownian, stochastic process

As you can see, the results actually look much like what you’d expect in a financial asset in terms of feel-and-look, but of course, these simulations have a lot of differences and limitations in terms of statistical properties (check out this post on Levy flights).

Diversity-weighted portfolios

The SPT theory assumes that stock market capitalisations (or prices, if we assume that the number of outstanding shares is one), follow a general stochastic process that fulfils a set of mathematical conditions.

The theory proposes ways of generating portfolios of these assets (modelled as stochastic processes) and then analyses the characteristics of these theoretical portfolios.

The best example of these portfolios are diversity-weighted portfolios. These portfolios are built by assigning weights according to the following function:

\( \pi_i = \frac{\mu_i^p}{\sum \mu_i^p}\)

Where \(\mu_i(t) := \frac{X_i(t)}{X_1(t) + … + X_n(t)}\) is the capitalisation share of asset i, \(\pi_i\) is the new weight assigned to the asset and \(p\) is a hyper-parameter of the investment function that is crucial for the performance of the strategy.

In layman terms, the diversity-weighted approach (for the case of negative p), assigns weights inversely proportional to market capitalization, overweighting small companies over big ones.

Surprisingly enough, under certain conditions, Fernholz proves that a portfolio built in such a way outperforms the capitalisation-weighted index –wait for it… – with probability one!

As appealing as it might sound, this portfolio just exploits a mix of a mean-reversion operative at the market level, and the effect of the small minus big factor.

All in all, this result is extremely interesting for an investment strategist, and also poses the question of how to solve the inverse problem. That is, of finding general investment functions that match our investment objectives.

The inverse problem

Fortunately enough, Kom Samo and Vervuurt introduce, in a recent paper, a Bayesian approach to learning this kind of functions for stock portfolios using random gaussian processes to model the objective investment strategy.

The idea behind their approach is that, by assigning a specific probability distribution to the results we want to obtain, we can force the distributions of the learnt parameters to meet our investment objective.

This is a very interesting idea that can be generalised without limits! To carry out a small test let’s imagine building a trading strategy over only one series (EURCHF currency cross for this example).

We want to find a function that maps the value of some features (macroeconomic, financial and technical indicators) at a given point in time to the position that should be kept for the next day.

\(X^d \rightarrow f\) with \( f\in [-1, 1] \)

where \(f\) is the daily position of the strategy.

To train that function, a Bayesian neuron with tanh activation function is perfect, because it’s naturally bounded between -1 and 1:

\(f = tanh(\beta ^T \cdot X)\)

We can now set normal priors on the betas and uninformative priors on the means of the betas. The last step to train our investment strategy would be computing our objective investment function from the positions and placing a prior on it.

A good investment objective is the well-known Sharpe Ratio, that with a small modification can be used to try to match some objective performance:

\( SR = \frac{mean – obj}{std} \cdot \sqrt{261} \)

Finally, we place a (very greedy) normal prior distribution over the Sharpe ratio with mean=3, standard deviation=1, using  a 30% annualised return as an objective.

Running 2500 simulations with the pyMC3 package for python, we obtain the following posterior distributions over the variables of our model:

MCMC, bayesian sampling

As we can see, the results aren’t very encouraging at first glance. The uncertainty of the estimations on the \(\beta\) is huge, and the posterior of the objective function (SR) takes negative values!

However, it’s worth noting that our objective was extremely greedy, so there’s still room for some hope.

The results of the learnt strategy

By taking the average of the means of our coefficients (the betas), we can get the cumulative performace of the strategy:

Cumulative performance, in-sample graph

It looks great, but playing in-sample is cheating, so let’s check the out-sample performance:

Cumulative performance, out-sample graph

As usual, out-sample performance of the learnt strategy is worse.

Finally, we can check the robustness of our results. The nice thing about having many sample strategies of our posterior distribution is that we can take a look at the different realisations of the trading function we have learnt:

All insample cumulative performances graph

The realisations of our strategy are quite random, but not very volatile. They have just enough positive bias to light the candle of hope in our little profit-seeking hearts…

0 Comments
Inline Feedbacks
View all comments