Bitcoin_Price_Prediction_Using_LSTM
Bitcoin_Price_Prediction_Using_LSTM
(IRJET)
Volume: 09 Issue: 04 | Apr 2022 www.irjet.net p-ISSN: 2395-0072
1,2,3Undergraduate Student, Dept. Of Computer Engineering, Universal College of Engineering, Mumbai, India
4Assistant Professor, Dept. Of Computer Engineering, Universal College of Engineering, Mumbai, India
---------------------------------------------------------------------***---------------------------------------------------------------------
Abstract - Bitcoin is one of the most popular and valuable paper, we are predicting the Bitcoin price trend using a
cryptocurrency in the current financial market, attracting Long Short-Term Memory (LSTM) model. Our model is
traders for investment and thereby opening new research aimed to predict the next five day’s price of Bitcoin.
opportunities for researchers. Countless research works
have been performed on Bitcoin price prediction with 2. REVIEW OF LITERATURE
different machine learning prediction algorithms. For the
research: relevant features are taken from the dataset A literature survey was carried out to find various papers
having strong correlation with Bitcoin prices and random published in international journals related to various
data chunks are then selected to train and test the model. Bitcoin price prediction algorithms, and associate the best
The random data which has been selected for model algorithm for the same.
training, may cause unfitting outcomes thus reducing the
price prediction accuracy. Here, a proper method to train a 2.1 Existing Systems
prediction model is being scrutinised. The proposed
methodology is then applied to train a simple Long Short Numnoda et al. [1] have obtained highly accurate results
Term Memory (LSTM) model to predict the bitcoin price for on implementing their prediction Gated Recurrent Unit
the upcoming 5 days. When the LSTM model is trained with (GRU) model. However, their prototype has a large time
a suitable data chunk, thus identified, sustainable results complexity. Thus, complicating the expected results in this
are found for the prediction. In the end of this paper, the ever-changing environment. Additionally, the selected
work culminates with future improvements. features aren’t enough to predict the Bitcoin prices; as
various factors like social media, policies, and laws that
Key Words: Bitcoin, Cryptocurrency, Machine each country announces to deal with digital currency, can
Learning, Price Prediction, LSTM all play a major effect on the fluctuation of the Bitcoin
prices.
1. INTRODUCTION
Mangla et al. [2] have compared four different price
Instead of any direct human investments, generating profit prediction models: Recurrent Neural Networks (RNN),
with the help of algorithms is a common practice in the Logistic Regression, Support Vector Machine, and Auto
stock market. Many case studies have been performed to Regressive Integrated Moving Average (ARIMA). Their
reach the conclusion that mathematical models warrant major findings are that- ARIMA performs poorly for
better results than humans. Bitcoins are an eye catching predictions extending beyond the next day. Their RNN
initiative in the fields of cryptography, economics, and model can accurately predict price fluctuations for up to
computer sciences, as such currencies have a special six days. And the logistic regression model can give
character which is gained when integrating currency units accurate results only if a separable hyperplane exists.
with cryptographic technology. Due to the fact that
cryptocurrency has a minute history, when compared to Guo et al. [3] have used a hybrid method consisting of
the stock market, new and unexplored territories are thus multi-scale residual blocks and an LSTM network to
being scouted. Structurally, both the stock market and the predict Bitcoin price. Although, their work does not
cryptocurrency price data are having characteristics such include comprehensive metrics which measure the
as time series data, but high volatility is routinely present investor’s attention to more timely detection of bitcoin
in the latter, with heavy wavering in the prices. A market volatility, therefore resulting in a less accurate
cryptocurrency market differs from a traditional stock prediction.
market in the respect that the former has a lot of new
features. It is required to apply new techniques for Awoke et al. [4] have considered basic deep learning
prediction suitable for the cryptocurrency market. Fewer models like GRU and LSTM. However, their research lacks
studies have been conducted on cryptocurrency price further investigation to enhance the model accuracy by
prediction when compared to the stock market. In this considering different parameters.
© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 123
International Research Journal of Engineering and Technology e-ISSN: 2395-0056
(IRJET)
Volume: 09 Issue: 04 | Apr 2022 www.irjet.net p-ISSN: 2395-0072
While using this model, first, the dataset of the crypto Fig -1: Bitcoin Dataset
currency used needs to be uploaded. This, usually, contains
the various features that the prediction model has to depend The second step involves filtering and cleaning the data
on. For e.g. average block size, total number of Bitcoins set. This involves removing all the incomplete data from
mined, day high & day low (highest and lowest values of the rows. It also involves filtering out unnecessary
different days), number of transactions, trade volume, etc. features present in the data collected. For our model, we
Then, secondly, the dataset will be applied on the regression will only use the columns labelled: Date, Price, Open, High,
model to obtain the predicted price. and Low, as shown in Table 1 below.
What the model proposes to do is that, first the data on Bitcoin Table -1: Features Used In the Dataset
Price fluctuations is gathered, of the past couple of years,
from the internet. Then, after the process of data acquisition, Features Used In The Dataset
the database should be organised. The database is divided into Sr. No. Variable Variable Description Data
various spreadsheet files, which are then uploaded to the Name Type
software mainly used for data processing. The necessary
calculations, like classification and regression, are then done. 1 Time Date and time of Date
And finally the results are evaluated in terms of accuracy, observation
error rates involved. 2 Volume Sum total of trades Numbe
taking place. r
4. DESIGN DETAILS
3 Open Opening price on the Numbe
given day. r
4.1 System Architecture
4. High Highest price on the Numbe
Firstly, we collect the data set from the online source: given day. r
Kaggle. The data set represents the Bitcoin price in United
5. Low Lowest price on the Number
States Dollars (USD). The dataset includes all the
given day.
information about bitcoin prices from 27th October, 2015
to 30th October, 2021.
6. Close Closing price on a given Number
day.
© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 124
International Research Journal of Engineering and Technology e-ISSN: 2395-0056
(IRJET)
Volume: 09 Issue: 04 | Apr 2022 www.irjet.net p-ISSN: 2395-0072
5. MODEL IMPLEMENTATION
© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 125
International Research Journal of Engineering and Technology e-ISSN: 2395-0056
(IRJET)
Volume: 09 Issue: 04 | Apr 2022 www.irjet.net p-ISSN: 2395-0072
5.4 Data Generator 5.7 LSTM Prediction using testX and plotting line
graph against actual testY
Post scaling, we will proceed with making the data
generator function, which will make the data ready for the Due to scaling done earlier with the help of MinMaxScaler,
LSTM model feed. We frame our model, using a “lookback” the predicted scale will be between zero and one. We have
period to take a window of the last five days of data to to transfer this scale to the original data scale. Thus, we
predict the data of the current day. A new function is are going to use inverse transformation to scale back the
defined, which will split the input sequence into windows data to the original presentation, as shown in Figure 6.
of data appropriate for fitting a LSTM model. We need to
define a lookback period which tells us how many
previous timesteps are used to predict the subsequent
timestep.
From the callback module of the keras library we are Fig -7: Plot of predicted test and actual test data
importing the callbacks: ModelCheckpoint, and
EarlyStopping. These callbacks are used as a best practice 5.8 LSTM Prediction using trainX and plotting
to save the model at various checkpoints or after each line graph against actual trainY
epoch. Also, EarlyStopping is used to stop the training
when the best loss is reached, that is, when a monitored This step is similar to the previous step, except the fact
metric has stopped improving. that we are performing inverse transformations on the
train data.
© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 126
International Research Journal of Engineering and Technology e-ISSN: 2395-0056
(IRJET)
Volume: 09 Issue: 04 | Apr 2022 www.irjet.net p-ISSN: 2395-0072
Fig -9: Plot of predicted train and actual train data Finally, we are generating a graph of the entire prediction
of the test data (including the future five days) against
5.9 Root Mean Square Error actual testY, as shown in Figure 12. Up to 30th October,
2021, we book the predicted test data (in red) and the
Finally, we will be generating the root mean square error actual test data (in blue) on the ground, because this is the
(RMSE) for both the test and the train data. RMSE is the time period for which we have the actual ground truth.
measure of how well a regression line will fit the data Beyond the aforementioned date we are having only the
points. forecasted price of Bitcoin.
© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 127
International Research Journal of Engineering and Technology e-ISSN: 2395-0056
(IRJET)
Volume: 09 Issue: 04 | Apr 2022 www.irjet.net p-ISSN: 2395-0072
REFERENCES
© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page 128