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

getOptionChain: object 'bid' not found #338

Closed
mathieu-lemire opened this issue Jul 25, 2021 · 1 comment
Closed

getOptionChain: object 'bid' not found #338

mathieu-lemire opened this issue Jul 25, 2021 · 1 comment

Comments

@mathieu-lemire
Copy link

mathieu-lemire commented Jul 25, 2021

If there are no bid, ask or volume data for all strikes at a certain expiry date, getOptionChain() will return the error message

getOptionChain("AAPL",Exp="2021-09-03" )
Error in data.frame(Strike = strike, Last = lastprice, Chg = change, Bid = bid,  : 
  object 'bid' not found

getOptionChain("AAPL", NULL ) will fail as well.

The above call is probably hard to reproduce since data change, so I am attaching below the json from

https://query2.finance.yahoo.com/v7/finance/options/AAPL?&date=1630627200

AAPL.txt (downloaded on 21/07/25)

tbl <- jsonlite::fromJSON("AAPL.txt") 
dftables <- lapply(tbl$optionChain$result$options[[1]][,c("calls", "puts")], `[[`, 1L)
names(dftables$calls)

 [1] "contractSymbol"    "strike"            "currency"         
 [4] "lastPrice"         "change"            "percentChange"    
 [7] "openInterest"      "contractSize"      "expiration"       
[10] "lastTradeDate"     "impliedVolatility" "inTheMoney"       

bid, ask and volume are missing, and as a result the NewToOld() function in getOptionChain.yahoo() will fail.

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] C

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

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1    jsonlite_1.6  
@joshuaulrich
Copy link
Owner

I assume you deleted your comment because it had already been fixed. I restored it so it wouldn't confuse me or others in the future. Don't worry if you accidentally report something that's been fixed. It happens.

I ask people to make sure to use the most recent development version so they don't spend time hunting down bugs that have been fixed; out of respect for your time. 😉

Duplicate of #300.

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

No branches or pull requests

2 participants