plotImpliedVol: Computes and plots the implied volatility of a set of...

Description Usage Arguments Value Examples

View source: R/plotivol.R

Description

The implied vol is derived from Black76 model. As implied volatility is derived from observed market prices, it is assumed that there is always an implied volatility figure that corresponds to the quoted prices, provided all inputs are filled in correctly. The user can choose to plot the implied volatility curve or just to return the computed ivol results. The user can elect to see ivol curves by strike, moneyness or option delta. Finally, the user can also elect to see both calls and puts, or to see only calls or only puts.

Usage

1
plotImpliedVol(df, plotting, type, style)

Arguments

df

data.frame containing all necessary inputs to derive implied volatility. Columns of the data.frame should be: strike: Strike price type: Option type, either call or put, entered as character 'C' or 'P'. option price: The market price of the option. future price: The price of the underlying future contract. time to expiry: The remaining life time of the option, expressed as a fraction of a year.

plotting

(optional, default=TRUE) Allows the user to switch off plotting and only get implied volatilities back.

type

(optional, default='both') Separates calls and puts. Takes one of values 'both', 'call', 'put'.

style

(optional, default='strike') Allows the user to choose between strike, moneyness and delta as plot's x-axis.

Value

The computed implied volatilities of a set of options. The ivol curves are also plotted by expiry. if an error is encountered during computation, the implied volatility is set to zero and the point is excluded from the plot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
df <- data.frame(strike = c(50, 20), # the option strike - in $
                type = c("C", "P"), # either <e2><80><9c>c<e2><80><9d> for call option or <e2><80><9c>p<e2><80><9d> for a put option
                optionPrice = c(1.62,0.01), # the option price - in $
                futurePrice = c(48.03, 48.03), # the price of the underlying future - in $
                time_to_expiry = c(0.1423, 0.1423))
Default case:
plotImpliedVol(df)

Get only implied volatility back:
plotImpliedVol(df, plotting=FALSE)

Plot Calls only, by delta:
plotImpliedVol(df, type='call', style='delta')

Plot puts on by strike:
plotImpliedVol(df, type='put')

hbianco/plotivol documentation built on May 18, 2019, 3:42 p.m.