Last active
October 18, 2020 13:52
-
-
Save addiversitas/6610ad0dc2bd1ee7f561caab032d6f31 to your computer and use it in GitHub Desktop.
iv calculation for APPL calls and puts including dividend yield
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
divYield <- getQuote(symbol, what = yahooQF("Dividend Yield"))$`Dividend Yield` | |
if(is.na(divYield)){divYield <- 0} | |
#calculating IV | |
calls$iv <- apply(calls, 1, getIV, S = lastPrice, r = 0.0011, q = divYield, type = "call") | |
puts$iv <- apply(puts, 1, getIV, S = lastPrice, r = 0.0011, q = divYield, type = "put") | |
#create grids | |
library(reshape2) | |
ivGridCalls <- acast(calls, ttm ~ moneyness, value.var = "iv") | |
ivGridPuts <- acast(puts, ttm ~ moneyness, value.var = "iv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment