diff options
Diffstat (limited to 'R/futurequotes.R')
| -rw-r--r-- | R/futurequotes.R | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/R/futurequotes.R b/R/futurequotes.R new file mode 100644 index 00000000..a9bad73e --- /dev/null +++ b/R/futurequotes.R @@ -0,0 +1,10 @@ +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)
|
