We can summarize the Bitcoin transaction level data using xts functionality:
This code generates a new variable called rawdaily which contains the mean USD value each day in the dataset.
rawdaily <- period.apply(rawdata$USD, INDEX = endpoints(rawdata, "days"), FUN = mean)
indexClass(rawdaily) <- "Date"
head(rawdaily)
We change the indexClass of the resulting variable to Date because it is supposed to be at the daily level.
It looks like this:
USD
2011-09-13 5.874167
2011-09-14 5.582143
2011-09-15 5.120000
2011-09-16 4.835000
2011-09-17 4.870000
2011-09-18 4.840000
Plot it to see what it looks like.
png('btc_plot_daily.png')
plot(rawdaily)
dev.off()
It looks like this:
We can also sum up the daily volume in Bitcoins and plot it:
rawdailyvol <- period.apply(rawdata$Volume, INDEX = endpoints(rawdata, "days"), FUN = sum)
indexClass(rawdailyvol) <- "Date"
head(rawdailyvol)
png('btc_plot_daily_vol.png')
plot(rawdailyvol)
dev.off()
It looks like this:
Next, we can set up a typical OHLC (Open, High, Low, Close, Volume) data set for further analysis: Setting up Bitcoin data in OHLC format
You can also jump to each section directly from here:
- Introduction to Bitcoin analysis with R
- Retrieving Bitcoin transaction data
- Part 2 - Reading the bitcoin data in to R
- Using the xts package and dates
- Using xts to summarize Bitcoin transaction data
- Setting up Bitcoin data in OHLC format
- Charting Bitcoin data
- Prliminary return analysis with plots
- Preliminary return analysis with rolling windows
- Technical analysis plots of Bitcoin
- Bitcoin's future price path
- Evaluating a portfolio
- Evaluating a stock portfolio
- Copulas and extreme values with Bitcoin
- Copulas and extreme value, many assets