Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 1.78 KB

README.md

File metadata and controls

60 lines (42 loc) · 1.78 KB

Stock Price Forecasting

This is an attempt to forecast the closing price of a stock given its previous closing prices.

This repository contains:

  1. The python code
  2. The generated prediction graph
  3. The sample dataset
  4. ReadMe file itself

Table of Contents

About

Dataset

The dataset used in this repo is the historical data of Tata Consultancy Services (a company listed in National Stock Exchange, India) from August 12, 2002 to November 26, 2021. The dataset was scraped from Yahoo Finance using Selenium. The data from Selenium is parsed using BeautifulSoup and converted to their respective datatypes before storing it in the Pandas dataframe.

Model

A stacked 2 layered-LSTM model followed by a Dense layer is employed. The inputs from the training dataset are concatenated with their true values whereas the inputs from the test dataset is concatenated with all zeroes. The model is expected to predict the true values of the test dataset. Shown below is a stacked LSTM model.

The hyper-parameters can be changed in the python file.

Output

Forecasted price vs Actual price

To Run

Make sure you have the following libraries installed to run the code.

numpy
pandas
matplotlib
bs4
selenium
scikit-learn
plotly
keras

Download the following files in the same directory.

Code.py 

Run Code.py

cd directory-where-the-files-are-saved
python3 Code.py