# Bitcoin Monte Carlo Tutorial

This report displays an approach towards the trading in the international digital currency, Bitcoin. We aim to match Econometric techniques with Monte Carlo simulation within COSSAN-X, which in turn allows the reader to better understand the price of Bitcoin through randomly sampling values within a given distribution. This report aims to utilise techniques learnt within the programme COSSAN-X, with regard to Bitcoin the Monte Carlo simulation conducted. The figures towards the end are descriptive in allowing the reader to visualise both COSSAN-X and the simulation completed.

# An Introduction to Bitcoin

In 2009, a digital currency was invented in order to utilise decentralized fiscal exchange through peer-to-peer transactions, whilst maintaining a distributed ledger within a ‘blockchain’. This digital currency was called Bitcoin and paved the way for other similar technologies to be introduced. At present, the total market capitalisation (how much is invested into the cryptocurrency) stands at \$325 billion (coinmarketcap.com, 2018). This report investigates the expectation and volatility of Bitcoin using modelling in COSSAN-X. The main method of obtaining Bitcoin is to ‘mine’ it, a process that involves using high powered computers and computer parts to solve complicated algorithms, which ultimately leads to ownership of the digital asset. Of course, one can purchase Bitcoin, along with other cryptocurrencies, through a dedicated exchange, such as Kraken, Binance, Bitfinex, etc. Trading is subject to high levels of volatility, which can be defined as the degree of variation and therefore instability of returns for a given security or market index. This is usually represented as the standard deviation. There are various models that can be applied to analyse the expected value and volatility regarding Bitcoin. For example, the one day value at risk computes the worst outcome of a portfolio at a given confidence interval over a denoted period of time (Degiannakis and Potamia, 2016; Linsmeier and Pearson, 2000).

## GARCH

The standard GARCH (1,1) model can be denoted in an equation (Takaishi, 2007) $\sigma_t^2=\omega+\alpha y_(t-1)^2+\beta \sigma_(t-1)^2$

Within this tutorial, we aim to use the GARCH approach to analyse and simulate the price of Bitcoin given past data, and to simulate using Monte Carlo techniques in order to minimise the spread of error, such that if we simulate n number of times, we eventually get to the true outcome needed.

# Problem Definition in COSSAN-X

## Create a new project

The first step in COSSAN-X is to create a new project and call it ‘GARCH’. Click on file on the top left and click new file.

The project name will appear on the left

## Input

The parameters can now be inputted. Right click on ‘parameters’ and add click ‘add parameter’. Call this parameter ‘omega’ and describe it as a constant. Input the value of the constant as 0.03. Now click Ctrl+S to save the parameter.

Create two more parameters using the same method and call these parameters ‘Alpha’ with a value of 0.02, and ‘Beta’ with a value of 0.94.

## Random Variables

To create a new random variable, right click on ‘random variables’ and click ‘add random variable’. Name this random variable ‘LVariance’ and click ‘Finish’. After this, the Random Variable properties window will appear. Change the distribution type to an Exponential and leave the Definition Type as Mean. Input the mean value of 0.109802687

Add another normal random variable and name this ‘RSQRD’ i.e. Return Squared. This is also an exponential distribution with a mean value of . COSSAN-X will display both the PDF and CDF chart of the random variable. Remember to type Ctrl+S to save each random variable.

## Evaluator

An Evaluator is an important aspect to define the model and converts an input into an output. On the ‘Evaluators’ folder right click Matlab Files and click ‘Add Matlab script’. This script can be named the default option as it is the only script for this model. This stage involves typing out the script in COSSAN-X to consider the GARCH model and commanding COSSAN-X to analyse the parameters/variables. It converts the input data and creates a function to give an output, i.e. out1.

Add all the parameters and random variables on the input and add ‘out1’ on the output. This can be done by clicking the + icon.

Click on the ‘Script/Function’ tab, and create a new line under line 15. On line 16 type

Touput(n).out1=Tinput(n).omega*(Tinput(n).Alpha*Tinput(n).RSQRD)*(Tinput(n).Beta*Tinput(n).Lvariance’


Save this script with Ctrl+S and remember to end the script.

## Model

A model must be created in order to investigate the uncertainty with regards to the function. A physical model is used to assess the skewness of the outcome by generating independent samples. This is COSSAN-X’s tab that allows the user to implement the inputs, and thus outputs, for the Monte Carlo analysis used. We can see here that the parameters alpha, beta and omega are implemented. The random variables ‘Lvariance’ and ‘RSQRD’ are inputted.

Right click on the ‘Models’ folder and click ‘Add Physical Model’. Call this ‘PhysicalG’ and add the Evaluators, the input values, the Random variable sets, and the Output. These were all defined in the previous sets.

Save this model with Ctrl+S

# Uncertainty Quantification Analysis

In this step, Uncertainty Quantification is uilised in accordance to our GARCH model implemented.

The analysis can start by clicking on the run analysis button.

Check the box for ‘Uncertainty Quantification’ and click next. Click next again as ‘simulation’ is automatically selected

Utilising Monte Carlo simulation here,total samples to be used are initialised. COSSAN-X’s ‘Batches’ function can also be utilised, wherein we analyse in batches of, say 1,000, in portions of 100. This would mean there would be 100 simulations in 10 batches and reduces the computing performance required.

Click on ‘Monte Carlo’ and choose 1000 samples per batch. Click outside so the Total Samples can update.

It’s advised to use a maximum of 10000 samples as performing can decrease beyond this limit Click on Finish and the simulation will run. After the simulation runs, a completion message will be displayed.

## Showing the results

The results can be displayed in many different forms, from scatter grpahs to histograms. Uncertainty quantification via the Monte Carlo method is usually displayed as a Histogram.

Expand the analysis folder, Uncertainty Quantification folder, and the results folder. Open a new table view, by clicking on the icon on the toolbar and then drag and drop the type of graph.

Histogram of the GARCH distribution realised in the analysis;

The Monte Carlo simulations can be assessed in more detail. The data can be viewed using the available options presented on the right under: Actions available. To view the data as an image

To view the data in table view

# Interpreting the results

The image indicates the simulations used for this report, and indicates the variables statistics after Monte Carlo simulation with respect to GARCH.

Here indicates the variables utilised for GARCH analysis and indicates the starting time used. Daily data has been applied within the parameters of this report.

Observed within this figure is the variable monthlyreturns (indicating bitcoins monthly returns) over the time period given in the dataset. The X axis is numbered from T1 to Tn. It is evident here the volatile nature of the digital asset Bitcoin over monthly time periods.

This figure indicates the squared returns within our dataset of Bitcoin prices. The large spikes indicate the volatile nature of Bitcoin, the digital asset in question within this report. Bitcoin’s volatility can be attributed to many converging ideas which are beyond the scope of this report. However, the most up to date standard deviation of Bitcoins opening price is 3383.68465 starting from the 27th December 2013 and ending on the 26th April 2018. The standard deviation is incredibly high within this time-frame and indicates the exceedingly high volatile nature of Bitcoin.

The outcome of analysis, providing the Alpha, omega, beta values

# References

References IG Group Limited (2018) How to trade Bitcoin, Available at: https://www.ig.com/uk/bitcoin-btc/how-to-trade-bitcoin (Accessed: 20th April 2018). Takaishi, T. (2017) 'Statistical properties and multifractality of Bitcoin', Physica A: Statistical Mechanics and its Applications, 450(1), pp. Investopedia (2018) Volatility, Available at: https://www.investopedia.com/terms/v/volatility.asp (Accessed: 22nd April 2018). Kinateder, H. and Wagner, N. (2014) 'Multiple-period market risk prediction under long memory: When VaR is higher than expected', Journal of Risk Finance, 15(1), pp. 4-32 Degiannakis, S. and Potamia, A. (2016) Multiple-days-ahead value-at-risk and expected shortfall forecasting for stock indices, commodities and exchange rates: inter-day versus intra-day data, Athens, Greece: Department of Economic and Regional Development, Panteion University. Linsmeier, T.J. and Pearson, N.D. (2000) 'Value at Risk', Financial Analysts Journal, 25(2), pp. 47-67. Takaishi (2007) Bayesian estimation of GARCH model by hybrid Monte Carlo, Hiroshima, Japan: Hiroshima University of Economics.