diff --git a/NEWS.md b/NEWS.md index 07e82eae..851fa8ab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,23 +1,34 @@ # ichimoku 1.4.11.9000 (development) +#### Updates: + * Uses 'mirai' to run `oanda_studio(new.process = TRUE)` -* Fixes `oanda_switch()`, regression since v1.4.11. +* Fixes `oanda_switch()` after a regression in 1.4.11. * Updates internal OANDA instruments list. * Internal performance enhancements. # ichimoku 1.4.11 +#### New features: + * Allows using the environment variable 'OANDA_API_KEY' as an alternative to the 'keyring' package. + +#### Updates: + * Arguments 'keep.data' and 'keep.attrs' across the package now have an explicit default value of FALSE (no resultant change in behaviour). * Internal performance enhancements. * Requires nanonext >= 0.11.0. # ichimoku 1.4.10 +#### Updates: + * Improves handling of OANDA API errors. # ichimoku 1.4.9 +#### Updates: + * Internal performance enhancements. * Requires nanonext >= 0.10.0 and R >= 3.5. diff --git a/R/iplot.R b/R/iplot.R index 951b48d4..c8b4ca4e 100644 --- a/R/iplot.R +++ b/R/iplot.R @@ -124,7 +124,7 @@ iplot <- function(x, server <- function(input, output, session) { - window <- reactive(paste0(input$dates[1L], "/", input$dates[2L])) + window <- reactive(sprintf("%s/%s", input$dates[1L], input$dates[2L])) left_px <- reactive(input$plot_hover$coords_css$x) top_px <- reactive(input$plot_hover$coords_css$y) posi_x <- reactive(round(input$plot_hover$x, digits = 0)) diff --git a/R/oanda.R b/R/oanda.R index 152efb72..bf603935 100644 --- a/R/oanda.R +++ b/R/oanda.R @@ -186,12 +186,13 @@ oanda <- function(instrument, getPrices <- function(instrument, granularity, count = NULL, from = NULL, to = NULL, price, server, apikey, .validate) { - url <- paste0("https://api-fx", switch(server, practice = "practice", live = "trade"), - ".oanda.com/v3/instruments/", instrument, "/candles?granularity=", - granularity, "&price=", price, - if (length(count)) strcat("&count=", as.character(count)), - if (length(from)) strcat("&from=", as.character(from)), - if (length(to)) strcat("&to=", as.character(to))) + url <- sprintf( + "https://api-fx%s.oanda.com/v3/instruments/%s/candles?granularity=%s&price=%s%s%s%s", + switch(server, practice = "practice", live = "trade"), instrument, granularity, price, + if (length(count)) strcat("&count=", as.character(count)) else "", + if (length(from)) strcat("&from=", as.character(from)) else "", + if (length(to)) strcat("&to=", as.character(to)) else "" + ) resp <- ncurl(url, convert = FALSE, follow = TRUE, @@ -759,7 +760,7 @@ oanda_studio <- function(instrument = "USD_JPY", type = input$type) }) - output$savedata <- downloadHandler(filename = function() paste0(input$instrument, "_", input$granularity, "_", input$price, ".rda"), + output$savedata <- downloadHandler(filename = function() sprintf("%s_%s_%s.rda", input$instrument, input$granularity, input$price), content = function(file) archive(pdata(), file)) session$onSessionEnded(stopApp) @@ -1007,9 +1008,9 @@ oanda_positions <- function(instrument, time, server, apikey) { server <- if (missing(server)) do_[["getServer"]]() else match.arg(server, c("practice", "live")) if (missing(apikey)) apikey <- do_[["getKey"]](server = server) - url <- paste0("https://api-fx", switch(server, practice = "practice", live = "trade"), - ".oanda.com/v3/instruments/", instrument, "/positionBook", - if (!missing(time)) paste0("?time=", unclass(as.POSIXct(time)))) + url <- sprintf("https://api-fx%s.oanda.com/v3/instruments/%s/positionBook%s", + switch(server, practice = "practice", live = "trade"), instrument, + if (missing(time)) "" else sprintf("?time=%.f", unclass(as.POSIXct(time)))) resp <- ncurl(url, convert = FALSE, follow = TRUE, headers = c(Authorization = strcat("Bearer ", apikey), `Accept-Datetime-Format` = "UNIX", `User-Agent` = .user_agent)) @@ -1099,9 +1100,9 @@ oanda_orders <- function(instrument, time, server, apikey) { server <- if (missing(server)) do_[["getServer"]]() else match.arg(server, c("practice", "live")) if (missing(apikey)) apikey <- do_[["getKey"]](server = server) - url <- paste0("https://api-fx", switch(server, practice = "practice", live = "trade"), - ".oanda.com/v3/instruments/", instrument, "/orderBook", - if (!missing(time)) paste0("?time=", unclass(as.POSIXct(time)))) + url <- sprintf("https://api-fx%s.oanda.com/v3/instruments/%s/orderBook%s", + switch(server, practice = "practice", live = "trade"), instrument, + if (missing(time)) "" else sprintf("?time=%.f", unclass(as.POSIXct(time)))) resp <- ncurl(url, convert = FALSE, follow = TRUE, headers = c(Authorization = strcat("Bearer ", apikey), `Accept-Datetime-Format` = "UNIX", `User-Agent` = .user_agent))