Question
Download option prices of ticker VIX for all expiration dates and name it VIX Download the current price (last quote price) for VIX For calls
Download option prices of ticker VIX for all expiration dates and name it "VIX"
Download the current price (last quote price) for VIX
For calls and puts at each expiration, add a column of "Price", which is the average of "Bid" and "Ask"
For calls and puts at each expiration, add a column of "moneyness", which takes value TRUE when it is out-of-money, and FALSE otherwise. (A call option is out-of-money when its strike is greater than current price of underlying. A put option is out-of-money if its strike is less than current price of underlying. And the current price of underlying is from the second question)
I have gotten the first two parts of the question and an attaching my code below, but cannot figure out how to get the moneyness column added with values.
library(quantmod)
getSymbols(Symbols="^VIX")
VIX=data.frame(VIX)
head(VIX)
tail(VIX)
#1.2
getQuote("^VIX")
#1.3
vix_opt=getOptionChain("^VIX")
vix_optall=getOptionChain("^VIX", NULL)
names(vix_optall)
pricefunc <- function(x){
x$calls$Price <- 0.5*(x$calls$Bid + x$calls$Ask)
x$puts$Price <- 0.5*(x$puts$Bid + x$puts$Ask)
return(x)
}
vix_optall=lapply(vix_optall, pricefunc)
names(vix_optall$Nov.04.2020$puts)
head(vix_optall$Nov.04.2020$puts)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started