Extract data from Alpha Vantage returned data
Usage
av_grep_opts(
indta,
grepstring = "F,M,C,otm",
spot = NULL,
mindays = 3,
startdt = Sys.Date(),
mindelta = 0.05,
dropsymbol = FALSE
)Arguments
- indta
A data.table as returned by
av_get_pf()- grepstring
(default
F,M,call,otm,act) Three to five item string to select specific maturities, option types, strike ranges, and open interest categories from option sets returned byav_get_pf(.,"HISTORICAL_OPTIONS"). Each item in the list is an abbreviated code for what to select. The items are not case sensitive and in order areItem Values description Expiration Limit `[F B Maturity Type `[M Q Option Type `[C P Moneyness `[otm itm Activity `[act A]` - spot
(default
NULL) Spot to be used to determine itm/otm, If null then it is inferred from most out of the money call or put Note: This parameter only applies if there is one symbol inindta. If there is more than one ticker inindtaa columnspotmust be inindtato get correct results.- mindays
(default 3). Minimum number of days to expiration to be passed through from
startdt- startdt
(default
Sys.Date()). Date from which expirations will be considered.- mindelta
(default
0.05) delta limit on both moneyness sides, i.e. pass only options with deltas in range c(mindelta,1-mindelta)- dropsymbol
(default
FALSE). Drop symbol from returned data table.
Value
A reduced set of options obtained from av_get_pf() using Alphavantage HISTORICAL_OPTIONS function.
Details
av_get_pf() returns a large list of options. This function helps to narrow down the list by maturity and moneyness.
Examples
if (FALSE) { # \dontrun{
av_get_pf("IBM","HISTORICAL_OPTIONS") |> av_grep_opts("F,M,put",mindays=2)
} # }