library(rjson) source("cds_utils.R") ticker <- "GE" monthcodes <- c("F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z") 3monthcodes <- c("H", "M", "U", "Z") 3monthindex <- 3*(1:4) 3monthindex[which(3monthindex>=as.integer(format(Sys.Date(), "%m")))(1)] monthcodes[(as.integer(format(nextIMMDate(Sys.Date()), "%m"))+3*(0:7)-1)%%12+1] uri <- sprintf("http://www.cmegroup.com/CmeWS/md/MDServer/V1/Venue/G/Exchange/XCME/FOI/FUT/Product/GE?currentTime=%s&contractCDs=%s", paste(round(as.numeric(Sys.time())*1000)), paste(contracts, collapse=",")) download.file(uri, destfile="futures.json", quiet=T)