Skip to content

Instantly share code, notes, and snippets.

@kumeS
Last active Nov 8, 2022
Embed
What would you like to do?
get ETH price
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