Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with...

23
IN DEGREE PROJECT COMPUTER ENGINEERING, FIRST CYCLE, 15 CREDITS , STOCKHOLM SWEDEN 2017 Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market Cap has an effect on portfolio performance when trading with Artificial Neural Networks trained on historical stock data LUCIA EDWARDS PATRIK FORSLIND KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND COMMUNICATION

Transcript of Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with...

Page 1: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

IN DEGREE PROJECT COMPUTER ENGINEERING,FIRST CYCLE, 15 CREDITS

, STOCKHOLM SWEDEN 2017

Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap StocksExploring if Market Cap has an effect on portfolio performance when trading with Artificial Neural Networks trained on historical stock data

LUCIA EDWARDS

PATRIK FORSLIND

KTH ROYAL INSTITUTE OF TECHNOLOGYSCHOOL OF COMPUTER SCIENCE AND COMMUNICATION

Page 2: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

Trading with Artificial Neural Networks on

Large-, Mid- and Small-Cap Stocks

Exploring if Market Cap has an e↵ect on portfolio performance when tradingwith Artificial Neural Networks trained on historical stock data

Lucia Edwards and Patrik Forslind

Degree Project in Computer Science, DD143XSupervisor: Jeanette Hellgren Kotaleski

Examiner: Orjan Ekeberg

June 5, 2017

Page 3: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

Abstract

In this report one-day ahead stock prediction using artificial neuralnetworks (ANN) is studied on stocks belonging to di↵erent market caps.Hennes & Mauritz, EnQuest PLC and Rottneros have been selected, rep-resenting large-, mid- and small-cap companies. This report aims to in-vestigate whether a company’s market cap a↵ects the ability to predictstock prices when ANNs are trained using historical stock data.

The study was carried out using feedforward ANNs and trained usingthe Levenberg-Marquardt backpropogation algorithm. The results fromthe study show that the large-cap company H&M was easier to predictthan the mid- and small-cap companies.

Although the results from this study indicate that a company’s marketcap a↵ects the ability to predict stock prices using ANNs, a deeper, moreextensive investigation has to be carried out in order to draw any realconclusions.

Keywords: Artificial neural network, stock prediction, backpropoga-tion, market cap

Page 4: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

Sammanfattning

I den har rapporten studeras endags aktieprognoser med hjalp av arti-ficiella neurala natverk (ANN) pa aktier med olika marknadsvarden. Ak-tierna som har valts ar Hennes & Mauritz, EnQuest PLC och Rottneros,som ar exempel pa foretag tillhorande high-, mid- och low-cap. Syftet medden har rapporten ar att undersoka hurvida ett foretags marknadsvardepaverkar hur val det gar att forutspa aktiepriser nar ANN tranas pa hi-storisk aktiedata.

Studien utfordes med feedforward ANN som tranandes med Levenberg-Marquradt backpropogation algoritm. Resultaten fran studien visar attH&M, som hade hogst marknadsvarde, presterade battre an EnQuest PLCoch Roternos, som hade lagre marknadsvarden.

Trots att resultaten fran denna studie indikerar att ett foretags mark-nadsvarde paverkar formagan att utfora aktieprognoser med ANN sa masteen djupare, mer omfattande undersokning genomforas for att kunna dranagra riktiga slutsatser.

Nyckelord: Artificiella neurala natverk, aktieprognos, backpropoga-tion, marknadsvarde

Page 5: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

Contents

1 Introduction 41.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . 51.2 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 Background 62.1 Stock Market . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.1.1 E�cient Market Hypothesis . . . . . . . . . . . . . . . . . 72.1.2 Seeking Alpha . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2 Artificial Intelligence . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.1 Machine Learning . . . . . . . . . . . . . . . . . . . . . . 82.2.2 Artificial Neural Networks . . . . . . . . . . . . . . . . . . 82.2.3 Learning Algorithm . . . . . . . . . . . . . . . . . . . . . 9

2.3 Stock Forecasting Using ANNs . . . . . . . . . . . . . . . . . . . 102.3.1 Configuration of the Network . . . . . . . . . . . . . . . . 102.3.2 Other Related Work . . . . . . . . . . . . . . . . . . . . . 10

3 Method 113.1 Data Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.2 Artificial Neural Network . . . . . . . . . . . . . . . . . . . . . . 113.3 Performance Measures . . . . . . . . . . . . . . . . . . . . . . . . 123.4 Trading Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4 Results 134.1 Configuring and Training the Networks . . . . . . . . . . . . . . 134.2 Trading Performance . . . . . . . . . . . . . . . . . . . . . . . . . 144.3 Comparison of Performance . . . . . . . . . . . . . . . . . . . . . 15

5 Discussion 16

6 Conclusion 17

References 18

Page 6: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

1 Introduction

The stock market is extremely important for the world’s financial system. Sev-eral driving forces exist behind the stock market, one of the obvious ones isthe strive to make money, both for companies and investors. If you look at thegeneral stock market it always seems to go up over time[20]. There will howeveralways be winners and losers, so picking the right stock is an important task forinvestors.

Automatic trading using computers began as early as the late 1990s and themarket has only evolved from there [15]. How much of all trading that is done bycomputers today is hard to estimate since it is a very secretive world. A reportfrom Morgan Stanley in 2012 stated that 84% of all trades on the US stockexchanges were done by algorithmic trading[23]. The amount of informationavailable to base stock predictions on has been growing in recent years, makingit impossible for people to analyze all the available data before making decisions.The role computers will play in the future of stock trading will only continueto grow. Using various algorithms, it is possible for computers to analyze hugeamounts of data and make trades in an instant [24].

Various approaches have been attempted in recent years using algorithms toforecast the stock market based on available data. Some examples of this areanalyses of the huge information flow in tweets and other social media platforms,used to determine the general sentiment about companies, this type of analysisis called sentimental analysis [4]. It is also possible to apply more traditionalanalyses such as technical and fundamental analyses with the help of computers.

Some machine learning algorithms have been proven to perform particularlywell at predicting how stocks will move. Examples of these are artificial neuralnetworks and support vector machines [11, 26]. But a lot of research still remainsto be done in the field to find the optimal set up for these algorithms.

The use of artificial neural networks to predict stock prices is a well stud-ied field, where many di↵erent approaches have been tried. Some studies havefocused on the algorithms used to train the network and the number of lay-ers while others have focused more on the data used as input to the network.Though no matter the focus, these previous studies have mainly been interestedin stock prediction using stocks from established large-cap companies or marketindices for example S&P 500 or OMXS30 [1, 25]. A less studied area are theriskier, more volatile mid- and small-cap stocks. In theory being able to predictthe short term movements of these stocks could yield greater returns, since theygenerally have more potential to grow[8].

4

Page 7: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

1.1 Problem Statement

In this study large-, mid- and small-cap stocks have been selected and the aimis to investigate if there’s a di↵erence in how well next day closing prices can bepredicted for these stocks when artificial neural networks are used. The questionthis report will aim to answer is therefore:

Is there a di↵erence in portfolio performance when trading on stocks withartificial neural networks trained on historical data of companies from di↵erentmarket caps?

1.2 Scope

This study will be restricted by a number of factors including the access tofinancial data, processing capabilities, prior knowledge and time. Earlier studiesof this type have had access to huge data sets not accessible to the generalpublic. The study has been limited to measuring performance of one stock fromeach market cap. For this reason the study is more exploratory than actuallyproducing definitive results, the aim being simply to give better knowledge andinsight into the emerging challenges in a computer-based financial market andintroduce a topic which could be interesting to research more thoroughly infuture research.

5

Page 8: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

2 Background

The aim of this section is to provide the reader with background information,which will be needed in order to understand the rest of the report. Firstly thefinancial aspects of the study will be presented followed by general informationabout artificial intelligence and machine learning and a deeper description of thealgorithm to be used in the study. Later artificial neural networks (ANN) andhow they can be applied to stock forecasting will be presented. Finally workwhich is related to this report is presented.

2.1 Stock Market

A stock market is a place where companies can let investors trade shares oftheir business in the public domain. The market exists to increase liquidity inthe stock and to open up for anyone to buy or sell shares in companies. Oftencompanies o↵er their stock on these markets as a way of generating more moneyfor the company. Stocks are traded based on the price that people are willingto sell and buy them for. The ask and bid price are what people on the marketwant to sell and buy shares for. When the ask and buy of a stock are matchedthe trade is executed instantly and therefore the supply and demand for a stockis basically what sets the price and valuation of a company publicly quoted.These prices are constantly changing, with no one factor determining what kindof change will occur.

Market Index is often used as a measurement of the movements on themarket as a whole. In Sweden the 30 most traded stocks on the largest SwedishStock Exchange (Nasdaq OMX) have an index called OMXS30. This is oftenused as a benchmark when comparing the performance of your investments.

The companies listed on the stock market are categorized into three groupsbased on their market capitalization (market cap). The value of a company’smarket cap is calculated by multiplying the current market price of the com-pany’s stock with the total number of shares a company has. This value thenplaces each company into one of three categories; large-cap, mid-cap or small-cap companies, which is used instead of sales or asset figures to determine thesize of a company. The market cap value will take other factors into account,such as risk, which is relevant to investors. Large-cap companies tend to bewell known companies that act in large industries and therefore do not carry alot of risk, where profit is seen in the long run. Mid-cap companies are oftenwell known companies which operate in growing industries, they carry higherrisk than large-cap companies but are more likely to give a profit over shorterperiods of time. Small-cap companies are associated with the highest risk, oftenbecause of their age, size and the industry in which they operate. Because ofthese factors small-cap companies are often more susceptible to changes in themarket [6].

Stock dividends and splits are two actions that a↵ect the value of a com-pany’s shares. A stock dividend is when a company pays shareholders in theform of more shares as opposed to a cash payout. This occurs when the com-

6

Page 9: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

pany does not have su�cient funds to pay out in cash or when there are plansto invest [9]. Stock split is when a company divides shareholders existing stocksinto more stocks. This a↵ects the price of the individual share but not the valueof the shareholders shares as a whole [10].

There are several strategies by which to trade on the stock market. Buyingstocks that you think are going to go up and selling them for a profit is probablythe most obvious one. You can also bet against a stock that you think willdecrease in value by taking something called a short position. Shorting a stockis when an investor pays to borrow stocks from a broker to sell it on the openmarket. The aim is to buy it back at a lower price and return it to the brokerhaving made a profit[7].

2.1.1 E�cient Market Hypothesis

The E�cient Market Hypothesis (EMH) states that the market price alwaysreflects all the factors known to the public which makes it impossible to “beat themarket”, unless riskier investments are made. In financial theory the hypothesisis widely debated. In more recent years many critics of the theory have arisen.These critics believe that stock prices can, at least in part, be predicted based onpast patterns and other values and it could therefore be possible to outperformthe market [5, 18].

2.1.2 Seeking Alpha

Alpha is a financial term for a measurement of investments generating returnsthat exceed the market index. Despite the EMH there exist several approachesin trying to forecast stocks and the stock market. Two of the most common waysto value a stock is technical analysis and fundamental analysis. Fundamentalanalysis focuses on financial factors such as a company’s balance sheet, marketpositions, credit value etc. and uses these to make an estimate of the com-pany’s intrinsic value. Technical analysis on the other hand bases its estimatespurely on historical data such as the stock price and di↵erent key indicators.A somewhat less common way of valuing a company or stock is by performinga sentimental analysis. This reflects the sentiment of investors who invest in aspecific company or market.

2.2 Artificial Intelligence

In computer science Artificial Intelligence (AI) is a term which describes thedevelopment of software, where the aim is to simulate human intelligence. Thisincludes, but is not limited to; learning, reasoning, recognition and self improv-ing software. There is no clear definition of what intelligence is and it is notpossible to give a yes or no answer to the question “Is this machine intelli-gent?”[17].

7

Page 10: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

2.2.1 Machine Learning

Machine Learning (ML) is a field within AI focused on constructing algorithmswhich learn based on past experience, i.e that have not been explicitly told howto behave by the programmer. ML is a combination of computer science andstatistics. The ML algorithms learn how to behave based on learning problemswith sample data, through which they can build data models to base futuredecisions on [12].

Within ML there are mainly two types of techniques used when training themodel, supervised and unsupervised learning. In supervised learning the goalis to develop a predictive model based on both input and output data. Whendoing unsupervised training only input data is used and this technique is mostlyused for clustering of data. This paper will focus on supervised learning, morespecifically, regression with Artificial Neural Networks.

2.2.2 Artificial Neural Networks

An artificial neural network (ANN) is an algorithm within machine learningthat simulates the workings of the human brain. The synapses in the braindi↵er largely from the computational methods of a computer and outperformcomputers in many areas, for example pattern recognition and motor control.That is why scientists have been attempting to construct computational modelsof the human brain since the 50’s, in hope that it will advance the field ofmachine learning [13, 19].

A simple reconstruction of the brain consists of billions of neurons that areinterconnected via synapses. An ANN is constructed in a similar fashion andcan easily be represented by a graph, where the nodes represent neurons andedges represent the synapses [13].

The artificial neuron is built up of three essential elements; a number ofinputs, xi , each with a weight, wji, an adder which sums the weighted inputsand an activation function which computes the output, limiting the amplitudeso small changes in input weight only cause small changes in output, giving theartificial neuron the desired functionality. A bias is added to the sum of theweighted inputs, this serves as a threshold value [13, 19].

ANNs can be single or multilayered which, as the names imply, either have asingle layer of neurons or several layers that are interconnected, with the outputsof one layer being the inputs of the next. The layers that are neither the firstinput layer nor the final output layer are called hidden layers. Networks canbe dealt into one of two groups, feedforward or recurrent depending on theirinterconnections. In a feedforward network there are no loops, one layer ofneurons passes input to the next, whereas in a recurrent network there areloops which form circular paths. Although both types serve a purpose, themultilayered, feedforward network is most popular [13].

8

Page 11: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

Figure 1: Neural network with two input nodes, one hidden layer with fournodes and an output layer with two output nodes

2.2.3 Learning Algorithm

Instead of having a programmer explicitly form a model of the real world basedon observations an ANN receives real world data and is able to form its ownmodel. The process through which this model is created is called the networkslearning algorithm. For supervised learning the learning algorithm adjusts theinputs’ weights, wji and bias value, so the network’s output corresponds with thedesired value, i.e. the real world result. Given a set of training data the ANN williteratively grow closer to being a correct model, this process stops when the ANNreaches its stopping criteria. The stopping criteria can be one or a collection ofparameters, for example the number of iterations. In order to iteratively growcloser to the desired result the network sends the calculated error back to thestart of the network, the mean squared error is used to calculate the error inthis study. This form of learning algorithm is called backpropogation and forthis study the Levenberg-Marquardt (LM) algorithm will be used. The LMalgorithm is a combination of the steepest descent (SD) method and the Gauss-Newton (GN) method. Combining these methods results in an algorithm withthe fast calculation ability of the GN method while maintaining the stabilityof the SD method. Given the calculated error the LM algorithm is used tore-adjust the nodes’ weights [13, 27].

During the learning process it is possible for overfitting to occur. Overfit-ting is when the error on the data used to train the network is small but whennew data is introduced it gives a large error. This is due to the network sim-ply memorizing the training data as opposed to actually learning to generalise

9

Page 12: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

from it, as intended. In order to avoid overfitting steps can be taken, smallerdata sets require less advanced functions, which lessens the risk of overfitting,regularisation and early stopping can also be used to avoid overfitting [16].

The ratio between the amounts of data used for training, validation andtesting a↵ects the performance of the network. The training data is used sothe network can update the node weights, validation data is used to determinehow well the network is generalizing and stop training when generalization isno longer improving and the test data is used to measure how well the networkperforms during and after training.

2.3 Stock Forecasting Using ANNs

Many studies similar to the one in this report have been carried out, applyingmachine learning techniques to the stock market has been a popular field ofstudy for the past decades. ANNs can be used to perform a technical analysisof the stock market. Using historical stock data as input it is possible to pick upon trends and predict future stock values. The ability ANNs have to generalizeon nonlinear data makes them an ideal choice to model the volatile stock marketby [22]. Feedforward ANNs are most commonly used when dealing with stockpredictions, with several previous studies finding them to be superior to otherANNs. Backpropagation algorithms have also been shown to outperform otherforms of training where stock predictions are concerned [25]. Market Cap hasbeen Identified as one of the important datapoints for analyzing stock data usingANNs [21].

2.3.1 Configuration of the Network

As mentioned earlier there are multiple ways of configuring ANNs. Choosing thenumber of nodes in the hidden layer(s), selecting the best data points, dividingthe training data and testing data etc are all examples of factors which a↵ectthe network. In earlier research there have been many di↵erent ratios used fortesting and training networks with historical stock data. For this study 70%was used for training, 15% for validation and 15% for testing, which has beenfound to be su�cient in other research about ANNs and stock forecasting[14].

2.3.2 Other Related Work

Some research focuses mainly on the pre-processing of the input data whendoing stock prediction with ANNs. Pre-processing by applying IndependentComponent Analysis (ICA) and Principal Component Analysis (PCA) haveproven to increase prediction performance by reducing noice associated withstock data [3, 2].

Due to limitations mentioned earlier the focus of this report is only to inves-tigate the di↵erence in behaviour when training ANNs on historical stock datafrom di↵erent market caps.

10

Page 13: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

3 Method

This section aims to give the reader a detailed description of how the study wascarried out. Starting with which data was collected and why, how the ANNwas initiated and trained and finally how the performance of the network ismeasured.

3.1 Data Collection

To train the network and simulate the algorithmic trading, historical stock datahad to be collected. It was downloaded from Nasdaq OMX Group’s website.The available data-points were: bid-, ask-, high-, low-, opening-, closing-, mean-, prices and volume, turnover and number of trades on every given date. Thedata was not directly compatible with our program and had to be convertedand pre-processed before imported into our program.

• Reverse the order of the historical data into chronological

• Divide into training data and testing data

• Extract the selected data points for the Network

Due to the exploratory nature of this research a single stock was chosenfrom each of the market cap lists. The stocks chosen for the study were ENQ(EnQuest PLC), HM-B (Hennes & Mauritz), and RROS (Rottneros). Theywere chosen based on the fact that they have not changed market cap listingduring the time span of the collected data. HM-B is a large-cap company, ENQis mid-cap and RROS is a small-cap company. Data was collected for the past7 years, 6 years for training and the final year to simulate trading on.

3.2 Artificial Neural Network

For each of the chosen stocks the ANN was implemented using MATLABs stan-dard library. The networks used were nonlinear autogressive neural networkswith external inputs (NARXNET). The opening, high and low prices were usedas the external inputs and the closing price as the internal input, resulting infour input nodes. Di↵erent configurations were experimented with in regards tothe number of neurons in the hidden layer and number of delays. After exper-imenting with a range of configurations, as will be presented in the results, weused the configuration of 2 delays and one hidden layer with 10 neurons for thenetworks used in the trading simulation. Each network had one output node,the following days closing price.

For this study 70% of the training data was used for training, 15% for valida-tion and 15% for testing. The Levenberg-Marquardt backpropogation algorithmwas used to train the network, which requires more memory than other algo-rithms but is stable and fast.

11

Page 14: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

3.3 Performance Measures

In order to measure the error the mean squared error (MSE) was calculated.MSE is a commonly used metric for determining the error between a givenvalue and an already known expected value. It is calculated by squaring thedi↵erence between the two values and dividing by the number of values to obtainthe average.

MSE =1

n

nX

i=1

(Yi � Yi)2

Where Yi is a vector of predicted values, Yi is a vector of real values and nis the number of predictions done to obtain Yi. A value close to zero representsa small error.

Training was done a number of epochs until the validation using MSE wasno longer improving more than a certain threshold between epochs. In orderto avoid overfitting the network to the training test data the last state of thenetwork, before the MSE dropped below this limit, was then deployed.

3.4 Trading Strategy

Simulation of the algorithmic trading is also done in MATLAB. The tradingstrategy used is to buy and hold the stock as long as the next day closing priceis predicted to be higher than the current day. If the next day closing price ispredicted to be lower a short condition is created and the stock is sold.

In order to make the portfolio’s success rate easier to visualize and compare,an average of the portfolio share values will be plotted against the stock price.When a new position is taken in the portfolio, it will be at a fixed number ofshares at the current trading price.

12

Page 15: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

4 Results

In the section below we present the results from training the networks andoutcome of the simulated trading.

4.1 Configuring and Training the Networks

The configuration of the neural networks was done with 10 neurons in the hiddenlayer and a range of di↵erent delays for the closing price was tested to find thebest configuration. The networks were trained two times with the range of oneto four days of delay to see which configuration had the best performance. Theresults of the di↵erent configurations, MSE and R, are presented in tables 4.1-4.3. MSE is the mean square error of the predicted price in comparison to theactual price and R is the result of the regression analysis.

Table 1: HM-B

Delay MSE R1 15,74756 0,9600672 14,77481 0,9607633 16,60682 0,9557814 17,35213 0,903689

Table 2: ENQ

Delay MSE R1 2,53176e-2 0,9866442 2,34032e-2 0,9873643 2,48115e-2 0,9874794 2,56882e-2 0,977479

Table 3: RROS

Delay MSE R1 2,52088e-2 0,9800472 1,79673e-2 0,9898553 1,96427e-2 0,9779154 2,81028e-2 0,977161

13

Page 16: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

4.2 Trading Performance

Presented below is the performance of the algorithmic trading portfolio in com-parison to the stock.

Figure 2: Hennes & Mauritz

Figure 4.1 shows Hennes Mauritz, which is a large cap company, in compar-ison to the trading algorithm. The graph shows that the algorithm outperformsthe stock but is still very volatile.

Figure 3: EnQuest PLC

Figure 4.2 is EnQuest PLC, a mid-cap company, compared to the portfo-lio and you can see that the algorithm performs poorly in the beginning andmanages to recover somewhat by the end of the year. The overall performanceof the stock is still stronger and the portfolio did not have an alpha over theoriginal stock.

14

Page 17: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

Figure 4: Rottneros

Figure 4.3 shows the performance of the simulated portfolio in comparisonto Rottneros stock, which is a small cap company. Here also the portfolio isoutperformed by the real stock.

4.3 Comparison of Performance

Studying the results shows that the portfolio that performed best was the onetrading on the large-cap stock HM-B. This was the only portfolio never to dropbelow the value of the traded stock. Below we discuss the outcome of the resultsand how it answers our problem statement.

15

Page 18: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

5 Discussion

Arguments can be made that our results indicate that large cap companies areeasier to forecast with ANNs. This should not be considered to be a final answerto our problem statement as there are a number of limitations with this study.

Our results could be caused by a number of other factors ranging fromnetwork performance to data selection. Regarding the historical prices used totrain the models they were adjusted to reflect dividends and eventual splits.This might have had an impact on the performance of the networks. The dataused in the simulation of the trading on the other hand was not adjusted toinclude eventual dividends. Though none of the stocks have had any splitsduring the year of data used for the algorithmic trading simulation. In order totruly measure the di↵erences several stocks would need to be selected from eachmarket-cap, in this study other factors that are not market-cap could be causingthe di↵erence in performance. By using several stocks from each market-cap thee↵ect of these other factors could be reduced.

One of the main research topics connected to this area is focused on reducingthe noise surrounding stock data. This is in order to get better inputs forthe neural network and produce better predictions. Due to the limitations ofknowledge, time and data we had going into this study the outcome of thereport does not conclusively answer the initial problem statement. A few stepsthat can be taken to further investigate this topic is a wider selection of stocksfrom each market cap, better pre-processing of the data and filtering can bedone before feeding it in to the Neural Network. Focusing more on reducing thenoise feeding into the network by for example applying techniques such as ICAor PCA could probably be done to improve the results.

Results from our algorithmic trading show that the network’s predictionswere not accurate enough to give a definitive alpha over the traded stock. Themethod for the simulation of the trading does involve potential measurement er-rors since factors such as buy-ask spread have not been taken into account. Alsothe fact that eventual brokerage fees have not been calculated when simulatingthe portfolio, which would have generated less cumulative returns. Di↵erenttrading strategies could have been tried to find the optimal one for each stock.To reduce noise from the generated trading signal you could apply rules, filteringor some sort of threshold which could make the trading less frequent.

As stated in the introduction this report only seeks to explore the subjectand was never meant to be a comprehensive study. A number of things can beendone to further investigate this topic. Due to the limitations in the proceedingsof this subject we refer from drawing any final conclusions.

16

Page 19: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

6 Conclusion

Regarding the E�cient market hypothesis we can derive that our method cannotbe used to support the hypothesis. We were not able to successfully use availabledata to gain alpha over the underlying stocks from di↵erent market caps. TheEMH already is and, most likely will, continue to be a future topic of furtherresearch.

To decisively answer the problem statement a more comprehensive studywould need to be carried out. As mentioned, a wider selection of stocks andbetter and more simulations would have to be done. Further analyses of theinput parameters feeding into the network could also be done. As mentionedearlier a lot of the research surrounding algorithmic trading and stock forecastingwith neural network is focused on reducing the noise surrounding stock data,which could be done in investigating this question as well.

17

Page 20: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

References

[1] Hedayati Moghaddama Amin, Hedayati Moghaddamb Moein, and Es-fandyaric Morteza. “Stock market index prediction using artificial neuralnetwork”. In: Journal of Economics, Finance and Administrative Science(2016). url: http://www.sciencedirect.com.focus.lib.kth.se/science/article/pii/S2077188616300245/pdfft?md5=1dde0cc01e6149310c0f81f9eb9a574d&

pid=1-s2.0-S2077188616300245-main.pdf (visited on 05/25/2017).

[2] Attila Ce↵er, Janos Levendovszky, and Norbert Fogarasi. “Applying ICAand NARX networks for algorithmic trading”. In: (2016).

[3] Sergey Golovachev. “Forecasting the U.S. Stock Market via Levenberg-Marquardt and Haken Artificial Neural Networks Using ICA&PCA Pre-processing Techniques”. In: Pattern Recognition and Machine Intelligence:4th International Conference, PReMI 2011, Moscow, Russia, June 27 -July 1, 2011. Proceedings. Ed. by Sergei O. Kuznetsov et al. 2011, pp. 351–357. isbn: 978-3-642-21786-9. url: http://dx.doi.org/10.1007/978-3-642-21786-9_57.

[4] Carol Hargreaves and Yi Hao. “Prediction of Stock Performance UsingAnalytical Techniques”. In: Journal of Emerging Technologies in Web In-telligence 5 (2013). url: http://www.jetwi.us/uploadfile/2014/1219/20141219042248163.pdf (visited on 02/15/2017).

[5] Investopedia. E�cient Market Hypothesis - EMH. url: http://www.investopedia.com/terms/e/efficientmarkethypothesis.asp (visitedon 03/02/2017).

[6] Investopedia. Market Capitalization. url: http://www.investopedia.com/terms/m/marketcapitalization.asp (visited on 03/15/2017).

[7] Investopedia. Short (or Short Position). url: http://www.investopedia.com/terms/s/short.asp (visited on 05/30/2017).

[8] Investopedia. Small Cap. url: http://www.investopedia.com/terms/s/small-cap.asp (visited on 05/30/2017).

[9] Investopedia. Stock Dividend. url: http://www.investopedia.com/terms/s/stockdividend.asp (visited on 05/02/2017).

[10] Investopedia. Stock Split. url: http://www.investopedia.com/terms/s/stocksplit.asp (visited on 05/02/2017).

[11] Haomiao Jiang, Shunrong Shen, and Tongda Zhang. Stock Market Fore-casting Using Machine Learning Algorithms. Tech. rep. Stanford Univer-sity, 2012. url: http://web.stanford.edu/

~

hjiang36/projectReports/

CS229.pdf.

[12] M. I. Jordan1 and T. M. Mitchell. “Machine learning: Trends, perspec-tives, and prospects”. In: Science (2015). url: http://science.sciencemag.org.focus.lib.kth.se/content/349/6245/255.full (visited on03/13/2017).

18

Page 21: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

[13] Mehmed Kantardzic. Data mining. Hoboken, New Jersey: John Wiley &Sons, Inc., 2011, pp. 199–234.

[14] Assia Lasfer, Hazim El-Baz, and Imran Zualkernan. “Neural Network de-sign parameters for forecasting financial time series”. In: Modeling, Simu-lation and Applied Optimization (ICMSAO), 2013 5th International Con-ference on. IEEE. 2013, pp. 1–4.

[15] Donald MacKenzie and Juan Pablo Pardo-Guerra. “Insurgent capitalism:Island, bricolage and the re-making of finance”. In: Economy and Society43.2 (2014), pp. 153–182.

[16] MathWorks. Improve Neural Network Generalization and Avoid Overfit-ting. url: https : / / se . mathworks . com / help / nnet / ug / improve -neural-network-generalization-and-avoid-overfitting.html (vis-ited on 05/02/2017).

[17] John McCarthy.What is artificial intelligence? url: http://www-formal.stanford.edu/jmc/whatisai/ (visited on 03/13/2017).

[18] Trevir Nath. “Investing Basics: What Is The E�cient Market Hypothesis,and What Are Its Shortcomings?” In: Nasdaq (2015). url: http://www.nasdaq.com/article/investing-basics-what-is-the-efficient-

market- hypothesis- and- what- are- its- shortcomings- cm530860

(visited on 03/02/2017).

[19] Michael A. Nielsen. Neural Networks and Deep Learning. url: http://neuralnetworksanddeeplearning.com/index.html (visited on 03/05/2017).

[20] Nasdaq OMX Nordic. Historical prices OMXS30. url: http : / / www .nasdaqomxnordic . com / indexes / historical _ prices ? Instrument =

SE0000337842 (visited on 05/12/2017).

[21] Tong-Seng Quah and Bobby Srinivasan. “Improving returns on stock in-vestment through neural network selection”. In: Expert Systems with Ap-plications 17.4 (1999), pp. 295–301. doi: http://dx.doi.org/10.1016/S0957- 4174(99)00041- X. url: http://www.sciencedirect.com/science/article/pii/S095741749900041X.

[22] Jonathan L. Ticknor. “A Bayesian regularized artificial neural network forstock market forecasting”. In: Expert Systems with Applications (2013).url: http://www.sciencedirect.com.focus.lib.kth.se/science/article/pii/S0957417413002509 (visited on 04/03/2017).

[23] Financial Times. ‘Real’ investors eclipsed by fast trading. url: *%20https://www.ft.com/content/da5d033c-8e1c-11e1-bf8f-00144feab49a#

axzz1t4qPww6r (visited on 05/12/2017).

[24] Matt Turner. “The robot revolution is coming for Wall Street traders”.In: Business Insider (2015). url: http://www.businessinsider.com/robots-to-replace-wall-street-traders-2015-8?r=US&IR=T&IR=T

(visited on 03/01/2017).

19

Page 22: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

[25] Chang Sim Vui et al. “A review of stock market prediction with Artificialneural network (ANN)”. In: IEEE International Conference on ControlSystem, Computing and Engineering (2013), pp. 477–482.

[26] Marcin Wasik. “Use of Artificial Neural Networks in Forecasting of Fi-nancial Time Series of High Frequencies with Stock Exchange Quotationsas an Example”. In: Schedae Informaticae (2010). url: http://www.ejournals.eu/sj/index.php/SI/article/view/3001/pdf_37 (visitedon 03/22/2017).

[27] Bogdan M Wilamowski and J David Irwin. Intelligent Systems. Boca Ra-ton, Florida: CRC Press, 2011.

20

Page 23: Trading with Artificial Neural Networks on Large-, Mid ...1114435/FULLTEXT01.pdf · Trading with Artificial Neural Networks on Large-, Mid- and Small-Cap Stocks Exploring if Market

www.kth.se