Revolutionizing the Future of Financial Services

In an era where financial services are rapidly evolving, Ambit Finance has emerged as a pioneering force in reshaping the landscape of banking, investing, and wealth management. With its innovative…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




The hidden secrets of the bitcoin price

Exploring the bitcoin price from a statistical point of view.

Bitcoin is a digital currency created in 2009 by Satoshi Nakamoto, he describes it as a “peer-to-peer version of electronic cash”. One big advantage of bitcoin (and other cryptocurrencies) is that all the data is open and immutable, residing inside the blockchain. The openness and immutability of the data has made the research behind blockchain really active, mostly on the price forecasting. Many, rightfully, rush into the blockchain data (such as addresses, transactions etc..), but I will show in this post that the bitcoin price itself is already really informative. Understanding how the price behaves will make a substantial difference in the choice of models and parameters for predicting price.

The behaviour of the price is best understood via two main properties of time series: stationarity and seasonality. For example, a stationary time series can be much easier to model than a non-stationary.

In what’s coming, I will share with you my thought process in looking at the price, using statistical tools and python programming.

As I said, there are two important properties attached to time series: seasonality and stationarity.
A stationary process means that the distribution (statistical properties) of the data does not changes over time, this is why it is much easier to model. Seasonality represents how frequently the data change (for the bitcoin price, we can express it in cycles per day), and also when it starts.

We will first focus on the analysis of the stationarity, and after the seasonality.

First, we want to create a function to load the data.

Now we will load the data by skipping the first year.

Let’s look at the bitcoin price over the time,

The non-stationary behaviour of the data is obvious when looking at the bitcoin price. We can also see clearly the big rises of Dec 2017/2020 there.

One way to remove the non-stationary component on the data is to compute its derivative. Another way is to filter the data with a Gaussian kernel, and subtract it to the original price data.

By comparing the two methods (derivative and filtering), we see that the resulting prices are now zero-centered. They are shown with the orange colour in the below charts:

png

In order to verify the quality of the process, one can check the auto-correlation for both the raw price data (blue line), and stationary price data with the filtering method (green line). This will inform us about how well the data is stationary after the process.

We will compute the auto-correlations with different delays of up to 2 days every hours.

Looking at the plot, it is clear that the auto-correlation for the stationary data degrades much faster than for the raw price data. This means that we successfully removed the non-stationary component for the price!

Looking into the stationarity component also allows us to determine the window of prediction that is most suitable for the data. For example by checking how fast, for a given timestamp, the distribution of the raw price differ with its neighbors.

By comparing the histogram (i.e. computing the correlation) for each timestamp with its neighbors, one can get an overview of what would be the acceptable range for a prediction. With the idea that if the distributions are close to each other, it is obviously easier to predict (because they are closed to each other).

In the following plot, the y-axis describes some samples taken at different timestamps of the bitcoin price. From up to down, it follows the chronological order, but this is not important since each sample can be taken independently. The x-axis describes the different offsets to compute the histograms (from -120 hours to +120 hours). And the color is the resulting correlation between these distributions and the distribution at timestamp h0 (the current timestamp of the sample).

png

Looking at it, we can say that the acceptable range for prediction is around +/-15 hours.

Let’s now switch the seasonality analysis by computing the FFT, and extract its magnitude and phase components.
As explained before, the FFT will be used here to understand the redundant patterns in the data. Because the FFT works better on LTI (linear and time invariant) systems, it cannot be applied with the raw bitcoin price (which is not stationary!). Therefore we will apply it on the stationary bitcoin price.

In the below figure, there is no clear evidence of a pattern there, although we see evidence for important frequency ranging from 1 to 1.9 cycles per day, with a little peak at 1.52. This means that the bitcoin price can “generally” be explained by a sinusoid with a period of ~15.8 hours.

png

Here, we will use a window size of 48 samples (hours), with a step of 1 and 62 frequency components.

png

Looking at the figure, whenever there are big changes in the data (for example Dec. 2017), there is a much higher magnitude response. Generally speaking, it seems that the FFT looks like a white noise whenever the time.

In the light of the properties that we saw above, one thing can be said with certainty; predicting bitcoin price is no easy task because of its time dependency.

Hopefully we found a way to simplify the process, by removing the non-stationary component of the data (so it does not depend on time anymore). This allowed us to analyse redundant patterns in the data and we found that such a pattern exists. The recurrent patterns are interesting, because they can be latter used as a new feature into a predictive model (think of adding the time of day into a weather prediction model for example).

These findings opened to us new ways to get an accurate predictive model for the bitcoin price, but this is another story…

Add a comment

Related posts:

WELCOME TO THE ERA DIGITAL MARKETING

There has been a continuously revolving technological advancement from the last ten years. The world has shown a paradigm shift from analog to digital. With the rising interest in internet people are…

The Islamic Europe

Since Mohammed was sent by God to transmit His Holy Message of Islam, the earth become Islam. Before Islam, the people were Christians. A story told in Morocco says Mohammed The Messenger of Islam…

Como me mantenho atualizado no universo DEV?

Nesse post vou falar um pouco sobre algumas fontes nas quais me mantenho atualizado com o que acontece no mundo de desenvolvimento. Está bem resumido, mas espero que gostem. É interessante não ficar…