www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/ImpliedVolRollGeskeWhaleyOptionExample.m

    %% Compute the Implied Volatility Using the Roll-Geske-Whaley Option Pricing Model
% This example shows how to compute the implied volatility using the
% Roll-Geske-Whaley option pricing model. Assume that on July 1, 2008 a
% stock is trading at $13 and pays a single cash dividend of $0.25 on
% November 1, 2008. The American call option with a strike price of $15
% expires on July 1, 2009 and is trading at $1.346. The annualized
% continuously compounded risk-free rate is 5% per annum. Calculate the
% implied volatility of the stock using the Roll-Geske-Whaley option
% pricing model.
%%

% Copyright 2015 The MathWorks, Inc.

AssetPrice = 13;
Strike = 15;
Rates = 0.05;
Settle = 'July-01-08';
Maturity = 'July-01-09';

% define the RateSpec and StockSpec
RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle,...
 'EndDates', Maturity, 'Rates', Rates, 'Compounding', -1);

StockSpec = stockspec(NaN, AssetPrice, {'cash'}, 0.25, {'Nov 1,2008'});

Price = [1.346];
Volatility = impvbyrgw(RateSpec, StockSpec, Settle, Maturity, Strike, Price)