Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error in getOptionChain expiry date for multiple tickers

I’m running the Getting options chain for multiple tickers but something is wrong with the expiration date for multiple tickers.

Here’s a sample code:

library(quantmod)
Symbols <- c("XOM","MSFT","JNJ")
Options.20220429 <- getOptionChain("Symbols", "2022-04-29")

And I’m getting the following error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    Error in getOptionChain.yahoo(Symbols = "Symbols", Exp = "2022-04-29") : 
  Provided expiry date(s) not found. Available dates are:

However, if I run a single ticker with same expiration date one by one like the one below, everything works fine.

getOptionChain("JNJ", "2022-04-29")

>Solution :

You need to provide the expiry date for each one of your tickers. The following code works:

Options.20220429 <- lapply(Symbols, getOptionChain, Exp = "2022-04-29")

names(Options.20220429) <- Symbols
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading