joshuaulrich / joshuaulrich/quantmod

Structured approach to handle default argument values

Open
#192 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
906
Forks
233
PR merge metrics
No merged PRs in 30d

Description

Users can set default argument values to `getSymbols()` functions via `setDefaults()` (per-function) and `setSymbolLookup()`(per-symbol).

All `getSymbols()` methods currently use `importDefaults()` to get any arguments set via `setDefaults()`. Per-symbol defaults aren't handled in a very structured way. Some arguments are checked for defaults, while others aren't, and some are only checked once (i.e. not for every symbol requested).

The current (correct) pattern looks like this:

```r
default.foo <- foo # from function call
...
for (sym in Symbols) {
...
foo <- getSymbolLookup()[[sym]]$foo
foo <- if (is.null(foo)) default.foo else foo
...
}
```

The check inside the for loop could be encapsulated in a function, perhaps in `getSymbolLookup()` via an additional `default` argument.

Also, we often need to check that the value of the argument is one of a set of arguments (e.g. periodicity either "daily", "weekly", etc).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.