Preliminary Results with the Neural Network Ensemble Continued …

Please see the disclaimer. This blog does not contain investment advice.

This blog post is continuing the discussion on what might be termed ‘stockmarket prediction’ using machine learning / artificial intelligence. More precisely, it is exploring whether pattern recognition and optimisation algorithms can discover strategies that profitably exploit the volatility in share prices. So far – and as discussed in preceding posts – I’ve developed neural-network-based ensemble algorithms that vote each trading day. When a voting threshold is reached during the day, the algorithms simulate trading the stock. Successful strategies should, on average, increase the total number of shares held – and hopefully the total value of the holding – over time. The previous post used the example of a strategy for RIO.

This blog post extends the preliminary results to show some more (partially) successful strategies developed using the same set of input functions and dates for the training and back test periods. As with RIO, trading costs are modelled as 0.5% tax on purchases with £10 trades on an initial £3k investment (I usually ignore spread when dealing with a FTSE100 company). The black chart is the valuation of a buy-and-hold strategy; the coloured charts are for the ensemble strategy at different voting percentages (the second chart is a ratio of total shares held).

Of the companies tested thus far, it seems that the mining sector (and highly correlated) emerging market sector are most likely to achieve a simulated lead over buy-and-hold. This may be partially due to both sectors experiencing heavy losses in share prices over recent past – any strategy that stays in cash at least some of the time on a falling price is likely to beat buy and hold.

First up is the mining company AAL (using the same dates and input function as per RIO). The strategy could be characterised as performing well for the first six months, ok thereafter until about May of last year when the value of the holding collapsed but at a slower rate than the disastrous buy and hold (at the optimal 40% voting).

AAL_20160104

The AAL ratio plot…

AAL_Ratio_20160104

Currently the neural networks train, test and operate without interference. An alternative would be to impose a stop loss model that the neural network has to learn to operate around during training. The danger is that in operation – without the benefit of hindsight – such a stop-loss is as likely to crystallize a loss, missing the subsequent upswing from a temporary downwards spike, as it is to save the strategy from a heavy and sustained losses. Instead I have used the gain or loss since the last trade as in input into the neural network. In this instance, ‘knowing’ that the most recent trade is in heavy loss hasn’t persuaded the ensemble to sell…

Next up are results for BLT (below) – similar comments as for AAL, though losses slightly less extreme, and optimal voting much higher at 55%.

BLT_20160104

The BLT Ratio plot…

BLT_Ratio_20160104

This is the last mining stock modelled from the FTSE 250 this time – VED (below). Only a 40% voting strategy would currently be profitable

VED_20160104

VED ratio plot…

VED_Ratio_20160104

This is a fund manager, ADN (see below). The results are far more sensitive to the voting percentage. Only 55% voting significantly beat buy-and-hold. If the ‘break-out’ of Jul/Aug 2013 could have been detected quickly, using automated monitoring of the voting percentage performances, the 55% voting would still have led to a significant gain over buy and hold.

ADN_20160104

ADN ratio plot…

ADN_Ratio_20160104

Results for ASHM – another fund manager in the emerging markets sector…

ASHM_20160104

ASHM ratio plot…

ASHM_Ratio_20160104

The software has so far proven unsuccessful – with these input functions and dates – in generating strategies that surpass buy and hold to a significant degree for other relatively volatile sectors. I am thinking primarily of the banks, where models have performed very poorly. For example, this is the strategy generated for RBS (still with the same dates and input functions)

RBS_20160104

For some other companies/sectors, the neural networks appear to be performing a random walk, e.g. GSK

GSK_20160104

… or be inconsistent across a sector (e.g. in the oil & gas sector, strategies for BG tend to beat buy and hold; those for RDSB do not).

This disparity in the performance between the different sectors must largely be down to whether the dynamics of the training data persists post training i.e. if we are to beat buy and hold we need the price dynamics – the underlying trends – to continue into the future (or use our judgement on the likely course of the near future to pick the most relevant price history period for training). For example, with the RIO strategy of the previous post: if the share price were to experience a strong recovery, the neural networks trained from 2011 to 2012 are likely to perform poorly; ones trained during the 09-11 might perform significantly better due the strong gains that characterised that period. Detecting this change in trend as it occurs and swapping to different sets of trained networks might be the key to developing a more universally successful solution.