%% Price a Vanilla Call Option Using Finite Difference Method
% Create a RateSpec.

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)

%
% Create a StockSpec.

StockSpec = stockspec(Volatility,AssetPrice)

%
% 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)

% Copyright 2012 The MathWorks, Inc.