From 5cfb4c9f79d0564055945a19d79d8fadb49f4432 Mon Sep 17 00:00:00 2001 From: jrburl <61259420+jrburl@users.noreply.github.com> Date: Sun, 8 Mar 2020 20:35:36 -0500 Subject: [PATCH] Update Bid & Ask fields to handle missing entries Similar to Vol & OI changes implemented previously. There are requests that are failing due to the bid & ask fields not having any info. This change solves. --- R/getOptionChain.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/getOptionChain.R b/R/getOptionChain.R index e83fa834..60ed2e32 100644 --- a/R/getOptionChain.R +++ b/R/getOptionChain.R @@ -22,8 +22,8 @@ getOptionChain.yahoo <- function(Symbols, Exp, ...) d <- with(x, data.frame(Strike=strike, Last=lastprice, Chg=change, - Bid=bid, - Ask=ask, + Bid= if("bid" %in% names(x)) {bid} else {NA}, + Ask= if("ask" %in% names(x)) {ask} else {NA}, Vol= if("volume" %in% names(x)) {volume} else {NA}, OI= if("openinterest" %in% names(x)) {openinterest} else {NA}, row.names=contractsymbol, stringsAsFactors=FALSE))