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

getQuote(ticker, what=what_metrics) throwing column error due to empty fields #208

Closed
wave-electron opened this Issue Dec 23, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@wave-electron

wave-electron commented Dec 23, 2017

Description

Error thrown because "Dividend Yield" is an empty field in AMZN ticker

Error in `[.data.frame`(sq, , QF) : undefined columns selected

Expected behavior

[return fields without the error]

Minimal, reproducible example

what_metrics <- yahooQF(c("Name","Price/Sales", "P/E Ratio","Dividend Yield"))
tickers = "AMZN"
metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)

Session Info

> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.2

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] jsonlite_1.5    quantmod_0.4-12 TTR_0.23-2      xts_0.10-1     
[5] zoo_1.8-0      

loaded via a namespace (and not attached):
[1] compiler_3.4.3  tools_3.4.3     curl_3.1        grid_3.4.3     
[5] lattice_0.20-35
@wave-electron

This comment has been minimized.

wave-electron commented Dec 23, 2017

tickers = "AMZN;AAPL"
> metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)
> tickers = "AAPL,AMZN"
> metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)

@joshuaulrich you are correct

Both these combinations don't throw errors for me either! However, you can still get the error with multiple tickers when they all have at least 1 missing field like in the case of

> tickers = "TSLA;AMZN"
> metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)
Error in `[.data.frame`(sq, , QF) : undefined columns selected

as TSLA is missing two fields P/E Ratio & Dividend Yield fields, whilst AMZN is missing the Dividend Yield field.

Edit: if you add AAPL to the query (has no missing fields) it doesn't throw the error

> tickers = "TSLA;AMZN;AAPL"
> metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)

output

TSLA | 2017-12-22 16:00:00 | Tesla, Inc. | NA | NA
AMZN | 2017-12-22 16:00:00 | Amazon.com, Inc. | 297.89902 | NA
AAPL | 2017-12-22 16:00:00 | Apple Inc. | 19.00217 | 0.013713

@joshuaulrich

This comment has been minimized.

Owner

joshuaulrich commented Dec 27, 2017

Thanks for the detailed report! This is certainly a bug, and I can replicate it.

@RajaPaul

This comment has been minimized.

RajaPaul commented Jan 8, 2018

getQuote("SBIN.NS",what=yahooQF())

Error in [.data.frame(sq, , "regularMarketTime") :
undefined columns selected

sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] quantmod_0.4-11 TTR_0.23-2 xts_0.10-0 zoo_1.8-0

loaded via a namespace (and not attached):
[1] lattice_0.20-35 codetools_0.2-15
[3] foreach_1.4.3 MASS_7.3-47
[5] grid_3.4.1 jsonlite_1.5
[7] PerformanceAnalytics_1.4.3541 curl_3.1
[9] boot_1.3-19 blotter_0.12.4
[11] iterators_1.0.8 tools_3.4.1
[13] yaml_2.1.14 FinancialInstrument_1.2.0
[15] compiler_3.4.1 quantstrat_0.10.7

@RobinL

This comment has been minimized.

RobinL commented Mar 15, 2018

To add another example:

> getQuote("GBPEUR=X")
Error in `[.data.frame`(sq, , QF) : undefined columns selected

whereas getQuote("GBPUSD=X") works fine.

Here is a diff between the json response from Yahoo of the two queries which shows significant differences in the keys of the response:

https://gist.github.com/RobinL/e13df2ee55aa6c1117d5d6b6371e9b69/revisions

RobinL added a commit to RobinL/costmodelr that referenced this issue Mar 15, 2018

RobinL added a commit to RobinL/costmodelr that referenced this issue Mar 15, 2018

@joshuaulrich joshuaulrich added the bug label Apr 1, 2018

@joshuaulrich joshuaulrich self-assigned this Apr 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment