Machine Learning Solutions in Financial Markets
General Context
The share market and the cryptocurrencies are very popular these days. Every
individual is looking forward to making a dime by investing into them. Often, these
decisions are irrational and made without background knowledge which leads to losing
money. Having no idea about what is happening into a market is harmful for everyone’s
wallet.
Share prices depend on many factors, the market can sometimes look random,
unpredictable and volatile. Not everyone can take advantage of available data about
companies and make profit. Profit is made by pure luck if there is no past study of the
subject or by decisions based on fundamental, technical and sentimental analysis. Often,
documentation about a specific object helps the individual with a more complex view
and decisions based on research will be much more helpful.
Fundamental analysis, also known as financial health of a company, examines
economic and fiscal elements such as the economy status, industry circumstances,
publicly available records like income statements, balance sheets, cash flow,
unemployment and interest rates. With fundamental analysis, an overview will be
gained about how the company is behaving related to the actual market and gives
insights about where the company is going, if it will climb up the ladder or not.
Technical analysis can be used to predict future events that may affect the price of
a share and it involves working with indicators MA (Moving Average), RSI (Relative
Strength Index), Bollinger Bands etc. and also focusing on historical price patterns, stock
trends and trading volume assuming that the history repeats itself. Taking time to
analyze these indicators comes in handy for investors because certain directions of a
stock price or movement can be forecasted, but this kind of analysis takes time to
understand and master. Technical analysis is a tool available in every experienced trader
or investor.
The sentimental analysis is based on human’s emotions, experienced traders will
follow social media channels that provide news for the company where they want to
invest money because that can predict how the price will be affected resulting in an
investment opportunity or not. As a real example from the Bitcoin market, when the
cryptocurrency is having corrections, often, people get scared, and they start to sell
losing previously invested money. This happens to non-experienced traders and
investors that do not follow any technical indicator available.
FOMO (Fear of Missing Out) is one of the biggest enemies for new traders, in this
case, it is the fear of losing an opportunity that others are taking part of. This concept is
mainly infringed by media that provides lots of news about how much a company price
has grown or how much a cryptocurrency is growing and people seeing these news or
ads often hop on the investing train having no knowledge about it making them lose
money.
Machine learning comes in handy helping traders to process big chunks of data in
order to make their investments less risky. The ability to train a computer in doing jobs
that usually take a lot of time is tremendous. As a subset of AI (Artificial Intelligence),
machine learning can provide helpful information based on learned patterns that will
lead to better decision making by humans. There already are multiple tools available for
experienced traders using machine learning that provide technical analysis insights and
investing tips.
That is where the stock price prediction steps in, with the help of a special kind
Recurrent Neural Networks (RNN), LSTMs (Long Short-Term Memory), are trying to
predict the future closing price of a share using historical data about companies listed.
Of course, using just previous prices of a stock will provide a good accuracy for
predictions, not the best one.
LSTMSs are used in this paper because the predictions made are based on long
interval data sets, the network can learn long term dependencies and the network
output depends on previous inputs. Also, LSTMs are special because they do not have
the disappearing gradient problem thanks to their recurrent gate structure. This type of
recurrent neural networks can be powerful depending on the complexity of the
implementation and configuration, higher accuracies of predictions can be provided
with much more data to be trained on.
Objectives
The main objective of this work is to find a solution for predicting the closing price
of a company share with a day or more in the future having a pleasant accuracy.
The prediction will be based on historical closing prices of the company, the preprocessed
data set that being split into training and testing sets, 80% for training and
the rest for testing. The neural network with LSTM, Dropout and Dense layers will be
trained and the results will be validated on the test set. Also, EarlyStopping callbacks
will be used to prevent overtraining of the model. Basically, this will stop the model
training when the loss is not improving.
The trained model will try to make predictions in the future, coming up with a
future closing price of the share. Being based on previous prices, the accuracy might turn
out high but that will be analyzed and explained further later in the paper.
Predictions will be plotted and analyzed accordingly, and the model performance
will be highlighted at the end of the paper.
Specifications
To come up with the solution on forecasting the future price of a share, the entire
historical closing price data set of a company will be taken from Yahoo Finance using
data-reader, converted to array, reshaped and normalized before it will be split into
training and testing sets. Then, the model is built based on a particular case of Recurrent
Neural Networks known as LSTMs, Dropout and Dense layers. Also, EarlyStopping
callbacks will be used to monitor the performance of the model and take actions when
needed. The Dropout layers are used to prevent overfitting while the Dense layer is used
as an output layer. Based on trial and error, the best performing parameters are chosen
for the neural network. As a result, a Sequential model will be available for training,
testing and forecasting.
Next, the training part of the neural network is made with the values included in
the previously made training set. Then, the model will be tested on unseen data available
in the testing sets built earlier.
Being ready to make future predictions, the model uses previous learned patterns
and data in order to forecast future closing prices of company shares.
Because there are studies and articles on stock markets following a random walk
concept, at the end of the paper, a comparison will be made between the model’s
performance trained and tested on the Intel Corporation data set and the same model
trained and tested on a randomly generated data set that mimics historical data of a
fictional company.