R/reset.R

Defines functions reset_quantstrat

Documented in reset_quantstrat

#' Reset quantstrat environments \code{.strategy},
#' \code{.blotter}, and \code{.audit}.
#' Creates each of these environments if they do not exist.
#' Removes all elements from each environment.
#' Sets the global currency to USD.
reset_quantstrat <- function() {
  if (! exists(".strategy")) .strategy <<- new.env(parent = .GlobalEnv)
  if (! exists(".blotter")) .blotter <<- new.env(parent = .GlobalEnv)
  if (! exists(".audit")) .audit <<- new.env(parent = .GlobalEnv)
  suppressWarnings(rm(list = ls(.strategy), pos = .strategy))
  suppressWarnings(rm(list = ls(.blotter), pos = .blotter))
  suppressWarnings(rm(list = ls(.audit), pos = .audit))
  FinancialInstrument::currency("USD")
}
greatgray/scorecard documentation built on May 17, 2019, 8:34 a.m.