Skip to content

Commit

Permalink
fixes oanda_switch()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Dec 8, 2023
1 parent fd8016d commit 532d2cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 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.4.11
Version: 1.4.11.9000
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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ichimoku 1.4.11.9000 (development)

* Fixes `oanda_switch()`, regression since v1.4.11.

# ichimoku 1.4.11

* Allows using the environment variable 'OANDA_API_KEY' as an alternative to the 'keyring' package.
Expand Down
17 changes: 9 additions & 8 deletions R/switch.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,27 @@ do_ <- function() {
switch(server_type,
practice = {
server_type <<- "live"
livestore <<- keystore <<- instruments <<- account <<- NULL
livestore <<- keystore <<- ""
instruments <<- account <<- NULL
message("Default OANDA server switched to 'live'")
},
live = {
server_type <<- "practice"
livestore <<- keystore <<- instruments <<- account <<- NULL
livestore <<- keystore <<- ""
instruments <<- account <<- NULL
message("Default OANDA server switched to 'practice'")
}),
getKey = function(server) {
if (missing(server)) server <- server_type
getKey = function(server = server_type) {
switch(server,
practice = {
if (!nzchar(keystore)) {
if (requireNamespace("keyring", quietly = TRUE)) {
apikey <- tryCatch(keyring::key_get(service = "OANDA_API_KEY"), error = function(e) {
message("No API key found for 'practice' account type\nPlease use oanda_set_key() to store your API key for automatic retrieval")
if (interactive()) readline("Please enter OANDA API key: ")
if (interactive()) readline("Please enter OANDA API key: ") else ""
})
} else {
apikey <- if (interactive()) readline("Please enter OANDA API key: ")
apikey <- if (interactive()) readline("Please enter OANDA API key: ") else ""
}
keystore <<- apikey
}
Expand All @@ -102,10 +103,10 @@ do_ <- function() {
if (requireNamespace("keyring", quietly = TRUE)) {
apikey <- tryCatch(keyring::key_get(service = "OANDA_LIVE_KEY"), error = function(e) {
message("No API key found for 'live' account type\nPlease use oanda_set_key() to store your API key for automatic retrieval")
if (interactive()) readline("Please enter OANDA API key: ")
if (interactive()) readline("Please enter OANDA API key: ") else ""
})
} else {
apikey <- if (interactive()) readline("Please enter OANDA API key: ")
apikey <- if (interactive()) readline("Please enter OANDA API key: ") else ""
}
livestore <<- apikey
}
Expand Down

0 comments on commit 532d2cf

Please sign in to comment.