Stok Final 1456

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

Ai Based Share Market Data Prediction Using Python

Submitted in partial fulfilment of the requirements of the degree of


Bachelor of Engineering
by

Ms. Mansi Manoj Salve (ARMIET/CS22/SM207)


Mr. Suyash Santosh Gamare (ARMIET/CSS22/GS214)
Mr. Baljeetsingh Mehra (ARMIET/CSS22/MB203)
Mr. Ketan Farde (ARMIET/CS21/FK057)

Under the Guidance of

PROF. VIVEK PANDEY

ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY

AFFILIATED TO
UNIVERSITY OF MUMBAI

Department of Computer Engineering


Academic Year – 2023-2024
CERTIFICATE
This project report entitled “Ai Based Share Market Data Prediction Using
Python” by Ms. Mansi Salve, Mr. Suyash Gamare, Mr. Baljeetsingh Mehra , Mr.
Ketan Farde is approved for the degree of Bachelor of Engineering in Computer
Engineering for academic year 2022 – 2023.

Examiners

1. _________________________

2. __________________________

Supervisor

1. __________________________

PROF. VIVEK PANDEY

______________________________ ____________________________

Head of the Department Principal


(Mr. Mayank Mangal)

Date:

Place:
DECLARATION

I declare that this written submission represents my ideas in my own words and where others' ideas or
words have been included, I have adequately cited and referenced the original sources. I also declare
that I have adhered to all principles of academic honesty and integrity and have not misrepresented or
fabricated or falsified any idea/data/fact/source in my submission. I understand that any violation of the
above will be cause for disciplinary action by the Institute and can also evoke penal action from the
sources which have thus not been properly cited or from whom proper permission has not been taken
when needed.

_____________________ _______________ ________________ _______________

Baljeetsingh Mehra Mansi Salve Suyash Gamre Ketan Farde

Date:
ACKNOWLEDGEMENT

A mini project is something that could not have been materialized without cooperation of many
people. This project shall be incomplete if I do not convey my heartfelt gratitude to those people from
whom I have got considerable support and encouragement.

It is a matter of great pleasure for us to have a respected Prof. Vivek Pandey as our project guide.
We are thankful to her for being constant source of inspiration.

We would also like to give our sincere thanks to Prof. Mayank Mangal, Head of Department, for
their kind support.

Last but not the least I would also like to thank all the staffs of ARMIET college of Engineering
(Computer Engineering Department) for their valuable guidance with their interest and valuable
suggestions brightened us.
TABLE OF CONTENTS

CH.
TOPIC NAME PAGE NO.
NO
LIST OF FIGURES I

LIST OF TABLES II

LIST OF SYMBOLS AND ABBREVATION IV

ABSTRACT V

1 INTRODUCTION 1

1.1 Motivation 3

1.2 Problem Statement 4


1.3 Existing System
1.3 Purpose 5

1.4 Scope 5

2 LITERATURE SURVEY 6

3 RESEARCH GAP 7

4 RESEARCH OBJECTIVE 8

PROPOSED SYSTEM 14
5 5.1 System Architecture 16

SYSTEM REQUIREMENT 17
6 6.1 Software Requirement 17

6.2 Technology Used 19

SYSTEM DESIGN 20
7 22
7.1 UML Diagram

7.2 DFD Level 0 23

8 PROJECT IMPLEMENTATION 26

8.1 Result / Output 27


Ai Based Share Market Data Prediction Using Python

TEST CASES 38
9
9.1 Unit Testing 38

10 CONCLUSION AND FUTURE WORK 41

REFERENCES 42

Page |2
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
LIST OF FIGURES

FIG. FIGURE NAME PAGE NO.


NO.
1 User Case Diagram for Overall System 10

2 System Design 16

3 Home page 17

4 Stock predictor 18

5 Prediction dashboard 18

6 Ticker list 19

I
LIST OF ABBREVIATION

Sr. No. ABBREVIATIONS DEFINITION


1 LMT Long Short Term Memory
2 ML Machine Learning

II
LIST OF TABLES

TABLE NO. TABLE NAME PAGE NO.

1 Literature Review 8

2 Project Overview 15

III
ABSTRACT

The project aims to predict the prices of a basket of stocks on the NSE/BSE with an acceptable
degree of accuracy. This study, based on the demand for stock price prediction and the practical
problems it faces, compared and analysed a variety of neural network prediction methods, and
finally chose LSTM (Long Short-Term Memory, LSTM) neural network. Then, through in-depth
study on how to predict the stock price by the LSTM, the feasibility of the method and the
applicability of the model are analysed, and finally the conclusion is drawn. It is found that
historical information is very important to investors as the basis of investment decisions. Past
studies have used opening and closing prices as key new predicators of financial markets, but
extreme maxima and minima may provide additional information about future price behaviour.
Therefore, the index of three representative stocks in stock market are selected as the research
objects, and the key data collected from them include the opening price, closing price, lowest price,
highest price, date and daily trading volume. The results show that although LSTM neural network
model has some limitations, such as the time lag of prediction, but with attention layer, it can
predict stock prices. Its main principle is to discover the role of time series through analysing the
historical information of the stock market, and to deeply explore its internal rules through the
selective memory advanced deep learning function of LSTM neural network model, so as to
achieve the prediction of stock price trend.
Keywords: lstm , dataset , neural network , stock , machine learning

IV
Ai Based Share Market Data Prediction Using Python

CHAPTER 1

INTRODUCTION

Page |1
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

INTRODUCTION

1.1 MOTIVATION

Data is used in the forecasting process, particularly in the financial market, as forecasting is used in
the stock market to create an automatic prediction of volatility in share prices. The main purpose of
forecasting by data mining in the stock market is to discover knowledge that can assist decision-
makers. With a successful model for stock prediction, we can gain insight about market behavior over
time, spotting trends that would otherwise not have been noticed. With the increasingly computational
power of the computer, machine learning will be an efficient method to solve this problem.

1.2 PROBLEM STATEMENT:

Predicting how the stock market price will perform is one of the most difficult things to do even
without the use of Machine Learning (ML). There are so many factors involved in the prediction
physical factors vs. psychological, rational and irrational behaviour, etc. All these aspects combine to
make share prices volatile and very difficult to predict with a high degree of accuracy. Stock
investment nowadays is a type of income that most people have, especially the wealthy. It is an income
that is called as portfolio income. An income received from 11 investments, dividends and capital
gains. Unlike earned income, is a type of income that received from jobs or company that you worked
for. Predicting the stock price can ease the work of investors in investing their next company’s stock
of choice. Now, investors of way in predicting the future price of a stock is by doing bunch of analysis
using formulas and they need to calculate by themselves. The analysis could be technical analysis,
P/E Ratio, earnings per share and more. By developing a Machine Learning model, all of that can
easily be automated and calculated by a computer algorithm without the need of having a human
supervision.

Page |2
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

1.3 EXISTING SYSTEM:

Nowadays, as the connections between worldwide economies are tightened by globalization,


external perturbations to the financial markets are no longer domestic. With evolving capital
markets, more and more data is being created daily. The intrinsic value of a company’s stock is
the value determined by estimating the expected future cash flows of a stock and discounting
them to the present, which is known as the book value. This is distinct from the market value of
the stock, that is determined by the company’s stock price. This market value of a stock can
deviate from the intrinsic value due to reasons unrelated to the company’s fundamental
operations, such as market sentiment. The fluctuation of stock market is violent and there are
many complicated financial indicators. Only few people with extensive experience and
knowledge can understand the meaning of the indicators and use them to make good prediction
to get fortune. Most people have to rely solely on luck to earn money from stock trading.
However, the advancement in technology, provides an opportunity to gain steady fortune from
stock market and also can help experts to find out the most informative indicators to make better
prediction. The prediction of the market value is of paramount importance to help in maximizing
the profit of stock option purchase while keeping the risk low.

1.4 SCOPE:

This project will help the targeted users to improve their future decision in making more effective
and more accurate and to solve the limitation issues as well in the stock market industry. This
study will be focusing on the investors, financial analyst, economist, businesses, individuals and
as well as finance college student as the users. Hence, the research and development process of
this study will consist of both targeted users and the variety of stock investing platforms and their
features. The details of the scope can be classified into two categories below:

• Targeted Users

Users that will mainly involve with this project’s platform are the users in the business world,
critics, and financial and economy analyst. The users will make use of this project’s dashboard
to make analyst to make their own future decision making process. This dashboard-based
prediction model will have a feature where some finance strategies and decision making will be

Page |3
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

done by Artificial Intelligence (AI) and Machine Learning (ML). This will ease the work of the
analyst out there in making their task for future decision making.

• Development Tools

The proposed development tools for this study will be a Machine Learning algorithm using the
LSTM (Long-Short Term Memory) Neural Network for the analyst of the stock price data and a
simple data scraping technique for extracting the data from the website (yahoo.finance.com). All
the technologies involved will be integrated with each other to make this study a success. The
implementation of the AI and ML technology on the dashboard will be developed via the backend
development of the dashboard with machine learning model and integrated with the data scraping
techniques for the stock data for the ML model to make analysis.

Page |4
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CHAPTER 2

LITERATURE SURVEY

Page |5
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

2. LITERATURE SURVEY

1) Sayavong Lounnapha et al(2019) on Stock Price Prediction Method Based on Convolutional


Neural Network, This paper intends for a prediction model for stock price which is centered at the
convolutional neural networks, that has exceptional capability of learning on its own. The data set is
taught and tested relating the behaviours of both Convolutional Neural Networks and Thai stock
market The result shows that the model on grounds of Convolutional Neural Networks can effectually
recognize the altering trend in stock market price and envisage it which provides significant allusion
for stock price forecast. The accuracy of the prediction is found to be elevated, and it could also be
promoted in the field of finance.

2) Soheila Abrishami(2019) 2 Enhancing Profit by Predicting Stock Prices using Deep Neural
Networks , The prediction of economic time series is quite a herculean task, which has fascinated the
attentiveness of many scholars and is extremely vital for investors. This paper focuses on presenting
a deep learning system, which makes use of a range of facts for a part of the stocks on the NASDAQ
exchange to predict the value of the stock. This model has been trained on the smallest of data for a
particular stock and accurately estimates the concluding value of that stock for multi-step ahead. It
consists of an auto encoder in order to remove noise and makes use of time series data engineering to
syndicate the advanced features with the original features. These new features are given to a Stacked
LSTM Autoencoder for multistep-ahead estimation of the stock concluding value. Further, this
estimation is used by a profit maximization approach to offer assistance on the right time for buying
and selling a particular stock. The results indicate that the suggested framework outclasses the state
of the art time series forecasting methodologies with respect to analytical accuracy and effectiveness.

3) Ferdiansyah et al(2019) on An LSTM-Method for Bit-coin Price Prediction , Bit-coin is a type


of Cryptocurrency and currently is one of a kind of investment on the stock market. Stock markets are
inclined by several risks. And bit-coin is one kind of crypto currency that keeps rising in recent years,
and sometimes suddenly falls without knowing influence on the stock market. There’s a need for
automation tools to predict bit-coin on the stock market because of its fluctuations. This research study
studies how to create mode prediction bit-coin stock market prediction using LSTM. Before
confirming the results the paper tries to measure the results using RMSE (the Root Mean Square

Page |6
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

Error).The RMSE will at all times be larger or equal to the MAE. The RMSE metric assesses how
well a model can calculate a continuous value. The method that is applied on this research to predict
Bit-coin on the stock market Yahoo finance can forecast the result above $12600 USD for the next
couple of days after prediction

4) Jeevan B et al (2019) on Share Price Prediction using Machine Learning Technique , Lately
stock market has been the talk of the town with more and more people from academics and business
showing interest in it. This paper mostly deals with the approach towards predicting stock prices using
RNN (Recurrent Neural Network) and LSTM (Long Short Term Memory) on National Stock
Exchange using numerous elements such as the present-day market price as well as anonymous events.
A recommendation system along with models constructed on RNN and LSTM methods are used in
selecting the company is also mentioned in this paper.

5) Naadun Siri mevan et al(2020) on Stock Market Prediction Using Machine Learning
Techniques , The Stock Market Prices play a crucial role in today’ economy. Researchers have
discovered that social media platforms such as twitter and web news tend to influence the decision
making process of any individual. In this research behavioural reflex towards web news is taken into
count to reduce the gap and make the prediction much more accurate. Precise predictions

Page |7
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

Table2.1 Literature Review

Sr.no Author Topic Name Year of Paper Limitation


Name Outcome
Publication
1 Sayavong Stock Price 2021 To improve Complexity,
Lounnapha Prediction Method integrity, scalability and
Based on transparency data size
Convolutional and security
Neural Network
2 Deepmala Enhancing Profit 2021 To improve Multiple judges
Saratkar by Predicting integrity, and no court trial.
Stock Prices using transparency
Deep Neural and security
Networks
3 Ferdiansyah An LSTM-Method 2021 Deep learning Limited
for Bit-coin Price methods show explanation of
promise in data
Prediction prediction preprocessing and
model parameters

4 Jeevan B Share Price 2021 LSTM's Lack of


Prediction using effectiveness in consideration of
Machine Learning predicting stock market dynamics
Technique prices and external
factors
5 Naadun Siri Stock Market 2021 Comparative Limited data
mevan Prediction Using evaluation of sample; may not
Machine Learning ML models generalize well
Techniques

Page |8
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CHAPTER 3
RESEARCH GAP

Page |9
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

RESEARCH GAP:

Identifying research gaps in stock market prediction is crucial for advancing the field and
improving the accuracy and reliability of predictive models. Here are some potential research
gaps in stock market prediction:

1.Incorporating External Factors:

Current models often focus on historical stock data and financial indicators. Research could
explore the integration of non-traditional data sources (e.g., macroeconomic indicators,
geopolitical events, weather data) to better capture market dynamics.

2. Sentiment Analysis Integration:

While sentiment analysis is used to gauge market sentiment, there's room to enhance its
integration. Research could delve into improving sentiment analysis techniques and
understanding how sentiment impacts stock prices and trading behavior.

3.Interpretable AI Models:

Many AI models used in stock market prediction, such as neural networks and deep learning,
are often considered black boxes. Research could focus on developing more interpretable AI
models that provide insights into the decision-making process, enhancing trust and
understanding.

4.Handling Non-Stationary Markets:

Stock markets are inherently non-stationary, making prediction challenging. Research could
focus on developing robust models that can adapt and perform well in non-stationary market
conditions.

5.Integration of Domain Expertise:

Integrating domain expertise and financial knowledge into predictive models could improve
accuracy. Research could explore ways to effectively combine machine learning with domain
expertise for better predictions.

P a g e | 10
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

6. Quantifying Market Volatility:

Volatility is a critical aspect of stock markets. Research could focus on developing models that
accurately quantify and predict market volatility, aiding risk assessment and portfolio
management.

7. Long-Term vs. Short-Term Predictions:

Most models focus on short-term predictions. Research could explore methods for making
reliable long-term stock market predictions, considering the different factors that influence
long-term trends.

8. Improving Robustness to Outliers:

Outliers can significantly impact stock prices and predictions. Research could focus on
developing models that are robust to outliers and extreme events, ensuring more stable
predictions.

9. Real-time and High-Frequency Trading:

Research could address the challenges of real-time stock market prediction and high-frequency
trading, aiming to develop models that operate efficiently and effectively in such fast-paced
environments.

10. Data Imbalance and Bias:

Stock market data is often imbalanced and biased. Research could focus on techniques to
handle imbalanced data effectively and mitigate biases that may affect prediction outcomes.

P a g e | 11
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CHAPTER 4
RESEARCH OBJECTIVE

P a g e | 12
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

RESEARCH OBJECTIVE:

Research objectives in the field of stock market prediction should be clear, specific, achievable, and aligned
with the overall goals of the study. Here are potential research objectives for a study on stock market prediction

1. Develop a Predictive Model:

Design and develop a predictive model using machine learning or statistical methods to forecast
stock prices accurately.

2. Enhance Model Accuracy:

Investigate and implement techniques to improve the accuracy and reliability of the predictive
model for stock market forecasting.

3. Incorporate External Factors:

Integrate non-traditional data sources such as social media sentiment, news articles, or economic
indicators to enhance the predictive power of the model.

4. Understand Market Volatility:

Analyze and model stock market volatility to provide insights into market dynamics and
fluctuations that impact investment decisions.

5. Optimize Trading Strategies:

Develop algorithms and models to optimize trading strategies based on the predicted stock prices,
aiming for higher returns and reduced risks.

P a g e | 13
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

6. Evaluate Long-Term Predictions:

Assess the accuracy and performance of the model for long-term stock market predictions to aid
investors in making informed decisions for the future.

7. Analyze Sentiment-Price Correlation:

Investigate the relationship between market sentiment (captured from news, social media) and stock
price movements to enhance sentiment analysis in prediction models.

8. Address Overfitting and Underfitting:

Explore techniques to handle overfitting and underfitting issues in predictive models, ensuring
the model generalizes well to unseen data.

9. Evaluate Model Robustness:

Assess the robustness of the predictive model against market irregularities, shocks, or financial crises
to determine its stability and reliability in varying market conditions.

10. Enhance Real-Time Prediction:

Optimize the predictive model for real-time stock market forecasting, aiming to provide timely and
accurate predictions for traders and investors.

P a g e | 14
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CHAPTER 5
PROPOSED SYSTEM

P a g e | 15
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

PROPOSED SYSTEM

The purpose of stock market prediction revolves around leveraging data, analytics, and models to
forecast future price movements in financial markets. This predictive process is driven by a variety of
objectives, each aiming to facilitate informed decision-making and ultimately enhance financial
outcomes for investors, traders, and various stakeholders. Here are the key purposes of stock market
prediction:

1. Risk Management:

Anticipate potential market fluctuations and risks to proactively manage investment portfolios and
reduce financial exposure.

2. Portfolio Optimization:

Optimize investment portfolios by strategically allocating assets based on predicted stock prices
and market trends to achieve higher returns with controlled risk.

3. Trading Strategy Development:

Create effective trading strategies by using predictive models to identify optimal entry and exit
points, improving trading outcomes for short-term investors.

4. Investment Decision Support:

Provide data-driven insights to guide investment decisions, assisting investors in selecting the right
stocks or assets based on predicted market movements.

P a g e | 16
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

5. Financial Planning and Goals:

Aid in long-term financial planning by forecasting stock prices, assisting individuals and
organizations in achieving their financial goals over an extended period.

6. Market Sentiment Analysis:

Analyze and interpret market sentiment by leveraging sentiment analysis techniques, helping in
understanding how public perception affects stock prices and market trends.

7. Fundamental Analysis Enhancement:

Complement traditional fundamental analysis by incorporating predictive models to assess intrinsic


stock values and make more accurate buy or sell recommendations.

8. Algorithmic Trading Automation:

Automate trading decisions using predictive models to execute trades in real-time, capitalizing on
short-term market movements and exploiting trading opportunities.

9. Investor Education and Awareness:

Educate investors about market dynamics, factors influencing stock prices, and the role of
predictive models, promoting a deeper understanding of financial markets.

10. Innovation and Technological Advancements:

Drive advancements in machine learning, artificial intelligence, and data analytics through the
development and refinement of predictive models for stock market forecasting.

P a g e | 17
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

5.1 SYSTEM ARCHITECTURE

Fig 1. SYSTEM DESIGN [9]

P a g e | 18
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CHAPTER 6
SYSTEM REQUIREMENTS

P a g e | 19
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

6.1 SOFTWARE REQUIREMENTS:

• Python
• HTML/CSS
• DJANGO
• VS CODE

6.2 HARDWARE REQUIREMENTS:


• Dedicated GPU
• 64 bit quad core processor
• 16 GB RAM

6.3 TECHNOLOGIES USED:

• Python: Python is a popular programming language used in a wide range of


applications, including data analysis, machine learning, web development, scientific
computing, automation, and more. Here's an overview of Python software commonly
used in various domains .
• Html & Css: HTML (Hypertext Markup Language) and CSS (Cascading Style
Sheets) are fundamental technologies for creating and designing web pages. They
work together to structure and style web content.
• Django : Django is a high-level, open-source Python web framework that enables
developers to build web applications quickly and efficiently. It follows the Model-View-
Controller (MVC) architectural pattern, although in Django, it's referred to as the Model-
View-Template (MVT) pattern. Django's primary goal is to help developers create robust,
secure, and scalable web applications with minimal effort.
• Vs Code : Visual Studio Code, often abbreviated as VS Code, is a free, open-source code
editor developed by Microsoft. It's one of the most popular code editors for a wide range of
programming languages and development tasks. VS Code is known for its versatility,
powerful features, and a rich ecosystem of extensions that can enhance your development
workflow.

P a g e | 20
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CHAPTER 7
SYSTEM DESIGN

P a g e | 21
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

7.1 UML Diagram:

Fig.2 User Case Diagram for Overall System

7.2 DFD LEVEL 0 :

Fig.3 DFD DIAGRAM 1

P a g e | 22
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CHAPTER 8

PROJECT IMPLEMENTATION

P a g e | 23
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

8.1 RESULT/OUTPUT:.

Fig.4 Home Page

Fig.5 To Predict stock price

P a g e | 24
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

Fig 6. Prediction Dashboard

Fig 7 Ticker List

P a g e | 25
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CHAPTER 9
TEST CASES

P a g e | 26
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

UNIT TEST CASE


Creating unit test cases for a stock market prediction system involves testing individual units of code
to ensure they work as expected in isolation. Unit tests are typically written for functions, methods, or
small components to validate their behavior and functionality. Below are examples of unit test cases
for a stock market prediction system:

1. Data Preprocessing:

Test Case 1: Test Data Cleaning Function:

Input: A dataset with missing or erroneous values

Expected Output: Cleaned dataset without missing or erroneous values

Validate that the data cleaning function effectively handles missing or erroneous data.

2. Prediction Model:

Test Case 2: Test Model Training Function:

Input: Historical stock market data

Expected Output: Trained prediction model

Validate that the model training function properly trains the prediction model.

3. User Interface:

Test User Input Handling:

Input: Various user input formats (e.g., CSV, JSON)

Expected Output: Parsed and processed data

Validate that the user input handling function correctly processes different input formats.

4. Integration Testing:

Test Case 5: Test Data Integration Function:

P a g e | 27
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

Input: Multiple data sources (e.g., stock prices, economic indicators)

Expected Output: Integrated and processed data

Validate that the data integration function accurately combines and processes data from various
sources.

5. Error Handling:

Test Case 6: Test Invalid Input Handling:

Input: Invalid or malformed input

Expected Output: Proper error handling (e.g., exception, error message)

Validate that the error handling mechanism properly handles invalid input

6. Real-Time Prediction:

Test Case 7: Test Real-Time Prediction Function:

Input: Latest available stock market data

Expected Output: Predicted stock market values

Validate that the real-time prediction function produces accurate predictions based on the latest data.

7. Performance Testing:

Test Case 8: Test Response Time:

Input: Large dataset for prediction

Expected Output: Prediction within a reasonable time limit

Validate that the prediction function meets the performance requirements for response time.

P a g e | 28
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CONCLUSION AND FUTURE WORK

P a g e | 29
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

CONCLUSION

To sum up everything that has been stated, stock market price is difficult to predict still. The reason
is to that, it is a curve which keeps changing and turning on prices from low to high and high to low.
Stock market is manipulated. What it means by that, is that nowadays, you can manipulate the
market by doing simple things like trending on social media.

Recent example, when a group of young people went on Reddit (Social media platform) and ask
their followers to buy a stock from the New York stock exchange so the price of that stock will go
up and eventually they sell all, then the stock is back to its low prices. This is an example how you
can manipulate the stock market.

However, if the stock market is manipulated regularly, a machine can learn from their pattern and
can still predict the stock prices or outcome. Hence, this project’s objectives can still be achieved
as it a machine that learns throughout time.

P a g e | 30
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

FUTURE WORK

Predicting stock market data using AI and Python is a challenging and promising field that continues
to evolve. There are several areas of future work and research you can explore to improve the accuracy
and reliability of AI-based share market data predictions. Here are some key directions you can
consider Advanced Machine Learning Models Explore more advanced machine learning and deep
learning models. Deep learning architectures like recurrent neural networks (RNNs), long short-term
memory (LSTM) networks, and transformers have shown promise in time-series forecasting tasks.

Ensemble Methods Implement ensemble methods to combine predictions from multiple models.
Techniques such as bagging, boosting, and stacking can help improve the overall predictive
performance.

Feature Engineering Investigate novel feature engineering techniques to extract more relevant
information from the data. Feature selection, dimensionality reduction, and domain-specific feature
engineering can be crucial.

Alternative Data Sources Incorporate alternative data sources, such as social media sentiment, news
sentiment, and economic indicators. These can provide valuable information for stock market
prediction.

Apply reinforcement learning techniques to develop trading algorithms that can adapt to changing
market conditions. Reinforcement learning agents can learn to make buy and sell decisions based on
rewards and penalties.

P a g e | 31
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

REFERENCES

P a g e | 32
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY
Ai Based Share Market Data Prediction Using Python

REFERENCES

[1] “Apache Spark - Lightning-Fast Unified Analytics Engine,” 2020. Available:


https://spark.apache.org/

[2] V. Atanasov, C. Pirinsky, and Q. Wang, “The efficient market hypothesis and
investor behavior,” 2018.

[3] S. Agrawal, D. Thakkar, D. Soni, K. Bhimani, and C. Patel, “Stock market


prediction using machine learning techniques,” International Journal of Scientific
Research in Computer Science, Engineering and Information Technology, 2019.

[4] M. Afeef, A. Ihsan, and H. Zada, “Forecasting stock prices through univariate arima
modeling,” 2018.

[5] P.-F. Pai and C.-S. Lin, “A hybrid arima and support vector machines model in stock
price forecasting,” Omega, vol. 33, no. 6, pp. 497–505, 2018.

[6] https://zerodha.com/varsity/

[7] https://towardsdatascience.com/illustrated-guide-to-lstms-and-gru-s-a-step-by-
step-explanation-44e9eb85bf21

[8] "A hybrid stock trading framework integrating technical analysis with machine
learning techniques" by P.K. Singh, G. K. Singh, and S.K. Singh. This paper
explores the integration of technical analysis and machine learning for stock
trading.

[9] "Stock Market Forecasting Using Machine Learning Algorithms" by N. Prasath,


A. Gopal, and S. Raghav. The study focuses on applying machine learning
algorithms to predict stock market trends.

[10] "Forecasting Stock Market Returns Volatility in the Emerging Markets" by C.


Cheng, R. Hasan, and D. Chow. This research paper examines forecasting stock
market volatility in emerging markets.

P a g e | 33
ALAMURI RATNAMALA INSTITUTE OF ENGINEERING AND TECHNOLOGY

You might also like