Calculate vanilla option prices using finite difference method
AssetPrice = 50; Strike = 45; Rate = 0.035; Volatility = 0.30; Settle = '01-Jan-2015'; Maturity = '01-Jan-2016'; Basis = 1; RateSpec = intenvset('ValuationDate',Settle,'StartDates',Settle,'EndDates',... Maturity,'Rates',Rate,'Compounding',-1,'Basis',Basis)
RateSpec = struct with fields: FinObj: 'RateSpec' Compounding: -1 Disc: 0.9656 Rates: 0.0350 EndTimes: 1 StartTimes: 0 EndDates: 736330 StartDates: 735965 ValuationDate: 735965 Basis: 1 EndMonthRule: 1
StockSpec = stockspec(Volatility,AssetPrice)
StockSpec = struct with fields: FinObj: 'StockSpec' Sigma: 0.3000 AssetPrice: 50 DividendType:  DividendAmounts: 0 ExDividendDates: 
Calculate the price of a European vanilla call option using the finite difference method.
ExerciseDates = 'may-1-2015'; OptSpec = 'Call'; Price = optstockbyfd(RateSpec,StockSpec,OptSpec,Strike,Settle,ExerciseDates)
Price = 6.7352
StockSpec— Stock specification for underlying asset
Stock specification for the underlying asset. For information
on the stock specification, see
stockspec handles several
types of underlying assets. For example, for physical commodities
the price is
StockSpec.Asset, the volatility is
and the convenience yield is
OptSpec— Definition of option
'put'| string array with values
Definition of the option as
as a character vector or string array with values
Strike— Option strike price value
Option strike price value, specified as a nonnegative scalar or vector.
For a European option, use a scalar of strike price.
For a Bermuda option, use a
of strike prices.
For an American option, use a scalar of strike price.
Settle— Settlement or trade date
Settlement or trade date for the barrier option, specified as a serial date number, a date character vector, or a datetime object.
ExerciseDates— Option exercise dates
Option exercise dates, specified as a serial date number, a date character vector, or a datetime object:
For a European option, use a
of dates, specified as a nonnegative scalar integer, a date character
vector, or a datetime object. For a Bermuda option, use a
of dates, specified as a nonnegative scalar integer, date character
vector, or datetime object.
For an American option, use a
array of date character vectors. The option can be exercised on any
date between or including the pair of dates on that row. If only one
NaN date is listed, or if
1 vector of serial date
numbers or a cell array of date character vectors, the option can
be exercised between
Settle and the single listed
comma-separated pairs of
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
Price = optstockbyfd(RateSpec,StockSpec,OptSpec,Strike,Settle,ExerciseDates,'AssetGridSize',1000)
AssetGridSize— Size of asset grid used for finite difference grid
400(default) | positive scalar
Size of the asset grid used for a finite difference grid, specified as the comma-separated
pair consisting of
'AssetGridSize' and a positive
AssetPriceMax— Maximum price for price grid boundary
StockSpecvalues are calculated using asset distributions at maturity (default) | positive scalar
Maximum price for price grid boundary, specified as the comma-separated pair consisting of
'AssetPriceMax' as a positive scalar.
TimeGridSize— Size of time grid used for finite difference grid
100(default) | positive scalar
Size of the time grid used for a finite difference grid, specified as the comma-separated pair
'TimeGridSize' and a positive
AmericanOpt— Option type
0(European/Bermuda) (default) | scalar with values
Option type, specified as the comma-separated pair consisting of
1 positive integer
scalar flags with values:
0 — European/Bermuda
1 — American
Price— Expected prices for vanilla options
Expected prices for vanilla options, returned as a
PriceGrid— Grid containing prices calculated by finite difference method
Grid containing prices calculated by the finite difference method,
returned as a grid that is two-dimensional with size
The number of columns does not have to be equal to the
because ex-dividend dates in the
added to the time grid. The price for
t = 0 is
Times— Times corresponding to second dimension of
Times corresponding to second dimension of the
returned as a vector.
A vanilla option is a category of options that includes only the most standard components.
A vanilla option has an expiration date and straightforward strike price. American-style options and European-style options are both categorized as vanilla options.
The payoff for a vanilla option is as follows:
For a call:
For a put:
St is the price of the underlying asset at time t.
K is the strike price.
For more information, see Vanilla Option.
 Haug, E. G., J. Haug, and A. Lewis. "Back to basics: a new approach to the discrete dividend problem." Vol. 9, Wilmott magazine, 2003, pp. 37–47.
 Wu, L. and Y. K. Kwok. "A front-fixing finite difference method for the valuation of American options." Journal of Financial Engineering. Vol. 6.4, 1997, pp. 83–97.