prep_maturity: Prepares a cross-section of data on options for a maturity to...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/vix.R

Description

This function consumes a cross-section of data on options for a maturity along with a set of weighting schemes. The function checks for sufficiency of data for calculation of IV and VIX for the schemes provided. Further, it filters out options with non-positive spreads and zero bid / ask prices. Options with prices that violate the no-arbitrage band of the option pricing model specified are also dropped. Filtering of options with zero traded volume is optional.

Usage

1
2
3
  prep_maturity(maturity, riskfree, carry, type, strike, underlying, 
                schemes, bid=NULL, ask=NULL, value=NULL, traded_vol=NULL,
                tv_filter=FALSE, verbose=TRUE)

Arguments

maturity

A numeric value that specifies time to expiration in years.

riskfree

A numeric value of the annualized risk-free interest rate to expiration; e.g. 0.16 means 16% pa.

carry

A numeric value of the annualized cost-of-carry rate; e.g. 0.10 means 10% pa.

type

A character vector of strings that specifies ‘“c”’ for a call option and ‘“p”’ for a put option.

strike

A numeric vector of excercise prices corresponding to each element in ‘type’.

underlying

A numeric vector of the asset prices corresponding to each element in ‘type’.

schemes

A character string/vector of strings that specifies which scheme(s) to employ. The four schemes corresponding to each volatility index are: ‘“vega”’, ‘“spread”’, ‘“volume”’, and ‘“elasticity”’.

bid

A numeric vector of best buy prices corresponding to each element in ‘type’. It is a required argument when “‘spread’” is one of the schemes.

ask

A numeric vector of best sell prices corresponding to each element in ‘type’. It is a required argument when “‘spread’” is one of the schemes.

value

An optional numeric vector of option prices corresponding to each element in ‘type’ when bid and ask prices are not available. If ‘bid’ and ‘ask’ prices are provided then ‘value’ is computed as ‘(bid + ask) / 2’ and any provided ‘value’ is ignored.

traded_vol

A numeric vector corresponding to each element in ‘type’. It is required when ‘“volume”’ is one of the ‘schemes’ or ‘tv_filter = TRUE’.

tv_filter

A logical value indicating whether options with zero traded value be discarded from the cross-section.

verbose

A logical value indicating whether warning messages be printed when dropping invalid options.

Details

The function checks for the validity of inputs for a cross-section of options for a maturity and weighting scheme. The maturity used must have at least eight days to expiration.

A number of filters are applied to discard invalid/illiquid options: options with zero bid / ask prices, negative spreads, and option prices (‘value’) that violate the no-arbitrage bounds of the option prcing model. Optionally, if traded volumes are available, one may drop options with zero traded volume by using the toggle ‘tv_filter’.

The function also computes the implied volatility of each option using an option pricing model. Note, that setting ‘carry = riskfree’ we get Black and Scholes' stock option model, ‘carry = riskfree-div’ we get Merton's stock option model with continuous dividend yield ‘div’, ‘carry = 0’ we get Black's futures option model, and ‘carry = riskfree-riskfreef’ we get Garman and Kohlhagen's currency option model with foreign interest rate ‘riskfreef’ (using GBSVolatility from package ‘fOptions’). In addtion, for the Black's Model on futures the ‘underlying’ value specified should be the futures price. If ‘schemes’ specified include either ‘“vega”’ or ‘“elasticity”’, the vega of each option is computed (using GBSGreeks from package ‘fOptions’) and returned in the prepared data.

Note: It is possible that the cleaning up of the dataset produces an ‘out’ in the returned value which is empty. This is by design and handled in ‘vix_ci’ and ‘vix_pt’.

Value

Returns a list of the following three elements:

maturity

Time to expiration in years as passed to prep_maturity.

schemes

The weighting scheme(s) as passed to prep_maturity.

out

A data frame of the filtered inputs, implied volatilities, and vega values.

Author(s)

Akhil S. Behl akhilsbehl@gmail.com;
Rohini Grover grover.rohini@gmail.com

References

Black, F. and Scholes, M. (1973). “The Pricing of Options and Corporate Liabilities”, Journal of Political Economy 81, 637-654.

See Also

GBSVolatility, GBSGreeks

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  # Example 1: SPX near month options and the Vega scheme.

  data(vix_spx)

  # Preparing data for near month spx options without filtering options with
  # zero traded volume.
  spx_near <- prep_maturity(maturity=vix_spx$opt_near$maturity[[1]],
                            riskfree=vix_spx$opt_near$riskfree[[1]],
                            carry=vix_spx$opt_near$riskfree[[1]],
                            type=vix_spx$opt_near$type,
                            strike=vix_spx$opt_near$strike,
                            underlying=vix_spx$opt_near$underlying,
                            schemes="vega",
                            bid=vix_spx$opt_near$bid,
                            ask=vix_spx$opt_near$ask,
                            tv_filter=FALSE)
  str(spx_near)

  # Example 2: NIFTY near month options and the Spread, Elasticity, and Vega
  # schemes.

  data(vix_nifty)

  # Preparing data for near month nifty options and filtering options with
  # zero traded volume.
  nifty_near <- prep_maturity(maturity=vix_nifty$opt_near$maturity[[1]],
                              riskfree=vix_nifty$opt_near$riskfree[[1]],
                              carry=vix_nifty$opt_near$riskfree[[1]],
                              type=vix_nifty$opt_near$type,
                              strike=vix_nifty$opt_near$strike,
                              underlying=vix_nifty$opt_near$underlying,
                              schemes=c("spread", "elasticity", "vega"),
                              bid=vix_nifty$opt_near$bid,
                              ask=vix_nifty$opt_near$ask,
                              traded_vol=vix_nifty$opt_near$traded_vol,
                              tv_filter=TRUE)
  str(nifty_near)

ifrogs documentation built on May 31, 2017, 2:27 a.m.