Based on the plots above, we could see that LTC has the highest increase rate since 2019, which is 173.97% Renturn on Inverstment since 2019-01-01. On the other hand, XRP has the lowest ROI, which is -13.29%. Therefore, in order to get the highest short term return on cryptocurrency, LTC is the best option.
---
title: "Cryptocurrency ROI Dashboard"
author: "Yueying Zhang"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
social: menu
source: embed
---
Page 1
=======================================================
```{r setup, include= FALSE, echo=FALSE}
chooseCRANmirror(graphics=FALSE, ind=1)
knitr::opts_chunk$set(echo = TRUE)
library(flexdashboard)
library(tidyverse)
library(ggplot2)
library(flexdashboard)
library(quantmod)
library(formattable)
library(DT)
library(plotly)
#fetch the data of four cryptocurrency
getSymbols(Symbols = 'BTC-USD', from = '2019-01-01', to = '2019-05-11', auto.assign = TRUE)
getSymbols(Symbols = 'XRP-USD', from = '2019-01-01', to = '2019-05-11', auto.assign = TRUE)
getSymbols(Symbols = 'ETH-USD', from = '2019-01-01', to = '2019-05-11', auto.assign = TRUE)
getSymbols(Symbols = 'LTC-USD', from = '2019-01-01', to = '2019-05-11', auto.assign = TRUE)
#change the dataset to data frame and see the ts.plot of close price for 4 currencies.
BTC = data.frame(`BTC-USD`)
ts.plot(BTC$BTC.USD.Close)
XRP = data.frame(`XRP-USD`)
ts.plot(XRP$XRP.USD.Close)
ETH = data.frame(`ETH-USD`)
ts.plot(ETH$ETH.USD.Close)
LTC = data.frame(`LTC-USD`)
ts.plot(LTC$LTC.USD.Close)
#Rename variables for ease of use
BTC = BTC %>% rename(Close = BTC.USD.Close, Open = BTC.USD.Open,
High = BTC.USD.High, Low = BTC.USD.Low, Volume = BTC.USD.Volume)
ETH = ETH %>% rename(Close = ETH.USD.Close, Open = ETH.USD.Open,
High = ETH.USD.High, Low = ETH.USD.Low, Volume = ETH.USD.Volume)
LTC = LTC %>% rename(Close = LTC.USD.Close, Open = LTC.USD.Open,
High = LTC.USD.High, Low = LTC.USD.Low, Volume = LTC.USD.Volume)
XRP = XRP %>% rename(Close = XRP.USD.Close, Open = XRP.USD.Open,
High = XRP.USD.High, Low = XRP.USD.Low, Volume = XRP.USD.Volume)
#Create a new date variable
date.2019 <- format(seq(as.Date("2019-01-01"), as.Date("2019-05-11"), by = "1 day"))
#Create a new dataset combine date and all four cryptocurrencies close price
Crypto.2019 = cbind(date.2019, BTC$Close, ETH$Close, LTC$Close, XRP$Close)
Crypto.2019 = as.data.frame(Crypto.2019)
Crypto.2019$date.2019 = as.Date(Crypto.2019$date.2019)
#Rename variables in the dataset
Crypto.2019 = Crypto.2019 %>% rename(BTC = V2, ETH = V3, LTC = V4, XRP = V5)
#Convert factor variables into numeric variables
Crypto.2019$BTC = as.numeric(as.character(Crypto.2019$BTC))
Crypto.2019$ETH = as.numeric(as.character(Crypto.2019$ETH))
Crypto.2019$LTC = as.numeric(as.character(Crypto.2019$LTC))
Crypto.2019$XRP = as.numeric(as.character(Crypto.2019$XRP))
#Calculate the change rate for each currency
BTC.change = (Crypto.2019[131,2] - Crypto.2019[1,2]) / Crypto.2019[1,2]
ETH.change = (Crypto.2019[131,3] - Crypto.2019[1,3]) / Crypto.2019[1,3]
LTC.change = (Crypto.2019[131,4] - Crypto.2019[1,4]) / Crypto.2019[1,4]
XRP.change = (Crypto.2019[131,5] - Crypto.2019[1,5]) / Crypto.2019[1,5]
#Calculate show the ROI
BTCroi = percent(BTC.change)
ETHroi = percent(ETH.change)
LTCroi = percent(LTC.change)
XRProi = percent(XRP.change)
BTCroi = as.character(percent(BTC.change))
ETHroi = as.character(percent(ETH.change))
LTCroi = as.character(percent(LTC.change))
XRProi = as.character(percent(XRP.change))
#Create a table for ROIs
roitable = data.frame("Start Price" = c(Crypto.2019[1,2],Crypto.2019[1,3],Crypto.2019[1,4],Crypto.2019[1,5]),
"End Price" = c(Crypto.2019[131,2],Crypto.2019[131,3],Crypto.2019[131,4],Crypto.2019[131,5]),
"ROI" = c(BTCroi,ETHroi,LTCroi,XRProi))
```
Sidebar {.sidebar}
-----------------------------------------------------------------------
### Cryptocurrency ROI Analysis
The dashboard investigate the price trends of four cryptocurrencies: Bitcoin (BTC),Ethereum (ETH),Litecoin (LTC),and Ripple (XRP).
The dashboard include following couple components:
1) the gauge part will directly display the increase/decrease rate of each cryptocurrency;
2) a line chart shows the closing prices of four cryptocurrencies from 2019-01-01 to 2019-05-11;
3) and one table showing the closing price on the start date (2019-01-01) and the closing price on the end date(2019-05-11), and the according price change for each cryprocurrency.
Based on the charts we could get a better idea of the return on investment for
each cryptocurrency and make a smarter financial decision.
row {data-widtch=100}
-----------------------------------------------------------------------
### BTC--% change
```{r,echo=FALSE}
gauge((roitable[1,3]), min = -20, max = 200, symbol = '%', gaugeSectors(success = c(50, 200), danger = c(-20, 0)))
```
###ETH--% change
```{r,echo=FALSE}
gauge((roitable[2,3]), min = -20, max = 200, symbol = '%', gaugeSectors(success = c(50, 200), danger = c(-20, 0)))
```
###LTC--% change
```{r,echo=FALSE}
gauge((roitable[3,3]), min = -20, max = 200, symbol = '%', gaugeSectors(success = c(50, 200), danger = c(-20, 0)))
```
###XRP--% change
```{r,echo=FALSE}
gauge((roitable[4,3]), min = -20, max = 200, symbol = '%', gaugeSectors(success = c(50, 200), danger = c(-20, 0)))
```
Row {data-width=400}
-----------------------------------------------------------------------
### Four Cryptocurrencies Price Change
```{r, include=TRUE,echo=FALSE}
ggplotly(ggplot(Crypto.2019) + geom_line(aes(date.2019, BTC, col = 'BTC')) +
geom_line(aes(date.2019, ETH, col = 'ETH')) +
geom_line(aes(date.2019, LTC, col = 'LTC')) +
geom_line(aes(date.2019, XRP, col = 'XRP')) +
xlab('Time 2019') +
ylab('Price (USD$)') +
theme_minimal() +
ggtitle('Cryptocurrency Closing Price (2019)'))
```
### ROI Chart
```{r, include=TRUE, echo=FALSE}
#Calculate the change rate for each currency
BTC.change = (Crypto.2019[131,2] - Crypto.2019[1,2]) / Crypto.2019[1,2]
ETH.change = (Crypto.2019[131,3] - Crypto.2019[1,3]) / Crypto.2019[1,3]
LTC.change = (Crypto.2019[131,4] - Crypto.2019[1,4]) / Crypto.2019[1,4]
XRP.change = (Crypto.2019[131,5] - Crypto.2019[1,5]) / Crypto.2019[1,5]
#Calculate show the ROI
BTCroi = percent(BTC.change)
ETHroi = percent(ETH.change)
LTCroi = percent(LTC.change)
XRProi = percent(XRP.change)
BTCroi = as.character(percent(BTC.change))
ETHroi = as.character(percent(ETH.change))
LTCroi = as.character(percent(LTC.change))
XRProi = as.character(percent(XRP.change))
#Create a table for ROIs
roitable = data.frame("Start Price" = c(Crypto.2019[1,2],Crypto.2019[1,3],Crypto.2019[1,4],Crypto.2019[1,5]),
"End Price" = c(Crypto.2019[131,2],Crypto.2019[131,3],Crypto.2019[131,4],Crypto.2019[131,5]),
"ROI" = c(BTCroi,ETHroi,LTCroi,XRProi))
rownames(roitable)= c('BTC','ETH','LTC','XRP')
datatable(roitable,options = list(pageLength = 4))
```
Page 2
=======================================================
Row
-----------------------------------------------------------------------
### BTC Price
```{r, include=TRUE, echo=FALSE}
ggplotly(ggplot(Crypto.2019) +
geom_line(aes(date.2019, BTC), col = 'red') +
ggtitle('BTC Closing Price') +
theme_minimal() +
xlab('Date 2019') +
ylab('BTC Price ($USD)'))
```
### ETH Price
```{r, include=TRUE, echo=FALSE}
ggplotly(ggplot(Crypto.2019)+
geom_line(aes(date.2019, ETH), col = 'blue') +
ggtitle('ETH Closing Price') +
theme_minimal() +
xlab('Date 2019') +
ylab('ETH Price ($USD)'))
```
Row
----------------------------------------------
### LTC Price
```{r, include=TRUE, echo=FALSE}
ggplotly(ggplot(Crypto.2019) +
geom_line(aes(date.2019, LTC), col = 'green') +
ggtitle('LTC Closing Price') +
theme_minimal() +
xlab('Date 2019') +
ylab('LTC Price ($USD)'))
```
### XRP Price
```{r, include=TRUE, echo=FALSE}
ggplotly(ggplot(Crypto.2019) +
geom_line(aes(date.2019, XRP), col = 'pink') +
ggtitle('XRP Closing Price') +
theme_minimal() +
xlab('Date 2019') +
ylab('XRP Price ($USD)'))
```
page 3
=============================================
### Conclusion
Based on the plots above, we could see that LTC has the highest increase rate since 2019, which is 173.97% Renturn on Inverstment since 2019-01-01. On the other hand, XRP has the lowest ROI, which is -13.29%. Therefore, in order to get the highest short term return on cryptocurrency, LTC is the best option.