Get daily BTC data (original) (raw)

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

getBTC <- function(){
#Read the old chart data
BTC <- read.table("https://gist.githubusercontent.com/kumeS/421c708f6e95c428fbfb4ccffb8fc6c6/raw/24ac495a21851f6618849109c3cdbe9d9f9a0eec/BTC\_HistoricalData\_by\_sk.csv", sep=",", header = T)
#Create dataframe
BTC01 <- data.frame(Date=as.Date(BTC$Date),
Close=as.numeric(BTC[,c(2)]),
Month=format(as.Date(BTC$Date), "%m"),
row.names=1:nrow(BTC))
#Data After 2022-10-21 From binance
BTC00 <- binancer::binance_klines('BTCUSDT', interval = '1d',
start_time = "2022-10-21",
end_time = lubridate::today())
BTC00A <- data.frame(Date=as.Date(BTC00$open_time),
Close=as.numeric(BTC00$close),
Month=format(as.Date(BTC00$open_time), "%m"),
row.names=1:nrow(BTC00))
#head(BTC00A)
#rbind data frames
Dat <- rbind(BTC01, BTC00A)
return(Dat)
}