Skip to content

Commit

Permalink
2024 03 28
Browse files Browse the repository at this point in the history
  • Loading branch information
risktoollib committed Mar 28, 2024
1 parent ee703cf commit e3e4840
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
20 changes: 19 additions & 1 deletion R/morningstar.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @section Current Feeds Supported:
#' \itemize{
#' \item CME_CbotFuturesEOD and CME_CbotFuturesEOD_continuous
#' \item CME_NymexFutures_EOD and CME_NymexFutures_EOD_continuous
#' \item CME_NymexFutures_EOD, CME_NymexFuturesFinal_EOD andCME_NymexFutures_EOD_continuous
#' \item CME_NymexOptionsFinal_EOD and CME_NymexOptions_EOD
#' \item CME_CmeFutures_EOD and CME_CmeFutures_EOD_continuous
#' \item CME_Comex_FuturesSettlement_EOD and CME_Comex_FuturesSettlement_EOD_continuous
Expand All @@ -33,6 +33,10 @@
#' @examples
#' \dontrun{
#' getPrice(
#' feed = "CME_NymexFuturesFinal_EOD", contract = "CL 2024 07",
#' from = "2019-08-26", iuser = username, ipassword = password
#' )
#' getPrice(
#' feed = "CME_NymexFutures_EOD", contract = "@CL21Z",
#' from = "2019-08-26", iuser = username, ipassword = password
#' )
Expand Down Expand Up @@ -123,6 +127,20 @@ getPrice <- function(feed = "CME_NymexFutures_EOD", contract = "@CL21Z",
if (feed %in% c("CME_STLCPC_Futures")) {
URL <- httr::modify_url(url = "https://mp.morningstarcommodity.com", path = paste0("/lds/feeds/", feed, "/ts?", "product=", contract, "&fromDateTime=", from))
}
if (feed %in% c("CME_NymexFuturesFinal_EOD")) {
if (grepl(",", contract)) stop(paste("Use a space instead of a comma to separate contract components e.g.", gsub(",", " ", contract)))
URL <- httr::modify_url(
url = "https://mp.morningstarcommodity.com",
path = paste0(
"/lds/feeds/", feed, "/ts?",
"fromDateTime=", from,
"&cols=Settlement_Price",
"&product_code=", stringr::word(contract, 1, 1),
"&contract_year=", stringr::word(contract, 2, 2),
"&contract_month=", stringr::word(contract, 3, 3)
)
)
}
if (feed %in% c("CME_NymexOptionsFinal_EOD")) {
if (grepl(",", contract)) stop(paste("Use a space instead of a comma to separate contract components e.g.", gsub(",", " ", contract)))
URL <- httr::modify_url(
Expand Down
6 changes: 5 additions & 1 deletion man/getPrice.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3e4840

Please sign in to comment.