a mobile application for stock price prediction
TRANSCRIPT
A MOBILE APPLICATION FOR
STOCK PRICE PREDICTION
CHOY YI TOU
A project report submitted in partial fulfilment of the
requirements for the award of Bachelor of Science
(Honours) Software Engineering
Lee Kong Chian Faculty of Engineering and Science
Universiti Tunku Abdul Rahman
April 2021
DECLARATION
I hereby declare that this project report is based on my original work except for
citations and quotations which have been duly acknowledged. I also declare that it
has not been previously and concurrently submitted for any other degree or award at
UTAR or other institutions.
Signature
:
Name : CHOY YI TOU
ID No. : 1701301
Date : 11/4/2021
APPROVAL FOR SUBMISSION
I certify that this project report entitled “A MOBILE APPLICATION FOR
STOCK PRICE PREDICTION” was prepared by CHOY YI TOU has met the
required standard for submission in partial fulfilment of the requirements for the
award of Bachelor of Science (Honours) Software Engineering at Universiti Tunku
Abdul Rahman.
Approved by,
Signature :
Supervisor : Khor Kok Chin
Date : 11/4/2021
Signature :
Co-Supervisor :
Date :
The copyright of this report belongs to the author under the terms of the
copyright Act 1987 as qualified by Intellectual Property Policy of Universiti Tunku
Abdul Rahman. Due acknowledgement shall always be made of the use of any
material contained in, or derived from, this report.
© 2021, Choy Yi Tou. All right reserved.
ACKNOWLEDGEMENTS
I would like to thank everyone who had contributed to the successful completion of
this project. I would like to express my gratitude to my research supervisor, Dr. Khor
Kok Chin for his invaluable advice, guidance and his enormous patience throughout
the development of the research.
In addition, I would also like to express my gratitude to my loving parents
and friends who had helped and given me encouragement during the whole process
of my project development.
ABSTRACT
Investing in stocks’ markets is risky and it needs a lot of research and time to make
the right decision for earning money in stock markets. Novice investors are limited to
specific investment knowledge and lack investment tools to gain wealth in the stocks’
markets. A mobile application for stock price prediction using time series algorithms
is developed to tackle the problem mentioned. There are a few prediction algorithms
being evaluated which were Long Short-Term Memory (LSTM), Holt Winter, Auto-
Regression Integrated Moving Average (ARIMA), Seasonal Auto-Regression
Integrated Moving Average (SARIMA) and Prophet. These prediction algorithms
were evaluated using 6 sectors of Bursa Malaysia stocks which are in total 216
stocks. The evaluation methods were Root Mean Square Error and Mean Absolute
Error. The results show ARIMA has the least error among all five prediction
algorithms. Therefore, ARIMA is the best prediction model to implement in the
mobile application for stock price prediction. The mobile application for stock price
prediction was developed with prototyping methodology. There were three iteration
in this project to develop and enhance the functionality of the mobile application.
Although the mobile application for stock price prediction had been developed, it
contains some limitations like the model is inaccurate for some time and users cannot
set the prediction period. All these limitations can be improved in the future. In
conclusion, this project’s objectives were achieved by developing the mobile
application for stock price prediction using the best time series algorithm evaluated,
which is ARIMA.
vii
TABLE OF CONTENTS
DECLARATION i
APPROVAL FOR SUBMISSION ii
ACKNOWLEDGEMENTS iv
ABSTRACT vi
TABLE OF CONTENTS vii
LIST OF TABLES xi
LIST OF FIGURES xiii
LIST OF SYMBOLS / ABBREVIATIONS xvi
LIST OF APPENDICES xvii
CHAPTER
1 INTRODUCTION 18
1.1 Introduction 18
1.2 Background 18
1.3 Problem Statement 19
1.4 Objectives 20
1.5 Proposed Solution 20
1.6 Proposed Approach 21
1.7 Project Scope 22
2 LITERATURE REVIEW 23
2.1 Introduction 23
2.2 Existing Mobile Applications for Stock Market 23
2.2.1 KLSE Screener (Bursa) 23
2.2.2 StockHunter – KLSE (Bursa) 25
2.2.3 BursaMKTPLC 27
2.2.4 Conclusion 28
viii
2.3 Stock Price Prediction Time Series Algorithms 29
2.4 Evaluation Methods 37
2.5 System Development Methodology 39
2.5.1 Waterfall 39
2.5.2 Rapid Application Development Model 40
2.5.3 Prototype Model 40
2.5.4 Scrum Model 41
2.5.5 Extreme Programming 42
2.5.6 Conclusion 42
3 PROJECT METHODOLOGY 43
3.1 Introduction 43
3.2 System Development Methodology 43
3.3 Project Plan 45
3.3.1 Work Breakdown Structure 45
3.3.2 Project Duration Plan 47
3.3.3 Gantt Chart 49
3.4 Development Tools 50
3.4.1 Fast API 50
3.4.2 React Native 50
3.4.3 JavaScript 50
3.4.4 Python 50
3.4.5 SQLite 50
3.5 Knowledge Discovery Process (KDD) 51
4 PROJECT SPECIFICATION 53
4.1 Introduction 53
4.2 Use Case Modelling 53
4.2.1 Use Case Diagram 53
4.2.2 Use Case Description 53
4.3 System Requirements 61
4.3.1 Functional Requirements 62
4.3.2 Non-Functional Requirements 62
ix
5 SYSTEM DESIGN 63
5.1 Introduction 63
5.2 Software Architecture Design 63
5.3 Database Design 64
5.3.1 Physical Entity Relationship Diagram 64
5.3.2 Logical Entity Relationship Diagram 65
5.3.3 Data Dictionary 65
5.4 User Interface 68
5.4.1 Log In Page 68
5.4.2 Sign Up Page 69
5.4.3 Favourite Page 70
5.4.4 Search Page 70
5.4.5 Sector Page 71
5.4.6 Individual Stock Page 72
5.4.7 Profile Page 74
6 IMPLEMENTATION 76
6.1 Introduction 76
6.2 Selection of Time Series Algorithms 76
6.2.1 Data Collection 76
6.2.2 Data Pre-Processing 76
6.2.3 Evaluate Prediction Algorithms 77
6.3 Implementation of Prediction Model 82
6.4 API Endpoints 84
7 TESTING 86
7.1 Introduction 86
7.2 Unit Testing 86
7.2.1 Sign Up Module 86
7.2.2 Log In Module 88
7.2.3 Favourite Module 88
7.2.4 Search Module 89
7.2.5 Sectors Module 90
x
7.2.6 Individual Stock Module 91
7.2.7 Profile Module 92
7.3 Integration Testing 94
7.3.1 Sign Up and Log In Module 94
7.3.2 Edit Profile and Log In Module 95
7.3.3 Store Favourite Stocks Module 95
7.3.4 Remove Favourite Stocks Module 96
7.4 System Testing 97
8 CONCLUSION AND RECOMMENDATIONS 99
8.1 Introduction 99
8.2 Limitations 99
8.3 Recommendations and Future Works 99
8.4 Conclusion 99
REFERENCES 100
APPENDICES 104
xi
LIST OF TABLES
TABLE TITLE PAGE
2.1 Table for input data, prediction techniques and
results from different papers 29
2.2 Table of results for each parameters and number of
epochs 35
2.3 Table for the model errors of ARIMA, SMA and
Holts Winter 36
3.1 Project Duration Plan 47
4.1 Use case description for creating account 54
4.2 Use case description for login account 55
4.3 Use case description for managing favourite stocks 56
4.4 Use case description for searching stocks 57
4.5 Use case description for extracting historical stock
prices from another stock portal 58
4.6 Use case description for predicting stock prices via
time series algorithms 59
4.7 Use case description for viewing predicted stock
prices 60
4.8 Use case description for viewing charts of
predicted stock prices 61
5.1 Users’ entity data dictionary 65
5.2 Sectors’ entity data dictionary 66
5.3 Stocks’ entity data dictionary 66
5.4 Favourites’ entity data dictionary 67
6.1 Average RMSE and MAE for 5 prediction
algorithms for all stocks 77
xii
6.2 Average RMSE and MAE for 5 prediction
algorithms for Construction sector 78
6.3 Average RMSE and MAE for 5 prediction
algorithms for Technology sector 78
6.4 Average RMSE and MAE for 5 prediction
algorithms for Plantation sector 78
6.5 Average RMSE and MAE for 5 prediction
algorithms for Health Care sector 79
6.6 Average RMSE and MAE for 5 prediction
algorithms for Real Estate Investment Trusts sector 79
6.7 Average RMSE and MAE for 5 prediction
algorithms for Utilities sector 79
6.8 List of FastAPI endpoints 84
6.9 List of FastAPI endpoints (continued) 85
7.1 Unit Test Cases for Sign Up Module 86
7.2 Unit Test Cases for Log In Module 88
7.3 Unit Test Cases for Favourite Module 88
7.4 Unit Test Cases for Favourite Module 89
7.5 Unit Test Cases for Sectors Module 90
7.6 Unit Test Cases for Individual Stock Module 91
7.7 Unit Test Cases for Profile Module 92
7.8 Integration Test Case for Sign Up & Log In 94
7.9 Integration Test Case for Edit Profile and Log In 95
7.10 Integration Test Case for Edit Profile and Log In 95
7.11 Integration Test Case for Edit Profile and Log In 96
7.12 Test Case for System Testing 97
xiii
LIST OF FIGURES
FIGURE TITLE PAGE
1.1 Overview of the proposed solution 21
1.2 System Prototyping 21
2.1 Screenshot of KLSEScreener Application Interface 23
2.2 Screenshot of StockHunter – KLSE (Bursa)
Application Interface 25
2.3 Screenshot of BursaMKTPLC Application
Interface 27
2.4 Prediction error for 10-day prediction of GOOGL
stock 33
2.5 Prediction error for 1-day prediction of GOOGL
stock 33
2.6 Predicted stock prices vs actual stock prices for
LSTM 34
2.7 Predicted stock prices vs actual stock prices for
MLP 35
2.8 Waterfall Model 39
2.9 Rapid Application Development Model 40
2.10 Prototype Model 41
2.11 Scrum Model 41
2.12 Extreme Programming Model 42
3.1 Prototyping Methodology 43
3.2 Project Gantt Chart 49
3.3 Knowledge Discovery Process overview 51
4.1 Use Case Diagram 53
5.1 Software Architecture Design 64
xiv
5.2 Physical entity relationship diagram 64
5.3 Logical entity relationship diagram 65
5.4 User interface for log in page 68
5.5 User interface for log in page when user’s
credentials are incorrect 68
5.6 User interface for sign up page 69
5.7 User interface for sign up page when duplicate
username or email entered 69
5.8 User interface for favourite page 70
5.9 User interface for search page 70
5.10 User interface for search page when keyword is
entered 71
5.11 User interface for sector page 71
5.12 User interface for clicking into sector page 72
5.13 User interface for individual stock page 72
5.14 User interface for individual stock page after
Predict button is clicked 73
5.15 User interface for individual stock page after
Historical Chart button is clicked 73
5.16 User interface for profile page 74
5.17 User interface for profile edit username page 74
5.18 User interface for profile change password page 75
6.1 Graph comparing the actual and predicted stock
prices of ARIMA 80
6.2 Graph comparing the actual and predicted stock
prices of ARIMA 80
6.3 Graph comparing the actual and predicted stock
prices of SARIMA 81
6.4 Graph comparing the actual and predicted stock
prices of Holt Winter 81
xv
6.5 Graph comparing the actual and predicted stock
prices of Prophet 82
6.6 Code for CORS in Python script 83
6.7 Code for acknowledgement of local server port in
mobile application 83
xvi
LIST OF SYMBOLS / ABBREVIATIONS
ANN Artificial Neural Network
ARIMA Auto-Regression Integrated Moving Average
BLSTM Bidirectional Long Short-Term Memory
CNX Credit Rating Information
DY dividend yield
EPS earning per share
FOREX Foreign Exchange Market
GRU Gated Recurrent Unit Networks
KDD Knowledge Discovery Process
LS-SVM Least Squares Support Vector Machine
LSTM Long Short-Term Memory Networks
MAE mean absolute error
MAPE mean absolute percentage error
MLP Multilayer Perceptron Neural Network
NB Naïve Bayes
NIFTY National Stack Exchange Fifty
NTA net tangible assets
P/E price to earnings ratio
PSO Particle Swarm Optimization
RAD Rapid Application Development
RF Random Forest
RMSE root-mean square error
RNN Recurrent Neural Networks
ROE return on equity
SLSTM Stacked Long Short-Term Memory
SMA Simple Moving Average
SVM Support Vector Machine
xvii
LIST OF APPENDICES
Appendix A: User Interface Design Iteration 1 104
18
CHAPTER 1
INTRODUCTION
1.1 Introduction
In the era of technology, people are more exposed to information. Everyone can
access the information they require anytime and anywhere with the help of
technology. It is also applied to the field of investment. People grow their wealth,
generate passive incomes and achieving financial goals through investment by doing
research online to live a decent life after retirement. There are many investment types
in the market such as properties, foreign exchange markets (Forex), bonds, fixed
deposits and others. In this project, the investment type that will be focused on is
stocks.
This chapter explores a brief introduction about the background, problem
statements, objectives, the proposed solution, the proposed approach and the project
scope.
1.2 Background
The process of investing in stock markets is easy and convenient nowadays.
Investors interested in investing in stock markets can open an account and trade
wherever they want as long as they have their mobile smart devices with them.
Technologies have made the investment in stock markets more convenient than
before for investors. There are few ways that investors can earn through investing in
stock markets which are capital gain and dividend. However, investing in stock
markets is risky as investors may lose their money if they did not do proper research.
Stocks investing requires investors to do many planning and analyses to find the right
timing and right stocks to invest in, and it is a time-consuming task.
The prediction of a stock price is one strategy for investors to identify which
stocks to invest. With predicted stock prices, investors will know whether the stock
price will rise or drop in the future. Therefore, stock price prediction is an important
aspect for investors to sort out the possible high return stocks and invest at the right
time.
19
1.3 Problem Statement
i. Mobile application for stock price prediction is less likely to be found in
the market.
According to Böhmer et al. (2011), mobile phones are used to be
communication-only devices but it have developed into multipurpose gadgets
that allow users to accomplish variation of tasks as there is a gradual growth
in the amount of mobile application. There is an increase in the usage of
mobile phones as well as mobile applications. Users can use mobile
applications anytime and anywhere when they are on their mobile phone.
There are many mobile applications for viewing stock prices that can be
found in Google Play store or App store. Some of these applications have the
function of providing buy or sell call using technical analysis to users.
However, mobile applications for stock price prediction are less likely to be
found in the market.
ii. Novice investors invest in stocks without proper investment tools.
To earn massive incomes in stock markets, planning should be carried out
and followed strictly in every single trade in the stock market. Unfortunately,
novice investors tend to invest their money in stock markets by just listening
to the rumours. Some of the investors are investing in the stock market with
emotions. They did not follow a systematic strategy for their investment
which causes them to experience a great loss in the stock market. Therefore, a
proper investment tool is essential to novice investors who wish to earn
passive income from stock markets. A proper investment tool can assist
novice users through their investment journey as it can minimise the losses
made by novice investors.
iii. Investors are limited to specific investment knowledge
The stock picking research and the techniques to find the right time to invest
require much knowledge about investing. Kiyosaki (2000) stated that
financial education is more important than money to help people build their
wealth. Novice investors are limited to investment knowledge as they might
not come from this field of study. On the other hand, investors who are still
working have limited time to learn about the knowledge for investing in the
stock market. Some expert investors realise the power of time series
algorithms which can help them to gain more profit from stock markets.
20
However, they are lack knowledge about the time series algorithms that can
apply in the investment in stock markets.
1.4 Objectives
i. To develop a mobile application for stock price prediction by the end of this
project.
ii. To provide stock price prediction using time series algorithms in the mobile
application.
iii. To select the best time series algorithms for the stock price prediction based
on empirical study.
1.5 Proposed Solution
These problems can be solved by developing a mobile application for stock price
prediction to the investors.
This system can extract the historical prices of the stocks in the Malaysian
market from a stock portal through an API. These data will be used for creating the
necessary charts and performing the prediction. This is because the future stock
prices are predicted based on historical stock prices.
There is a module that enables users to view the predicted price chart of the
stocks they selected. Users can search a particular stock and the application will
generate a predicted price chart. With the help of the visualise charts, users will
better understand the current trend of the particular stock. Thus, they can have better
planning on their investment portfolio.
The main purpose of this system is to provide stock price prediction and time
series algorithms for predicting stock prices. There are lots of time-series algorithms,
such as moving average, autoregression, autoregressive moving average, etc. The
best time-series algorithm will be chosen by comparing the performance of the
algorithms via research. Users can use this system to predict future stock prices using
the best performance among time series algorithms.
21
Figure 1.1: Overview of the proposed solution
1.6 Proposed Approach
The system development methodology proposed to be used in this project is the
prototyping methodology. Figure 1.1 shows the system development workflow in a
project.
Figure 1.2: System Prototyping
Prototyping methodology is focusing on building the system prototypes after
planning, analysis, design and implementation phases. Analysis, design and
implementation phases will be conducted simultaneously to produce the system
prototype. After the first system prototype is released, it will be shown to customers
or users to review and to give some comments to make the system better. Then the
22
analysis, design and implementation phases will be going through again to ensure the
suggestions given by users or customers are fulfilled. The process of rebuilding the
system prototype will be carried out for a few times until the prototype reaches the
satisfaction of users and customers. Then the prototype is implemented into the real
system. The prototyping methodology is a good system development methodology
for this mobile application for stock price prediction as it makes sure the system
implemented will have a reasonable rate of satisfaction among the users.
1.7 Project Scope
The project aims to develop a mobile application for stock price prediction using
time series algorithms. The platform of this system is a mobile platform. The target
users of this system are investors that invest in the Malaysian stock market. The
algorithms for predicting the stock price are time series algorithms only. This system
will help users to predict future stock prices for the stocks that they prefer. This
system can extract the history prices from a stock portal and store them as data.
There is also a module to display charts so that the users have a better view of the
stock prices. Last but not least, there is a stock price prediction module in the system.
23
CHAPTER 2
LITERATURE REVIEW
2.1 Introduction
This chapter discusses the existing mobile applications for stocks markets. The
features and functions of the existing mobile applications for stock markets will be
studied and analysed as some of the features may be implemented in this project.
Furthermore, different time series algorithms are studied to choose a suitable
algorithm for this project using an evaluation matrix.
2.2 Existing Mobile Applications for Stock Market
2.2.1 KLSE Screener (Bursa)
KLSE Screener is a free mobile application which available on both android and iOS
platforms, used by most of the stock investors in the market as it is easy to use for
analysing Malaysia stock market. KLSE Screener provides real-time stock price for
the Malaysian stock market and some popular world indices such as STI, Dow Jones,
Hang Seng Index and others. It has high ratings in android, which is 4.2 and iOS,
which is 4.3 as this means that KLSE Screener is a useful application for its users.
Figure 2.1: Screenshot of KLSEScreener Application Interface
24
Main features
• Searching of stocks
Users can search the stocks in the search module by using the symbol of
stocks, code of stocks and description of stocks.
• Details of stocks
This application shows all the details of stocks to users such as financial
information, historical charts, quarter and annual reports, dividends pay-outs,
capital changes, news related to the stock, the announcement of the company,
discussions regarding the company, company summary and underlying
warrants. With these details, users can analyse the stocks easily.
• Watchlist
Users can store the favourite stocks in some self-created list so that it is
convenient for them to watch the stocks every time. Users can create a few
watchlists with different names to store the stocks according to the categories.
If the particular stock no longer favoured by the users, they can remove it
from their watchlist.
• Screener of stocks and warrants
Users are allowed to filter the stock list shown by giving the maximum and
minimum value of the financial information of stocks such as P/E, ROE, DY,
EPS, NTA and others.
• Stock alerts
This feature is a very important and useful function for the users who are
more to trading stocks. Users can set the stock prices and when the stock
reaches the target prices, the system will send a notification to alert the users.
• Fee’s calculator
The fees of trading stocks can be costly if investors have many trades within
a short time. This feature allows users to calculate the fees by setting
brokerage, clearing fee and stamp duty according to their broker.
KLSE Screener provides a lot of detailed information for the users to do
researches on the stocks that they in favour. However, the researches that needed to
carry out to find quality stocks are time consuming. The weakness of this application
is that it does not have a function that predicts the future stock prices for investors as
25
it aims more to value investors who invest in the stocks that have strong
fundamentals.
2.2.2 StockHunter – KLSE (Bursa)
StockHunter – KLSE (Bursa) is available on android and iOS platforms and it is free
of charge, but it offers in-app purchase to let users upgrade to access more features.
StockHunter application provides Bursa stock prices with 15 minutes delayed and
some indices like Hang Seng, KOSPI, S&P 500 and others. It also shows the prices
for currency and commodity.
Figure 2.2: Screenshot of StockHunter – KLSE (Bursa) Application Interface
Main features
• Hunt
This feature is a module that allows different types of investors to sort the
stocks they like. First, users can customise their filter with StockHunter
analysis, Technical analysis and Fundamental analysis. However, the
fundamental and technical analysis of sorting stocks need to purchase for
membership to access. Other than the custom-made filter, StockHunter has a
few strategy lists for the users to take it as references. The strategy lists
contain Hot, Trend, Growth, Top, Report, Momentum and Sector. Hot is the
26
list containing high volume stocks, while trend consists of bullish up trend
and down trend stocks which categorised by stars. The stocks that increase in
profit are collected in Growth and Top will store the stocks with the highest
profit, dividend, net cash or loss. For Report, the stocks will be separated into
different categories as the report financial month. On the other hand,
Momentum consists of volume up, gap up and high turnover stocks. Lastly,
the stocks are categories into different groups according to their sector, which
stores in the Sector strategy list.
• Searching of stocks
This feature allows users to search for stocks they want using a stock name
and stock code.
• Watchlist
This application allows users to store their favourite stocks on the watchlist
they like. There is a maximum of 10 watchlists that users can use.
• Information about stocks
The information of the stock consists of the chart of the stock with many
indicators that can be applied to the chart. There is also fundamental and
technical financial information provided to the users. Quarterly results of the
stock will be shown but users cannot download the quarter report from the
application. There are news related to the stock, dividend pay-outs, and the
underlying warrant in this feature. The application also allows the users
access to the information of the stock in other financial websites such as
Malaysia Stock Biz, Bloomberg, I3 Financial and others.
StockHunter – KLSE (Bursa) is an application that very useful for traders
who like technical analysis as it contains many indicators that can be applied to price
charts and the information for technical analysis for each stock. However, it does not
provide real-time stock prices but with 15 minutes of delay. This application only
provides investors the strategy to pick the right stocks but does not let the investors
know when is the right time to invest in the stocks.
27
2.2.3 BursaMKTPLC
BursaMKTPLC is an application developed by Bursa Malaysia and is free to use.
BursaMKTPLC provides real-time Malaysia stock prices and data for the users to
make better decision when investing.
Figure 2.3: Screenshot of BursaMKTPLC Application Interface
• Screener of stocks
The screener of stocks allows users to sort the stocks using indicators like
price-earnings, dividend yield and others. However, users cannot customise
the values themselves as the values of the indicators are all set to a certain
range and let the users choose.
• Trading ideas
This feature let users know the rating of the stocks as the ratings are
calculated by Bursa Malaysia. The ratings indicate 10-8 (positive), 7-4
(neutral), 3-1 (negative) and 0/NR (no rating).
• Watchlist
This application allows users to store their favourite stocks on the watchlist
so that it is convenient for them to find the stocks next time.
• Alerts
Users can set the target prices for a stock. When the stock price reaches the
target prices, notifications will be sent to the users to inform them.
28
• Details of stocks
This feature contains the price chart of the stock, financial information, rating
of the stock, and values of balance sheets, income statements and cash flow
statements of quarter and annual reports. The news related to the stock and
the underlying warrants will also be shown to the users.
Users can get many trading ideas from BursaMKTPLC as the rating features
of this application can let users know the quality of stocks easily. Users can sort the
stocks using the rating system in each indicator such as earning, fundamental, value,
risk, etc. Although it provides a rating to let users choose the quality stocks that
suitable for them, users will not know when to invest or dispose the stocks in the
future.
2.2.4 Conclusion
There are lots of applications related to the Malaysian stock market nowadays as the
investment is very important to all people. The applications like those mentioned
above have many features that can aid investors to analyse the Malaysian stock
market and find good stocks to enhance their portfolio so as to earn more passive
income. These applications are easy to use as the menu bars are all on the bottom of
the applications. This is a norm for stock related applications. Hence, this project will
implement some features that can enhance the performance of the applications from
the review above. Since there are time limitations for this project, not all the above-
mentioned applications features will be implemented in this project.
The applications mentioned above do not provide the right timing and right
stock prices for investors to invest. This gives investors trouble to investors as they
need to do more research on the stocks, such as technical analysis and calculating the
intrinsic value of stocks for finding the suitable prices to invest. Hence, stock price
prediction, which is the main study in this project, is important and has to be
implemented to stock application.
29
2.3 Stock Price Prediction Time Series Algorithms
Stock price prediction is a challenging activity that requires analyses. Therefore, this
analysis would be easier for investors if it can analyse the time series data (Obthong
et al., 2020). An interesting variable that is in a temporal or systematic sequence is
called time series (Montgomery, Jennings and Kulahci, 2016). According to
Montgomery, Jennings and Kulahci (2016), time series is usually used for
forecasting and predicting of future data. Hence, time series algorithms will be
studied and analysed in this project.
Table 2.1: Table for input data, prediction techniques and results from different
papers
Author Problem Input Data Prediction
Techniques
Results
Chau et al.
(2019)
Provide
guidance to
retail investors
in stock market
through stock
price prediction
mobile
application. 10-
day and 1-day
stock prices will
be predicted.
S&P 500 stocks
from different
sectors.
Historical stock
prices, daily
percentage
change and
moving
averages with
22, 50, 100 and
200 days are
used.
-Dense Neural
Network
-Simple
Recurrent Neural
Networks
(RNNs)
- Long Short-
Term Memory
Networks
(LSTMs)
-Gated Recurrent
Unit Networks
(GRUs)
Refer to
Figure 2.4
and Figure
2.5
Khare et al.
(2017)
Applying deep
learning in
predicting short
term stock
prices.
10 New York
Stock Exchange
stocks.
Historical
minute stock
prices for all
-Multilayer
Perceptron
Neural Network
(MLP)
-Long Short-
Term Memory
Refer to
Figure 2.6
and Figure
2.7
30
trading days in
1-year period.
Neural Network
(LSTM)
Roondiwala,
Patel and
Varma
(2015)
To seek for best
indicators to
enhance
predicting of
stock prices
using LSTM
Daily historical
stock data which
consists of
opening, high,
low and closing
prices and
volume.
-Long Short-
Term Memory
(LSTM)
Refer to
Table 2.1
Kulkarni,
Jadha and
Dhingra
(2020)
Research on
time series data
analysis for
predicting stock
prices
High, low,
opening and
closing prices
and volume of
monthly stock
data from
January 2009 to
October 2019
retrieved from
Bombay Stock
Exchange
-Auto-Regression
Integrated
Moving Average
(ARIMA)
-Simple Moving
Average
-Holt-Winters
Method
Refer to
Table 2.2
Althelaya,
El-Alfy and
Mohammed
(2018)
Use
multivariate
analysis with
bidirectional
and stacked
LSTM for
forecasting
stock market.
Historical daily
closing stock
prices for S&P
500 stocks
-Multilayer
Perceptron
(MLP)
-Long Short-
Term Memory
(LSTM)
-Bidirectional
Long Short-Term
Memory
(BLSTM)
-Stacked Long
Short-Term
Memory
Error
Percentage:
Short-term:
BLSTM:
0.00947
SLSTM:
0.01248
LSTM:
0.01582
MLP:
0.03875
Long-term:
BLSTM:
31
(SLSTM) 0.06055
SLSTM:
0.06637
LSTM:
0.08371
MLP:
0.09369
Selvin et al.
(2017)
Short, medium
and long term
of predicting
stock prices
NIFTY-IT index
and NIFTY-
Pharma index
with minute
stock prices.
-Long Short-
Term Memory
(LSTM)
-Recurrent
Neural Network
(RNN)
-Convolutional
Neural Network
(CNN)
-Auto-Regression
Integrated
Moving Average
(ARIMA)
Error
Percentage:
CNN: 2.36,
8.96, 3.63
RNN: 3.9,
7.65, 3.83
LSTM:
4.18, 7.82,
3.94
ARIMA:
31.91,
21.16, 36.53
Adebiyi,
Adewumi
and Ayo
(2014)
To differentiate
ARIMA and
Artificial
Neural
Networks on
predicting stock
prices.
Historical daily
stock prices for
Dell index.
-Auto-Regression
Integrated
Moving Average
(ARIMA)
-Artificial Neural
Network (ANN)
Error
Percentage:
ARIMA:
0.608
ANN:
0.8614
Hegazy,
Soliman and
Salam
(2014)
Prediction of
the stock
market using
machine
learning model.
Historical daily
stock prices for
S&P 500 stocks
from different
fields.
-Least Squares
Support Vector
Machine (LS-
SVM)
-Particle Swarm
Optimization
Error
Percentage:
LS-SVM:
0.1147
PSO:
0.7417
32
(PSO)
-Artificial Neural
Network (ANN)
ANN:
1.7212
Roncoroni,
Fusai and
Cummins,
(2015)
Analysis of
different
commodity
markets.
NIFTY 50
stocks with
daily historical
stock prices
-Long Short-
Term Memory
(LSTM)
Error
Percentage:
0.00859
Patel et al.,
(2015)
Use machine
learning models
to forecast the
stock prices.
Daily historical
stock prices of
CNX NIFTY
index and S&P
Bombay Stock
Exchange
Sensex index.
-Artificial Neural
Network (ANN)
-Support Vector
Machine (SVM)
-Random Forest
(RF)
-Naïve Bayes
(NB)
Accuracy
Percentage:
NB: 90.19
RF: 89.98
SVM: 89.33
ANN: 86.69
Chau et al. (2019) conducted research on developing applications for stock
prices prediction by using evolutional optimized machine learning models. The
algorithms tested in their projects were long short-term memory networks (LSTMs),
gated recurrent unit networks (GRUs), simple recurrent neural networks (RNNs) and
dense neural network. This paper consisted of two types of stock prices predictions
which were 10-day and 1-day prediction. The data of the historical stock prices was
trained with the models above and the mean squared error was calculated. Two
models were selected and the better performed model was taken as the parent and
another one was removed. The parent model was mutated to come out with a new
network and trained it again. The process was repeated for a number of iterations set
by them. This evolution algorithm can optimise the hyperparameter search. In terms
of accuracy, the prediction errors were higher in the 10-day predict than the 1-day
predict, but the errors were increasing from time to time in the 1-day predict. In this
project, this method will not be implemented because there is time limitation and the
evolution algorithm is a complicated and time-consuming method as it requires few
members to conduct each part.
33
Figure 2.4: Prediction error for 10-day prediction of GOOGL stock
(Chau et al., 2019)
Figure 2.5: Prediction error for 1-day prediction of GOOGL stock
(Chau et al., 2019)
Another research that was done by Kumar et al. (2018) included five models
which using Random Forest, Naïve Bayes, Softmax, Support Vector Machine and K-
Nearest Neighbor. In this paper, features were extracted at first followed by training
and testing of the data set. Lastly, the results of the prediction were obtained to find
the best models. Kumar et al. (2018) reported that Random Forest had the most
accurate results in the large data set, while Naïve Bayes had the best performance in
accuracy for small datasets. This research was conducted for supervised
classification models that predicted the trend of the stock market, so it will not be
34
implemented in this project as it is not suitable for this project predicting the prices
of the stocks using time series data.
Khare et al. (2017) stated that they implemented a long short-term memory
model and a feed-forward multilayer perceptron model for predicting short term
stock prices. The multilayer perceptron model received the data a few times to
decrease the errors by altering the weights until a number of epochs were hit. Based
on Cheng, Dong and Lapata (2016), long short-term memory model adds latest data
into a memory slot gradually, and it is controlled by a gate as it will remove the
outdated data, store the latest data and show the current data. From the research
conducted by Khare et al. (2017), the long short-term memory model can predict the
stock price trend accurately, but the accuracy of predicting exact stock prices was
higher in the multilayer perceptron model. The evaluation metric to analyse the
performance of these two models was Root Mean Square Error (RMSE). The result
showed that multilayer perceptron gave less error than long short-term memory.
Although the long short-term memory model was not accurate as compared with the
multilayer perceptron model in predicting stock prices, both of the results were in the
same trend as the actual stock prices. The results can be seen in the figure below.
Hence, both of these models are suitable in predicting time series stock price data so
they will be taken into consideration to implement in this project.
Figure 2.6: Predicted stock prices vs actual stock prices for LSTM
(Khare et al., 2017)
35
Figure 2.7: Predicted stock prices vs actual stock prices for MLP
(Khare et al., 2017)
Another research that proposed long short-term memory (LSTM) model was
done by Roondiwala, Patel and Varma (2015) which used LSTM and recurrent
neural network (RNN) algorithms to build the model for predicting future stock
prices. Data preprocessing was gone through for the raw data taken from
https://www.quandl.com/data/NSE so that the data can be used to predict the results.
This paper also proposed that the data was used to train and test the models.
According to Roondiwala, Patel and Varma (2015), this paper analysed the
performance of the results using Root Mean Square Error (RMSE) which compared
the results of different parameters and number of epochs. The table below shows the
results for each parameter and the number of epochs.
Table 2.2: Table of results for each parameters and number of epochs
Parameters No. of Epochs Training RMSE Testing RMSE
Open/Close 250 0.01491 0.01358
Open/Close 500 0.01027 0.00918
High/Low/Close 250 0.01511 0.014
High/Low/Close 500 0.01133 0.01059
High/Low/Open/Close 250 0.0133 0.01236
High/Low/Open/Close 500 0.00983 0.00859
(Roondiwala, Patel and Varma, 2015)
36
From the table above, it is obvious that the model with High/Low/Open/Close
and 500 epochs had the best performance among others as it had the lowest value of
RMSE for both train and test predictions. Therefore, with such a low value of RMSE,
long short-term memory and recurrent neural network can provide an accurate result
of prediction future stock prices so this model may be implemented in this project.
Based on Kulkarni, Jadha and Dhingra (2020), a few time series algorithms
were used to build the model to predict the future stock prices based on 10 years of
historical data of the Bombay Stock Exchange. These algorithms were Auto-
Regression Integrated Moving Average (ARIMA), Simple Moving Average (SMA)
and Holt-Winters Method. The parameters of the data used by Kulkarni, Jadha and
Dhingra (2020) in this research are similar to the research conducted by Roondiwala,
Patel and Varma (2015) which are high, low, open, close and another parameter
which is volume. The predicted prices were used to plot a graph used to compare
with the actual stock prices graph. The performances of these three algorithms on
predicting the future stock prices were evaluated using RMSE, MAE and MAPE,
which can be seen from the table below.
Table 2.3: Table for the model errors of ARIMA, SMA and Holts Winter
Model Name/ Metrics RMSE MAE MAPE
ARIMA (training error) 1.101809 0.6353445 8.313343
ARIMA (test error) 1.320584 1.2807830 11.601874
SMA (training error) 0.4874397 0.2748435 3.675369
SMA (test error) 1.2990895 1.2641892 11.456808
Holts Winter (training
error)
1.106470 0.6419695 8.792462
Holts Winter (test error) 1.319503 1.2796688 11.591707
(Kulkarni, Jadha and Dhingra, 2020)
The results of this research can be seen clearly from the table above, which
SMA had the best performance among the others as it contained the lowest errors in
three of the evaluation methods. Other than SMA, Holts Winter obtained better
results than ARIMA, which had the highest value of errors in test error.
37
The time series algorithms mentioned above, such as Auto-Regression
Integrated Moving Average, which is ARIMA, Long Short-Term Memory (LSTM),
Recurrent Neural Network (RNN) and Multilayer Perceptron (MLP) can be used for
the data type of time series as well as financial time series. All these algorithms can
be used for forecasting related to the project conducted by Obthong et al. (2020).
However, all these algorithms have their advantages and disadvantages. For the
ARIMA algorithm, the pattern found on one series often does not suit another series,
so the trends or processes found in the data as a whole cannot be established (Selvin
et al., 2017). However, Obthong et al. (2020) reported that ARIMA provides more
stable and systematic predictions for short term data. According to Kumar, Goomer
and Singh (2018), LSTM is considered as a subset of RNN that can help RNN, which
is problematic in building model (Obthong et al., 2020) to overcome the problem of
slowed learning because of the gap between the different networks in the loop.
LSTM is also better than other algorithms in storing the data for a long period
(Kumar, Goomer and Singh, 2018). Although MLP provides accurate results for
difficult problems in predictions, the connection of MLP is dragging and it is
difficult to set the range (Pradeepkumar and Ravi, 2017). In the paper written by
Svetunkov and Petropoulos (2018), the Simple Moving Average algorithm is mainly
used in projects as it is easy to understand due to its simplicity. But it also has the
disadvantage of setting the sequence of the moving average first before applying the
algorithm.
In conclusion, getting suitable algorithms for a problem requires much effort
as it is difficult to identify the best algorithm for a particular problem. Therefore,
after reviewing the research mentioned above, this project evaluated Long Short-
Term Memory, Holt Winter, Auto-Regression Integrated Moving Average, Seasonal
Auto-Regression Integrated Moving Average and Prophet to find the best among
them for predicting future stock prices. This is because these algorithms are
frequently used in predicting financial time series problems, and they also have good
performance compared to other algorithms.
2.4 Evaluation Methods
According to Kulkarni, Jadha and Dhingra (2020), mean absolute error (MAE) and
root mean square error (RMSE) are used as evaluation metrics for analysing the
performance of the prediction models. Chai and Draxler (2014) also stated that both
38
MAE and RMSE are widely used for evaluating purposes, but there is no conclusion
stated that one of these methods is the best method to evaluate the prediction model.
When it comes to calculating average error using nature measure, MAE is more
unambiguous compared to RMSE as calculating MAE is not complicated (Chai and
Draxler, 2014). Therefore, some research prefered MAE rather than RMSE as the
evaluation metric. On the other hand, MAE provides all errors with the same weight
but RMSE penalises variance because RMSE provides more weight to errors with
greater absolute values than to the errors with low absolute values.
Based on Roondiwala, Patel and Varma (2015), Root Mean Square Error
(RMSE) was used to analyse and compare the models in their research. RMSE can
be used to reduce the error between the actual results and the value of the output
acquired from the models (Roondiwala, Patel and Varma, 2015). Wang and Lu (2018)
stated that RMSE is the evaluation metric that commonly used by many systems for
calculating the errors between predicted values and actual values, such as SVD
model, Recommending Based on Rating Frequencies and Slope One. Rahman et al.
(2019) who did the stock market prediction using Gated Recurrent Units research
stated that the model they used was regression model which normally uses Root
Mean Square Error to assess the performance of the models. From all the research
mentioned above, it can be clearly seen that the evaluation method to monitor the
stock prices prediction models’ performance is mainly Root Mean Square Error.
Hence, the evaluation method that will be implemented in this project to analyse the
accuracy of results of the models bulit will be Root Mean Square Error. The formula
of RMSE is as below:
RMSE = √∑(�̂�𝑖 − 𝑦𝑖)²
𝑛
𝑛
𝑖=1
where
ŷ = predicted values,
y = observed values,
n = number of observation.
39
The formula of MAE is as below:
𝑀𝐴𝐸 =∑ |𝑦𝑖 − 𝑥𝑖|𝑛
𝑖=1
𝑛
where
y = predicted values,
x = observed values,
n = total number of data points
2.5 System Development Methodology
Developing a system requires involves not only code writing but also many other
activities such as requirement gathering, document writing, testing and others.
System development is not an easy task as all the activities have to be done in a well-
planned manner. Hence, the development methodologies are guidelines or blueprint
to develop the system effectively and efficiently.
2.5.1 Waterfall
The most traditional development methodology is the waterfall model which is
developing the system through orderly manner processes (Chowdhury et al., 2018).
In the waterfall model, the development life cycle will go through phase by phase as
the development team has to complete a phase before going to the next. Basesd on
Iyawa, Herselman and Coleman (2016), the costs required in developing a system
through the waterfall model is high as well as the level of dissatisfaction of the
customers. On the other hand, the model required much time compared to other
models as the development team needs to ensure the quality of deliverables in each
phase before moving on to the next phase.
Figure 2.8: Waterfall Model
(Eason, 2016)
40
2.5.2 Rapid Application Development Model
Fatimah, Supriatna and Kurniawati (2018) reported that Rapid Application
Development Model (RAD) is a model that focuses on the development cycle which
is in a short period. Chowdhury et al. (2018) claimed that customers and users will
have high participation throughout the stages in the RAD model as this model is
adapted to the modifications in requirements. Since customers will highly participate
in developing the application in the RAD model, the time limitations may be affected
as this model is focusing on a short period in each iteration (Iyawa, Herselman and
Coleman, 2016).
Figure 2.9: Rapid Application Development Model
(Chowdhury et al., 2018)
2.5.3 Prototype Model
The prototype model requires the involvement of users or clients in the early phases,
such as the requirement gathering phase and design phase, as this can help to develop
the best design before implementation. Based on Chandra (2015), the prototype
model is suitable for projects with unclear requirements as clients can add the
requirements during the design phase. Since the prototype model will keep building
the prototype until the prototype accepted by users and customers, it is best to be
used in the projects that have less understanding of specifications so that the
development team can alter the requirements from time to time.
41
Figure 2.10: Prototype Model
(Chowdhury et al., 2018)
2.5.4 Scrum Model
In the Software Development Life Cycle model, Scrum is an agile model which
enables frequent changes in the requirements from the customers. Srivastava,
Bhardwaj and Saraswat (2017) claimed that Scrum is a very flexible model as it does
not have strict procedures to be followed, but a development team need to conduct
meetings frequently to communicate about the project. Scrum emphasises the
communication and collaboration between team members giving them the privilege
to find solutions for the problem during development. The scrum model requires a
development team that can communicate well and team members that can meet up
frequently without obstacles.
Figure 2.11: Scrum Model
(Chowdhury et al., 2018)
42
2.5.5 Extreme Programming
Extreme programming is also an agile model in the software development
methodology. It is a development model that fitting small development teams and it
will deploy some smaller version frequently as the development processes are easy to
be managed (Chowdhury et al., 2018). According to Iyawa, Herselman and Coleman
(2016), the documentation needed in extreme programming is relatively less
compared to other models as this will lighten the burden of development teams.
Figure 2.12: Extreme Programming Model
(Chowdhury et al., 2018)
2.5.6 Conclusion
All of the system development methodologies have their own advantages and
disadvantages to different projects development. The development team should
choose the most suitable methods to develop the project as there is no best
methodology that can be applied to all projects. In this project, the algorithms used
for predicting future stock prices are unclear as the performance of each algorithm
needs to be evaluated before implementing it to the application. Hence, prototyping
methodology is chosen in this project to develop the prototypes of algorithms from
time to time until the best performance algorithm is designed.
43
CHAPTER 3
PROJECT METHODOLOGY
3.1 Introduction
In this chapter, this project’s system development methodology and the planning of
this project will be reviewed.
3.2 System Development Methodology
System development methodologies are used by software developers as a guideline
or blueprint to have a systematic plan to develop the system well. Among many
system development methodologies in the industry, prototyping methodology will be
used in this project as it is suitable for developing the mobile application for stock
price prediction.
Figure 3.1: Prototyping Methodology
The figure above shows that the phases included in the prototyping model are
planning, analysis, design, implementation and deployment. In prototyping
methodology, the prototype will be implemented and analyse to get the best version
of the prototype then only deploy the prototype into the system.
44
a. Planning phase
This is the phase that lists out all the activities and tasks that will be
performed in this project and set the time frames to complete it. The planning
phase is to ensure that the project can be conducted and completed smoothly.
In this project, a project plan which includes Work Breakdown Structure and
Gantt Chart will be created in this planning phase. Work Breakdown
Structure lists down all the sub-tasks of this project while Gantt Chart set the
time frames to complete each task in the Work Breakdown Structure.
b. Analysis phase
The analysis phase is to study, analyse and gather the requirements of the
project. The requirements related to the algorithm of predicting future stock
prices, are gathered through researching papers and also some advice from
the supervisor. The requirements of the time series algorithms and evaluation
methods of the algorithms will be analysed.
c. Design phase
This phase aims to design the system in detail based on the requirements
analysed in the previous phase. In this phase, the workflow of the tasks and a
brief picture of the system’s interface will be developed.
d. Implementation phase
After designing what the system should look like, it is followed by an
implementation phase to implement the prototype by referring to the design.
A prototype will be evaluated in performance and user experience. Then the
prototype will go through the analysis phase, design phase and
implementation phase again to refine the prototype based on the evaluation.
e. Deployment phase
When the prototype is being evaluated to a stage satisfaction level is high,
then it will undergo deployment phase. The prototype is implemented into a
system and testing of the system will be conducted. Lastly, the system will be
deployed.
45
There are three iterations planned to be implemented in this project. All of the
iterations will be enhanced by analysing the requirement gathered and the system’s
design. Besides that, the prototype of each iteration will be evaluated to identify the
part that can be improved to enhance the prototype from one iteration to another
iteration. After the prototype has gone through iteration 3, which is the last iteration
planned, the testing phase will be taken place. A few types of testing will be carried
out, such as unit testing for each module, integration testing for the interconnection
between modules, system testing for the reliability of the system and user acceptance
testing for getting review from users. The testing phase is to ensure that the system is
developed and deployed with minimal bugs or errors to increase user experience.
Once the system passes through all the tests in the testing phase, the system is ready
to be delivered. The user interface design for prototype iteration 1 is shown in
Appendix A.
3.3 Project Plan
In the project plan, Work Breakdown Structure, Project Duration Plan and Gantt
Chart of this project will be discussed.
3.3.1 Work Breakdown Structure
0.0 Mobile Application for Stock Price Prediction
1.0 Planning
1.1 Title Selection and Registration
1.2 Project Plan
1.3 Problem Formulation
1.4 Objectives Formulation
1.5 Scope Defining
1.6 Preliminary Report
2.0 Prototyping Iteration 1
2.1 Analysis
2.1.1 Requirement Gathering
2.1.2 Review on Requirement Gathered
2.2 Design
2.2.1 Selection of Stock Price Prediction Algorithm
46
2.2.2 Selection of Dataset
2.2.3 Interface
2.3 Implementation
2.4 Evaluation
3.0 Prototyping Iteration 2
3.1 Analysis Improvement from Iteration 1
3.2 Design Improvement from Iteration 1
3.3 Implementation
3.4 Evaluation
4.0 Prototyping Iteration 3
4.1 Analysis Improvement from Iteration 2
4.2 Design Improvement from Iteration 2
4.3 Implementation
4.4 Evaluation
4.0 Testing
4.1 Unit Testing
4.2 Integration Testing
4.3 System Testing
4.4 User Acceptance Testing
5.0 Deployment
5.1 Delivery of Project
47
3.3.2 Project Duration Plan
Table 3.1: Project Duration Plan
Task Name Start Date
(dd/mm/yyyy)
End Date
(dd/mm/yyyy)
Duration
Planning
Title Selection and Registration 15/06/2020 21/06/2020 7
Project Plan 22/06/2020 26/06/2020 5
Problem Formulation 27/06/2020 29/06/2020 3
Objectives Formulation 30/06/2020 02/07/2020 3
Scope Definition 03/07/2020 05/07/2020 3
Preliminary Report 27/06/2020 12/07/2020 16
Prototyping Iteration 1
Analysis
• Requirement Gathering 13/07/2020 26/07/2020 14
• Review on Requirement
Gathered
20/07/2020 09/08/2020 21
Design
• Selection of Stock Price
Prediction Algorithms
10/08/2020 12/08/2020 3
• Selection of Dataset 13/08/2020 23/08/2020 11
• Interface 20/08/2020 26/08/2020 7
Implementation 27/08/2020 06/09/2020 11
Evaluation 07/09/2020 13/09/2020 7
Prototyping Iteration 2
Analysis Improvement from Iteration
1
14/09/2020 27/09/2020 14
Design Improvement from Iteration 1 28/09/2020 15/11/2020 49
Implementation 16/11/2020 08/01/2021 54
Evaluation 09/01/2021 17/01/2021 9
Prototyping Iteration 3
Analysis Improvement from Iteration
1
18/01/2021 24/01/2021 7
48
Design Improvement from Iteration 1 25/01/2021 14/02/2021 21
Implementation 15/02/2021 07/03/2021 21
Evaluation 08/03/2021 14/03/2021 7
Testing
Unit Testing 15/03/2021 21/03/2021 7
Integration Testing 22/03/2021 28/03/2021 7
System Testing 29/03/2021 04/04/2021 7
User Acceptance Testing 05/04/2021 11/04/2021 7
Deployment
Delivery of Project 12/04/2021 18/04/2021 7
49
3.3.3 Gantt Chart
Figure 3.2: Project Gantt Chart
50
3.4 Development Tools
3.4.1 Fast API
Fast API is a web framework which used by developers to build API with Python 3.6
and above. In this project, the stock code is passed to the API built with Fast API and
all the retrieval of historical stock prices and the model to predict future stock prices
are all coded in the Python script which hosts in Fast API. The predicted stock prices
then pass back to the mobile application.
3.4.2 React Native
This mobile application framework which developers use to build mobile
applications with both android and iOS is called React Native. JavaScript is the
programming language used in React Native.
3.4.3 JavaScript
JavaScript is a programming scripting language that allows developers to build
applications with complicated features like updating contents, controlling multimedia,
etc. In this project, JavaScript was being used to build the user interface of the
application.
3.4.4 Python
Python is a programming language that is widely used for machine learning and data
analysis. This is because it is simple to learn and has a good data handling capacity
compared to other programming languages. The stock price prediction algorithm in
this project used Python as the machine learning language.
3.4.5 SQLite
An SQL database engine is implemented by SQLite which is a C-language library.
SQLite is frequently used by developers to build mobile applications. In this project,
the database which stored the user list, stocks list and favourite stocks list, was
developed using SQLite.
51
3.5 Knowledge Discovery Process (KDD)
Figure 3.3: Knowledge Discovery Process overview
(Ristoski and Paulheim, 2016)
In this project, the KDD process will be implemented for the part of stock price
prediction. KDD is a process that consists of several steps to transform the raw data
into knowledge and present it to end-users. These steps include selecting data, data
pre-processing, transformation of data, data mining, and the last step is interpretation
or evaluation of the data mining model.
Since this is a time series prediction project, the historical data is essential for
the predicting task in this project. The raw data of this project will be the data of the
stock in the Malaysian stock market. For the data selection process, the historical
daily prices of the stocks will be chosen as the data to be used for data mining. These
historical stock prices will be extracted from the stock portal, which is Investing.com.
After selecting the stock data from the stock portal, these data need to go
through data pre-processing and transforming process to form useful data and
maximise the information taken. First of all, the data will be cleaned by eliminating
the null or missing values, affecting the accuracy of prediction. Retrieve data from
Investing.com will get some unwanted data, such as the daily volume of the stocks.
Therefore, useful features such as daily prices will be taken out as processed data to
lower the load when conducting data mining. The dataset becomes smaller with only
52
useful data after data pre-processing. The data will be split into two categories: the
training set and the testing set.
Data mining will be carried out when the historical daily stock prices are
cleaned and can be used to obtain a more accurate result. The time series algorithms
that will be used in this project are ARIMA, LSTM, SARIMA, Holt Winter and
Prophet, which are discussed in Chapter 2 Literature Review. The models will be
built based on these five algorithms and the prediction models will be continued for
the next process.
The last step in KDD is the interpretation and evaluation of the prediction
models. There are five predictions models from the previous step, which are ARIMA,
LSTM, SARIMA, Holt Winter and Prophet models. These five models will undergo
an evaluation to analyse the performance of the prediction and choose the best model
among them. The evaluation method that will be used in this step is RMSE and MAE.
After the evaluation, the best model will be chosen to be implemented into the
application for stock price prediction purposes.
CHAPTER 4
53
PROJECT SPECIFICATION
4.1 Introduction
The specification of this project will be discussed in this chapter through the use case
diagram, use case description, functional requirements and non-functional
requirements.
4.2 Use Case Modelling
4.2.1 Use Case Diagram
The use case diagram below shows the relationship between use cases, system and
user.
Figure 4.1: Use Case Diagram
4.2.2 Use Case Description
54
Use case description describes the details and flow of all the use cases in the use case
diagram above.
4.2.2.1 Create Account
Table 4.1: Use case description for creating account
Use Case Name: Create Account Use Case ID: 1 Importance Level: High
Primary Actor: User Use Case Type: Detailed, Essential
Stakeholders and interests:
User – wants to create an account of the mobile application for stock price
prediction.
Brief Description: This use case description describes how user creates a user
account for the mobile application for stock price prediction.
Trigger: User downloads the application and wants to register an account for this
mobile application.
Relationship:
Association: User
Include: -
Extend: -
Generalization: -
Normal flow of events:
1. User clicks on “Sign Up” button on the first page of the interface of the
application.
2. The Sign-Up page will be navigated.
3. User enters username, email, password and confirm password to create the
account.
4. System creates an account that only belong to particular user.
Subflows:
None
Alternative/exceptional flows:
3.1 The username or email have been used.
3.1.1 User re-enter another username or email which is not stored in the
database.
3.1.2 Account created.
55
4.2.2.2 Login Account
Table 4.2: Use case description for login account
Use Case Name: Login Account Use Case ID: 2 Importance Level: High
Primary Actor: User Use Case Type: Detailed, Essential
Stakeholders and interests:
User – wants to login into the registered account of the mobile application for stock
price prediction.
Brief Description: This use case description describes how user login into his/her
registered account of this mobile application for stock price prediction.
Trigger: User wants to login to their registered account of the mobile application for
stock price prediction.
Relationship:
Association: User
Include: -
Extend: -
Generalization: -
Normal flow of events:
1. User input registered email or username and designated password to the “Log
In” page.
2. User clicks on the “Log In” button to verify the email and password in order
to login.
3. System starts to verify the validity of the email or username and password
entered.
4. User successfully login to the home page of the application.
Subflows:
None
Alternative/exceptional flows:
4.1 The email or username and the password have been wrongly entered.
4.1.1 System pops out a warning message about the invalid email or
username or password entered.
4.1.2 User needs to re-enter the correct email or username and password to
login.
56
4.1.3 Email or username and password have been verified and user is
successfully login.
4.2.2.3 Manage Favourite Stocks
Table 4.3: Use case description for managing favourite stocks
Use Case Name: Manage Favourite
Stocks
Use Case ID: 3 Importance Level: High
Primary Actor: User Use Case Type: Detailed, Essential
Stakeholders and interests:
User – wants to monitor some favourite stocks in a more convenient way.
Brief Description: This use case description describes how user manage their
favourite stocks by adding them to a wish list or removing them from the wish list.
Trigger: User wants to monitor the stocks in a list or user do not want to monitor the
stock in the list anymore.
Relationship:
Association: User
Include: -
Extend: -
Generalization: -
Normal flow of events:
1. User wants to modify the stocks in the Favourite Stocks list.
2. User add or remove the stocks from the Favourite Stocks list.
If user wants to add stocks to Favourite Stocks list, 2.1: Add stocks to
Favourite Stocks list subflow is performed.
If user wants to remove stocks from Favourite Stock list, 2.2: Remove
stocks from Favourite Stocks list subflow is performed.
3. The Favourite Stocks list has been managed.
Subflows:
2.1 Add stocks to Favourite Stocks list
2.1.1 User wants to monitor and has interest on the stock.
2.1.2 User clicks on the heart button on that particular stock.
2.1.3 The stock has been stored in the Favourite Stocks list.
57
2.2 Remove stocks from Favourite Stocks list
2.2.1 User does not want to monitor the stock anymore.
2.2.2 User click on the heart icon on the menu bar to navigate to Favourite
Stocks list page.
2.2.3 User clicks on the heart button of the stock that wanted to be removed
from the list.
2.2.4 The stock has been removed from the Favourite Stocks list.
Alternative/exceptional flows:
None
4.2.2.4 Search Stocks
Table 4.4: Use case description for searching stocks
Use Case Name: Search Stocks Use Case ID: 4 Importance Level: High
Primary Actor: User Use Case Type: Detailed, Essential
Stakeholders and interests:
User – wants to find stocks that are not in the wish list.
Brief Description: This use case description describes how user search the stocks that
are not in the wish list.
Trigger: User wants to search the stocks which are new to them.
Relationship:
Association: User
Include: -
Extend: -
Generalization: -
Normal flow of events:
1. User found some new stocks from other stock portal or news.
2. User click on the magnifying glass icon on the menu bar to navigate to search
page.
3. User enters the details of the stocks on the search bar.
4. User clicks on the “Search” button to search for the stocks.
5. The stocks which related to the stocks’ details entered will be shown on the
search page.
58
Subflows:
3.1 User enters the name of the stocks that wanted to be searched.
3.2 User enters the code of the stocks that wanted to be searched.
Alternative/exceptional flows:
3.1 The name or code of the stocks that wanted to be searched could not be
found.
3.2 The use case ended.
4.2.2.5 Extract Historical Stock Prices from Another Stock Portal
Table 4.5: Use case description for extracting historical stock prices from another
stock portal
Use Case Name: Extract Historical
Stock Prices from Another Stock
Portal
Use Case ID: 5 Importance Level: High
Primary Actor: - Use Case Type: Detailed, Essential
Stakeholders and interests:
System – get the historical stock data so as to use for predicting the future stock
prices.
User – get a more reliable results of prediction based on historical stock data.
Brief Description: This use case description describes how mobile application for
stock price prediction extract the historical stock prices form another stock portal.
Trigger: System wants to predict the future stock prices.
Relationship:
Association: User
Include: Predict Stock Prices via Time Series Algorithms
Extend: -
Generalization: -
Normal flow of events:
1. System will use historical stock prices to predict the future stock prices.
2. System extracts the historical stock data from another stock portal.
3. System stores the historical stock data into the database of mobile application
for stock price prediction.
59
Subflows:
None
Alternative/exceptional flows:
None
4.2.2.6 Predict Stock Prices via Time Series Algorithms
Table 4.6: Use case description for predicting stock prices via time series algorithms
Use Case Name: Predict Stock Prices
via Time Series Algorithms
Use Case ID: 6 Importance Level: High
Primary Actor: - Use Case Type: Detailed, Essential
Stakeholders and interests:
User – able to know the future stock prices using time series algorithm
Brief Description: This use case description describes how the system predicts the
future stock prices using time series algorithm.
Trigger: User wants to get the predicted stock prices.
Relationship:
Association: User
Include: View Predicted Stock Prices
View Charts of Predicted Stock Prices
Extend: -
Generalization: -
Normal flow of events:
1. A few time series algorithms will be used to test the best model for stock
price prediction.
2. Those time series algorithms will go through evaluation method to find the
best and most accurate model.
3. The model is then used to predict the future stock prices.
4. The input data will be the historical stock data retrieve from database.
5. The predicted stock prices will be sent to the front end of the mobile
application for stock price prediction.
Subflows:
None
60
Alternative/exceptional flows:
None
4.2.2.7 View Predicted Stock Prices
Table 4.7: Use case description for viewing predicted stock prices
Use Case Name: View Predicted
Stock Prices
Use Case ID: 7 Importance Level: High
Primary Actor: User Use Case Type: Detailed, Essential
Stakeholders and interests:
User – able to view the future stock prices for maximizing the profit.
Brief Description: This use case description describes how user view the predicted
stock prices.
Trigger: User wants to view the predicted stock prices.
Relationship:
Association: User
Include: -
Extend: -
Generalization: -
Normal flow of events:
1. User wants to know the predicted stock prices of certain stocks.
2. User search the stocks from the system.
3. User click on the “Predict” button to predict the stock prices.
4. The predicted stock prices appear on the page for the user.
Subflows:
2.1 User search the stocks through search page.
2.2 User find the stocks from the Favourite Stocks list.
Alternative/exceptional flows:
None
4.2.2.8 View Charts of Predicted Stock Prices
61
Table 4.8: Use case description for viewing charts of predicted stock prices
Use Case Name: View Charts of
Predicted Stock Prices
Use Case ID: 8 Importance Level: High
Primary Actor: User Use Case Type: Detailed, Essential
Stakeholders and interests:
User – able to view the predicted stock prices in an easier way which is in charts
form.
Brief Description: This use case description describes how user view the predicted
stock prices in a chart view.
Trigger: User wants to view the charts of predicted stock prices.
Relationship:
Association: User
Include: -
Extend: -
Generalization: -
Normal flow of events:
1. User wants to know the predicted stock prices of certain stocks in chart form.
2. User search the stocks from the system.
3. User click on the “Predict Chart” button to predict the stock prices.
4. The predicted stock prices in a chart form appear on the page for the user.
Subflows:
2.1 User search the stocks through search page.
2.2 User find the stocks from the Favourite Stocks list.
Alternative/exceptional flows:
None
4.3 System Requirements
62
The system requirements, which consist of functional requirements and non-
functional requirements, will be discussed.
4.3.1 Functional Requirements
• The system shall allow users to search the blue-chip stocks in the Malaysian
stocks market (KLSE) by entering stock’s name and stock’s code.
• The system shall allow users to manage their favourite stocks list.
i. The system shall allow users to store favourite stocks into a list.
ii. The system shall allow users to remove stocks from the favourite
stock list.
• The system shall be able to extract historical stock prices for prediction
purposes from another stock portal.
• The system shall be able to predict future stocks prices by using time series
algorithms.
• The system shall be able to view the predicted stock prices to the users.
• The system shall be able to display the predicted stock prices charts to the
users.
4.3.2 Non-Functional Requirements
• The system shall allow users who do not have an account to create their
account for this application.
• The system shall allow users to login to their registered account of this
mobile application.
• The system shall restore all the favourite list of the users once they login to
their account although using other mobile devices.
• The system shall be able to provide instructions manual to the users so that
they can use it without any problem.
• The system shall be secure for the users to use.
CHAPTER 5
63
SYSTEM DESIGN
5.1 Introduction
In this chapter, the design of the system including the software architecture, database
and user interface design.
5.2 Software Architecture Design
The system architecture designed for the mobile application is a client-server
architecture. The client-side is the user interface that the users interact with while the
server-side is the combination of the database and the stock price prediction model.
The user interface was built by using react native framework while the
database was created in SQLite. The user interface consists of Log In, Sign Up,
Favourite, Search, Stocks List, Stock and Profile screens. All these screens will be
shown in the section below. The database is created to store the information of stocks,
the list of the users and the favourite stocks of each user. The details of the database
design will also be shown in the section below.
The performance of a few stock price prediction models was examined in
order to select the best performance model to predict the stock prices. All the
historical stock prices of the stocks were retrieved from the Investing.com website
through an API which retrieve the data from the website to python file. This can
ensure that the data can run automatically through the model without manually
download the csv files from the website. Other than that, the prediction algorithm
scripted in Python is hosted in a local server so that the mobile application can pass
the stock code to the algorithm and get the predicted stock prices from the algorithm.
This process needs a web framework called Fast API to allow the communication
between the prediction algorithm and mobile application.
64
Figure 5.1: Software Architecture Design
5.3 Database Design
5.3.1 Physical Entity Relationship Diagram
Figure 5.2: Physical entity relationship diagram
65
5.3.2 Logical Entity Relationship Diagram
Figure 5.3: Logical entity relationship diagram
5.3.3 Data Dictionary
Entity: Users
Table 5.1: Users’ entity data dictionary
Column Description Data
Type
Key FK
Referenced
Table
Null
user_id Unique identification for
all registered users
Integer PK - Not
Null
user_name Preferred name of the
registered users
Text - - Not
Null
user_email Email of the registered Text - - Not
66
users Null
user_password Password of the
registered users
Text - - Not
Null
Entity: Sectors
Table 5.2: Sectors’ entity data dictionary
Column Description Data
Type
Key FK
Referenced
Table
Null
sector_id Unique identification for
all sectors
Integer PK - Not
Null
sector_name Name of the sector in
Bursa Malaysia market.
(Example: Technology)
Text - - Not
Null
Entity: Stocks
Table 5.3: Stocks’ entity data dictionary
Column Description Data
Type
Key FK
Referenced
Table
Null
stock_id Unique identification
for all stocks
Integer PK - Not
Null
sector_id Unique identification
for all sectors
Integer FK Sectors Not
Null
stock_name Name of the stocks in
Bursa Malaysia
market. (Example:
MAYBANK)
Text - - Not
Null
stock_code Code of the stocks in
Bursa Malaysia
market. (Example
Text - - Not
Null
67
stock code for
MAYBANK: 1155)
stock_InvestingCode Code of the Bursa
Malaysia stocks in
Investing.com
website. (Example
code for
MAYBANK:
MBBM)
Text - - Not
Null
Entity: Favourites
Table 5.4: Favourites’ entity data dictionary
Column Description Data
Type
Key FK
Referenced
Table
Null
id Unique identification for all
favourite stocks for each user
Integer PK - Not Null
user_id Unique identification for all
registered users
Integer FK Users Not Null
stock_id Unique identification for all
stocks
Integer FK Stocks Not Null
68
5.4 User Interface
5.4.1 Log In Page
Log In screen requires users to input email or username which are already registered
and the particular password to log in to the system. If visitors have not registered as
users, they need to click on the red “Sign Up” title to navigate to the sign up page.
Figure 5.4: User interface for log in page
Figure 5.5: User interface for log in page when user’s credentials are incorrect
69
5.4.2 Sign Up Page
Sign Up page let users input their personal information such as preferred username,
email and password to create an account for this application.
Figure 5.6: User interface for sign up page
Figure 5.7: User interface for sign up page when duplicate username or email entered
70
5.4.3 Favourite Page
Favourite page allows users to store the stocks they prefer so they can monitor these
stocks frequently in a list.
Figure 5.8: User interface for favourite page
5.4.4 Search Page
Search page allows users to type in certain keywords such as the name of the stocks
or the stock code of the stocks to search for a particular stock.
Figure 5.9: User interface for search page
71
Figure 5.10: User interface for search page when keyword is entered
5.4.5 Sector Page
Sector page shows all the sectors in the database to the users.
Figure 5.11: User interface for sector page
72
Figure 5.12: User interface for clicking into sector page
5.4.6 Individual Stock Page
Individual stock page enables users to favourite the stock, shows related information,
show historical chart and also predict the future stock prices of that particular stock.
Figure 5.13: User interface for individual stock page
73
Figure 5.14: User interface for individual stock page after Predict button is clicked
Figure 5.15: User interface for individual stock page after Historical Chart button is
clicked
74
5.4.7 Profile Page
Profile page allows users to edit their username, change password and log out.
Figure 5.16: User interface for profile page
Figure 5.17: User interface for profile edit username page
75
Figure 5.18: User interface for profile change password page
76
CHAPTER 6
IMPLEMENTATION
6.1 Introduction
The selection of time series algorithms, implementation of the prediction model and
API endpoints will be discussed in this chapter.
6.2 Selection of Time Series Algorithms
As discussed in Chapter 2, Long Short-Term Memory, Holt Winter, Auto-Regression
Integrated Moving Average, Seasonal Auto-Regression Integrated Moving Average
and Prophet were evaluated to find the best prediction model for implementing into
the mobile application.
6.2.1 Data Collection
First of all, the stock market focused on in this project is the Bursa Malaysia. Hence,
the data must retrieve from Bursa Malaysia stocks. The stocks that underwent all five
prediction algorithms were retrieved from six sectors of stocks: Construction,
Technology, Plantation, Real Estate Investment Trusts, Health Care and Utilities.
The total number of stocks from these six sectors is 216.
After finding the targeted stocks, the historical prices of these stocks were
retrieved from Investing.com. The historical prices have to be called and retrieved
automatically for the prediction algorithms. In this case, an API named investpy is
used along with the prediction algorithms to retrieve the historical prices from
Investing.com.
6.2.2 Data Pre-Processing
The period of historical prices was set to one year. The historical prices retrieved
may contain some null or missing values, so these values were cleaned to ensure
better accuracy on the prediction results. The one-year historical prices were split
into two sets of data: the train set and the test set. 70% of the trading days in a year
belonged to the train set, while the other 30% belonged to the test set. The train set
was used to train prediction algorithms while the test set was used to evaluate the
accuracy of prediction algorithms.
77
Other than that, the historical prices retrieved contain daily open prices, daily
high prices, daily low prices, daily close prices and daily volume. There was only
one type of prices taken to underwent prediction algorithms which was daily close
prices.
6.2.3 Evaluate Prediction Algorithms
After data collection and data pre-processing, the train set was passed through all
five prediction algorithms: LSTM, ARIMA, Holt Winter, SARIMA and Prophet to
train all these algorithms. The predicted stock prices of each prediction algorithm
were then compared with the test set using graph plotting and evaluation method:
Root Mean Square Error (RMSE) and Mean Absolute Error (MAE). After
conducting all the training and predicting activities, the average of RMSE and MAE
from 216 stocks were being calculated. Parameters of prediction algorithms are
shown in the first table below as other tables are followed same parameters. The
results are shown in the tables below.
Table 6.1: Average RMSE and MAE for 5 prediction algorithms for all stocks
Algorithms RMSE MAE
ARIMA
Parameters:
order=(4,1,0)
0.026992 0.018855
LSTM
Parameters:
Dropout(0.2),
Dense(units = 1),
optimizer = 'RMSProp',
epochs = 100,
batch_size = 32
0.049386 0.038917
SARIMA
Parameters:
order=(2,1,4),
seasonal_order=(0,1,1,7)
0.141947 0.117713
Holt Winter 0.144702 0.119861
78
Parameters:
seasonal_periods=7,
trend='add',
seasonal='add',
Prophet 0.169365 0.144526
Table 6.2: Average RMSE and MAE for 5 prediction algorithms for Construction
sector
Algorithms RMSE MAE
ARIMA 0.016676418 0.011720139
LSTM 0.029513763 0.024086467
SARIMA 0.084710008 0.071691036
Holt Winter 0.096906925 0.082272729
Prophet 0.078496928 0.066122917
Table 6.3: Average RMSE and MAE for 5 prediction algorithms for Technology
sector
Algorithms RMSE MAE
ARIMA 0.021602484 0.015221912
LSTM 0.046597948 0.0387713
SARIMA 0.132089442 0.11457744
Holt Winter 0.13086616 0.113678954
Prophet 0.166523867 0.149357676
Table 6.4: Average RMSE and MAE for 5 prediction algorithms for Plantation sector
Algorithms RMSE MAE
ARIMA 0.048977215 0.033637076
LSTM 0.084139441 0.061222394
SARIMA 0.252713371 0.195633329
79
Holt Winter 0.252997757 0.194311614
Prophet 0.311426245 0.245653238
Table 6.5: Average RMSE and MAE for 5 prediction algorithms for Health Care
sector
Algorithms RMSE MAE
ARIMA 0.025698962 0.017260259
LSTM 0.04264388 0.033139367
SARIMA 0.104144608 0.086326631
Holt Winter 0.113768482 0.094152217
Prophet 0.097223454 0.084216448
Table 6.6: Average RMSE and MAE for 5 prediction algorithms for Real Estate
Investment Trusts sector
Algorithms RMSE MAE
ARIMA 0.013911074 0.009869636
LSTM 0.018993417 0.015720226
SARIMA 0.067014767 0.060490379
Holt Winter 0.064642397 0.058342467
Prophet 0.09504377 0.087113114
Table 6.7: Average RMSE and MAE for 5 prediction algorithms for Utilities sector
Algorithms RMSE MAE
ARIMA 0.048797025 0.035789725
LSTM 0.077359327 0.060349001
SARIMA 0.215506139 0.17899808
Holt Winter 0.211562492 0.176297634
Prophet 0.278322143 0.248588347
80
From the tables above, it is clearly seen that ARIMA has the lowest RMSE
and MAE, which means it has the least error in prediction. There are graphs
comparing the actual stock prices and the predicted stock prices which shown as
below.
Figure 6.1: Graph comparing the actual and predicted stock prices of ARIMA
Figure 6.2: Graph comparing the actual and predicted stock prices of ARIMA
81
Figure 6.3: Graph comparing the actual and predicted stock prices of SARIMA
Figure 6.4: Graph comparing the actual and predicted stock prices of Holt Winter
82
Figure 6.5: Graph comparing the actual and predicted stock prices of Prophet
From the graphs and table shown above, ARIMA is the best among all five
prediction algorithms because it has the least error and most accurate when
comparing to actual stock prices. Therefore, ARIMA was chosen as the stock price
prediction model for the mobile application of this project.
6.3 Implementation of Prediction Model
After the prediction model had been developed, it was implemented into the
mobile application and there is user interface to show the predicted prices to the
users. To run the prediction model in the mobile application, an API is needed to link
Python script, which consists of the prediction model, and the mobile application.
The API used in this project is FastAPI, which hosts the prediction model on
the local server, and let the mobile application call the prediction results from the
local server. A few functions which return the prediction results, history stock prices
and information of stocks were developed in the Python script and is hosted by
FastAPI. On the other hand, the backend of React Native, which scripted the mobile
application, needs to pass the specific stock codes and date through FastAPI to the
prediction model. This can ensure that the prediction model can get historical stock
prices of specific stocks and perform prediction.
83
The connection between the mobile application and the Python script needed
to be established. This is because the port of the mobile device and the local server is
different. In the FastAPI hosted Python script, Cross-Origin Resource Sharing
(CORS) was configured to establish the communication between React Native
backend and the Python script. In the mobile application, the port number of the local
server also needed to be acknowledged. From the code below, the 8081 is the port
number for the mobile device which runs the mobile application while 8000 is the
port number of the local server.
Figure 6.6: Code for CORS in Python script
Figure 6.7: Code for acknowledgement of local server port in mobile application
84
6.4 API Endpoints
There are in total 9 API endpoints hosted by FastAPI which return different
information of stocks.
Table 6.8: List of FastAPI endpoints
Method: Get
Path Description Parameters
/predict/{stock_code}/?toDate=
{toDate}&fromDate={fromDate}
Get the prediction results of
specific stock.
• stock_code
• toDate
• fromDate
/history/{stock_code}/?toDate=
{toDate}&fromDate={fromDate}
Get one-year historical daily
close prices of specific stock.
• stock_code
• toDate
• fromDate
/yearHigh/{stock_code}/?toDate=
{toDate}&fromDate={fromDate}
Get the highest reached stock
price in a year of specific
stock.
• stock_code
• toDate
• fromDate
/yearLow/{stock_code}/?toDate=
{toDate}&fromDate={fromDate}
Get the lowest reached stock
price in a year of specific
stock.
• stock_code
• toDate
• fromDate
/open/{stock_code}/?toDate=
{toDate}&fromDate={fromDate}
Get the current daily open
price of specific stock.
• stock_code
• toDate
• fromDate
/high/{stock_code}/?toDate=
{toDate}&fromDate={fromDate}
Get current daily highest price
of specific stock.
• stock_code
• toDate
• fromDate
/low/{stock_code}/?toDate=
{toDate}&fromDate={fromDate}
Get current daily lowest price
of specific stock.
• stock_code
• toDate
• fromDate
/close/{stock_code}/?toDate=
{toDate}&fromDate={fromDate}
Get current daily close price
of specific stock.
• stock_code
• toDate
• fromDate
85
Table 6.9: List of FastAPI endpoints (continued)
Method: Get
Path Description Parameters
/volume/{stock_code}/?toDate=
{toDate}&fromDate={fromDate}
Get current daily
transaction volume
of specific stock.
• stock_code
• toDate
• fromDate
86
CHAPTER 7
TESTING
7.1 Introduction
This chapter discusses the testing of this project, including unit testing, integration
testing, and system testing.
7.2 Unit Testing
Unit testing was conducted when the mobile application had been developed. Its
purpose is to perform testing on the functionality of the individual units or functions
of the mobile application. If errors or defects were found, corrective actions will be
taken to minimise the errors and defects before deployment.
7.2.1 Sign Up Module
Table 7.1: Unit Test Cases for Sign Up Module
Test Case Test Execution Steps Expected Results Results
(Pass/Fail)
Sign Up page
navigation
1. Users do not have any
account to login.
2. Users want to register an
account.
3. Click on the red “Sign
Up” quote to navigate to
Sign Up page.
The view navigates
from Log In page to
Sign Up page.
Pass
Field required
validation
1. Let username, email,
password or confirm
password empty.
2. Click on the “Sign Up”
button to register an account.
An alert window will
pop up to inform
users that the field is
required.
Pass
Email format
validation
1. Type an invalid email.
(example: 1234word)
2. Fill in other fields with
An alert window
which stated “Email
format is incorrect”
Pass
87
valid values.
3. Click on the “Sign Up”
button to register an account.
will pop up.
Password
matching
validation
1. Fill in all fields with valid
values.
2. Fill in differently for
password field and confirm
password field.
3. Click on the “Sign Up”
button to register an account.
An alert window
which stated
“Password did not
match” will pop up.
Pass
Same username
or email
validation
1. Fill in username or email
that already exists in the
system.
2. Fill in all other fields with
valid values.
3. Click on the “Sign Up”
button to register an account.
An alert window
which stated
“Username or email
already exists” will
pop up.
Pass
Account
registration
1. Fill in all fields with valid
values.
2. Click on the “Sign Up”
button to register an account.
An alert window
which stated “You
are Registered
Successfully” will
pop up and navigate
back to Log In page.
Pass
88
7.2.2 Log In Module
Table 7.2: Unit Test Cases for Log In Module
Test Case Test Execution Steps Expected Results Results
(Pass/Fail)
Log In page
initiation
1. Launch the mobile
application.
The view is Log In
page once launching
application.
Pass
Fields required
validation
1. Leave “Email or
Username” or “Password”
field empty.
2. Click “Log In” button to
login to the system.
An alert window will
pop up to inform
users that the field is
required.
Pass
Field validation 1. Fill in email, username or
password that are not
registered in the system.
2. Click “Log In” button to
login to the system.
An alert window
which stated
“Incorrect
Credentials!” will
pop up.
Pass
Users Log In 1. Fill in email or username
and password that are
registered in the system.
2. Click “Log In” button to
login to the system.
Users successful
logging in and
navigate to Favourite
page.
Pass
7.2.3 Favourite Module
Table 7.3: Unit Test Cases for Favourite Module
Test Case Test Execution Steps Expected Results Results
(Pass/Fail)
Favourite page
navigation after
logging in
1. Log in to the system. The view is
Favourite page once
logging in.
Pass
Favourite page
navigation in
1. Click on the bottom tab
menu which contains a heart
The view navigates
to Favourite page.
Pass
89
other page shape icon and stated
“Favourite”.
Show favourite
stocks list
1. Favourite a few stocks by
clicking the heart icon at
Individual Stock page.
2. Navigate back to Favourite
page.
Favourite page
contains that stocks
that have been
favourited.
Pass
Individual
Stocks page
navigation
1. Click on a specific stock
from the favourite stocks list.
The view navigates
from Favourite page
to Individual Stock
page.
Pass
7.2.4 Search Module
Table 7.4: Unit Test Cases for Favourite Module
Test Case Test Execution Steps Expected Results Results
(Pass/Fail)
Search page
navigation
1. Click on the bottom tab
menu which contains a
magnifying glass shape icon
and stated “Search”.
The view navigates
to Search page.
Pass
Search stock
without
keyword
1. Leave empty for the field.
2. Click “Search” button to
search the stocks.
All stocks shown in
the list following
alphabetical order.
Pass
Search stock
with stock
symbol (stock
name) in
capital letter.
1. Type in specific stock
name in capital letter.
2. Click “Search” button to
search the stocks.
All stocks related to
the stock name
shown in the list
following
alphabetical order.
Pass
Search stock
with stock
symbol (stock
name) in small
1. Type in specific stock
name in small letter.
2. Click “Search” button to
search the stocks.
All stocks related to
the stock name
shown in the list
following
Pass
90
letter. alphabetical order.
Search stock
with stock code
1. Type in specific stock
code.
2. Click “Search” button to
search the stocks.
All stocks related to
the stock code shown
in the list following
alphabetical order.
Pass
Search stock
with stock
name or stock
code that is not
in the system.
1. Type in specific stock
name or stock code that is not
in the system.
2. Click “Search” button to
search the stocks.
An alert window
which stated “No
stock found” will pop
up.
Pass
Individual
Stocks page
navigation
1. Click on a specific stock
from the stocks list.
The view navigates
from Search page to
Individual Stock
page.
Pass
7.2.5 Sectors Module
Table 7.5: Unit Test Cases for Sectors Module
Test Case Test Execution Steps Expected Results Results
(Pass/Fail)
Sectors page
navigation
1. Click on the bottom tab
menu which contains an
incline bars shape icon
and stated “Sectors”.
The view navigates to
Sectors page.
Pass
Show sector list 1. Navigate to Sectors
page.
All the sectors that
stored in the system will
be shown.
Pass
Stock List page
navigation
1. Click on a sector that
shown in the sector list.
All the stocks belong to
the sector will be shown.
Pass
Individual
Stocks page
navigation
1. Click on a specific
stock from the stocks list.
The view navigates from
Stock List page to
Individual Stock page.
Pass
91
7.2.6 Individual Stock Module
Table 7.6: Unit Test Cases for Individual Stock Module
Test Case Test Execution Steps Expected Results Results
(Pass/Fail)
Show stock
information
1. Navigate to Individual
Stock page.
The information
which are high, low,
open, close, 52
weeks high and low
and volume of the
stock will be shown.
Pass
Favourite stock 1. Click on the heart shape
icon which is in grey colour.
The heart shape icon
will turn to red
colour once clicked.
Pass
Unfavourite
stock
1. Click on the heart shape
icon which is in red colour.
The heart shape icon
will turn to grey
colour once clicked.
Pass
Historical Chart
page navigation
1. Click on the “Historical
Chart” button on Individual
Stock page.
The view navigates
from Individual
Stock page to
Historical Chart
page.
Pass
Show one-year
historical chart
1. Click on the “Show 1 Year
Historical Chart” button on
Historical Chart page.
The page shows a
chart which has the
trend line of one-year
historical stock
prices of the stock.
Pass
Show predicted
stock price
1. Click on the “Predict”
button on Individual Stock
page.
The predicted stock
prices will be shown
in chart and price
table after a few
seconds.
Pass
92
7.2.7 Profile Module
Table 7.7: Unit Test Cases for Profile Module
Test Case Test Execution Steps Expected Results Results
(Pass/Fail)
Profile page
navigation
1. Click on the bottom tab
menu which contains a
profile shape icon and
stated “Prrofile”.
The view navigates to
Profile page.
Pass
Show username 1. Navigate to Profile page. The view shows a
quote which stated
“Welcome,
{username}” on top.
Pass
Edit Username
page navigation
1. Click on the “Edit
Username” button on
profile page.
The view navigates
from Profile page to
Edit Username page.
Pass
Show username
and email in
Edit Username
page.
1. Navigate to Edit
Username page.
The view shows
current username and
email of the user.
Pass
Change
username
validation
1. Leave all field as it
current state or fill in
username that already
registered.
2. Click “Confirm” button
to change username.
An alert window
stated “Username is
required” will pop up.
Pass
Change email
validation
1. Change the email in
Email field.
The Email field not
allow user to input
data.
Pass
Change
username
1. Insert a valid username in
Username field.
2. Click “Confirm” button
to change username.
An alert window
stated “Username
updated successfully
and navigate back to
Profile page with new
Pass
93
username welcome
banner.
Change
Password
navigation
1. Click on the “Change
Password” button on the
Profile page.
The view navigates
from Profile page to
Change Password
page.
Pass
Field required
validation
1. Leave “Old Password”,
“New Password” or
“Confirm Password” field
empty.
2. Click on “Change
Password” button on
Change Password page to
change the password of the
account.
An alert window will
pop up to inform users
that the field is
required.
Pass
Old Password
validation
1. Fill in an incorrect old
password.
2. Click on “Change
Password” button on
Change Password page to
change the password of the
account.
An alert window
which stated
“Incorrect old
password entered” will
pop up.
Pass
Password
matching
validation
1. Fill in correct old
password.
2. Fill in different password
for New Password field and
Confirm Password field.
3. Click on “Change
Password” button on
Change Password page to
change the password of the
account.
An alert window
which stated
“Password did not
match” will pop up.
Pass
Change 1. Fill in correct old An alert window Pass
94
password password.
2. Fill in new password.
3. Fill in confirm password
that match with new
password.
4. Click on “Change
Password” button on
Change Password page to
change the password of the
account.
which stated
“Password updated
successfully” will pop
up and navigate back
to Profile page.
Log Out 1. Click on “Log Out”
button on Profile page.
Application log out
and navigate to Log In
page.
Pass
7.3 Integration Testing
Integration testing is to test the functionality of two or more individual units when
integrated together. This can ensure that related functions of the application are
working well when they are combined.
7.3.1 Sign Up and Log In Module
Table 7.8: Integration Test Case for Sign Up & Log In
Test Case Test Execution Steps Expected
Results
Results
(Pass/Fail)
Sign Up
and Log In
with same
credentials
1. Click on “Sign Up” quote to navigate to
Sign Up page.
2. Fill in the field with valid values.
3. Click on the “Sign Up” button to
register an account.
4. Fill in the credentials that registered in
the Log In page.
5. Click on the “Log In” button to login.
Account
successfully
registered
and login
using the
same
credentials.
Pass
95
7.3.2 Edit Profile and Log In Module
Table 7.9: Integration Test Case for Edit Profile and Log In
Test Case Test Execution Steps Expected
Results
Results
(Pass/Fail)
Edit
username or
password
and login
successfully
1. Click on the bottom tab menu which
contains a profile shape icon and stated
“Profile”.
2.1. Click on “Edit Username” button on
Profile page.
2.2. Fill in username filed with valid
values.
2.3. Click on “Confirm” button to
change username.
OR
3.1. Click on “Change Password” button
on Profile page.
3.2. Fill in fields with valid values.
3.3. Click “Change Password” button to
change password.
4. Click “Log Out” button on Profile
page.
5. Fill in username and password that
have been changed in Log In page.
6. Click on the “Log In” button to login.
Account
successfully
login with the
changed
username and
password.
Pass
7.3.3 Store Favourite Stocks Module
Table 7.10: Integration Test Case for Edit Profile and Log In
Test Case Test Execution Steps Expected
Results
Results
(Pass/Fail)
Store
favourite
stocks in
1.1. Click on the bottom tab menu
which contains a magnifying glass
shape icon and stated “Search”.
The stock that
is favourited
will show in
Pass
96
Favourite
page
1.2. Search stocks with valid values.
1.3. Click on a particular row of stock
and navigate to Individual Stock page.
OR
2.1. Click on the bottom tab menu
which contains an incline bars shape
icon and stated “Sectors”.
2.2. Click on a sector that shown in the
sector list.
2.3. Click on a specific stock from the
stocks list to navigate to Individual
Stock page.
3. Click on the heart shape icon in grey
colour on Individual Stock page.
4. Click on the bottom tab menu which
contains a heart shape icon and stated
“Favourite”.
the list in
Favourite
page.
7.3.4 Remove Favourite Stocks Module
Table 7.11: Integration Test Case for Edit Profile and Log In
Test Case Test Execution Steps Expected
Results
Results
(Pass/Fail)
Remove
favourite
stocks in
Favourite
page
1.1. Click on the bottom tab menu
which contains a magnifying glass
shape icon and stated “Search”.
1.2. Search stocks with valid values.
1.3. Click on a row of favourite stock
and navigate to Individual Stock page.
OR
2.1. Click on the bottom tab menu
which contains an incline bars shape
icon and stated “Sectors”.
The stock that
is
unfavourited
will remove
from the list in
Favourite
page.
Pass
97
2.2. Click on a sector that shown in the
sector list.
2.3. Click on a specific favourite stock
from the stocks list to navigate to
Individual Stock page.
OR
3.1. Click on the bottom tab menu
which contains a heart shape icon and
stated “Favourite”.
3.2. Click on a specific stock from the
favourite stocks list to navigate to
Individual Stock page.
4. Click on the heart shape icon in red
colour on Individual Stock page.
5. Click on the bottom tab menu which
contains a heart shape icon and stated
“Favourite”.
7.4 System Testing
The purpose of system testing is to test on the system which has all units fully
integrated. System testing can verify the functionality and flow of the whole system.
Table 7.12: Test Case for System Testing
Test Case Test Execution Steps Expected
Results
Results
(Pass/Fail)
Login to
predict
stock
prices
1. Fill in the credentials in Log In
page.
2. Click on the “Log In” button on
Log In page.
3. Click on the bottom tab menu
which contains a magnifying glass
shape icon and stated “Search”.
Every account
will have
different
favourite stocks
list in Favourite
page. The
predicted prices
Pass
98
4. Search stocks with specific stock
name or stock code.
5. Click on the row of a stock in the
searched stocks list on Search page.
6. Click on the heart shape icon in
grey colour on Individual Stock page.
7. Click on the bottom tab menu
which contains a heart shape icon
and stated “Favourite”.
8. Click on the row of a stock in the
favourite stocks list on Favourite
page.
9. Click on the “Predict” button on
the Individual Stock page.
10. Click on the bottom tab menu
which contains a profile shape icon
and stated “Profile”.
11. Click “Log Out” button on
Profile page.
12. Repeat step 1 to step 11 with
another account.
of the stock will
be shown
successfully and
they are differed
for every stock.
99
CHAPTER 8
CONCLUSION AND RECOMMENDATIONS
8.1 Introduction
This chapter discusses the limitations of this project, recommendations and future
works and the conclusion of this project.
8.2 Limitations
Although all required features were developed in this mobile application, there are
still some limitations of this mobile application. One of the limitations is the
prediction is not accurate all the time. It might be inaccurate if there is some external
factor affecting the trend of the market. Another limitation is the period of the
prediction results is fixed to 65 trading days. Users cannot set the period that they
want to predict the stock prices. The last limitation is there is no any solution that
user can do when user forget their password to login to the system.
8.3 Recommendations and Future Works
One of the recommendations is to monitor the performance of the prediction model
from time to time. Some improvement can be taken if there are new solutions found
to increase the accuracy of the prediction model and decrease the time used to predict
future stock prices. Other than that, the mobile application can allow users to input
the period of prediction. In this case, users can specify a period of trading days and
the prediction results will show only the specific period. Lastly, the mobile
application can send an email notification to reset password for the users who forget
their password.
8.4 Conclusion
In conclusion, a mobile application for stock price prediction was developed to let
users have a better view on the stocks market trend. Five time series algorithms had
been evaluated to find out the best prediction models for the mobile application.
ARIMA has the best accuracy among all five time series algorithms and it had been
chosen as the prediction model for the mobile application for stock price prediction.
100
REFERENCES
Adebiyi, A.A., Adewumi, A.O. and Ayo, C.K., 2014. Comparison of ARIMA and
artificial neural networks models for stock price prediction. Journal of Applied
Mathematics, 2014, pp.9–11.
Althelaya, K.A., El-Alfy, E.S.M. and Mohammed, S., 2018. Stock Market Forecast
Using Multivariate Analysis with Bidirectional and Stacked (LSTM, GRU). In: 21st
Saudi Computer Society National Computer Conference, NCC 2018. Institute of
Electrical and Electronics Engineers Inc.
Böhmer, M., Hecht, B., Schöning, J., Krüger, A. and Bauer, G., 2011. Falling asleep
with Angry Birds, Facebook and Kindle: A large scale study on mobile application
usage. Mobile HCI 2011 - 13th International Conference on Human-Computer
Interaction with Mobile Devices and Services, pp.47–56.
Chai, T. and Draxler, R.R., 2014. Root mean square error (RMSE) or mean absolute
error (MAE)? -Arguments against avoiding RMSE in the literature. Geoscientific
Model Development, 7(3), pp.1247–1250.
Chandra, V., 2015. Comparison between Various Software Development
Methodologies. International Journal of Computer Applications, 131(9), pp.7–10.
Chau, T.M., Suen, H.P., To, C.L. and Wong, C.K., 2019. Stock Price Prediction App
using Machine Learning Models Optimized by Evolution. pp.2018–2019.
Cheng, J., Dong, L. and Lapata, M., 2016. Long short-term memory-networks for
machine reading. EMNLP 2016 - Conference on Empirical Methods in Natural
Language Processing, Proceedings, pp.551–561.
Chowdhury, A.E., Bhowmik, A., Hasan, H. and Rahim, M.S., 2018. Analysis of the
Veracities of Industry Used Software Development Life Cycle Methodologies.
[online] pp.1–7. Available at: <http://arxiv.org/abs/1805.08631>.
101
Eason, O.K., 2016. Information Systems Development Methodologies Transitions:
An Analysis of Waterfall to Agile Methodology. University of New Hampshire,
[online] pp.1–23. Available at:
<http://scholars.unh.edu/honors%0Ahttp://scholars.unh.edu/honors>.
Fatimah, D.D.S., Supriatna, A.D. and Kurniawati, R., 2018. Design of personnel
information systems using rapid application development method. MATEC Web of
Conferences, 197.
Hegazy, O., Soliman, O.S. and Salam, M.A., 2014. A Machine Learning Model for
Stock Market Prediction. International Journal for Research in Applied Science and
Engineering Technology, 8(6), pp.209–216.
Iyawa, G.E., Herselman, M.E. and Coleman, A., 2016. Customer interaction in
software development: A comparison of software methodologies deployed in
Namibian software firms. Electronic Journal of Information Systems in Developing
Countries, 77(1), pp.1–13.
Khare, K., Darekar, O., Gupta, P. and Attar, V.Z., 2017. Short term stock price
prediction using deep learning. RTEICT 2017 - 2nd IEEE International Conference
on Recent Trends in Electronics, Information and Communication Technology,
Proceedings, 2018-Janua, pp.482–486.
Kiyosaki, R.T., 2000. Rich Dad Poor Dad: What the Rich Teach Their Kids About
Money – That the Poor and Middle Class Do Not. Plata Publishing, LLC.
Kulkarni, M., Jadha, A. and Dhingra, D., 2020. Time Series Data Analysis for Stock
Market Prediction. SSRN Electronic Journal, (2019), pp.1–5.
Kumar, I., Dogra, K., Utreja, C. and Yadav, P., 2018. A Comparative Study of
Supervised Machine Learning Algorithms for Stock Market Trend Prediction.
Proceedings of the International Conference on Inventive Communication and
Computational Technologies, ICICCT 2018, (Icicct), pp.1003–1007.
102
Kumar, J., Goomer, R. and Singh, A.K., 2018. Long Short Term Memory Recurrent
Neural Network (LSTM-RNN) Based Workload Forecasting Model for Cloud
Datacenters. Procedia Computer Science, [online] 125, pp.676–682. Available at:
<https://doi.org/10.1016/j.procs.2017.12.087>.
Montgomery, D.C., Jennings, C.L. and Kulahci, M., 2016. Introduction Time Series
Analysis and Forecasting. [online] p.671. Available at:
<https://d1wqtxts1xzle7.cloudfront.net/38610334/Introduction-to-Time-Series-
Analysis-and-Forecasting-2015.pdf?1440890728=&response-content-
disposition=inline%3B+filename%3DIntroduction_to_Time_Series_Analysis_and.p
df&Expires=1594222324&Signature=YIPmU4pxKh>.
Obthong, M., Tantisantiwong, N., Jeamwatthanachai, W. and Wills, G., 2020. A
Survey on Machine Learning for Stock Price Prediction: Algorithms and Techniques.
pp.63–71.
Patel, J., Shah, S., Thakkar, P. and Kotecha, K., 2015. Predicting stock and stock
price index movement using Trend Deterministic Data Preparation and machine
learning techniques. Expert Systems with Applications, 42(1), pp.259–268.
Pradeepkumar, D. and Ravi, V., 2017. Forecasting financial time series volatility
using Particle Swarm Optimization trained Quantile Regression Neural Network.
[online] Applied Soft Computing Journal, Elsevier B.V. Available at:
<http://dx.doi.org/10.1016/j.asoc.2017.04.014>.
Rahman, M.O., Hossain, M.S., Junaid, T.-S., Forhad, M.S.A. and Hossen, M.K.,
2019. Predicting Prices of Stock Market using Gated Recurrent Units (GRUs) Neural
Networks. International Journal of Computer Science and Network Security (IJCSNS)
(Thomson Reuters), 19(1), pp.213–222.
Ristoski, P. and Paulheim, H., 2016. Semantic Web in data mining and knowledge
discovery: A comprehensive survey. Journal of Web Semantics, 36, pp.1–22.
103
Roncoroni, A., Fusai, G. and Cummins, M., 2015. Handbook of multi-commodity
markets and products: Structuring, trading and risk management. [online] Available
at:
<https://books.google.com/books?hl=en&lr=&id=bd8bBgAAQBAJ&oi=fnd&pg=P
R19&dq=Handbook+of+multi-
commodity+markets+and+products:+structuring,+trading+and+risk+management&o
ts=dp7_bhPPy8&sig=a86LW9nT_WdILAKjICJC_IHugfI> [Accessed 22 Aug.
2020].
Roondiwala, M., Patel, H. and Varma, S., 2015. Predicting Stock Prices Using
LSTM. International Journal of Science and Research, [online] 6(4), pp.2319–7064.
Available at: <https://www.quandl.com/data/NSE>.
Selvin, S., Vinayakumar, R., Gopalakrishnan, E.A., Menon, V.K. and Soman, K.P.,
2017. Stock price prediction using LSTM, RNN and CNN-sliding window model.
2017 International Conference on Advances in Computing, Communications and
Informatics, ICACCI 2017, 2017-Janua, pp.1643–1647.
Srivastava, A., Bhardwaj, S. and Saraswat, S., 2017. SCRUM model for agile
methodology. Proceeding - IEEE International Conference on Computing,
Communication and Automation, ICCCA 2017, 2017-Janua, pp.864–869.
Svetunkov, I. and Petropoulos, F., 2018. Old dog, new tricks: a modelling view of
simple moving averages. International Journal of Production Research, 56(18),
pp.6034–6047.
Wang, W. and Lu, Y., 2018. Analysis of the Mean Absolute Error (MAE) and the
Root Mean Square Error (RMSE) in Assessing Rounding Model. IOP Conference
Series: Materials Science and Engineering, 324(1).
104
APPENDICES
Appendix A: User Interface Design Iteration 1
105