# impvbybaw

Calculate implied volatility using Barone-Adesi and Whaley option pricing model

## Syntax

``Volatility = impvbybaw(RateSpec,StockSpec,Settle,Maturity,OptSpec,Strike,OptPrice)``
``Volatility = impvbybaw(___,Name,Value)``

## Description

example

````Volatility = impvbybaw(RateSpec,StockSpec,Settle,Maturity,OptSpec,Strike,OptPrice)` calculates implied volatility using the Barone-Adesi and Whaley option pricing model.```

example

````Volatility = impvbybaw(___,Name,Value)` adds optional name-value pair arguments.```

## Examples

collapse all

This example shows how to compute implied volatility using the Barone-Adesi and Whaley option pricing model. Consider three American call options with exercise prices of \$100 that expire on July 1, 2017. The underlying stock is trading at \$100 on January 1, 2017 and pays a continuous dividend yield of 10%. The annualized continuously compounded risk-free rate is 10% per annum, and the option prices are \$4.063, \$6.77 and \$9.46. Using this data, calculate the implied volatility of the stock using the Barone-Adesi and Whaley option pricing model.

```AssetPrice = 100; Settle = 'Jan-1-2017'; Maturity = 'Jul-1-2017'; Strike = 100; DivAmount = 0.1; Rate = 0.05;```

Define the `RateSpec`.

```RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle,... 'EndDates', Maturity, 'Rates', Rate, 'Compounding', -1, 'Basis', 1)```
```RateSpec = struct with fields: FinObj: 'RateSpec' Compounding: -1 Disc: 0.9753 Rates: 0.0500 EndTimes: 0.5000 StartTimes: 0 EndDates: 736877 StartDates: 736696 ValuationDate: 736696 Basis: 1 EndMonthRule: 1 ```

Define the `StockSpec`.

`StockSpec = stockspec(NaN, AssetPrice, {'continuous'}, DivAmount)`
```StockSpec = struct with fields: FinObj: 'StockSpec' Sigma: NaN AssetPrice: 100 DividendType: {'continuous'} DividendAmounts: 0.1000 ExDividendDates: [] ```

Define the American option.

```OptSpec = {'call'}; OptionPrice = [4.063;6.77;9.46];```

Compute the implied volatility for the American option.

```ImpVol = impvbybaw(RateSpec, StockSpec, Settle, Maturity, OptSpec,... Strike, OptionPrice)```
```ImpVol = 3×1 0.1802 0.2808 0.3803 ```

## Input Arguments

collapse all

Interest-rate term structure (annualized and continuously compounded), specified by the `RateSpec` obtained from `intenvset`. For information on the interest-rate specification, see `intenvset`.

Data Types: `struct`

Stock specification for the underlying asset. For information on the stock specification, see `stockspec`.

`stockspec` handles several types of underlying assets. For example, for physical commodities the price is `StockSpec.Asset`, the volatility is `StockSpec.Sigma`, and the convenience yield is `StockSpec.DividendAmounts`.

Data Types: `struct`

Settlement date for the American option, specified as a `NINST`-by-`1` matrix using a serial date number, a date character vector, or a datetime object.

Data Types: `double` | `char` | `datetime`

Maturity date for the American option, specified as a `NINST`-by-`1` matrix using a serial date number, a date character vector, or a datetime object.

Data Types: `double` | `char` | `datetime`

Definition of the option as `'call'` or `'put'`, specified as a `NINST`-by-`1` cell array of character vectors or string arrays with values `'call'` or `'put'`.

Data Types: `char` | `string`

American option strike price value, specified as a nonnegative scalar or `NINST`-by-`1` matrix of strike price values. Each row is the schedule for one option.

Data Types: `single` | `double`

American option prices from which the implied volatility of the underlying asset is derived, specified as a nonnegative scalar or `NINST`-by-`1` matrix of strike price values.

Data Types: `single` | `double`

### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: `Volatility = impvbybaw(RateSpec,StockSpec,Settle,Maturity,OptSpec,Strike,OptionPrice)`

Lower and upper bound of implied volatility search interval, specified as the comma-separated pair consisting of `'Limit'` and a `1`-by-`2` positive vector.

Data Types: `double`

Implied volatility search termination tolerance, specified as the comma-separated pair consisting of `'Tolerance'` and a positive scalar.

Data Types: `double`

## Output Arguments

collapse all

Expected implied volatility values, returned as a `NINST`-by-`1` matrix. If no solution can be found, a `NaN` is returned.

 Barone-Adesi, G. and Robert E. Whaley. “Efficient Analytic Approximation of American Option Values.” The Journal of Finance. Volume 42, Issue 2 (June 1987), 301–320.

 Haug, E. The Complete Guide to Option Pricing Formulas. Second Edition. McGraw-Hill Education, January 2007.