Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default handling to getQuote #291

Closed
ethanbsmith opened this issue Jan 29, 2020 · 4 comments
Closed

add default handling to getQuote #291

ethanbsmith opened this issue Jan 29, 2020 · 4 comments
Assignees

Comments

@ethanbsmith
Copy link
Contributor

Description

Some of the getQuote functions do not import defaults

Expected behavior

missing in:
getQuote (master function)
getQuote.yahoo

@helgasoft
Copy link

Results are confusing. Docs say in setDefaults(name...), name = name of function, quoted or unquoted.
Here is what happens with AV.

setDefaults(getQuote.av, api.key='xxx')
# Error in setDefaults(getQuote.av, api.key = "xxx") :   object 'getQuote.av' not found
setDefaults('quantmod:::getQuote.av', api.key='xxx')
# Error in get(fun, mode = "function", envir = envir) :   object 'quantmod:::getQuote.av' of mode 'function' was not found
setDefaults('getQuote.av', api.key='xxx')
# works, huh

@joshuaulrich
Copy link
Owner

@helgasoft Can you help me understand how this relates to the initial report. It looks like a separate issue.

@helgasoft
Copy link

Maybe I entered the wrong room. Was searching for issues with getQuote and defaults ...
Sorry, I don't really understand what 'import defaults' means.

@joshuaulrich
Copy link
Owner

Oh, that makes sense. I don't think this is related to the issue you uncovered, so I'd appreciate it if you create a new issue.

For some examples of what Ethan is referring to by "import defaults", you can search for "importDefaults" in getSymbols.R.

A bit more background: setDefaults() and importDefaults() basically let you set global options that are injected into the function call. It allows you to change the default value of an argument for all subsequent calls.

For example, you can set the default "from" date to 1 year ago. Then all your calls to getSymbols() will use that date by default.

setDefaults("getSymbols.yahoo", from = Sys.Date() - 365)
getSymbols("SPY")
head(SPY)
## [1] "SPY"
##            SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
## 2019-10-24   300.91   301.07  299.46    300.37   35453100     294.6716
## 2019-10-25   299.74   302.20  299.68    301.60   45205400     295.8783
## 2019-10-28   302.94   303.85  302.91    303.30   42147000     297.5460
## 2019-10-29   303.00   304.23  302.86    303.21   44284900     297.4577
## 2019-10-30   303.43   304.55  301.99    304.14   49643900     298.3701
## 2019-10-31   304.13   304.13  301.73    303.33   69053800     297.5754

@joshuaulrich joshuaulrich self-assigned this Nov 7, 2020
@joshuaulrich joshuaulrich added this to the Release 0.4.18 milestone Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants