Last active
November 8, 2022 14:37
-
-
Save kumeS/3260853bb9278061a4a245a4e11092b2 to your computer and use it in GitHub Desktop.
get ETH price
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
getETH <- function(){ | |
#Read the old chart data | |
ETH <- read.table("https://gist.githubusercontent.com/kumeS/a8087b786bb5fae771e4884baae4a698/raw/3528da13c90dd8cbc06a8a2e3618ab63e4e4b6d2/2015-08-07_2022-11-08_ethereumprice_org.csv", sep=",", header = T) | |
ETH$timestamp <- as.Date(as_datetime(ETH$timestamp)) | |
ETH <- ETH[!grepl("undefined", ETH$open),] | |
ETH <- ETH[order(ETH$timestamp, decreasing = F),] | |
ETHd <- ETH[!duplicated(ETH$timestamp),] | |
#head(ETHd); tail(ETHd) | |
#Create dataframe | |
ETH01 <- data.frame(Date=as.Date(ETHd$timestamp), | |
Close=as.numeric(ETHd$open), | |
Month=format(as.Date(ETHd$timestamp), "%m"), | |
row.names=1:nrow(ETHd)) | |
#Data After 2022-10-21 From binance | |
ETH00 <- binancer::binance_klines('ETHUSDT', interval = '1d', | |
start_time = "2022-11-08", | |
end_time = lubridate::today()) | |
ETH00A <- data.frame(Date=as.Date(ETH00$open_time), | |
Close=as.numeric(ETH00$close), | |
Month=format(as.Date(ETH00$open_time), "%m"), | |
row.names=1:nrow(ETH00)) | |
#head(ETH00A) | |
#rbind data frames | |
Dat <- rbind(ETH01, ETH00A) | |
return(Dat) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment