Introduction

In this document we aim to perform different time series analysis methods over the Cardano data extracted from Yahoo! Finance. At first we will import, clean and transform the data. Next we will proceed to apply various forecasting methods which in turn will be followed by visualized graphs and personal interpretation and commentary (based on the output). Basic understanding in R and forecasting principles (such as time series regression models) is expected. We will however explain each concept applied step by step to obtain a better understanding.

Step 1 - Importing, Cleaning and Manipulating the Data (Using QuantMod and from Local Excel File)

First, in order to follow along with the code chunks, you will need to import these libraries:

library(quantmod)
library(tidyquant)
library(tidyverse)
library(forecast)
library(timetk)
library(readxl)
library(lubridate)
library(tibbletime)
library(PerformanceAnalytics)
library(scales)

A faster way to access the data from Yahoo! Finance is to use the quantmode library. To do that we need to use the function getSymbols() and specifically assign the symbol, the date range and the warnings / autoassign options. We can implement that as below:

options("getSymbols.warning4.0"=FALSE)
options("getSymbols.yahoo.warning"=FALSE)
# Downloading the Bitcoin price using quantmod

getSymbols("ADA-USD", from = '2020-12-31', #import through ticker name, and date
           to = "2021-06-05",warnings = FALSE,
           auto.assign = TRUE)  #assign name by default as is
## [1] "ADA-USD"

To check if the code ran correctly, lets see the first 5 rows of the Bitcoin Data:

head(`ADA-USD`, 5)
##            ADA-USD.Open ADA-USD.High ADA-USD.Low ADA-USD.Close ADA-USD.Volume
## 2020-12-31     0.184034     0.185749    0.176594      0.181397     1132268397
## 2021-01-01     0.181382     0.184246    0.172022      0.175350     1122218004
## 2021-01-02     0.175359     0.184253    0.169233      0.177423     1408849504
## 2021-01-03     0.177382     0.208679    0.173376      0.204995     2303857909
## 2021-01-04     0.205236     0.239661    0.194450      0.224762     3260699086
##            ADA-USD.Adjusted
## 2020-12-31         0.181397
## 2021-01-01         0.175350
## 2021-01-02         0.177423
## 2021-01-03         0.204995
## 2021-01-04         0.224762

We can clearly discern the OHLC with the Volume and Adjusted value for each column. To have a better understanding of how the prices of Bitcoin have fluctuated from the previous year, we can use the chart series function from the quantmod library as below:

chart_Series(`ADA-USD`)

Changing theme, additional customization,

chartSeries(`ADA-USD`, subset='2020-12-31::2021-06-01',
            theme = chartTheme('black'),
            TA = "addBBands(); addDEMA()")

            addVo()

            addDPO()

Convert to monthly returns

Simple Return

simple_return <- Return.calculate(`ADA-USD`,
                                  method = "simple") %>%
  na.omit()

Log Return

plot

chartSeries(simple_return,
            theme = chartTheme('white'),
            TA = "addBBands(); addDEMA()")

            addVo()

            addDPO()

Covariance Returns

covariance_matrix <- cov(simple_return)
round(covariance_matrix,5)
##                  ADA-USD.Open ADA-USD.High ADA-USD.Low ADA-USD.Close
## ADA-USD.Open          0.00755      0.00231     0.00359      -0.00056
## ADA-USD.High          0.00231      0.00535     0.00295       0.00445
## ADA-USD.Low           0.00359      0.00295     0.00901       0.00399
## ADA-USD.Close        -0.00056      0.00445     0.00399       0.00749
## ADA-USD.Volume       -0.00155      0.01793    -0.01001       0.01380
## ADA-USD.Adjusted     -0.00056      0.00445     0.00399       0.00749
##                  ADA-USD.Volume ADA-USD.Adjusted
## ADA-USD.Open           -0.00155         -0.00056
## ADA-USD.High            0.01793          0.00445
## ADA-USD.Low            -0.01001          0.00399
## ADA-USD.Close           0.01380          0.00749
## ADA-USD.Volume          0.18019          0.01380
## ADA-USD.Adjusted        0.01380          0.00749

Adjusted Standard Deviation

SD <- StdDev(simple_return, OHLCV=FALSE)
percent_SD <- round(SD * 100, 2)
percent_SD[1,6]
## [1] 8.65