diff --git a/DESCRIPTION b/DESCRIPTION index b73e5770..86cab0b0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,6 +30,7 @@ Depends: R (>= 3.5) Imports: ggplot2 (>= 3.4.0), + mirai (>= 0.11.0), nanonext (>= 0.11.0), RcppSimdJson (>= 0.1.9), shiny (>= 1.4.0), diff --git a/NAMESPACE b/NAMESPACE index 25f2891e..2e1f7769 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -78,6 +78,7 @@ importFrom(ggplot2,scale_x_continuous) importFrom(ggplot2,scale_y_continuous) importFrom(ggplot2,theme) importFrom(ggplot2,theme_grey) +importFrom(mirai,mirai) importFrom(nanonext,ncurl) importFrom(nanonext,sha256) importFrom(shiny,HTML) @@ -99,6 +100,7 @@ importFrom(shiny,reactiveVal) importFrom(shiny,renderPlot) importFrom(shiny,renderUI) importFrom(shiny,req) +importFrom(shiny,runApp) importFrom(shiny,selectInput) importFrom(shiny,shinyApp) importFrom(shiny,sliderInput) diff --git a/NEWS.md b/NEWS.md index 6eb451a3..0674c52b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # ichimoku 1.4.11.9000 (development) +* Uses 'mirai' to run `oanda_studio(new.process = TRUE)` * Fixes `oanda_switch()`, regression since v1.4.11. * Internal performance enhancements. diff --git a/R/ichimoku-package.R b/R/ichimoku-package.R index 13737bc6..a690191c 100644 --- a/R/ichimoku-package.R +++ b/R/ichimoku-package.R @@ -82,12 +82,13 @@ #' PositionIdentity rel scale_color_manual scale_fill_manual #' scale_x_continuous scale_y_continuous Stat StatIdentity theme theme_grey #' %+replace% +#' @importFrom mirai mirai #' @importFrom nanonext ncurl sha256 #' @importFrom shiny checkboxInput column downloadButton downloadHandler HTML #' fillPage fluidPage fluidRow hoverOpts invalidateLater isolate #' numericInput observeEvent plotOutput reactive reactiveVal renderPlot -#' renderUI req selectInput shinyApp sliderInput stopApp tags textInput -#' uiOutput wellPanel +#' renderUI req runApp selectInput shinyApp sliderInput stopApp tags +#' textInput uiOutput wellPanel #' @importFrom RcppSimdJson is_valid_json #' @importFrom stats na.omit sd #' @importFrom utils packageVersion str diff --git a/R/oanda.R b/R/oanda.R index 7fea35e3..d78e5f36 100644 --- a/R/oanda.R +++ b/R/oanda.R @@ -576,11 +576,7 @@ oanda_studio <- function(instrument = "USD_JPY", isTRUE(new.process) && { mc <- match.call() mc[["new.process"]] <- NULL - cmd <- switch(.subset2(.Platform, "OS.type"), - unix = file.path(R.home("bin"), "Rscript"), - windows = file.path(R.home("bin"), "Rscript.exe")) - return(system2(command = cmd, args = c("-e", shQuote(paste0("ichimoku::", deparse(mc)))), - stdout = NULL, stderr = NULL, wait = FALSE)) + return(invisible(mirai(mc, oanda_studio = oanda_studio))) } if (!missing(instrument)) instrument <- sub("-", "_", toupper(force(instrument)), fixed = TRUE) granularity <- match.arg(granularity, c("D", "W", "M", @@ -771,7 +767,8 @@ oanda_studio <- function(instrument = "USD_JPY", session$onSessionEnded(stopApp) } - shinyApp(ui = ui, server = server, options = list(launch.browser = launch.browser, ...)) + app <- shinyApp(ui = ui, server = server, options = list(launch.browser = launch.browser, ...)) + runApp(app) } diff --git a/vignettes/reference.Rmd b/vignettes/reference.Rmd index 8d2888dd..701909a4 100644 --- a/vignettes/reference.Rmd +++ b/vignettes/reference.Rmd @@ -426,6 +426,7 @@ ichimoku currently has the following external package dependencies: - ggplot2 - for graphics and visualization - shiny - for interactive and live visualizations - xts, zoo - for enhanced time series methods +- mirai - for running applications in background processes - nanonext - for interfacing with external APIs and verifying the data integrity of archived objects - RcppSimdJson - for parsing data received from external APIs