Data Acquisition:
For stock market open price prediction, I have collected historical data of Reliance Industries. It is a past 3 years data.
Reliance Industries stock market data past 3 years ( you can adjust time period )
Nifty index past 3 years data
* Date must be same for Reliance and Nifty 50.
* From Nifty 50 extract open (bcoz we consider open price) column, and add to Reliance data set.
The required final dataset is
Data Exploration:
Here, we have imported required libraries and dataset.
To build a model we need previous day closing price and volume for the current day open price. By using the shift command, we adjust the close and volume column.
Then we check for null by using isnull() function, then we drop those null values by dropna(). The shape of dataset is (731, 7) 731 rows and 7 columns.
Outliers can affect model accuracy, so we need to remove the outliers. The box plot will shows the presence of outliers. These outliers can be removed by using Inter quartile range method.
From the heatmap plot, there is strong positive correlation between current day open price and previous day closing price. open price is having positive correlation with Nifty index and previous day volume.
Data Modeling:
The variables divided into dependent variable (x⇒open price) and independent variables (y⇒other than open price). I have split data into 80:20. 80% is the training set and 20% is the testing set.
We choose Linear Regression algorithm to build model. And we compared actual values with predicted values. Finally, dump into pickle file to deploy the model.
Data Deployment:
Comments
Post a Comment