Page 5 - Fister jr., Iztok, Andrej Brodnik, Matjaž Krnc and Iztok Fister (eds.). StuCoSReC. Proceedings of the 2019 6th Student Computer Science Research Conference. Koper: University of Primorska Press, 2019
P. 5
ine Long Short-Term Memory Network for Stock
Trading

Dušan Fister Timotej Jagricˇ

Univerza v Mariboru, Ekonomsko-poslovna Univerza v Mariboru, Ekonomsko-poslovna
fakulteta, fakulteta,

Razlagova 14, Razlagova 14,
SI-2000 Maribor, Slovenia SI-2000 Maribor, Slovenia

dusan.fister1@um.si timotej.jagric@um.si

ABSTRACT sive trading strategy. LSTMs are found usable in broad ar-
eas, such as sentence classification [2], trajectory prediction
Economic theory teaches that it is impossible to earn higher- of autonomous vehicles [9], flood forecasting [8] and malware
than-normal returns on trading stocks, and that the only detection [15]. Furthermore, LSTM are used in engineering
chance to earn higher profits is to take higher risk. Often, for estimating remaining useful life of systems [17] and in
the practice reveals that higher-than-normal stock returns medicine for automated diagnosis of arrhythmia [11]. The
may indeed be earned, which is a hypothesis we would like structure of the paper is as follows: chapter two outlines
to empirically test. In this way, we design so-called mechan- the fundamentals of LSTM networks. Chapter three lists
ical trading system, which focuses on the technical analysis the information about the dataset and explains methodol-
of past stock data, and perform daily trading for the Ger- ogy. Chapter four shows the experiments and results, while
man stock from period 2010-2019. Long short-term memory chapter five concludes the paper.
network is taken as a basis of the mechanical trading sys-
tem. Obtained results show that higher-than-normal returns 2. LONG SHORT-TERM MEMORY
are easily obtainable, which polemicizes the efficiency of the
observed stock. Long short-term memory networks (LSTMs) are a kind of
artificial neural networks, specifically designed to deal with
Keywords sequential and dynamic data [6]. LSTMs are recurrent neu-
ral networks (RNN) with an agile structure that attempt
LSTM networks, mechanical trading system, stock trading to remember long-term dependencies and prevent both the
usual RNN problems: exploding and vanishing gradients.The
1. INTRODUCTION benefit of the LSTM lies in a memory cell, i.e. central el-
ement of the network, and the three kinds of gates which
Efficient market hypothesis (EMH) states that asset prices control the flow of information. Memory cell accumulates
fully reflect all information available [3] and that asset prices the internal state by supplying the sequences of data. Each
quickly incorporate any new information without delay. Con- gates constitutes of weights, which are adapted during the
sequently, higher-than-normal returns cannot be achieved learning process [5]. Figure 1 shows the structure of the
and predictions of future prices cannot be valuable [10]. usual LSTM. The common LSTM structure consists of the
Stocks strictly follow a random walk (are unpredictable) and
it is impossible to beat the market. Malkiel [10] reports op- FORGET MEMORY CELL OUTPUT
posite opinion, where he states that market inefficiencies and GATE INPUT GATE
arbitrage opportunities to earn higher-than-normal returns GATE
indeed exist. A sample of these includes market bubbles, x tanh
market crashes and other irrational pricing. Pedersen [12] +
even outlines common investment strategies to detect arbi- sigmoid x
trage opportunities. To investigate any market inefficien- x
cies for a case study of Germany, we employ a single-stock
automated mechanical trading system (MTS). As a bench- sigmoid tanh sigmoid
mark, we choose the stock Daimler AG. We implement the
MTS trading strategy using the long short-term memory
network (LSTM) and compare its performance to the pas-

Figure 1: LSTM structure.

forget, input and output gate. Forget gate, which is a sim-
ple sigmoid function, is used to filtrate past information to
be brought into following time step. Input gate, which is
a combination of sigmoid and tanh functions, is used to
enter new information into the memory cell. Output gate,

StuCoSReC Proceedings of the 2019 6th Student Computer Science Research Conference DOI: https://doi.org/10.26493/978-961-7055-82-5.5-8 5
Koper, Slovenia, 10 October
   1   2   3   4   5   6   7   8   9   10