Translate

Thursday, November 26, 2020

Bitcoin and Gold prices




Bitcoin 



Gold prices







The ratio of Bitcoin to Gold prices - The average of ratio is 5.






library(Quandl)

library(dplyr)

library(forecast)


bit_coin=Quandl("BITSTAMP/USD", start_date="2017-01-01" )[,c("Date","Last")]


Gold_Price=Quandl("LBMA/GOLD", start_date="2017-01-01" )[,c("Date","USD (PM)")]

head(bit_coin)



ratio=Bit/Gold

avg_ratio=mean(ratio)


plot(ratio, main="Ratio of Bitcoin Prices to Gold Prices")


hist(ratio)




candleChart( Bit, up.col = "black", dn.col = "red", theme = "white", subset = "2019-01-04/")

addSMA(n = c(20, 50, 200))

addBBands()

addMACD()




candleChart( Gold, up.col = "black", dn.col = "red", theme = "white", subset = "2019-01-04/")

addSMA(n = c(20, 50, 200))

addBBands()

addMACD()




head(Gold_Price)

class(bit_coin)

mergedata<-merge(bit_coin, Gold_Price, by="Date")



Gold_Price=Quandl("LBMA/GOLD.2", start_date="2017-01-01" )

head(Gold_Price)



#Coverting bitcoin to timeseries


Bit <- xts(bit_coin[,-1], order.by=as.Date(bit_coin[,1], "%m/%d/%Y"))

autoplot(Bit)


Gold <- xts(Gold_Price[,-1], order.by=as.Date(Gold_Price[,1], "%m/%d/%Y"))


autoplot.zoo(Gold)





fit<-arima(coin, order=c(1,0,1))

accuracy(fit)

forecast(fit,50)

plot(forecast(fit,50))


d.arima <- forecast::auto.arima(coin)

autoplot(forecast::forecast(d.arima, h = 50))

autoplot(forecast::forecast(d.arima, level = c(85), h = 50))

autoplot(forecast::forecast(d.arima, h = 5), conf.int = FALSE, is.date = FALSE)

autoplot(forecast::forecast(stats::HoltWinters(UKgas), h = 10))


d.arima <- forecast::auto.arima(Gold)

autoplot(forecast::forecast(d.arima, h = 50))




d.arima <- forecast::auto.arima(ratio)

autoplot(forecast::forecast(d.arima, h = 50))


No comments:

Post a Comment