Skip to content

Bayesian analysis and forecasting of Bitcoin volatility. Definition of GARCH and ARCH models through MCMC sampling.

License

Notifications You must be signed in to change notification settings

Engrima18/Volatility_in_the_Cryptosphere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Volatility_in_the_Cryptosphere

Quick advice: if you are really interested in understanding the work done and the results obtained read the official project report contained in the BTC_analysis.pdf file in this repo.
This project addresses the study and construction of econometric models in Bayesian frame- work that can capture the volatility of bitcoin. Various Bayesian models will then be improved by adjustment of the MCMC-based sampling process and reformulation of prior beliefs. The main goal is to build a useful tool in decision analysis/risk management and in general try to infer the main critical factors when investing on assets of this type.



The data set

The Yahoo Finance Bitcoin Historical Data from Kaggle, spanning from 2014 to 2023, capture the evolution of Bitcoin’s price over a decade. We are only interested in the adjusted closing price of bitcoin (in terms of BTC/USD value), from which we also derive the “LogREturns” feature.

data

\

We report below the decomposition results for prices and returns considering that we have one observation per day (for 9 years).

proces returns

The following ACF plot suggests that the scale of returns changes in time and the (conditional) variance of the process is time varying.

acfs

In order to capture volatility clustering, we need to introduce appropriate time series processes able to model this behavior!

The model(s)

Our model will have to adhere to a number of features to enable consistent results to be obtained:

  1. It need not be robust to modeling any trends, patterns or forms of seasonality
  2. Instead, it must provide for strong heteroscedasticity.
  3. It can be based on the assumption of stationarity of the data.

We use three JAGS (MCMC based) models typically used in econometrics for volatility forecasting:

  • ARCH(1)
  • GARCH(1, 1)
  • t-student GARCH(1, 1)

Then we compare the results of our models and select the one with minimum DIC.

comparison1 forecasting

The winner is the Bayesian GARCH(1,1) model with a non-central t-student prior distribution for returns:

$$ \begin{aligned} y_t &= \sqrt{\sigma^2_t} \cdot z_t \nonumber \\ \sigma^2_t &= \omega + \alpha y^2_{t-1} + \beta \sigma_{t-1}^2 \end{aligned} $$

$$ \begin{aligned} y_t &\sim t(\mu, \sigma_t^2, \nu) \nonumber \\ \mu &\sim N(0, 100^2) \nonumber \\ \omega &\sim U(0, 10) \nonumber \\ \alpha &\sim U(0, 1) \nonumber \\ \beta &\sim U(0, 1) \end{aligned} $$

where:

  • $\delta = \mu \cdot \sigma^{- \frac{1}{2}}_t$ is the non-centrality parameter
  • $\nu = 8$ represents the degrees of freedom and we set it equal to a constant

This variables and parameters have a specific meaning in our model:

  • $y_t$ is the observed value at time t
  • $z_t$ is the white noise (innovation) term at time t
  • $\sigma_t^2$ is the conditional variance of $y_t$
  • $\omega$ is the baseline volatility
  • $\alpha$ represents the impact of past squared residuals on the conditional variance

Here the JAGS code:

tstud_model_code <- "
model
{
  # Likelihood
  for (t in 1:N) {
    y[t] ~ dt(mu, tau[t], 8)
    tau[t] <- 1/pow(sigma[t], 2)
  }
  sigma[1] ~ dunif(0,10)
  for(t in 2:N) {
    sigma[t] <- sqrt(omega + alpha * pow(y[t-1] - mu, 2) +
                     beta * pow(sigma[t-1], 2))
  }

  # Priors
  mu ~ dnorm(0.0, 0.01)
  omega ~ dunif(0, 10)
  alpha ~ dunif(0, 1)
  beta ~ dunif(0, 1)
}
"

Convergence analysis

Our model is based on Markov Chain Monte Carlo sampling technique (Gibbs sampling) and we have to check for the convergence of its parameters to the target distributions.

con1 con2

Used technologies

RStudio R

About

Bayesian analysis and forecasting of Bitcoin volatility. Definition of GARCH and ARCH models through MCMC sampling.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages