Skip to content

Instantly share code, notes, and snippets.

@kumeS
Created November 5, 2022 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumeS/c466e97d42f6facbb8ba5a22ed361bf4 to your computer and use it in GitHub Desktop.
Save kumeS/c466e97d42f6facbb8ba5a22ed361bf4 to your computer and use it in GitHub Desktop.
Get daily BTC data
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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment