Skip to content

Commit

Permalink
Build 1.2.0 CRAN release
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Sep 20, 2021
1 parent 6c5ffcb commit 95c7e98
Show file tree
Hide file tree
Showing 25 changed files with 83 additions and 78 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ichimoku
Type: Package
Title: Visualization and Tools for Ichimoku Kinko Hyo Strategies
Version: 1.1.9.1
Version: 1.2.0
Description: An implementation of 'Ichimoku Kinko Hyo', also commonly known as
'cloud charts'. Static and interactive visualizations with tools for
creating, backtesting and development of quantitative 'ichimoku' strategies.
Expand Down
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ichimoku 1.1.9
# ichimoku 1.2.0

#### New features:

Expand All @@ -14,12 +14,14 @@
#### Updates:

* Adds fallback for `oanda_instruments()` using an internal instruments table when the API call fails.
* `plot.ichimoku()` now returns the original object invisibly, use autoplot() and extraplot() to return plot objects.
* For all plot functions, the argument 'message' is renamed to 'subtitle'.
* Plots now show Tenkan-sen over Kijun-sen.
* Slight adjustments to original theme: cloud edges now plum-tinted for Senkou A, cyan-tinted for Senkou B.
* Fixes certain cases where calculation of the future cloud could fail for data frequency lower than daily.
* Updates to `sample_ohlc_data` to add volume column, adhere to working days etc.
* OANDA internal functions re-implemented as encapsulated closure list.
* `oanda_get_key()` is removed as no longer required.
* `oanda_get_key()` is removed as functionality incorporated elsewhere.
* New sub-plot functionality adds 'gridExtra' package dependency.
* 'rlang' package dependency is retired as no longer required.
* Internal C++ code: now includes only required cpp11 headers, adds rolling mean function, miscellaneous improvements.
Expand Down
21 changes: 8 additions & 13 deletions R/archive.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,21 @@ archive <- function(..., object, file) {
if (missing(object) && missing(file)) {

dots <- list(...)
dlen <- length(dots)

if (length(dots) == 1L) {
if (dlen == 1L) {
file <- dots[[1L]]
readArchive(file = file)

} else if (length(dots) == 2L) {
} else if (dlen == 2L) {
object <- dots[[1L]]
file <- dots[[2L]]
writeArchive(object = object, file = file)

} else if (length(dots) > 2L) {
stop("Too many arguments passed to archive()",
"\nFor read operations specify 'file' only",
"\nFor write operations specify both 'object' and 'file'", call. = FALSE)

} else {
stop("archive() is used to read/write objects to/from archive files",
"\nFor read operations specify 'file' only",
"\nFor write operations specify both 'object' and 'file'", call. = FALSE)
stop(dlen, " arguments passed to archive() which requires 1 or 2",
"\nFor read operations specify 'file' only, write operations both 'object' and 'file'", call. = FALSE)

}

} else if (!missing(file)) {
Expand Down Expand Up @@ -146,12 +142,11 @@ readArchive <- function(file) {
"\nDid you omit the surrounding quotes \"\"?", call. = FALSE)
}

object <- x_archive_sha256 <- NULL
x_archive_names <- load(file)
if (!length(x_archive_names) == 2L || !identical(x_archive_names[2L], "x_archive_sha256")) {
if (!identical(x_archive_names[2L], "x_archive_sha256") || !identical(x_archive_names[1L], "object")) {
stop("archive file was not created by archive()", call. = FALSE)
}
object <- get(x_archive_names[1L])
x_archive_sha256 <- get(x_archive_names[2L])

if (is.na(x_archive_sha256[1L])) {
message("Archive read from '", file, "'\nData unverified: sha256 hash not present")
Expand Down
7 changes: 4 additions & 3 deletions R/ichimoku-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#' unaffiliated with the ichimoku package.
#'
#' Gao, C. (2021), \emph{ichimoku: Visualization and Tools for Ichimoku
#' Kinko Hyo Strategies}. R package version 1.1.9,
#' Kinko Hyo Strategies}. R package version 1.2.0,
#' \url{https://CRAN.R-project.org/package=ichimoku}.
#'
#' @useDynLib ichimoku, .registration = TRUE
Expand Down Expand Up @@ -85,10 +85,11 @@ zoo::coredata
#' @export
xts::xts

utils::globalVariables(c(".data", "do_oanda"))
utils::globalVariables(".data")

.onLoad <- function(libname, pkgname) {
do_oanda <<- do_oanda()
do_oanda <- do_oanda()
do_oanda <<- do_oanda
invisible()
}

7 changes: 3 additions & 4 deletions R/ichimoku.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@
#' @param x a data.frame or other compatible object, which includes xts,
#' data.table, tibble, and matrix.
#' @param ticker (optional) specify a ticker to identify the instrument,
#' otherwise this is set to the name of the object supplied.
#' otherwise this is set to the name of the input object.
#' @param periods [default c(9L, 26L, 52L)] a vector defining the length of
#' periods used for the cloud. This parameter shoud not normally be modified
#' as using other values would be invalid in the context of traditional
#' ichimoku analysis.
#' @param keep.data (optional) set to TRUE to retain additional data present
#' in the object supplied as additional columns and/or attributes.
#' in the input object as additional columns and/or attributes.
#' @param ... additional arguments, for instance 'holidays', passed along to
#' \code{\link{tradingDays}} for calculating the future cloud on daily data.

#'
#' @return An ichimoku object is returned with S3 classes of 'ichimoku', 'xts'
#' and 'zoo'.
#' @return An ichimoku object with S3 classes of 'ichimoku', 'xts' and 'zoo'.
#'
#' @details Calling an ichimoku object automatically invokes its print method,
#' which by default produces a printout of the data to the console as well
Expand Down
2 changes: 1 addition & 1 deletion R/iplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' \code{getOption("shiny.launch.browser")}.
#'
#' @return A Shiny app object with class 'shiny.appobj'. With default arguments,
#' this Shiny app is launched in the default browser.
#' the Shiny app is launched in the default browser.
#'
#' @details This function has a dependency on the 'shiny' package.
#'
Expand Down
4 changes: 2 additions & 2 deletions R/look.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#' specific to that data type, or if 'which' is specified on an autostrat
#' list, an ichimoku object containing a strategy.
#'
#' For other objects, a list of attributes that are non-standard for matrix /
#' data.frame / xts objects, or else invisible NULL if none are present.
#' For other objects, a list of non-standard attributes for matrix /
#' data.frame / xts classes, or else invisible NULL if none are present.
#'
#' @details Note: for a level 2 autostrat object, if the attributes fail to print
#' correctly due to their length, please access the them directly using
Expand Down
11 changes: 8 additions & 3 deletions R/oanda.R
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ getPrices <- function(instrument, granularity, count, from, to, price, server,
#' For further details please refer to the OANDA fxTrade API vignette by
#' running: \code{vignette("xoanda", package = "ichimoku")}.
#'
#' @return Returns invisible NULL on function exit. The streaming data is output
#' as text to the console.
#' @return Invisible NULL on function exit. The streaming data is output as text
#' to the console.
#'
#' @section Streaming Data:
#'
Expand Down Expand Up @@ -444,7 +444,7 @@ oanda_chart <- function(instrument,
#' parameters, or the 'options' argument of \code{shiny::shinyApp()}.
#'
#' @return A Shiny app object with class 'shiny.appobj'. With default arguments,
#' this Shiny app is launched in the default browser.
#' the Shiny app is launched in the default browser.
#'
#' @details This function polls the OANDA fxTrade API for the latest prices and
#' updates a customisable reactive Shiny app at each refresh interval.
Expand Down Expand Up @@ -700,7 +700,9 @@ oanda_studio <- function(instrument = "USD_JPY",
#' @export
#'
oanda_instruments <- function(server, apikey) {

do_oanda$getInstruments(server = server, apikey = apikey)

}

#' Set OANDA fxTrade API Key
Expand Down Expand Up @@ -733,8 +735,11 @@ oanda_instruments <- function(server, apikey) {
#' @export
#'
oanda_set_key <- function() {

if (requireNamespace("keyring", quietly = TRUE)) {

type <- readline("Please choose:\n(1) for practice account \n(2) for live account")

if (type == 1) {
keyring::key_set(service = "OANDA_API_KEY")
} else if (type == 2) {
Expand Down
28 changes: 15 additions & 13 deletions R/switch.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#' @export
#'
oanda_switch <- function() {

do_oanda$switchServer()

}

#' OANDA Internal Functions
Expand All @@ -36,16 +38,17 @@ oanda_switch <- function() {
#' @noRd
#'
do_oanda <- function() {

server_type <- "practice"
keystore <- NULL
account <- NULL
instruments <- NULL

func <- list()
func$getServer <- function() {
server_type
}
func$switchServer <- function() {
list(
getServer = function() {
server_type
},
switchServer = function() {
if (server_type == "practice") {
server_type <<- "live"
keystore <<- account <<- instruments <<- NULL
Expand All @@ -55,8 +58,8 @@ do_oanda <- function() {
keystore <<- account <<- instruments <<- NULL
message("Default OANDA server switched to 'practice'")
}
}
func$getKey <- function() {
},
getKey = function() {
if (is.null(keystore)) {
if (requireNamespace("keyring", quietly = TRUE)) {
actype <- switch(do_oanda$getServer(), practice = "OANDA_API_KEY", live = "OANDA_LIVE_KEY")
Expand All @@ -71,8 +74,8 @@ do_oanda <- function() {
keystore <<- apikey
}
invisible(keystore)
}
func$getAccount <- function(server, apikey) {
},
getAccount = function(server, apikey) {
if (is.null(account)) {
if (missing(apikey)) apikey <- do_oanda$getKey()
server <- if (missing(server)) do_oanda$getServer() else match.arg(server, c("practice", "live"))
Expand All @@ -90,8 +93,8 @@ do_oanda <- function() {
account <<- data$id[1L]
}
invisible(account)
}
func$getInstruments <- function(server, apikey) {
},
getInstruments = function(server, apikey) {
if (is.null(instruments)) {
if (missing(apikey)) apikey <- do_oanda$getKey()
server <- if (missing(server)) do_oanda$getServer() else match.arg(server, c("practice", "live"))
Expand All @@ -118,8 +121,7 @@ do_oanda <- function() {
}
instruments
}

func
)

}

Binary file modified R/sysdata.rda
Binary file not shown.
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ autostrat(cloud, n = 3)

## Vignettes

Online versions:
Long-form documentation links:

{ 1 } [Cloud Charts - The Reference Manual](https://shikokuchuo.net/ichimoku/articles/reference.html)

Expand All @@ -118,7 +118,7 @@ Sasaki, H. 佐々木 英信 (1996), *一目均衡表の研究 [ichimoku kinkouhy

'OANDA' and 'fxTrade' are trademarks owned by OANDA Corporation, an entity unaffiliated with the ichimoku package.

Gao, C. (2021), *ichimoku: Visualization and Tools for Ichimoku Kinko Hyo Strategies*. R package version 1.1.9, <https://CRAN.R-project.org/package=ichimoku>.
Gao, C. (2021), *ichimoku: Visualization and Tools for Ichimoku Kinko Hyo Strategies*. R package version 1.2.0, <https://CRAN.R-project.org/package=ichimoku>.

--

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ autostrat(cloud, n = 3)

## Vignettes

Online versions:
Long-form documentation links:

{ 1 } [Cloud Charts - The Reference
Manual](https://shikokuchuo.net/ichimoku/articles/reference.html)
Expand All @@ -165,7 +165,7 @@ no kenkyuu]*. Tokyo, Japan: Toushi Radar.
entity unaffiliated with the ichimoku package.

Gao, C. (2021), *ichimoku: Visualization and Tools for Ichimoku Kinko
Hyo Strategies*. R package version 1.1.9,
Hyo Strategies*. R package version 1.2.0,
<https://CRAN.R-project.org/package=ichimoku>.

Expand Down
6 changes: 3 additions & 3 deletions data-raw/internal_sysdata.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## code to prepare internal sysdata

ichimoku_themes <- cbind(
original = c("#ffc0cb", "#8b8989", "#dda0dd", "#b22222", "#228b22", "#add8e6",
original = c("#ffc0cb", "#b4cdcd", "#dda0dd", "#b22222", "#228b22", "#a4d1eb",
"#00008b", "#00008b", "#00008b", "#ffffff", "#191970", "#00008b"),
dark = c("#ffb6c1", "#8b8989", "#dda0dd", "#c71585", "#40e0d0", "#b58900",
dark = c("#ffb6c1", "#b4cdcd", "#dda0dd", "#c71585", "#40e0d0", "#b58900",
"#eee8d5", "#fdf6e3", "#fdf6e3", "#002b36", "#eee8d5", "#fdf6e3"),
solarized = c("#d33682", "#eee8d5", "#6c71c4", "#cb4b16", "#859900", "#268bd2",
"#002b36", "#002b36", "#002b36", "#fdf6e3", "#073642", "#002b36"),
Expand Down Expand Up @@ -90,6 +90,6 @@ x_oanda_instruments <- data.frame(
"METAL","CURRENCY")
)

x_user_agent <- "r-ichimoku/1.1.9"
x_user_agent <- "r-ichimoku/1.2.0"

usethis::use_data(ichimoku_themes, x_oanda_instruments, x_user_agent, internal = TRUE, overwrite = TRUE)
Binary file modified man/figures/README-ichimoku-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/ichimoku-package.Rd

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

7 changes: 3 additions & 4 deletions man/ichimoku.Rd

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

2 changes: 1 addition & 1 deletion man/iplot.Rd

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

4 changes: 2 additions & 2 deletions man/look.Rd

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

4 changes: 2 additions & 2 deletions man/oanda_stream.Rd

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

2 changes: 1 addition & 1 deletion man/oanda_studio.Rd

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

Loading

0 comments on commit 95c7e98

Please sign in to comment.