ShinyApp Options Data Management
Source:vignettes/ShinyApp_3A_Options_Data.Rmd
ShinyApp_3A_Options_Data.RmdOptions Data Issues and Overview
As of 2026, Alphavantage has some pre-canned option metrics, but none that are relevant to valuation. They do, however, have full histories of option-level data which (once downloaded) can be used for almost any analysis desired.
Unlike simple time series data, options data requires knowing three more dimensions per point in time, per ticker. Specifically, a complete set of options requires a schema with 5 keys: Symbol, timestamp, expiration, strike, and put vs call. Needless to say, that’s more data than could ever be retrieved in real time. It’s also more data than comfortably fits inside any one given data.table. The only option then is to download (and process) the data outside of the Shiny app.
This vignette describes the procedure for downloading options data and how it is summarized for external use. In particular, the underlying data can be used to construct
- Constant maturity implied volatilities at a number of deltas using the SSVI volatility surface interpolation method Gatheral and Jacquier for a given symbol and date.
- Closest option to a given delta moneyness (e.g. 25 delta call or -25 delta put) for a given symbol and date.
The data from these efforts can be used externally using av_load_shinydata() or via user-developed functions as could be added using av_add_analytic()
Adding Full Option sets
The function av_add_options()
handles all options downloads. Given a set of tickers and a date range
(specified in the usual way, e.g. "-1y::"), it will use the
HISTORICAL_OPTIONS API call to get a full set of options
per symbol and date. If no symbols are specified, it will either start
the database out with SPY or download all tickers that have
previously been requested.
For example, to download all data for the (currently hot) ticker
MU for the past year, just run:
> av_add_options("update",dtstr="-1y::",symbols=c("MU"))
Option data to get:MU from 2025-11-06 to 2026-11-06 (252 days)
AVOpt:MU (2025-11-06::2026-11-06) [=============] 100% [ 4m]
Now: 16:34:16 Estimated end time data collection from AV: 16:38:13
Option update: Adding 1937969 rows to partitioned parquet set
Returned 1937969 new options, refreshing inventory, took 2.97 secs
Updated option inventory in 0.36sec
NULL
>
Note that downloading options data can take a considerable amount of time depending on what level of service you are paying for and the speed of your underlying infrastructure. With a simple limit of 70 requests per minute, the above operation took about 4 minutes. Collecting data for index ETFs in particular takes longer simply due to the volume of data requested. Initial data population may take several hours if not days, but once done, updates are fairly fast.
A note on storage
The av_add_options() call downloads all data, which can be substantial given the number of independent dimensions as outlined above. Alphavantage provides full greeks as well as last trades, marks, bid/offers and market sizes and volumes per contract id (i.e. per option with given expiration and strike for a given symbol).
This data is certainly too large to keep in one file (or
data.frame()), so this package instead stores the data as a
partitioned parquet directory below the user specified cache
directory. For example, the data downloaded above was stored underneath
my cache directory c:\t\avsh as
Directory of C:\t\avsh\eqopt\symbol=MU
11/07/2026 16:34 <DIR> .
11/07/2026 16:34 <DIR> ..
11/07/2026 16:34 104,243,776 part-0.parquet
As this data is stored in a different format, it requires the
function av_load_cached_opts()
to retrieve individual records. For example, to retrieve first and
second month calls for the tickers JPM and GS
over the past year, just run (for example)
> opttest2=av_load_cached_opts(optsDT=CJ(symbol=c("JPM","GS"), expcode=c("MO_1","MO_2"), type=c("call")), dtstr="-1y::")
> opttest2
ts expcode expiration type strike contractid last open_interest iv spot dtoexp mark delta gamma vega bid bid_size ask ask_size volume theta
<Date> <char> <Date> <char> <num> <char> <num> <int> <num> <num> <num> <num> <num> <num> <num> <num> <num> <num> <num> <num> <num>
2025-11-07 MO_1 2025-11-21 call 230 GS251121C00230000 487.83 0 1.49 NA 14 556.20 1.00000 0.00000 0.00000 552 20 560.40 5 0 -0.02435
2025-11-07 MO_1 2025-11-21 call 240 GS251121C00240000 0.00 0 1.49 NA 14 546.40 1.00000 0.00000 0.00000 542 20 550.40 5 0 -0.02541
2025-11-07 MO_1 2025-11-21 call 250 GS251121C00250000 0.00 0 1.49 NA 14 536.23 1.00000 0.00000 0.00000 532 21 540.45 21 0 -0.02647
...
Summarizing the data.
The raw options data needs to be aggregated in some way to be truly useful. There are two different techniques coded into this package. Each tries to find an option or option volatility that are closest to a given delta category for a given expiration, date, and symbol. There are three methods of aggregation available:
Simple inventory of data available.
The inventory option creates an internal list of three
data.tables: An inventory summary, a table of symbols and dates for
which options have been downloaded, and the last dates’ data for each
ticker. Note that this process can a minute or two.
> av_add_options("inventory",dtstr="-1m::")
Updated option inventory in 26.72sec
NULL
Using the data is as simple as the following:
> head(av_load_shinydata("eqoptinv")$inv)
symbol min_DT_ENTRY max_DT_ENTRY cnt nYrs nperYr min_ivn_dt max_ivn_dt min_iv_dt max_iv_dt
<char> <Date> <Date> <int> <num> <num> <Date> <Date> <Date> <Date>
ALL 2018-11-02 2026-11-06 444 8.02 55.4 <NA> <NA> <NA> <NA>
AMD 2018-11-02 2026-11-06 444 8.02 55.4 <NA> <NA> <NA> <NA>
ARGT 2021-04-09 2026-11-06 312 5.58 55.9 <NA> <NA> <NA> <NA>
Closest Option:
Find the option for a given expiration tenor which is closest (e.g.)
to a 25 delta call, by date and symbol. Culling them from the database
is accomplished with the "iv_nearest" option
> av_add_options("iv_nearest",dtstr="-2w::")
restore_avs_state restoring lazy loaded datasets iv_nearest
AV IV NEAR [=================================>-] 98% [14s] save_avs_state(all|px|fst) writing iv_nearest,
NULL
>
To retrieve this data, use
> av_load_shinydata("iv_nearest")[symbol=="QQQ" & expcode=="MO_1",]
symbol ts expcode type moneyn expiration strike contractid last open_interest iv spot dtoexp mark delta gamma vega bid bid_size ask ask_size volume
<char> <Date> <char> <char> <fctr> <Date> <num> <char> <num> <int> <num> <num> <num> <num> <num> <num> <num> <num> <num> <num> <num> <num>
QQQ 2016-10-11 MO_1 put P75 2016-10-21 119 QQQ161021P00119000 1.91 11798 10.3 NA 10 1.75 -0.7646 0.15399 0.0598 1.74 50 1.77 89 4312
QQQ 2016-10-11 MO_1 put P50 2016-10-21 118 QQQ161021P00118000 1.20 37076 12.2 NA 10 1.19 -0.5737 0.16497 0.0763 1.18 50 1.21 118 6898
QQQ 2016-10-11 MO_1 put P25 2016-10-21 116 QQQ161021P00116000 0.54 14735 14.2 NA 10 0.52 -0.2838 0.12292 0.0659 0.51 50 0.53 109 2839
QQQ 2016-10-11 MO_1 put P10 2016-10-21 114 QQQ161021P00113500 0.21 3210 17.1 NA 10 0.17 -0.1060 0.05506 0.0356 0.17 253 0.18 143 168
Constant maturity Fair Value vols
This calculates fair value (arbitrage free) implied volatilities for
a given delta moneyness and fixed tenor, using the SSVI approach of Gatheral
and Jacquier The fair value fits are created using the
"iv_fv" function, which will create/update a internal table
iv with
- Fair value volatilities for each fixed maturity expiration, e.g. for next monthly expiration 25 delta calls on SPY for a given date.
- Fair value volatilities for a constant maturity date (defined as
CWK_1orCMO_1for 1 week and 1 month out (e.g.) resepctively. There are three tenors for each, so the full set of expiration codes calculated are in(CWK_1,CWK_2,CWK_3,CMO_1,CMO_2,CMO_3).
> av_add_options("iv_fv",dtstr="-2w::")
restore_avs_state restoring lazy loaded datasets iv
Updating SOFR levels from FRED via quantmod
save_avs_state(all|px|fst) writing pxd,
av_one_px(SOFR @ userdata) userdata
...
save_avs_state(all|px|fst) writing iv,
NULL
>
Note that SOFR rates are used as risk free rates for purposes of calculating forwards prices. The data calculated can be retrieved using (e.g.):
> av_load_shinydata("iv")[symbol=="QQQ" & ts==max(ts),]
ts expcode moneyn strike iv symbol
<Date> <char> <fctr> <num> <num> <char>
2026-11-06 CMO_1 P75 693 0.331 QQQ
2026-11-06 CMO_1 P50 665 0.297 QQQ
2026-11-06 CMO_1 P25 660 0.293 QQQ