Translate

Showing posts with label Bitcoin. Show all posts
Showing posts with label Bitcoin. Show all posts

Thursday, November 26, 2020

Bitcoin Analysis as of 11-24-2020

 




/* Generated Code (IMPORT) */
/* Source File: DATA.csv */
/* Source Path: /folders/myfolders/Stock Market */
/* Code generated on: 11/25/20, 10:12 AM */

%web_drop_table(WORK.IMPORT);


FILENAME REFFILE '/folders/myfolders/Bitcoin.csv';

PROC IMPORT DATAFILE=REFFILE
DBMS=CSV
OUT=WORK.Bitcoin;
GETNAMES=YES;
RUN;

proc sort data=bitcoin out=bitcoin;
by date;
run;

proc sgplot data=Bitcoin;
title height=14pt "Bitcoin";
footnote2 justify=left height=8pt "Source: Coinbase";
series x=Date y=Last /;
xaxis grid;
yaxis grid;
run;

ods graphics / reset;
title;
footnote2;

DATA Bitcoin.Bitcoin;
set Bitcoin (drop=VAR1);
rename Last=Bitcoin;

Year=Year(Date);
Month=Month(Date);
Day=Day(Date);

pctchng = dif(Last) / lag( Last ) * 100;
label pctchng = "Percent Change";

pctchng_month = ( ( Last / lag( Last ) ) ** 30 - 1 ) * 100;
label pctchng_month = "Monthly Percent Change, At Annual Rates";

pctchng_yr = dif365( Last ) / lag365( Last ) * 100;
label pctchng_yr = "Percent Change from One Year Ago";
run;


proc sgplot data=Bitcoin.Bitcoin;
title height=14pt "Percent changes from previous year";
footnote2 justify=left height=8pt "Source: Coinbase";
series x=Date y=pctchng_yr /;
xaxis grid;
yaxis grid;
run;

proc sgplot data=Bitcoin.Bitcoin;
title height=12pt "Bitcoin";
vbar Year / response=pctchng fillattrs=(color=CXcad5e5) datalabel;
yaxis grid;
run;

proc sgplot data=Bitcoin.Bitcoin;
vbar Month / response=pctchng fillattrs=(color=CXcad5e5) datalabel stat=mean;
yaxis grid;
run;

proc sgplot data=Bitcoin.Bitcoin;
vbar Day / response=pctchng fillattrs=(color=CXcad5e5) datalabel stat=mean;
yaxis grid;
run;




SAS codes


FILENAME REFFILE '/folders/myfolders/Bitcoin.csv';
PROC IMPORT DATAFILE=REFFILE
DBMS=CSV
OUT=WORK.Bitcoin;
GETNAMES=YES;
RUN;
proc sort data=bitcoin out=bitcoin;
by date;
run;
proc sgplot data=Bitcoin;
title height=14pt "Bitcoin";
footnote2 justify=left height=8pt "Source: Coinbase";
series x=Date y=Last /;
xaxis grid;
yaxis grid;
run;
ods graphics / reset;
title;
footnote2;
DATA Bitcoin.Bitcoin;
set Bitcoin (drop=VAR1);
rename Last=Bitcoin;
Year=Year(Date);
Month=Month(Date);
Day=Day(Date);
pctchng = dif(Last) / lag( Last ) * 100;
label pctchng = "Percent Change";
pctchng_month = ( ( Last / lag( Last ) ) ** 30 - 1 ) * 100;
label pctchng_month = "Monthly Percent Change, At Annual Rates";
pctchng_yr = dif365( Last ) / lag365( Last ) * 100;
label pctchng_yr = "Percent Change from One Year Ago";
run;
proc sgplot data=Bitcoin.Bitcoin;
title height=14pt "Percent changes from previous year";
footnote2 justify=left height=8pt "Source: Coinbase";
series x=Date y=pctchng_yr /;
xaxis grid;
yaxis grid;
run;
proc sgplot data=Bitcoin.Bitcoin;
title height=12pt "Bitcoin";
vbar Year / response=pctchng fillattrs=(color=CXcad5e5) datalabel;
yaxis grid;
run;
proc sgplot data=Bitcoin.Bitcoin;
vbar Month / response=pctchng fillattrs=(color=CXcad5e5) datalabel stat=mean;
yaxis grid;
run;
proc sgplot data=Bitcoin.Bitcoin;
vbar Day / response=pctchng fillattrs=(color=CXcad5e5) datalabel stat=mean;
yaxis grid;
run;



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))