This repository demonstrates how to forecast stock prices using the ARIMA (AutoRegressive Integrated Moving Average) model in Python. The stock market data of HCL from April 2017 to April 2022 is used as a case study to predict the future stock prices.
- Introduction
- Data Information
- Dependencies
- Installation
- Usage
- Results
- Further Reading
- Contributing
- License
The stock market is highly volatile and unpredictable, making it challenging to forecast stock prices accurately. In this project, we use the ARIMA model, a class of statistical models for analyzing and forecasting time series data, to predict future stock prices.
The dataset used in this project consists of stock market data for HCL from 2017-04-21 to 2022-04-21. The dataset includes various attributes such as Open, High, Low, Close, Adj Close, and Volume. The 'Adj Close' column is used for predicting the future stock prices.
- Python 3.x
- pandas
- numpy
- matplotlib
- statsmodels
- pmdarima
- Clone the repository:
git clone https://github.com/yourusername/StockPriceForecasting_ARIMA.git
Certainly! Below is a suggested README file for your GitHub repository on forecasting stock prices using ARIMA in Python. I've also included some potential names for your repository.
StockPriceForecasting_ARIMAARIMA_StockPredictionStockPricePredictorStockForecastingARIMA_StockAnalysis
# Stock Price Forecasting using ARIMA in Python
This repository demonstrates how to forecast stock prices using the ARIMA (AutoRegressive Integrated Moving Average) model in Python. The stock market data of HCL from April 2017 to April 2022 is used as a case study to predict the future stock prices.
## Table of Contents
- [Introduction](#introduction)
- [Data Information](#data-information)
- [Dependencies](#dependencies)
- [Installation](#installation)
- [Usage](#usage)
- [Results](#results)
- [Further Reading](#further-reading)
- [Contributing](#contributing)
- [License](#license)
## Introduction
The stock market is highly volatile and unpredictable, making it challenging to forecast stock prices accurately. In this project, we use the ARIMA model, a class of statistical models for analyzing and forecasting time series data, to predict future stock prices.
## Data Information
The dataset used in this project consists of stock market data for HCL from 2017-04-21 to 2022-04-21. The dataset includes various attributes such as Open, High, Low, Close, Adj Close, and Volume. The 'Adj Close' column is used for predicting the future stock prices.
## Dependencies
- Python 3.x
- pandas
- numpy
- matplotlib
- statsmodels
- pmdarima
## Installation
1. Clone the repository:
```bash
git clone https://github.com/yourusername/StockPriceForecasting_ARIMA.git- Navigate to the project directory:
cd StockPriceForecasting_ARIMA - Install the required dependencies:
pip install -r requirements.txt
- Load the dataset:
import pandas as pd data = pd.read_csv('path/to/your/data.csv')
- Check for missing values:
data.isnull().sum()
- Visualize the data:
import matplotlib.pyplot as plt plt.plot(data['Adj Close']) plt.title('Stock Prices of HCL') plt.show()
- Check for stationarity using Augmented Dicky Fuller (ADF) test and make the data stationary if needed:
from statsmodels.tsa.stattools import adfuller result = adfuller(data['Adj Close']) print('ADF Statistic:', result[0]) print('p-value:', result[1])
- Apply the ARIMA model:
from pmdarima import auto_arima model = auto_arima(data['Adj Close'], seasonal=False) model.summary()
- Make predictions and evaluate the model:
train = data[:int(0.75*len(data))] test = data[int(0.75*len(data)):] model.fit(train['Adj Close']) predictions = model.predict(n_periods=len(test)) plt.plot(test['Adj Close'].values, label='Actual') plt.plot(predictions, label='Predicted') plt.legend() plt.show()
The ARIMA model with optimal parameters (p=0, d=1, q=1) is used to predict the stock prices. The model performance is evaluated using metrics such as Mean Squared Error (MSE), Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), and Mean Absolute Percentage Error (MAPE).
- Autoregressive Integrated Moving Average - Wikipedia
- What is ARIMA and SARIMA Model?
- Autocorrelation and Partial Autocorrelation in Time Series Data
Contributions are welcome! Please open an issue or submit a pull request for any improvements or suggestions.
This project is licensed under the MIT License - see the LICENSE file for details.