Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
9 views

Stock Analysis Prediction Python Report

The document discusses the application of machine learning, particularly Long Short-Term Memory (LSTM) networks, for predicting stock prices based on historical data and various market indicators. It emphasizes the importance of developing a real-time prediction system to assist investors in making informed decisions amidst market volatility. The project aims to enhance prediction accuracy and operational efficiency by leveraging advanced technologies and methodologies in stock market analysis.

Uploaded by

dhanumb1983
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Stock Analysis Prediction Python Report

The document discusses the application of machine learning, particularly Long Short-Term Memory (LSTM) networks, for predicting stock prices based on historical data and various market indicators. It emphasizes the importance of developing a real-time prediction system to assist investors in making informed decisions amidst market volatility. The project aims to enhance prediction accuracy and operational efficiency by leveraging advanced technologies and methodologies in stock market analysis.

Uploaded by

dhanumb1983
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 83

Stock Market Analysis

Summary
With recent research trends, a popular approach is to apply machine learning algorithms to
learn from historical price data, thereby being able to predict future prices. The scale
demonstrates predictive power on historical stock price data that outperforms other methods
due to its suitability for this data type.

Stock Price Prediction using machine learning is the process of predicting the future value of
a stock traded on a stock exchange for reaping profits. With multiple factors involved in
predicting stock prices, it is challenging to predict stock prices with high accuracy, and this is
where machine learning plays a vital role.

Treating stock data as time-series, one can use past stock prices (and other parameters) to
predict the stock prices for the next day or week. Machine learning models such as Recurrent
Neural Networks (RNNs) or LSTMs are popular models applied to predicting time series data
such as weather forecasting, election results, house prices, and, of course, stock prices. The
idea is to weigh out the importance of recent and older data and determine which parameters
affect the “current” or “next” day prices the most. The machine learning model assigns
weights to each market feature and determines how much history the model should look at
for stock market prediction using machine learning project to work out.

Financial markets provides an essential platform for financial transactions and investments to
happen and the it allows people to have the opportunity of making their investment grow.
Therefore, stock market prediction is essential in helping the investors make correct and
profitable decisions. LSTM performed better than the Regression-based model when training
on a relative small dataset, SVM performed the best among SVM, CNN and LSTM in
predicting future prices based on large stock datasets and the combination of CNN and LSTM
also produces better results. It is recommended that people try to choose suitable data sets
with different time spans and investigate the characteristics of the data before building a
model. At the same time, a computationally efficient method is used when training the model,
and it is recommended to apply the model to the current and training experiments. So as to
avoid the over-fitting problem in the market forecasting process, so as to improve the process
efficiency and forecasting accuracy.

1
Stock Market Analysis

2. Introduction

In today's fast-paced and ever-evolving financial landscape, the ability to make informed and
timely investment decisions is paramount. To this end, predictive tools have become
indispensable for traders, investors, and financial analysts. The integration of cutting-edge
technologies and machine learning algorithms has redefined the way we approach stock
market prediction. Among these technologies, Long Short-Term Memory (LSTM) networks,
a variant of recurrent neural networks, have gained prominence for their exceptional
capabilities in capturing intricate temporal patterns within financial time series data

This project introduces a robust and innovative approach to stock market prediction, utilizing
Python and LSTM to forecast stock prices and trends in real-time. The main objective of this
endeavour is to develop a real-time prediction system that empowers traders and investors
with up-to-the-minute insights, enabling them to make well-informed decisions in the highly
dynamic stock market environment.

The significance of this project lies in its potential to revolutionize the investment landscape,
providing a predictive tool that adapts to changing market conditions and offers a competitive
advantage. With the power of LSTM and the versatility of Python, we aim to harness the
historical stock price data, news sentiment, and relevant financial indicators to create a
predictive model that can respond to fluctuations in real time, providing timely
recommendations and insights.

2
Stock Market Analysis

2.1 Background Overview


The stock market is a complex and dynamic financial ecosystem, influenced by a multitude
of factors such as economic indicators, investor sentiment, news events, and more. Accurate
and timely prediction of stock prices is crucial for traders, investors, and financial institutions
to make informed decisions. Utilizing advanced technologies like Long Short-Term Memory
(LSTM) and Python, we aim to develop a real-time stock market prediction system that can
assist stakeholders in making data-driven choices. A stock prediction analysis project
involves forecasting the future performance of financial securities, such as stocks, using
various quantitative and qualitative methods. These projects typically leverage historical data,
market trends, and advanced computational models to generate predictions. The project
focuses on forecasting stock market behaviour to assist investors, traders, and financial
analysts in making informed decisions. By analysing historical data, market trends, and other
influencing factors, these projects aim to predict stock prices, trends, or volatility using
statistical, machine learning, and deep learning techniques.

3
Stock Market Analysis

2.1.1. The organization profile

 Stock Market Analysis


 To develop a sophisticated, data-driven model for predicting stock prices and market
trends, assisting investors in making better trading decisions.

 Automation and Efficiency


 Automating the stock prediction process to save time and reduce errors, helping
individuals and institutional investors gain real-time insights.
 Accuracy Improvement

 Improving the accuracy of stock price predictions by using machine learning


techniques, historical data analysis, and real-time market data.

 Market Analysis

 Monitoring and analyzing stock market trends.


 Assessing macroeconomic indicators and their effects on stock performance.

 Predictive Modeling

 Building, training, and optimizing statistical and AI-based models to predict stock
prices and market trends.

 Technology Development

 Developing proprietary tools, platforms, or APIs for automated stock prediction and
trading.

 Portfolio Management

 Assisting clients in optimizing their investment portfolios using prediction insights.

 Research and Innovation

 Conducting research on new methodologies for financial forecasting.


 Publishing white papers and reports on stock prediction models.

 Client Services

 Providing analytics reports, dashboards, and consultation services.

4
Stock Market Analysis

2.1.2. Study on existing system

In the finance world stock trading is one of the most important activities. Stock market
prediction is an act of trying to determine the future value of a stock other financial
instrument traded on a financial exchange. This paper explains the prediction of a stock using
Machine Learning. The technical and fundamental or the time series analysis is used by the
most of the stockbrokers while making the stock predictions. The programming language is
used to predict the stock market using machine learning is Python. we propose a Machine
Learning (ML) approach that will be trained from the available stocks data and gain
intelligence and then uses the acquired knowledge for an accurate prediction. In this context
this study uses a machine learning technique called Support Vector Machine (SVM) to
predict stock prices for the large and small capitalizations and in the three different markets,
employing prices with both daily and upto-the-minute frequencies.

Stock prediction analysis systems are rooted in financial theories, statistical modeling, and
advancements in computational intelligence. This theoretical study highlights the underlying
concepts, methodologies, and frameworks employed in existing systems.

Existing systems in stock prediction rely on diverse theoretical foundations, ranging from
classical statistical methods to advanced machine learning and deep learning. These systems
attempt to balance the challenges of financial market unpredictability with innovative
methodologies to extract meaningful insights. A strong theoretical understanding forms the
backbone of effective predictive systems, guiding both development and evaluation
processes.

5
Stock Market Analysis

2.2. Statement of the problem

The objective of this project is to design and implement a real-time stock market prediction
system, employing LSTM-based deep learning models and Python programming. The
primary problem to address can be summarized as follows: To develop a system capable of
predicting stock price movements (including price direction and magnitude) for a selected set
of stocks in real-time, and to provide insights that enable investors, traders, and financial
analysts to make informed decisions. The stock market is inherently volatile and influenced
by numerous unpredictable factors, including economic indicators, company performance,
geopolitical events, and market sentiment. Despite significant advancements in financial
markets, accurately predicting stock prices remains a challenging problem, especially for
individual investors and financial institutions that rely on historical data to forecast future
market trends.

In the current landscape, investors often rely on traditional methods of stock analysis, such as
technical analysis (based on historical price movements) and fundamental analysis (focused
on company financials). While these approaches have proven useful to some extent, they are
limited in their ability to account for complex, non-linear relationships and emerging trends
in the market. Moreover, they may not fully leverage big data or machine learning techniques
that have been successfully applied in other industries.

6
Stock Market Analysis

3. System Analysis

System analysis is a crucial phase in a stock prediction project, focusing on understanding the
problem domain, analysing the requirements, and designing the system to achieve its
objectives effectively.

System analysis ensures that the stock prediction project aligns with its objectives, technical
capabilities, and user requirements. By addressing functional and non-functional needs,
evaluating risks, and defining a scalable architecture, the system is well-positioned to deliver
meaningful insights and empower financial decision-making.

System analysis is a key step in the development of a stock prediction analysis project, as it
involves studying the current environment, identifying requirements, and designing a solution
that addresses the project's objectives. This document provides a detailed system analysis for
a stock prediction analysis project.

In the finance world stock trading is one of the most important activities. Stock market
prediction is an act of trying to determine the future value of a stock other financial
instrument traded on a financial exchange. This paper explains the prediction of a stock using
Machine Learning. The technical and fundamental or the time series analysis is used by the
most of the stockbrokers while making the stock predictions. The programming language is
used to predict the stock market using machine learning is Python. we propose a Machine
Learning (ML) approach that will be trained from the available stocks data and gain
intelligence and then uses the acquired knowledge for an accurate prediction. In this context
this study uses a machine learning technique called Support Vector Machine (SVM) to
predict stock prices for the large and small capitalizations and in the three different markets,
employing prices with both daily and upto-the-minute frequencies.

7
Stock Market Analysis

3.1. Preliminary Investigation

This project will investigate how different machine learning techniques can be used and will
affect the accuracy of stock price predictions. Different models, from linear regression to
dense and recurrent neural networks are tested. Different hyperparameters are also tuned for
better performance These arch space for all neural network architectures and hyperparameter
combinations is huge, and with limited time in conducting this project, apart from manually
trying combinations, the team optimizes the models with evolution algorithm, replicating
AutoML techniques from other researches with promising results in the financial context.

The project aims to introduce and democratize the latest machine learning technologies for
retail investors. No prediction is 100% accurate. Therefore, the upper bound and lower bound
of the stock prices will be displayed to illustrate the trading range the investors should be
looking at. This application serves as a supplementary quantitative tool for investors to see
the market at a different perspective with the help of technology. This project is divided into
2 parts, namely are search component and an application component, aiming to provide retail
investors with stock price predictions using different machine learning models in a good user
experience way for reference.

8
Stock Market Analysis

4. Feasibility Study

A feasibility study evaluates the practicality and potential success of a stock prediction
analysis project by examining technical, operational, economic, legal, and scheduling factors.
This ensures the project is viable, cost-effective, and aligned with its objectives before
significant resources are invested.

Purpose of the Feasibility Study is to assess whether the project is achievable with available
resources and technologies, to identify potential challenges and risks early, to ensure
alignment with user requirements and project goals, to provide a foundation for decision-
making on project initiation.

A feasibility study evaluates the practicality and potential success of the stock prediction
analysis project by considering technical, economic, operational, legal, and scheduling
aspects. This theoretical exploration ensures that the project is viable and that the resources
required for its implementation align with the anticipated outcomes.

Legal feasibility addresses the compliance of the project with data privacy laws and financial
regulations. With the system accessing vast amounts of sensitive data, adherence to laws such
as the General Data Protection Regulation (GDPR) and the California Consumer Privacy Act
(CCPA) is paramount. Additionally, the project must secure permissions for the use of third-
party data sources and ensure that intellectual property rights are respected, particularly in the
deployment of proprietary algorithms.

The scheduling feasibility considers the timeline for project completion. With appropriate
resource allocation, the project can achieve milestones such as data collection, model
development, and system deployment within a reasonable timeframe. Potential delays, like
challenges in data pre-processing or model training, could be mitigated by adopting agile
development practices and leveraging scalable computational resources.

4.1. Technical Feasibility

In the technical domain, the project leverages advanced tools and technologies. Modern
machine learning frameworks like TensorFlow, PyTorch, and Scikit-learn provide robust

9
Stock Market Analysis

capabilities for building predictive models. These frameworks, combined with access to
reliable financial data sources such as Alpha Vantage or Quandl, ensure the technical
soundness of the project. The availability of high-performance computational infrastructure,
either on-premises or via cloud platforms like AWS and Google Cloud, further supports the
project's scalability and computational needs. However, challenges such as the need for
skilled personnel in data science and financial analytics highlight the importance of
assembling a proficient team.

4.2. Economic Feasibility

Economic feasibility examines the financial implications of the project. Initial costs include
salaries for the development team, data acquisition fees, and infrastructure expenses. Despite
these upfront investments, the project promises significant financial returns. Revenue streams
could include subscription services for users, partnerships with brokerage firms, or licensing
predictive tools to financial institutions. The system's ability to enhance decision-making
efficiency and accuracy adds economic value, justifying the project’s costs in the long term.

4.3. Operational Feasibility

From an operational perspective, the project's success depends on its ability to integrate
seamlessly into the workflows of traders, investors, and financial analysts. The proposed
system should feature user-friendly dashboards for data visualization and actionable insights.
It must also provide compatibility with existing trading platforms to ensure ease of use. The
project’s operational viability is reinforced by its capacity to offer real-time predictions and
alerts, which are critical for decision-making in dynamic stock markets.

10
Stock Market Analysis

5. Methodology Applied
The methodology for a stock prediction analysis project using machine learning typically
involves a systematic approach that includes data collection, pre-processing, model selection,
training, evaluation, and deployment. Below is an outline of the theoretical methodology
applied in such projects.

The first step is to define the project's objectives clearly. Stock prediction involves
forecasting future stock prices or trends based on historical and alternative data.

 Predicting stock prices for specific time horizons (e.g., daily, weekly, or monthly).
 Identifying market trends (e.g., bullish or bearish).
 Providing actionable insights for traders and investors.

The quality and quantity of data significantly impact the project's success. Various data
sources are utilized:

 Historical Data: Stock prices, trading volumes, and market indices from sources like
Yahoo Finance or Alpha Vantage.
 Technical Indicators: Features like moving averages (MA), relative strength index
(RSI), and Bollinger Bands are derived from historical data.
 Alternative Data: News sentiment, social media trends, and macroeconomic indicators
are used to enhance predictions.
 Real-Time Data: Streaming data for real-time predictions and analysis.

APIs, web scraping, or data subscription services facilitate data acquisition.

Raw data is often incomplete or noisy and must be cleaned and transformed for effective
modeling. The preprocessing steps include:

 Handling Missing Values: Using techniques like interpolation or mean imputation to


fill gaps in data.
 Normalization: Scaling data to a uniform range (e.g., [0,1]) to prevent features with
large magnitudes from dominating the model.

11
Stock Market Analysis

 Feature Engineering: Creating new features like lagged values, rolling averages, or
sentiment scores to improve predictive power.

6. Software and Hardware Requirements and Specifications

HARDWARE REQUIREMENTS

 Hardware :Processor Intel dual core and above


 Clock speed :3.0 GHz
 RAM size :512 MB
 Hard Disk capacity :400 GB
 Monitor type :15 inch color monitor

SOFTWARE REQUIREMENTS

 Operating System :Windows XP, Windows 7, Windows 8,Windows


10
 Application :HTML, CSS, JS, Python, Flask
 Browser :Google chrome, Firefox
 Database :MySQL, Google Firestore.
 Documentation :MS-Office

12
Stock Market Analysis

7. System Design

The architecture of the system follows a client-server model , where the server and the client
are loosely coupled.

After relevant stock data are retrieved from the third-party data provider through the cloud,
the backend pre-processes the data and builds the models. After that, predictions are made
and the prediction results will be stored on another cloud, which can be retrieved from the
mobile application. The advantages of the loosely coupled architecture include improved
scalability and ease of collaboration. The workload for the cloud which serves the models and
the one which serves the mobile application will be very different. One cloud serves the
model prediction results, which are simple text files; another cloud serves the mobile
application with a lot of rich user content such as images and large UI libraries. Having two
clouds to adapt to two different demand patterns is more efficient, especially since cloud
providers these days usually serve content on demand. Also, these parathion allows different
team members in the team to focus on different parts after agreeing on a common interface. It
speeds up development as team members responsible for different parts of the system do not
need to take care of the under lying implementation details. Also, it is easier to swap out

13
Stock Market Analysis

different components, e.g. to replace the models the team could simply make changes to the
backend, while the frontend remains unaffected.

7.1. Flow Chart

Users are separated into two groups, normal users and advanced users. For users that would
like to know about the historical (test set) performance of a model and more information
behind the machine learning models like the architecture and inputs, they can enable
advanced user mode in the settings page to view those details in each individual stock page.

14
Stock Market Analysis

7.1.2. E-R Diagram

The Entity-Relationship (ER) model was originally proposed by Peter in 1976


[Chen76] as a way to unify the network and relational database views. Simply
stated the ER model is a conceptual data model that views the real world as
entities and relationships. A basic component of the model is the Entity-
Relationship diagram which is used to visually represent data objects. Since Chen
wrote his paper the model has been extended and today it is commonly used for
database design For the database designer, the utility of the ER model is:

 It maps well to the relational model. The constructs used in the ER model
can easily be transformed into relational tables.
 It is simple and easy to understand with a minimum of training. Therefore,
the model can be used by the database designer to communicate the design
to the end user.
 In addition, the model can be used as a design plan by the database
developer to implement a data model in specific database management
software.
Connectivity and Cardinality

The basic types of connectivity for relations are: one-to-one, one-to-many, and
many-to-many. A one-to-one (1:1) relationship is when at most one instance of a
entity A is associated with one instance of entity B. For example, "employees in
the company are each assigned their own office. For each employee there exists a
unique office and for each office there exists a unique employee.

A one-to-many (1:N) relationships is when for one instance of entity A, there are
zero, one, or many instances of entity B, but for one instance of entity B, there is
only one instance of entity A. An example of a 1:N relationships is
a department has many employees

Each employee is assigned to one department

A many-to-many (M:N) relationship, sometimes called non-specific, is when for


one instance of entity A, there are zero, one, or many instances of entity B and for

15
Stock Market Analysis

one instance of entity B there are zero, one, or many instances of entity A. The
connectivity of a relationship describes the mapping of associated
ER Notation

There is no standard for representing data objects in ER diagrams. Each


modeling methodology uses its own notation. The original notation used by Chen
is widely used in academics texts and journals but rarely seen in either CASE
tools or publications by non-academics. Today, there are a number of notations
used; among the more common are Bachman, crow's foot, and IDEFIX.

All notational styles represent entities as rectangular boxes and relationships


as lines connecting boxes. Each style uses a special set of symbols to represent the
cardinality of a connection. The notation used in this document is from Martin.
The symbols used for the basic ER constructs are:

 Entities are represented by labelled rectangles. The label is the name of the
entity. Entity names should be singular nouns.
 Relationships are represented by a solid line connecting two entities. The name
of the relationship is written above the line. Relationship names should be verbs
 Attributes, when included, are listed inside the entity rectangle. Attributes
which are identifiers are underlined. Attribute names should be singular nouns.
 Cardinality of many is represented by a line ending in a crow's foot. If the
crow's foot is omitted, the cardinality is one.
 Existence is represented by placing a circle or a perpendicular bar on the line.
Mandatory existence is shown by the bar (looks like a 1) next to the entity for an
instance is required. Optional existence is shown by placing a circle next to the
entity that is optional.

16
Stock Market Analysis

ADMIN

New Staff

View Staff
Admin
View Users

View Reports

Staff

View

View Profile
Staff
View Users

View Reports

Customer

View Profile

Customer Stock Analysis


Prediction

View Reports

17
Stock Market Analysis

Sequence Diagram
Sequence diagram and collaboration diagram are called INTERACTION
DIAGRAMS. An interaction diagram shows an interaction, consisting of set of
objects and their relationship including the messages that may be dispatched
among them.
A sequence diagram is an introduction that empathizes the time ordering of
messages. Graphically a sequence diagram is a table that shows objects arranged
along the X-axis and messages ordered in increasing time along the Y-axis.

A Use case is a description of set of sequence of actions. Graphically it is


rendered as an ellipse with solid line including only its name. Use case diagram
is a behavioral diagram that shows a set of use cases and actors and their
relationship. It is an association between the use cases and actors. An actor
represents a real-world object. Primary Actor – Sender, Secondary Actor
Receiver.

7.1.3. Structure Chart

First of all, users need to login to use the system, as there will be customization options for
different users. Since users might not want to create a separate account just for our
application, it will more convenient if users can log in with their existing social media
accounts. In particular, Facebook login is a good option, since there are over 2 billion users
worldwide. Thus, it might be possible to reach a larger market by adopting Facebook login.
Only the very basic user information like the user name will be collected by the system. For

18
Stock Market Analysis

normal users (advanced user mode disabled), after logging into the system, they can view the
stock list and search from it by stock name.

DFD LEVEL 0

Add New Staffs


ADMIN
Stock Analysis
Prediction

DFD LEVEL 1

View Users, Staffs


ADMIN
Stock Analysis
Prediction

DFD LEVEL 2
View Reports
ADMIN
Stock Analysis
Prediction

DATA FLOW DIAGRAMS:


The DFD takes an input-process-output view of a system i.e. data objects
flow into the software, are transformed by processing elements, and resultant data
objects flow out of the software.

Data objects represented by labeled arrows and transformation are


represented by circles also called as bubbles. DFD is presented in a hierarchical
fashion i.e. the first data flow model represents the system as a whole. Subsequent
DFD refine the context diagram (level 0 DFD), providing increasing details with
each subsequent level.

The DFD enables the software engineer to develop models of the


information domain & functional domain at the same time. As the DFD is refined

19
Stock Market Analysis

into greater levels of details, the analyst performs an implicit functional


decomposition of the system. At the same time, the DFD refinement results in a
corresponding refinement of the data as it moves through the processes that
embody the applications.

A context-level DFD for the system the primary external entities produce
information for use by the system and consume information generated by the
system. The labeled arrow represents data objects or object hierarchy.

20
Stock Market Analysis

7.1.4. Module Descriptions

1. Flask: Flask is a high-level Python web framework that enables rapid development of
secure and maintainable websites. It provides a powerful set of tools for building web
applications, including a robust ORM (Object-Relational Mapping) system, automatic
admin interface, and built-in security features.

2. Python: Python is a high-level programming language used for a wide range of


purposes, including web development. It is known for its ease of use, simplicity, and
versatility
3. HTML: Hypertext Markup Language (HTML) is the standard markup language used
to create web pages. It provides a structure for content on the internet, allowing
developers to define and organize the various elements on a webpage.
4. CSS: Cascading Style Sheets (CSS) is a language used for describing the presentation
of a document written in HTML. It provides a way to add style and design to a
webpage, including colors, fonts, and layouts.
5. Java Script: JavaScript (JS) is a programming language used primarily for developing
interactive and dynamic front-end web applications. It allows for the creation of
responsive and user friendly websites.
6. DBSql: DBSql is a SQL database system that provides a flexible and scalable solution
for storing and retrieving data. It is designed for handling large volumes of data and
provides high availability and automatic scaling.

21
Stock Market Analysis

8.Coding

Index.html

{% extends 'commonheader.html' %}

<html lang="en">

<head>

<meta charset="utf-8">

<meta content="width=device-width, initial-scale=1.0" name="viewport">

<meta content="" name="description">

<meta content="" name="keywords">

</head>

<body>

{% block content %}

<!-- ======= Hero Section ======= -->

<section id="hero" class="d-flex justify-cntent-center align-items-center">

<div id="heroCarousel" data-bs-interval="5000" class="container carousel carousel-fade"

data-bs-ride="carousel">

<!-- Slide 1 -->

<div class="carousel-item active">

<div class="carousel-container">

<h2 class="animate__animated animate__fadeInDown">Welcome to

22
Stock Market Analysis

<span>QuantTrade Hub</span></h2>

<p class="animate__animated animate__fadeInUp">QuantTrade Hub using

Algorithmic Trading helps you discover the future value of company stock and other

financial assets traded on an exchange. The entire idea of predicting stock prices is to gain

significant profits.</p>

</div>

</div>

<!-- Slide 2 -->

<div class="carousel-item">

<div class="carousel-container">

<h2 class="animate__animated animate__fadeInDown">Welcome to

<span>QuantTrade Hub</span></h2>

<p class="animate__animated animate__fadeInUp">QuantTrade Hub has been a

critical area of research and is one of the top applications of machine learning. This tutorial

will teach you how to perform stock price prediction using machine learning and deep

learning techniques.</p>

</div>

</div>

<!-- Slide 3 -->

<div class="carousel-item">

<div class="carousel-container">

23
Stock Market Analysis

<h2 class="animate__animated animate__fadeInDown">Welcome to

<span>QuantTrade Hub</span></h2>

<p class="animate__animated animate__fadeInUp">A stock market is a public market

where you can buy and sell shares for publicly listed companies. The stocks, also known as

equities, represent ownership in the company. The stock exchange is the mediator that allows

the buying and selling of shares.</p>

</div>

</div>

<a class="carousel-control-prev" href="#heroCarousel" role="button" data-bs-

slide="prev">

<span class="carousel-control-prev-icon bx bx-chevron-left" aria-

hidden="true"></span>

</a>

<a class="carousel-control-next" href="#heroCarousel" role="button" data-bs-

slide="next">

<span class="carousel-control-next-icon bx bx-chevron-right" aria-

hidden="true"></span>

</a>

</div>

</section><!-- End Hero -->

{% endblock %}

24
Stock Market Analysis

</body>

</html>

Main.py

import os.path

import time

import datetime

import pandas as pd

import yfinance as yf

from flask import Flask, request, redirect, render_template, session

import firebase_admin

import random

from firebase_admin import credentials, firestore

cred = credentials.Certificate("key.json")

firebase_admin.initialize_app(cred)

app = Flask(__name__)

app.secret_key = "StockAnalysisProject@123"

UPLOAD_FOLDER = 'static/uploads/'

app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024

ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])

#companies = ["Accenture","IBM","Infosys","AMZN", "MSFT"]

compsigns = ["TCS.NS","HDFCBANK.NS","INFY.NS",

"HINDUNILVR.NS","ICICIBANK.NS","SBIN.NS","BAJAJFINSV.NS",

"WIPRO.NS","BHARTIARTL.NS","ITC.NS","MARUTI.NS",

25
Stock Market Analysis

"LT.NS","HCLTECH.NS","AXISBANK.NS","SUNPHARMA.NS",

"NTPC.NS","TECHM.NS","INDUSTOWER.NS","MUTHOOTFIN.NS",

"IOB.NS","BOSCHLTD.NS","MPHASIS.NS"]

compnames=["TCS","HDFC Bank","Infosys",

"Hindustan Unilever","ICICI Bank","State Bank Of India","Bajaj Finance",

"Wipro","Bharti Airtel","ITC","Maruthi Suzuki India Ltd",

"Larsen & Toubro","HCL","Axis bank Ltd","Sun Pharmaceuticals",

"NTPC Ltd","TechMahindra Ltd","Indus Tower Ltd","Muthoot Finance Ltd ",

"Indian Overseas Bank","Bosch Ltd","Mphasis Ltd"]

@app.route('/userchecktrade1', methods=["POST","GET"])

def userchecktrade1():

try:

msg=""

today = datetime.date.today()

#format_data = "%y-%m-%d"

#today = datetime.strptime(str(today), format_data)

if(request.method=="POST"):

compname = request.form.get("cname")

fromdate = request.form.get("fromdate")

todate = request.form.get("todate")

print("From Date : ", fromdate, " To Date : ", todate)

filename = "File"+str(round(time.time()))+".csv"

#file = request.files['file']

#file.save(os.path.join(app.config['UPLOAD_FOLDER'],filename))

#session['filename']=filename

26
Stock Market Analysis

session['compname'] = compname

value_index=-1

if compname in compnames:

value_index = compnames.index(compname)

if(value_index>=0):

compsign=compsigns[value_index]

df = yf.download(compsign, start=fromdate, end=todate)

information = yf.Ticker(compsign)

df.to_csv(os.path.join(app.config['UPLOAD_FOLDER'],filename))

# whole python dictionary is printed here

#print("Details : ", information.info)

time.sleep(3)

dataframe = pd.read_csv(os.path.join(app.config['UPLOAD_FOLDER'],filename))

print("Data Frame from CSV : \n", dataframe)

#for key, value in information.info.items():

# print(key , " : ", value)

print("Keys : ",df.keys())

#print("Open Values : ", df['Low'])

print("Index : \n", dataframe.index)

print("Close : \n", dataframe['Close'])

columns = ["Price", "Open", "High", "Low", "Close", "Adj Close", "Volume"]

data = []

for ind in dataframe.index:

print("Index : ", ind)

if(ind>1):

27
Stock Market Analysis

temp = []

#temp.append(str(ind-2))

for col in columns:

if(col == "Price"):

temp.append(dataframe[col][ind])

else:

formatvalue = "{:.2f}".format(float(dataframe[col][ind]))

temp.append(formatvalue)

print("Temp : ", temp)

data.append(temp)

print("Data : \n", data)

#print("Len : ", len(data))

dbdata = []

x = len(data) - 1

lowcount, highcount = 0, 0

openvaluedic, closevaluedic = {}, {}

while (x >= 0):

stockdate = data[x][0]

str1 = stockdate.split("-")

stockdate1 = str1[0] + "-" + str1[1]

print("Stock Date : ", stockdate1)

if (stockdate1 in openvaluedic.keys()):

openvaluedic[stockdate1] = int(openvaluedic[stockdate1]) + int(float(data[x]

[1]))

else:

28
Stock Market Analysis

openvaluedic[stockdate1] = int(float(data[x][1]))

if (stockdate1 in closevaluedic.keys()):

closevaluedic[stockdate1] = int(closevaluedic[stockdate1]) + int(float(data[x]

[4]))

else:

closevaluedic[stockdate1] = int(float(data[x][4]))

if (int(float(data[x][1])) < int(float(data[x][4]))):

highcount += 1

else:

lowcount += 1

dbdata.append(data[x])

x -= 1

print("High Count : ", highcount, " Low Count : ", lowcount)

# print("Open List : ", openvaluedic)

# print("Close List : ", closevaluedic)

openvaluelist, closevaluelist = [], []

for key, value in openvaluedic.items():

temp = {}

temp["label"] = key

temp["y"] = value

#print("Temp : ", temp)

openvaluelist.append(temp)

for key, value in closevaluedic.items():

29
Stock Market Analysis

temp = {}

temp["label"] = key

temp["y"] = value

closevaluelist.append(temp)

userid = session['userid']

uname = session['username']

compname = session['compname']

status = ""

print("High Count : ", highcount, " Low Count : ", lowcount)

if (highcount > lowcount):

status = "GoodTime"

msg = "From the given data, it's good to invest in " + str(compname)

else:

status = "Risky"

msg = "From the given data, it's risky to invest in " + str(compname)

id = str(random.randint(1000, 9999))

json = {'id': id, 'UserId': userid,

'CompanyName': compname, 'UserName': uname, 'Status': status,

'HighCount': highcount, 'LowCount': lowcount}

db = firestore.client()

newuser_ref = db.collection('newpredict')

id = json['id']

newuser_ref.document(id).set(json)

columns = ["Date", "Open", "High", "Low", "Close", "Adj Close", "Volume"]

30
Stock Market Analysis

return render_template("userchecktrade.html",

companies=compnames, checktrade=True,

data=dbdata, columns=columns,

msg=msg, today=today,

openvaluelist=openvaluelist,

closevaluelist=closevaluelist,

information=information.info)

else:

msg="Sorry Something went wrong"

return render_template("userchecktrade.html",

companies=compnames,checktrade=True,

msg=msg, today=today)

except Exception as e:

print("Exception : ", e)

return str(e)

8.1. Module wise coding with comments

Index.html

{% extends 'commonheader.html' %}

<html lang="en">

<head>

<meta charset="utf-8">

<meta content="width=device-width, initial-scale=1.0" name="viewport">

31
Stock Market Analysis

<meta content="" name="description">

<meta content="" name="keywords">

</head>

<body>

{% block content %}

<!-- ======= Hero Section ======= -->

<section id="hero" class="d-flex justify-cntent-center align-items-center">

<div id="heroCarousel" data-bs-interval="5000" class="container carousel carousel-fade"

data-bs-ride="carousel">

<!-- Slide 1 -->

<div class="carousel-item active">

<div class="carousel-container">

<h2 class="animate__animated animate__fadeInDown">Welcome to

<span>QuantTrade Hub</span></h2>

<p class="animate__animated animate__fadeInUp">QuantTrade Hub using

Algorithmic Trading helps you discover the future value of company stock and other

financial assets traded on an exchange. The entire idea of predicting stock prices is to gain

significant profits.</p>

</div>

</div>

32
Stock Market Analysis

<!-- Slide 2 -->

<div class="carousel-item">

<div class="carousel-container">

<h2 class="animate__animated animate__fadeInDown">Welcome to

<span>QuantTrade Hub</span></h2>

<p class="animate__animated animate__fadeInUp">QuantTrade Hub has been a

critical area of research and is one of the top applications of machine learning. This tutorial

will teach you how to perform stock price prediction using machine learning and deep

learning techniques.</p>

</div>

</div>

<!-- Slide 3 -->

<div class="carousel-item">

<div class="carousel-container">

<h2 class="animate__animated animate__fadeInDown">Welcome to

<span>QuantTrade Hub</span></h2>

<p class="animate__animated animate__fadeInUp">A stock market is a public market

where you can buy and sell shares for publicly listed companies. The stocks, also known as

equities, represent ownership in the company. The stock exchange is the mediator that allows

the buying and selling of shares.</p>

</div>

33
Stock Market Analysis

</div>

<a class="carousel-control-prev" href="#heroCarousel" role="button" data-bs-

slide="prev">

<span class="carousel-control-prev-icon bx bx-chevron-left" aria-

hidden="true"></span>

</a>

<a class="carousel-control-next" href="#heroCarousel" role="button" data-bs-

slide="next">

<span class="carousel-control-next-icon bx bx-chevron-right" aria-

hidden="true"></span>

</a>

</div>

</section><!-- End Hero -->

{% endblock %}

</body>

</html>

Main.py

import os.path

import time

import datetime

import pandas as pd

import yfinance as yf

34
Stock Market Analysis

from flask import Flask, request, redirect, render_template, session

import firebase_admin

import random

from firebase_admin import credentials, firestore

cred = credentials.Certificate("key.json")

firebase_admin.initialize_app(cred)

app = Flask(__name__)

app.secret_key = "StockAnalysisProject@123"

UPLOAD_FOLDER = 'static/uploads/'

app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024

ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])

#companies = ["Accenture","IBM","Infosys","AMZN", "MSFT"]

compsigns = ["TCS.NS","HDFCBANK.NS","INFY.NS",

"HINDUNILVR.NS","ICICIBANK.NS","SBIN.NS","BAJAJFINSV.NS",

"WIPRO.NS","BHARTIARTL.NS","ITC.NS","MARUTI.NS",

"LT.NS","HCLTECH.NS","AXISBANK.NS","SUNPHARMA.NS",

"NTPC.NS","TECHM.NS","INDUSTOWER.NS","MUTHOOTFIN.NS",

"IOB.NS","BOSCHLTD.NS","MPHASIS.NS"]

compnames=["TCS","HDFC Bank","Infosys",

"Hindustan Unilever","ICICI Bank","State Bank Of India","Bajaj Finance",

"Wipro","Bharti Airtel","ITC","Maruthi Suzuki India Ltd",

"Larsen & Toubro","HCL","Axis bank Ltd","Sun Pharmaceuticals",

"NTPC Ltd","TechMahindra Ltd","Indus Tower Ltd","Muthoot Finance Ltd ",

"Indian Overseas Bank","Bosch Ltd","Mphasis Ltd"]

35
Stock Market Analysis

@app.route('/userchecktrade1', methods=["POST","GET"])

def userchecktrade1():

try:

msg=""

today = datetime.date.today()

#format_data = "%y-%m-%d"

#today = datetime.strptime(str(today), format_data)

if(request.method=="POST"):

compname = request.form.get("cname")

fromdate = request.form.get("fromdate")

todate = request.form.get("todate")

print("From Date : ", fromdate, " To Date : ", todate)

filename = "File"+str(round(time.time()))+".csv"

#file = request.files['file']

#file.save(os.path.join(app.config['UPLOAD_FOLDER'],filename))

#session['filename']=filename

session['compname'] = compname

value_index=-1

if compname in compnames:

value_index = compnames.index(compname)

if(value_index>=0):

compsign=compsigns[value_index]

df = yf.download(compsign, start=fromdate, end=todate)

information = yf.Ticker(compsign)

df.to_csv(os.path.join(app.config['UPLOAD_FOLDER'],filename))

36
Stock Market Analysis

# whole python dictionary is printed here

#print("Details : ", information.info)

time.sleep(3)

dataframe = pd.read_csv(os.path.join(app.config['UPLOAD_FOLDER'],filename))

print("Data Frame from CSV : \n", dataframe)

#for key, value in information.info.items():

# print(key , " : ", value)

print("Keys : ",df.keys())

#print("Open Values : ", df['Low'])

print("Index : \n", dataframe.index)

print("Close : \n", dataframe['Close'])

columns = ["Price", "Open", "High", "Low", "Close", "Adj Close", "Volume"]

data = []

for ind in dataframe.index:

print("Index : ", ind)

if(ind>1):

temp = []

#temp.append(str(ind-2))

for col in columns:

if(col == "Price"):

temp.append(dataframe[col][ind])

else:

formatvalue = "{:.2f}".format(float(dataframe[col][ind]))

temp.append(formatvalue)

print("Temp : ", temp)

37
Stock Market Analysis

data.append(temp)

print("Data : \n", data)

#print("Len : ", len(data))

dbdata = []

x = len(data) - 1

lowcount, highcount = 0, 0

openvaluedic, closevaluedic = {}, {}

while (x >= 0):

stockdate = data[x][0]

str1 = stockdate.split("-")

stockdate1 = str1[0] + "-" + str1[1]

print("Stock Date : ", stockdate1)

if (stockdate1 in openvaluedic.keys()):

openvaluedic[stockdate1] = int(openvaluedic[stockdate1]) + int(float(data[x]

[1]))

else:

openvaluedic[stockdate1] = int(float(data[x][1]))

if (stockdate1 in closevaluedic.keys()):

closevaluedic[stockdate1] = int(closevaluedic[stockdate1]) + int(float(data[x]

[4]))

else:

closevaluedic[stockdate1] = int(float(data[x][4]))

if (int(float(data[x][1])) < int(float(data[x][4]))):

38
Stock Market Analysis

highcount += 1

else:

lowcount += 1

dbdata.append(data[x])

x -= 1

print("High Count : ", highcount, " Low Count : ", lowcount)

# print("Open List : ", openvaluedic)

# print("Close List : ", closevaluedic)

openvaluelist, closevaluelist = [], []

for key, value in openvaluedic.items():

temp = {}

temp["label"] = key

temp["y"] = value

#print("Temp : ", temp)

openvaluelist.append(temp)

for key, value in closevaluedic.items():

temp = {}

temp["label"] = key

temp["y"] = value

closevaluelist.append(temp)

userid = session['userid']

uname = session['username']

compname = session['compname']

status = ""

39
Stock Market Analysis

print("High Count : ", highcount, " Low Count : ", lowcount)

if (highcount > lowcount):

status = "GoodTime"

msg = "From the given data, it's good to invest in " + str(compname)

else:

status = "Risky"

msg = "From the given data, it's risky to invest in " + str(compname)

id = str(random.randint(1000, 9999))

json = {'id': id, 'UserId': userid,

'CompanyName': compname, 'UserName': uname, 'Status': status,

'HighCount': highcount, 'LowCount': lowcount}

db = firestore.client()

newuser_ref = db.collection('newpredict')

id = json['id']

newuser_ref.document(id).set(json)

columns = ["Date", "Open", "High", "Low", "Close", "Adj Close", "Volume"]

return render_template("userchecktrade.html",

companies=compnames, checktrade=True,

data=dbdata, columns=columns,

msg=msg, today=today,

openvaluelist=openvaluelist,

closevaluelist=closevaluelist,

information=information.info)

else:

msg="Sorry Something went wrong"

40
Stock Market Analysis

return render_template("userchecktrade.html",

companies=compnames,checktrade=True,

msg=msg, today=today)

except Exception as e:

print("Exception : ", e)

return str(e)

41
Stock Market Analysis

9. Code Efficiency Analysis

 Dependencies and Setup

 The script uses several libraries such as pandas, yfinance, firebase_admin, and Flask
for web handling and stock data analysis.

 Firebase is initialized using a certificate from a JSON file (key.json), which indicates
authentication to access Firebase Firestore.

 Flask Web Application

 The Flask app is set up with a secret key for session management and has
configuration for handling file uploads.

 It serves a web page that allows users to select a company, input a date range
(fromdate and todate), and analyze stock data.

 Stock Data Retrieval

 The application fetches stock data for a selected company (represented by its ticker
symbol from Yahoo Finance, e.g., "TCS.NS" for TCS).

 The user inputs a date range, and the script downloads the stock data for the specified
range using yfinance and stores it as a CSV file.

 Stock data is retrieved and processed into a dataframe containing key fields like
"Open", "Close", "High", "Low", etc.

 Data Analysis

 The script analyzes the stock data by counting how many times the stock's opening
price is lower than its closing price (lowcount), and vice versa (highcount).

 Based on these counts, it determines whether it's a "GoodTime" (more closes higher
than opens) or "Risky" (more opens higher than closes) to invest in the selected
company.

 Saving Data to Firebase

42
Stock Market Analysis

 The analysis results (including the high and low counts, company name, and the user's
details) are saved to Firebase Firestore under the newpredict collection.

 Each document in Firestore represents an analysis result with fields such as UserId,
CompanyName, Status, HighCount, LowCount, etc.

 Rendering Results

 The userchecktrade1 route renders a page that displays the stock data, analysis result,
and visualizes the stock trends over time using the high and low count data.

 It also displays a message (msg) based on the analysis, which tells the user whether
it’s a good time or risky to invest in the selected company.

9.1. Optimization of Code

 Data Validation: Before performing analysis, you should ensure that the dates
provided by the user are valid, and the stock data is not empty.

 Improve Firestore Document ID Generation: Currently, id = str(random.randint(1000,


9999)) is used to generate an ID for Firestore. While this works, it's not very reliable
for unique identifiers. Consider using Firebase's built-in document() method for
generating unique IDs.

 Date Range Logic: Ensure that the date range selected by the user is valid and that
yfinance doesn't return empty or incomplete data for the selected range.

Potential Enhancements:

1. Advanced Visualization:

o Integrate graphs and charts directly into the webpage to visualize trends in
stock prices over time.

o Libraries like plotly or Chart.js could be used to display stock price


movements interactively.

2. Real-Time Stock Data:

o Extend the functionality to include real-time stock data or more frequent


updates (using yfinance's interval parameter).

43
Stock Market Analysis

3. User Authentication:

o Consider adding user authentication to personalize data, track history, and


allow users to see their previous stock analysis.

10. Verification Checks

To perform verification checks on the stock prediction analysis in your Python project, we
can focus on several key aspects:

1. Input Validation: Verify that the user input (company name, date range) is valid and
correct.

2. Data Integrity: Verify that the stock data retrieved from Yahoo Finance is complete
and consistent.

3. Business Logic: Verify that the logic for calculating the investment status (GoodTime
vs. Risky) is correct.

4. Error Handling: Ensure that the application handles errors gracefully and informs
the user appropriately.

5. External Integrations: Verify interactions with external systems, like Firebase


Firestore and Yahoo Finance.

Verify Data Processing Efficiency:

 If your stock analysis is slow for large date ranges or multiple companies, you should
ensure that you're using efficient data processing methods (e.g., vectorized operations
in Pandas instead of loops).

Example: Instead of looping through each row, you could use apply or other efficient
methods for calculating highcount and lowcount:

highcount = (df['Close'] > df['Open']).sum()

lowcount = len(df) - highcount

44
Stock Market Analysis

11. Validation Checks

In stock prediction analysis, validation checks are crucial to ensure the model's performance
is reliable and that the predictions made by the model are meaningful and trustworthy. These
checks help identify potential issues with data quality, model overfitting, and other pitfalls,
making sure that predictions are based on sound analysis.

Here are the key validation checks to consider for stock prediction analysis:

1. Data Validation Checks

Before feeding data into a model, you need to perform a few checks to ensure the data is
valid.

a. Check for Missing Values

Missing values can skew predictions. You need to verify that your data is clean.

# Check for missing values in the dataset

if df.isnull().sum().any():

print("Warning: Missing values found in the dataset")

df = df.dropna() # Drop rows with missing values or handle imputation

else:

print("No missing values in the dataset")

b. Check for Duplicate Records

Ensure there are no duplicate records in the data that could distort predictions.

# Check for duplicates

if df.duplicated().any():

print("Warning: Duplicates found in the dataset")

df = df.drop_duplicates() # Remove duplicates

else:

45
Stock Market Analysis

print("No duplicates in the dataset")

c. Check for Correct Data Types

Ensure that each feature in the dataset has the correct data type (e.g., numerical data for
technical indicators).

# Ensure the columns have appropriate data types

print(df.dtypes)

d. Check for Outliers

Outliers can significantly affect stock prediction models. You can use statistical methods
(like IQR) or visual methods (like boxplots) to identify and handle them.

import seaborn as sns

import matplotlib.pyplot as plt

# Visualizing for outliers using a boxplot

sns.boxplot(x=df['Close'])

plt.show()

# Statistical approach (using IQR to find outliers)

Q1 = df['Close'].quantile(0.25)

Q3 = df['Close'].quantile(0.75)

IQR = Q3 - Q1

outliers = df[(df['Close'] < (Q1 - 1.5 * IQR)) | (df['Close'] > (Q3 + 1.5 * IQR))]

print(f"Number of outliers detected: {len(outliers)}")

2. Model Validation Checks

Once the model is trained, you need to verify that it is predicting stock prices in a meaningful
way.

46
Stock Market Analysis

a. Train-Test Split

Always split your data into training and testing sets. This ensures that your model
generalizes well and doesn't overfit.

from sklearn.model_selection import train_test_split

# Train-test split

X = df[['MA20', 'MA50', 'RSI']] # Features

y = df['Close'] # Target

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False)

Cross-Validation

Perform cross-validation to ensure the model performs consistently across different subsets
of data.

python

Copy code

from sklearn.model_selection import cross_val_score

# Cross-validation to validate the model's performance

scores = cross_val_score(model, X, y, cv=5)

print(f"Cross-validation scores: {scores}")

print(f"Average cross-validation score: {scores.mean()}")

47
Stock Market Analysis

12. Testing and Implementation

SYSTEM TESTING

The purpose of testing is to discover errors. Testing is the process of trying to


discover every conceivable fault or weakness in a work product. It provides a way to check
the functionality of components, sub-assemblies, assemblies and/or a finished product It is
the process of exercising software with the intent of ensuring that the

Software system meets its requirements and user expectations and does not fail in an
unacceptable manner. There are various types of test. Each test type addresses a specific
testing requirement.

TYPES OF TESTS

Unit testing

Unit testing involves the design of test cases that validate that the internal program
logic is functioning properly, and that program inputs produce valid outputs. All decision
branches and internal code flow should be validated. It is the testing of individual software
units of the application .it is done after the completion of an individual unit before
integration. This is a structural testing, that relies on knowledge of its construction and is
invasive. Unit tests perform basic tests at component level and test a specific Flightiness
process, application, and/or system configuration. Unit tests ensure that each unique path of a
Flightiness process performs accurately to the documented specifications and contains clearly
defined inputs and expected results.

Integration testing

Integration tests are designed to test integrated software components to determine if


they actually run as one program. Testing is event driven and is more concerned with the
basic outcome of screens or fields. Integration tests demonstrate that although the
components were individually satisfaction, as shown by successfully unit testing, the
combination of components is correct and consistent. Integration testing is specifically aimed
at exposing the problems that arise from the combination of components.

48
Stock Market Analysis

Functional test

N Functional tests provide systematic demonstrations that functions tested are


available as specified by the Flightiness and technical requirements, system documentation,
and user manuals.

Functional testing is centered on the following items:

Valid Input : identified classes of valid input must be accepted.

Invalid Input : identified classes of invalid input must be rejected.

Functions : identified functions must be exercised.

Output : identified classes of application outputs must be exercised.

Systems/Procedures: interfacing systems or procedures must be invoked.

Organization and preparation of functional tests is focused on requirements, key


functions, or special test cases. In addition, systematic coverage pertaining to identify
Flightiness process flows; data fields, predefined processes, and successive processes must be
considered for testing. Before functional testing is complete, additional tests are identified
and the effective value of current tests is determined.

System Test

System testing ensures that the entire integrated software system meets requirements.
It tests a configuration to ensure known and predictable results. An example of system testing
is the configuration oriented system integration test. System testing is based on process
descriptions and flows, emphasizing pre-driven process links and integration points.

White Box Testing

White Box Testing is a testing in which in which the software tester has knowledge of
the inner workings, structure and language of the software, or at least its purpose. It is
purpose. It is used to test areas that cannot be reached from a black box level.

Black Box Testing

49
Stock Market Analysis

Black Box Testing is testing the software without any knowledge of the inner
workings, structure or language of the module being tested. Black box tests, as most other
kinds of tests, must be written from a definitive source document, such as specification or
requirements document, such as specification or requirements document.

Unit Testing:

Unit testing is usually conducted as part of a combined code and unit test phase of the
software lifecycle, although it is not uncommon for coding and unit testing to be conducted as
two distinct phases.

The unit test module from Python is used to implement all unit tests, as it is available
by default in Python and integrates well with existing Python codes. Unit tests are done for
the build dataset script, which transforms the raw input data into feature vectors usable for
training and testing, as well as models core calculations. Unit tests are conducted because the
components are error-pron, calculation intensive. Also, they exhibit garbage-in-garbage-out
properties, that the model will be completely wrong if it receives the wrong input, and if the
model scores are wrong, the final buy-sell recommendation will be totally incorrect..
Combinations of input options are tested, including n-day stock price look back as well as n-
day moving average. Correctness is ensured by asserting the feature vectors’ shapes, as well
as starting and ending elements.

12.1 Testing

Testing is a critical step in stock prediction analysis projects. It ensures the reliability and
effectiveness of the model used to predict stock prices. There are several testing approaches
and techniques used to evaluate the performance of stock prediction models, especially in
machine learning and statistical models. Here's a structured approach to testing in stock
prediction analysis:

1. Data Splitting

 Training and Testing Split: Divide the dataset into two main parts: training and
testing sets.

o Training Set: Used to train the model.

50
Stock Market Analysis

o Testing Set: Used to evaluate how well the model generalizes to unseen data.

 Cross-Validation: Use k-fold cross-validation to improve the robustness of your


model. This involves splitting the dataset into k subsets and iterating over different
combinations of training and testing sets.

2. Model Evaluation Metrics

After training, it's important to evaluate the model using appropriate metrics. Common
metrics used in stock prediction include:

 Mean Absolute Error (MAE): Measures the average magnitude of the errors in a set
of predictions.

 Root Mean Squared Error (RMSE): A frequently used metric for regression
models, which penalizes large errors more than MAE.

 Mean Absolute Percentage Error (MAPE): Provides a percentage error that helps
in evaluating model performance in a more interpretable way.

 R-Squared (R²): A statistical measure of how well the predictions fit the data. It tells
you the proportion of variance in the dependent variable that is explained by the
model.

 Precision, Recall, and F1-Score: If the task involves classification (e.g., predicting
whether stock price will go up or down), these metrics are useful.

3. Backtesting

 Historical Backtesting: Simulate how well the model would have performed in the
past using historical data. This is especially useful in financial forecasting.

 Walk-forward Validation: Involves testing on data that has never been seen during
the training phase, and progressively training and testing the model on future time
windows (also called out-of-sample testing).

4. Out-of-Sample Testing

51
Stock Market Analysis

 Holdout Set: Set aside a portion of the data to be used as a holdout set that the model
never sees during training. This helps to test how the model generalizes on unseen
data.

 Real-Time Paper Trading: Simulating trading with real market data without real
financial risk is often done to test how well the model performs under actual market
conditions.

5. Performance Analysis

After testing the model, you can analyze its performance:

 Plotting Predicted vs Actual Prices: Visualize how well the predicted prices match
the actual prices over time.

 Residual Analysis: Examine the residuals (differences between predicted and actual
values) to identify patterns that may indicate model improvements.

 Sharpe Ratio (for trading models): Measures the return of the strategy compared to
its risk. A higher Sharpe ratio indicates a better risk-adjusted return.

6. Sensitivity Testing

 Hyperparameter Tuning: Test different combinations of model hyperparameters to


see how they affect performance. Use grid search or randomized search for tuning.

 Stress Testing: Evaluate how the model handles extreme market conditions (e.g.,
crashes, bubbles, or black swan events).

7. Ensemble Methods and Comparisons

 Ensemble Models: Combine multiple models to improve the prediction accuracy,


such as random forests or gradient boosting models.

 Comparison with Benchmarks: Compare the performance of your model with


simple baseline models like moving averages or linear regression.

8. Risk and Uncertainty Evaluation

 Monte Carlo Simulation: Run multiple simulations to assess the impact of


uncertainty in the model’s predictions.

52
Stock Market Analysis

 Drawdown Analysis: Measure the peak-to-trough decline in the value of a portfolio


to assess risk.

Tools for Testing in Stock Prediction Projects

 Python Libraries: Libraries like scikit-learn, TensorFlow, PyTorch, and XGBoost for
modeling, and pandas, numpy for data manipulation are commonly used.

 Backtesting Libraries: Libraries such as Backtrader or Zipline help in backtesting


trading strategies.

 Financial Data: Use datasets from APIs such as Yahoo Finance, Alpha Vantage, or
Quandl to gather stock market data for training and testing.

12.1.1 Methodology of testing

Various tools have been used to assist in the development of the mobile application. In
particular , Chrome Mobile Emulator is used to simulate the mobile view while developing
the mobile application on desktop/laptop computers. After the application is deployed to the
cloud, mobile phones with different operating systems and browsers, Google Chrome, are
used to verify the user experience is consistent across different devices with different
resolutions.

Test strategy and approach

Field testing will be performed manually and functional tests will be written in detail.

Test objectives

 All field entries must work properly.


 Pages must be activated from the identified link.
 The entry screen, messages and responses must not be delayed.

Features to be tested

 Verify that the entries are of the correct format


 No duplicate entries should be allowed
 All links should take the user to the correct page.

53
Stock Market Analysis

Integration Testing

Software integration testing is the incremental integration testing of two or more


integrated software components on a single platform to produce failures caused by interface
defects.

12.1.2 Test Results

All the test cases mentioned above passed successfully. No defects encountered

Test Case
Number Testing Scenario Expected result Result

Registration Testing

Alert "Please fill all


TC – 01 Clicking submit without entering details details" Pass

Clicking submit without entering Alert "Please fill


TC – 02 Username Username" Pass

Clicking submit without entering Alert "Please fill


TC – 03 password Password" Pass

Clicking submit without entering email


TC – 04 id Alert "Please fill email id" Pass

Clicking submit without entering phone Alert "Please fill contact


TC – 05 number number" Pass

Clicking submit entering confirm Alert "Password and


password data which is not matching Confirm Password do not
TC – 06 with password data match" Pass

Login Testing

TC – 07 Clicking submit without entering login Alert "Please enter the Pass
details username and password"

54
Stock Market Analysis

Clicking submit without entering Alert "Please enter the


TC – 08 password password" Pass

Clicking submit without entering Alert "Please enter the


TC – 09 Username Username" Pass

Clicking submit entering wrong


TC – 10 Username Alert "Invalid User" Pass

Clicking submit entering wrong


TC – 11 password Alert "Invalid User" Pass

Clicking submit entering wrong


TC – 12 Username and password Alert "Invalid User" Pass

12.1.3 Analysis

Exploratory Data Analysis

EDA is an approach to analysing the data using visual techniques. It is used to discover
trends, and patterns, or to check assumptions with the help of statistical summaries and
graphical representations.

While performing the EDA of the Tesla Stock Price data we will analyse how prices of the
stock have moved over the period of time and how the end of the quarters affects the prices of
the stock.

55
Stock Market Analysis

12.2 Implementation

STOCK INFORMATION COLLECTION:

Company information is collected from the IEX Stock API [25]. A Firebase Cloud Function
[26] is written to get the data from the API and store it in Firebase Cloud Fire store [27],
which the application will access through another Firebase Callable Cloud Function.

GOOGLE CHARTS:

Google Charts is used to plot the stock prices and the predictions. It provides a simple and
separate set of APIs that does not depend on other libraries while maintaining
customizability. Also, it integrates nicely with the user interface which follows the Material
Design, which improves the overall user experience.

COMPONENT:

The whole application is broken down into the following hierarchy of components. At the top
level, the App component brings everything together. If the user is not logged in he/she will
be directed to the login page (Login Page).The router component (Router) controls where the
user will end up at, including the home page(Home Page), which is the default starting point
for users with a list of stocks and a search bar, all broken down into separate components
Other components include the details page (Detail Page), which is where details about a stock
price, including the stock price chart, a list of models with a model score attached to each
model, along with a buy/sell score that indicates the overall predictions for whether the stock
should be purchased or sold, are included in. It shows that the 1-day interval historical
predictions line follows closely with the historical prices. The graph looks like the prediction
line is just 1 day shifting from the historical prices, similar to a shifted and smoothed out
historical prices line. Therefore, the shape of the historical predictions line is similar to the
shape of the exponential moving averages (EMA), where the price changes from ttot+1
heavily depends on the direction and Magnitude of changes fromt-1tot, followed by
decreasing importance from earlier historical prices. Other models in predicting stock prices
of other stocks also show similar results. Although price reflects all available information, the
magnitude of price changes in the future might need other data for forecasting purpose, such
as market sentiment company announcement, retail and institutional investors’ attention on
the company, etc.

56
Stock Market Analysis

12.2.1 Implementation Procedures

Step 1: Install Required Libraries

First, we need to install the necessary Python libraries. We’ll use Yfinance for fetching
historical stock data, Pandas for data manipulation, Scikit-learn for machine learning, and
Matplotlib for plotting.

!pip install yfinance pandas scikit-learn matplotlib

Explanation:
This command installs the required libraries. Each library has a specific use case:
- Yfinance: Fetches historical stock data from Yahoo Finance.
- Pandas: Provides data structures and data analysis tools.
- Scikit-learn: Offers simple and efficient tools for predictive data analysis.
- Matplotlib: Used for creating static, animated, and interactive visualizations in Python.

Step 2: Fetch Historical Data

We’ll use Yfinance to fetch historical stock price data for a chosen company, such as Apple
Inc. (AAPL).

import yfinance as yf
import pandas as pd
# Fetch historical data for Apple Inc.
ticker = 'AAPL'
data = yf.download(ticker)
# Display the first few rows of the dataset
print(data.head())

Explanation:
- `import yfinance as yf` and `import pandas as pd`: Import the necessary libraries.
- `yf.download(ticker, start, end)`: Fetches historical stock data for the specified ticker
symbol (AAPL in this case) from the start date to the end date.
- `data.head()`: Displays the first few rows of the dataset to ensure that the data has been
loaded correctly.

57
Stock Market Analysis

Use Case:
Fetching historical stock data is crucial for any financial analysis or predictive modeling. It
provides the raw data needed to train and evaluate machine learning models.

Step 3: Preprocess Data

Next, we’ll preprocess the data to create features for our machine learning model. We’ll
calculate technical indicators like moving averages, which are commonly used in financial
analysis.

# Calculate moving averages


data['MA_10'] = data['Close'].rolling(window=10).mean()
data['MA_50'] = data['Close'].rolling(window=50).mean()
# Drop NaN values
data = data.dropna()
# Define features and target
X = data[['Close', 'MA_10', 'MA_50']]
y = data['Close'].shift(-1).dropna()
X = X[:-1]
# Split data into training and testing sets
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

Explanation:
- `data[‘MA_10’]` and `data[‘MA_50’]`: Calculate the 10-day and 50-day moving averages
of the closing prices.
- `data.dropna()`: Removes rows with missing values that result from calculating moving
averages.
- `X = data[[‘Close’, ‘MA_10’, ‘MA_50’]]`: Defines the feature set, which includes the
closing price and the moving averages.
- `y = data[‘Close’].shift(-1).dropna()`: Defines the target variable, which is the closing price
shifted by one day (to predict the next day’s price).
- `train_test_split(X, y, test_size=0.2, random_state=42)`: Splits the data into training and
testing sets, with 20% of the data reserved for testing.

58
Stock Market Analysis

Use Case:
Preprocessing the data and creating features is a critical step in machine learning. It
transforms raw data into a format suitable for modelling and helps the model learn patterns
from historical data.

Step 4: Train a Predictive Model

We’ll use a linear regression model to predict future stock prices based on the features we’ve
engineered.

from sklearn.linear_model import LinearRegression


# Initialize and train the model
model = LinearRegression()
model.fit(X_train, y_train)
# Make predictions
predictions = model.predict(X_test)
# Evaluate the model
from sklearn.metrics import mean_squared_error, r2_score
mse = mean_squared_error(y_test, predictions)
r2 = r2_score(y_test, predictions)
print(f'Mean Squared Error: {mse}')
print(f'R² Score: {r2}')

Explanation:
- `from sklearn.linear_model import LinearRegression`: Imports the linear regression model
from Scikit-learn.
- `model = LinearRegression()`: Initializes the linear regression model.
- `model.fit(X_train, y_train)`: Trains the model using the training data.
- `predictions = model.predict(X_test)`: Uses the trained model to make predictions on the
testing data.
- `mean_squared_error(y_test, predictions)`: Calculates the mean squared error, a measure of
the average squared difference between actual and predicted values.
- `r2_score(y_test, predictions)`: Calculates the R² score, which represents the proportion of
variance in the dependent variable that is predictable from the independent variables.

59
Stock Market Analysis

Use Case:
Training a predictive model allows us to forecast future stock prices based on historical data.
Evaluating the model helps us understand its accuracy and reliability.

Step 5: Visualize the Results

We’ll plot the actual vs. predicted stock prices to visualize the model’s performance.

import matplotlib.pyplot as plt


plt.figure(figsize=(14, 7))
plt.plot(y_test.index, y_test.values, label='Actual Price')
plt.plot(y_test.index, predictions, label='Predicted Price')
plt.xlabel('Date')
plt.ylabel('Price')
plt.title('Actual vs. Predicted Stock Prices')
plt.legend()
plt.show()

Explanation:
- `initial_balance = 10000`: Sets the starting balance in USD.
- `balance = initial_balance`: Initializes the balance.
- `position = 0`: Initializes the number of shares held.
- The loop iterates over each test data point:
— `current_price = X_test.iloc[i][‘Close’]`: Gets the current stock price.
— `predicted_price = predictions[i]`: Gets the predicted stock price.
— If the predicted price is higher than the current price and there’s enough balance, it buys
shares.
— If the predicted price is lower than the current price and there are shares held, it sells the
shares.
- `final_balance` and `profit`: Calculates the final balance and profit after the trading period.

Use Case:
Visualizing the results helps us understand how well the model’s predictions match the actual
stock prices. It provides a clear picture of the model’s performance.

Step 6: Implement Trading Strategy

60
Stock Market Analysis

Finally, we’ll implement a basic trading strategy based on our predictions. The strategy will
buy when the predicted price is higher than the current price and sell when it’s lower.

initial_balance = 10000 # Starting balance in USD


balance = initial_balance
position = 0 # Number of shares

for i in range(len(X_test)):
current_price = X_test.iloc[i]['Close']
predicted_price = predictions[i]

if predicted_price > current_price and balance >= current_price:


# Buy stock
shares_to_buy = int(balance // current_price) # Buy whole shares only
if shares_to_buy > 0: # Ensure we are buying at least one share
position += shares_to_buy
balance -= shares_to_buy * current_price
print(f"Buying {shares_to_buy} shares at {current_price:.2f}")

elif predicted_price < current_price and position > 0:


# Sell stock
balance += position * current_price
print(f"Selling {position} shares at {current_price:.2f}")
position = 0

# Calculate final balance including the value of the remaining shares


final_balance = balance + (position * X_test.iloc[-1]['Close'])
profit = final_balance - initial_balance
print(f"Final balance: ${final_balance:.2f}")
print(f"Profit: ${profit:.2f}")

Explanation:
- `initial_balance = 10000`: Sets the starting balance in USD.
- `balance = initial_balance`: Initializes the balance.
- `position = 0`: Initializes the number of shares held.

61
Stock Market Analysis

- The loop iterates over each test data point:


— `current_price = X_test.iloc[i][‘Close’]`: Gets the current stock price.
— `predicted_price = predictions[i]`: Gets the predicted stock price.
— If the predicted price is higher than the current price and there’s enough balance, it buys
shares.
— If the predicted price is lower than the current price and there are shares held, it sells the
shares.
- `final_balance` and `profit`: Calculates the final balance and profit after the trading period.

12.2.3 Operational Documentation

Operational feasibility is the measure of how well a proposed system solves the problems,
and takes advantage of the opportunities identified during scope definition and how it
satisfies the requirements identified in the requirements analysis phase of system
development. The operational feasibility assessment focuses on the degree to which the
proposed development projects fits in with the existing business environment and objectives
with regard to development schedule, delivery date, corporate culture and existing business
processes. To ensure success, desired operational outcomes must be imparted during design
and development. These include such design-dependent parameters as reliability,
maintainability, supportability, usability, producibility, disposability, sustainability,
affordability and others. These parameters are required to be considered at the early stages of
design if desired operational behaviors are to be realized. A system design and development
requires appropriate and timely application of engineering and management efforts to meet
the previously mentioned parameters. A system may serve its intended purpose most
effectively when its technical and operating characteristics are engineered into the design.
Therefore, operational feasibility is a critical aspect of systems engineering that needs to be
an integral part of the early design phases.

62
Stock Market Analysis

13. Cost estimation of the project

As any one of us could guess, the market is unstable and, more than often, unpredictable. For
several decades researchers have toyed with time-series data to predict future values – of
which the most challenging and potentially lucrative application is predicting the values of
stocks for a given company. However, as expected, market change depends on many
parameters of which only a bunch can be quantified, such as historical stock data, the volume
of trade, current prices. Of course, fundamental factors such as a company’s intrinsic value,
assets, quarterly performance, recent investments, and strategies all affect the traders’ trust in
the company and thus the price of its stock. Only a few of the latter can be incorporated
effectively into a mathematical model. This makes stock price prediction using machine
learning project challenging and unreliable to a certain extent. Moreover, it is nearly
impossible to anticipate a piece of news that will shatter or boost the stock market in the
coming weeks – a pandemic or a war.

63
Stock Market Analysis

14. Time scheduling of the project

When creating a time schedule for a stock prediction analysis project, it's essential to break
down the tasks into manageable chunks and allocate time based on complexity, resources,
and expertise. Below is a sample project timeline for a typical stock prediction analysis
project, assuming it's a medium-sized project that spans 6-8 weeks. You can adjust the
timeline based on the specific requirements and scope of your project.

Day 1-2: Project Planning

Day 3-5: Data Collection

Day 6-7: Data Preprocessing and Exploration

Day 8-9: Feature Engineering

Day 10-11: Data Transformation

Day 12-13: Model Selection

Day 14: Set Up the Development Environment

Day 15-17: Model Implementation

Day 18-21: Model Training

Day 22-23: Evaluate Model Performance

Day 24-26: Hyperparameter Tuning

Day 27-28: Cross-Validation and Backtesting

Day 29-31: Testing the Model

Day 32-34: Model Refinement

Day 35: Model Deployment Preparation

Day 36-38: Visualization

Day 39-40: Reporting

Day 41-42: Model Deployment (Optional)

Day 43-45: Final Evaluation and Documentation

Day 46-47: Presentation and Final Reporting

Day 48-50: Post-deployment Monitoring and Feedback

64
Stock Market Analysis

15. Future scope and Future Enhancement


Limitations. Despite the promising results, there are several limitations that should be
noted. First, the study was based on a single dataset and may not be generalizable to other
populations or stock groups. Furthermore, the study only considered a limited set of stock
variables and did not take into account other potential risk factors for a user to invest on a
stock, such as open, close, adj-close. Additionally, the performance of the model on a held-
out test dataset was not evaluated, which would have provided insight on how well the model
generalizes to new, unseen data. Lastly, the interpretability of the results and the ability to
explain the clusters formed by the algorithm was not evaluated. In light of these limitations, it
is recommended to conduct further research to address these issues and to better understand
the potential of k-modes clustering.

Future research: Future research could focus on addressing the limitations of this study
by comparing the performance of the k-modes clustering algorithm with other commonly
used clustering algorithms, such as k-means or hierarchical clustering, to gain a more
comprehensive understanding of its performance. Additionally, it would be valuable to
evaluate the impact of missing data and outliers on the accuracy of the model and develop
strategies for handling these cases. Furthermore, it would be beneficial to evaluate the
performance of the model on a held-out test dataset in order to establish its generalizability to
new, unseen data. Ultimately, future research should aim to establish the robustness and
generalizability of the results and the interpretability of the clusters formed by the algorithm,
which could aid in understanding the results and support decision making based on the
study’s findings.

We plan to formalize our approach that will allow us to provide more rigorous
evaluation. This would include developing a core calculus for the TPM’s machine model
based on the cryptographic protocol Spi calculus. This semantics would account for the
authentication, secrecy, and integrity properties of the TPM. Furthermore, a formal semantics
for our approach can be built on top of this core calculus similar to the techniques

65
Stock Market Analysis

17. List of Screens


Home Page

AboutPage

66
Stock Market Analysis

Services

Gallery

67
Stock Market Analysis

AdminLogin

UserLogin

68
Stock Market Analysis

Contact

NewUser

69
Stock Market Analysis

AdminMainPage

AdminViewUsers

70
Stock Market Analysis

AdminViewContacts

AdminViewStaffs

71
Stock Market Analysis

UserMainPage

UserCheckTrade

72
Stock Market Analysis

73
Stock Market Analysis

UserViewReports Page

AdminViewReportsPage

74
Stock Market Analysis

18. List of Fgures

 UML Diagrams
Actor: A coherent set of roles that users of use cases play when interacting with the use
cases.

Use case: A description of sequence of actions, including variants, that a system


performs that yields an observable result of value of an actor.

UML stands for Unified Modeling Language. UML is a language for specifying,
visualizing and documenting the system. This is the step while developing any
product after analysis. The goal from this is to produce a model of the entities

75
Stock Market Analysis

involved in the project which later need to be built. The representation of the
entities that are to be used in the product being developed need to be designed.

19. List of tables


TestCase
Number Testing Scenario Expected result Result

Registration Testing

Alert "Please fill all


TC – 01 Clicking submit without entering details details" Pass

Clicking submit without entering Alert "Please fill


TC – 02 Username Username" Pass

Clicking submit without entering Alert "Please fill


TC – 03 password Password" Pass

Clicking submit without entering email


TC – 04 id Alert "Please fill email id" Pass

TC – 05 Clicking submit without entering phone Alert "Please fill contact Pass

76
Stock Market Analysis

number number"

Clicking submit entering confirm Alert "Password and


password data which is not matching Confirm Password do not
TC – 06 with password data match" Pass

Login Testing

Clicking submit without entering login Alert "Please enter the


TC – 07 details username and password" Pass

Clicking submit without entering Alert "Please enter the


TC – 08 password password" Pass

Clicking submit without entering Alert "Please enter the


TC – 09 Username Username" Pass

Clicking submit entering wrong


TC – 10 Username Alert "Invalid User" Pass

Clicking submit entering wrong


TC – 11 password Alert "Invalid User" Pass

Clicking submit entering wrong


TC – 12 Username and password Alert "Invalid User" Pass

77
Stock Market Analysis

20. Conclusion

The System was successfully developed to meet the needs of the clients. It was found
to provide all the features that required for the organization. The accuracy and complexity of
the software are also ensured and this system provides benefits such as user-friendly
environment, which serves to verify the integrity of a remotely-hosted Requirements monitor.

The project analysis the foundation for democratizing machine learning technologies for
retail investors, connecting predictions made by machine learning model store tail investors
through a mobile application. It helps investors navigate through the stock markets with
additional analysis and help them make more informed decisions. The findings demonstrated
that the application provides significance in trend prediction. When compared to the baseline,
the prediction shows useful trend tendency with the real stock trend. Through the application
interface, the user can easily compare the predictions and model scores from different
machine learning models, then choosing the one that fits their preference. The models used in
the application will continue to improve itself by searching for a better model topology,
structure and hyper parameters through evolution algorithm. The findings concluded the
usefulness of evolution algorithm in lowering the mean squared error when predicting stock
prices, which is helpful for improving the trend prediction for retail investors. Therefore, with
the application and research findings, to large extent the project team achieved the aim of
creating an user-friendly system for retail investors whom does not have previous technical
knowledge to navigate the machine model predictions result with useful benchmarks

There are 4 possible further improvements building upon the findings of this project. First,
multiple approach test of raming the problems could be explained ,such as Predicting
Whether the stock price goes upon down (binary classification based on the previous stock
prices. Other features could being corporated, such as market news and sentiment .Combined
with the development of more advanced machine learning techniques, the accuracy of the
information provided to retail investors might be improved significantly. Second, a larger
scale of evolution with larger population size and more iterations could also be tested for

78
Stock Market Analysis

achieving better results. Model inputs can also be included into the evolution algorithm as a
variable to optimize. Regularized evolution [38] can be tested to eliminate old models
regardless of their accuracy, which could allow the algorithm to search for more distant
models in the search space. Third, it is also possible to use more finance-specific scores, like
those introduced, as the objective function instead of simple mean squared errors to achieve
better results. Fourth, mobile applications with better presentation of stock price predictions
could be developed to help investors understand the implications of the stock price
predictions, e.g. when to buy or sell. This would allow investors to make more informed
decisions based on the machine learning models and truly democratize machine learning
technologies, which were believed to be only in the hands of very few people.

21. Bibliography

[1] “Survey Finds Hong Kong Securities Market Attracts Wide Range of Investors,” HKEX,
13 Jul2017;http://www.hkex.com.hk/news/newsrelease/2017/170713news?sc_lang=en. Y.
Dai and Y. Zhang, “Machine Learning in Stock Price Trend Forecasting,” Stan ford
University;
http://cs229.stanford.edu/proj2013/DaiZhangMachineLearningInStockPriceTrendForecasting
.pdf.

[2] J. Patel, S. Shah, P. Thakkar, and K. Kotecha, “Predicting stock and stock price index
movement using Trend Deterministic Data Preparation and machine learning techniques,
”Expert Systems with Applications: An International Journal, Vol. 42, Jan. 2015, pp. 259-268

[3]B. Wanjawa and L. Muchemi, “ANN Model to Predict Stock Prices at Stock Exchange
Markets,”arXiv:1502.06434 [q-fin.ST], 2014

[4] D. Mandic and J. Chambers, Recurrent Neural Networks for Prediction, Wiley, 2001

[5] R. Williams and D. Zipser, “Gradient-based learning algorithms for recurrent


networksandtheircomputationalcomplexity”,inBackpropagation:Theory,ArchitecturesandApp
liCations, Hillsdale, NJ: Erlbaum, 1992, pp. 433 - 486

[6] S. Hochreiter, Y. Bengio, P. Frasconi, J. Schmidhuber, “Gradient flow in recurrent nets:


the difficulty of learning long-term dependencies”, in A Field Guide to Dynamical Recurrent
Neural Networks, S. C. Kremer and J. F. Kolen, eds., IEEE press, 2001

79
Stock Market Analysis

[7] S. Hochreiter and J. Schmidhuber, “Long Short-term Memory”,Neural Computation, vol.


9,no. 8, pp. 1735 - 1780, 1997

[8] K. Cho et al., “Learning Phrase Representations using RNN Encoder-Decoder for
Statistical Machine Translation” , arXiv:1406. 1078 [cs.CL], 2014.

[9] W. Gail, G. Yoav, and Y. Eran, "On the Practical Computational Power of Finite
PrecisionRNNs for Language Recognition", arXiv:1805.04908 [cs.NE], 2018

[10] J. Chung, C. Gulcehre, K. Cho and Y. Bengio, "Empirical Evaluation of Gated


RecurrentNeural Networks on Sequence Modeling". arXiv:1412.3555 [cs.NE]. 2014

[11] E. Real, et al. “Large-Scale Evolution of Image Classifiers,”arXiv:1703.01041

[cs.NE]. Jun2017.

[12] D. Alajbeg, Z. Bubas and D. Vasic, “Price Distance To Moving Averages And
SubsequentReturns”, International Journal of Economics, Commerce and Management, Vol.
V, Dec 2017,pp. 33 – 47.

80
Stock Market Analysis

22. Glossary of Technical Terms Appendices

API (Application Programming Interface): A set of rules and protocols for building and
interacting with software applications.

Backend: The server-side portion of a software application responsible for processing data
and handling requests from the frontend.

Cache: Temporary storage used to store frequently accessed data for quicker retrieval.

Client: A computer or device that requests services or resources from a server in a client-
server architecture.

CSS (Cascading Style Sheets): A style sheet language used to define the presentation of a
document written in HTML or XML.

Database: A structured collection of data organized for efficient retrieval, storage, and
manipulation.

Frontend: The client-side portion of a software application responsible for user interaction
and presentation.

HTTP (Hypertext Transfer Protocol): An application protocol for distributed, collaborative,


and hypermedia information systems.

IDE (Integrated Development Environment): A software application that provides


comprehensive facilities to programmers for software development.

JSON (JavaScript Object Notation): A lightweight data-interchange format that is easy for
humans to read and write and easy for machines to parse and generate.

Loop: A control flow statement for executing a block of code repeatedly.

81
Stock Market Analysis

Middleware: Software that acts as a bridge between an operating system or database and
applications, especially on a network.

OAuth (Open Authorization): An open standard for access delegation commonly used as a
way for Internet users to grant websites or applications access to their information on other
websites.

SQL (Structured Query Language): A domain-specific language used in programming and


designed for managing data held in a relational database management system.

Template: A pre-designed layout used to create consistent designs across multiple pages or
documents.

URL (Uniform Resource Locator): A reference to a web resource that specifies its location on
a computer network and a mechanism for retrieving it.

Version Control: The management of changes to documents, computer programs, large web
sites, and other collections of information.

Algorithm: A set of rules or instructions designed to perform a specific task.

Authentication: The process of verifying the identity of a user or system.

Authorization: The process of determining whether a user or system has permission to access
a resource.

Compiler: A program that translates code written in a high-level programming language to a


lower-level language.

Data Structure: A way of organizing and storing data so that it can be accessed and modified
efficiently.

Encryption: The process of converting data into a code to prevent unauthorized access.

Framework: A collection of pre-written code that provides a foundation for software


development.

82
Stock Market Analysis

Inheritance: A feature of object-oriented programming that allows a class to inherit properties


and behaviour from another class.

Interface: A point of interaction between components or systems.

Library: A collection of precompiled routines that a program can use.

Metadata: Data that describes other data.

83

You might also like