Bitcoin Price Prediction using Deep Learning
Sulochana Devi Sheldon Noronha Aditya Jagtap Sahil Desai
Department of Department of Department of Department of
Information Technology Information Technology Information Technology Information Technology
Xavier Institute of Xavier Institute of Xavier Institute of Xavier Institute of
Engineering Engineering Engineering Engineering
Mumbai, India Mumbai, India Mumbai, India Mumbai, India
sulochana.d@[Link] sheldonnoronha26@[Link] adityajagtap38@[Link] sahild2809@[Link]
m
56,832 points.24 hrs of data was taken as input and output for
Abstract — Bitcoin is a decentralized digital currency created the BTC price of the next hour. For this the Multi-Layer
in January 2009..We will go deep into the datasets, do an Perceptron (MLP) was the unsuitable case for predicting price
EDA, feature extraction and predict the price of bitcoin using based on current trends whereas Long Short-Term Memory
Stochastic, Machine Learning and Deep Learning models. In (LSTM) gave the best prediction when the past memory and
this particular work we will be visualising the Time Series Gated Recurrent Network (GRU) was included.[1]
data, handling the missing values with various imputation
techniques. Feature extraction is performed before model
So here to predict BTC price movement and prices in short and
building, the focus of study will be these four models ARIMA,
medium terms, High performance ML-based classification and
Facebook prophet, XG boost and LSTM. Comparing the
models and their evaluation metrics to see how each model regressions are demonstrated. In this the work goes beyond
have performed that by using machine learning-based models for one, seven,
Keywords: Blockchain, Bitcoin, Cryptocurrency, Neural thirty and ninety days compared to the previous ML-based
Network. classification which has only one-day time frames. The models
which are developed have 65% accuracy for the next-day
I. INTRODUCTION forecast and 62-64% for seventh-ninetieth day forecast, while
Bitcoin is a cryptographic currency which is utilized the error percentage is as low as 1.44% while it varies from
worldwide for advanced installment or basically for 2.88-4.10% for horizons of seven to ninety days.[2]
speculation purposes. Bitcoin is decentralized, for example it
isn't possessed by anybody. Exchanges made by Bitcoins are So here firstly what affects the BTC value is taken into
simple as they are not attached to any nation. Speculation
consideration. Here there are two phases in the first phase is to
should be possible through different commercial centers
understand and identify the daily trends in the BTC market
known as "bitcoin trades". These enable individuals to
sell/purchase Bitcoins utilizing various monetary forms. while gaining insight where the data sets consists of various
features relating to the BTC price and payment network over
Bitcoin emerged out of the 2008 global economic crisis when the course of five years daily records and in the second phase
big banks were caught misusing borrowers' money, using the available information it will be possible to predict the
manipulating the system, and charging exorbitant fees. To sign of daily price change with highest possible accuracy.[3]
address such issues, Bitcoin creators wanted to put the owners
of bitcoins in-charge of the transactions, eliminate the This paper looks over user comments in online communities to
middleman, cut high interest rates and transaction fees, and predict the transactions taking place in crypto. It was predicted
make transactions transparent. They created a distributed that the prices would fluctuate at low costs. The method used
network system, where people could control their funds in a approved buying crypto currencies, and gave information on
transparent way. aspects influencing user decisions. Moreover, the simulated
investment demonstrated the methods used are applicable
However, there are issues with bitcoins such as hackers while trading in crypto. [4]
breaking into accounts, high volatility of bitcoins, and long
transaction delays. Considering the volatility it's always In this paper a tree-based classifier is used to perform the
challenging to predict the bitcoin price. predictionDecision Tree Classification [Link] their
analysis they implement decision tree learning based on
In this study, we have used models such as ARIMA, LSTM, cross-entropy impurity function optimization. They perform
FB prophet, XG boost to predict the price 1,000 independent rounds of training and [Link] each of
the rounds they select the last 510 sample points as test data
and return the win ratio of each type of prediction and they try
to clip the trading cutoff to check the real trading performance
of the predictive model. [5]
II. LITERATURE REVIEW
Here the data of BTC per minute was gathered and it was The study revolves around forecasts of crypto currency
rearranged so that to reflect BTC price in hours, and a total of particular bitcoin price using algorithms like
Electronic copy available at: [Link]
ARIMA-autoregressive integrated moving average and NEAR We replaced the missing values by using three imputation
neural network autoregressive models. techniques which are ‘ffill’ or ‘pad’, ‘bfill’ or ‘backfill’ and
Using the static forecast approach they have tried to forecast the linear interpolation method. In the ‘ffill’ method, the
next day bitcoin prices both with and without re-estimation of NaNs are replaced with the observed value. In the ‘bfill’
method, the NaNs are replaced with the next observed value.
the forecast model. [6]
By using these two methods, a fair portion of missing values
are filled. In order to fill the remaining values, we use the
III. PROPOSED WORK linear interpolation method. It is an imputation technique that
assumes a linear relationship between data points and utilises
In the system that we have implemented, we have taken the non-missing values from adjacent data points to compute a
data from January, 2012. This data is within 1 minute value for a missing data point. Thus, using these three
intervals. Four types of ML models have been used: ARIMA, methods, we observe no null values in our dataset.
Facebook prophet, XG boost and LSTM.
Exploratory Data Analysis:
1. Visualizing the weighted price using markers:
When working with time-series data, a lot can be revealed
through visualizing it. It is possible to add markers in the plot
to help emphasize the specific observations or specific events
in the time series.
Fig 1: Comparison of various Cryptos
At first we compared various cryptos using a dataset that
consisted of various coins like Bitcoin, Dash, Etherium,
Cardano, etc which were mapped with each other alongside
columns such as Date, Open, High, Close, Adj Close, Volume,
etc. We then plotted various pyplots, box plots, pie charts,
Fig 2: Weighted prices v years
violin plots in order to analyze all the currencies and figured
out that bitcoin would be ideal to work upon because of the
volume that it is traded in and its stability. 2. Visualizing using KEDs:
Summarizing the data with Density plots to see where the
mass of the data is located.
Methodology:
Data Collection:
In this study, we are focusing on the time-series forecast of
BTC prices using machine learning. A time-series is a set of
data values with respect to successive moments in time.
Time-series forecast is the forecast of future behavior by
analyzing time-series data. First we collect all the Data from
the “Bitcoin Historical Data” dataset which is available on
Kaggle. Included here is historical bitcoin market data at
1-min intervals for select bitcoin exchanges where trading
takes place. It consists of a time period of Jan 2012 to
September 2020, with minute to minute updates of OHLC
(Open, High, Low, Close), Volume in BTC and indicated
currency, and weighted bitcoin [Link] Open and Close Fig 3: Visualizing KEDs
columns indicate the opening and closing price on a particular
day. The High and Low columns provide the highest and the
lowest price on a particular day, respectively. The Volume 3. Visualizing using Lag Plots:
column tells us the total volume of traded on a particular Lag plots are used to observe the autocorrelation. These are
[Link] Weighted price is a trading benchmark used by traders crucial when we try to correct the trend and stationarity and
that gives the weighted price a security has traded at we have to use smoothing functions. Lag plot helps us to
throughout the day, based on both volume and price. It is understand the data better.
important because it provides traders with insight into both the
trend and value of a security.
Missing Values:
Electronic copy available at: [Link]
7. ADF test:
The only difference here is the Null hypothesis which is just
opposite of KPSS. The null hypothesis of the test is the
presence of unit root, that is, the series is non-stationary.
Fig 4: Lag plots
Thus, We can see that there is a positive correlation for
minute, hour and daily lag plots. We observed absolutely no
correlation for month lag [Link], we resampled our data to
utmost the daily level to preserve autocorrelation. Fig 6: Result of Dickey-fuller test
Thus ADF says that the series is stationary. As KPSS says it is
4. Time resampling: not stationary, we came to the conclusion that the series is
As we noticed the correlation in the above diagram, we difference stationary.
decided to resample the data in an Hourly format. Thus we
replaced the price of the particular hour by the mean of all the Feature Extraction:
minute prices in that hour.
Time series data can be noisy due to high fluctuations in the
5. Time Series Decomposition: market. As a result, it becomes difficult to gauge a trend or
We can decompose a time series into trend, seasonal and pattern in the [Link] we’re looking at daily data, there’s quite
remainder components. The series can be decomposed as an a bit of noise present. It would be nice if we could average this
additive or multiplicative combination of the base level, trend, out by a week, which is where a rolling mean comes in.A
seasonal index and the [Link],we performed some rolling mean, or moving average, is a transformation method
statistical tests like KPSS and Augmented Dickey-Fuller tests which helps average out noise from data. It works by simply
to check stationarity. splitting and aggregating the data into windows according to
function, such as mean(), median(), count(), etc. For this
example, we’ll use a rolling mean for 3, 7 and 30 [Link]
data becomes a lot less noisy and more reflective of the trend
than the data itself.
Model building:
To measure the performance of our forecasting model, We
typically want to split the time series into a training period and
a validation period. This is called fixed partitioning.
We'll train our model during the training period, we'll evaluate
it during the validation period. Here's where you can
Fig 5: Time series Decomposition experiment to find the right architecture for training. And
work on it and your hyper parameters, until you get the
desired performance, measured using the validation set. Often,
Post time series decomposition we don't observe any once you've done that, you can retrain using both the training
seasonality. Also, there is no constant mean, variance and and validation [Link] then test during the test(or forecast)
covariance, hence the series is Non Stationary. period to see if your model will perform just as well.
6. KPSS test: And if it does, then you could take the unusual step of
retraining again, using also the test data. The test data is the
The KPSS test, short for Kwiatkowski-Phillips-Schmidt-Shin
closest data you have to the current point in time. And as such
(KPSS), is a type of Unit root test that tests for the stationarity
it's often the strongest signal in determining future values. If
of a given series around a deterministic trend.
your model is not trained using that data, too, then it may not
be optimal.
1. ARIMA model:
An autoregressive integrated moving average, or ARIMA, is a
In this test, the null hypothesis is that the series is Stationary.
statistical analysis model that uses time series data to either
As we got a p-value of 0.01(<0.05), we reject the null
better understand the data set or to predict future
hypothesis. Hence, we came to the conclusion that the series is
trends[7].ARIMA is an acronym that stands for
not stationary.
AutoRegressive Integrated Moving Average. It is a class of
models that captures a suite of different standard temporal
Electronic copy available at: [Link]
structures in time series [Link] acronym is descriptive,
capturing the key aspects of the model itself. Briefly, they are:
● AR: Autoregression A model that uses the dependent
relationship between an observation and some
number of lagged observations.
● I: Integrated The use of differencing of raw
observations (e.g. subtracting an observation from an
observation at the previous time step) in order to
make the time series stationary.
● MA: Moving Average A model that uses the
dependency between an observation and a residual
error from a moving average model applied to lagged
observations.
Fig 7: Arima prediction subplot
2. Facebook Prophet:
Facebook Prophet is an open-source algorithm for generating
2. FB PROPHET model:
time-series models that uses a few old ideas with some new
twists. It is particularly good at modeling time series that have
Our FB prophet model gave an RMSE score of 323.009 and an
multiple seasonalities.[8]Prophet is a procedure for forecasting
MAE score of 229.302.
time series data based on an additive model where non-linear
trends are fit with yearly, weekly, and daily seasonality, plus
holiday effects.
It works best with time series that have strong seasonal effects
and several seasons of historical data. Prophet is robust to
missing data and shifts in the trend, and typically handles
outliers well.
3. XG Boost:
XGBoost is a decision-tree-based ensemble Machine Learning
algorithm that uses a gradient boosting framework. In
prediction problems involving unstructured data (images, text,
etc.) artificial neural networks tend to outperform all other
algorithms or frameworks.[8]
4. LSTM:
Long short-term memory (LSTM) is an artificial recurrent
neural network (RNN) architecture used in the field of deep Fig 8: Fb prophet prediction subplot
learning. Unlike standard feedforward neural networks, LSTM
has feedback connections. It can process not only single data 3. XG BOOST model:
points (such as images), but also entire sequences of data
(such as speech or video). For example, LSTM is applicable to For this model, we opted for a hold-out based validation which
tasks such as unsegmented, connected handwriting means we selected data after 2019 as holdout and trained our
recognition, speech recognition and anomaly detection in model on data from 2012 to 2019. We obtained an RMSE
network traffic or IDSs (intrusion detection systems).[9] score of 470.260 and a MAE score of 369.104.
V. RESULTS
In this section, we present the results of the models used to
predict the bitcoin prices.
1. ARIMA model:
The Auto ARIMAX model did a fairly good job in predicting
the bitcoin price given data till the previous day. After
applying this model, we got an RMSE score of 322.432 and a
MAE score of 227.302.
4. LSTM model:
We obtained the best results from our LSTM model and thus
decided to use it for our prediction of the bitcoin price for the
next 30 days. The RMSE for our LSTM model obtained is
Electronic copy available at: [Link]
0.04792 and it’s MAE result is 0.20979 for our train datasets. We observed remarkable results using LSTMs. They really
After using this model on our test dataset we got an incredible work a lot better for most sequence tasks. Also the other
accuracy and the RMSE and MAE values for this test dataset model’s performance was not as good as LSTM which is
are 0.05444 and 0.22614 respectively. evident from the RMSE score.
We can increase the number of epochs to refine our model
performance, we can increase epochs to 100 and see the
results. Also, the number of lag features can be increased
beyond 100 to help in model learning.
VI. REFERENCES
[1] Bitcoin Price Prediction Based on Deep Learning Methods
Xiangxi Jiang Published: February 11, 2020
[2] Time-series forecasting of Bitcoin prices using
high-dimensional features: a machine learning approach
Comparing various models: Mohammed Mudassir, Shada Bennbaia, Devrim Unal &
Mohammad Hammoudeh Published: 04 July 2020
Below is show the RMSE and MAE score which are the
validation metrics for the models performance
[3] Bitcoin Price Prediction using Machine Learning Siddhi
Velankar, Sakshi Valecha, Shreya Maji Published: 11
February 2018
[4] Predicting Fluctuations in Cryptocurrency Transactions
Based on User Comments and Replies Young Bin Kim,Jun
Gi Kim,Wook Kim,Jae Ho Im,Tae Hyeong Kim,Shin Jin
Kang,Chang Hun Kim Published: August 17, 2016
[5] Predicting Bitcoin Returns Using High-Dimensional
Technical Indicators Jing-Zhi Huang, William Huang, Jun
Ni Received Date: 12 October 2018Accepted Date: 29
Fig 8: Validation metrics October 2018
[6] Next-Day Bitcoin Price Forecast Ziaul Haque Munim
The subplot below shows the comparison between the actual ,Mohammad Hassan Shakil and Ilan Alon Published: 20
weighted price along with the predicted weighted price by the June 2019
ARIMA, Fb prophet and XG boost model.
[7] Investopedia/ARIMA
[8] Towards data science
[9] Wikipedia
V. CONCLUSION & FUTURE WORK
Electronic copy available at: [Link]