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

    %% Compute the Implied Volatility Using the Black Option Pricing Model
% This example shows how to compute the implied volatility using the Black
% option pricing model. Consider a European call and put options on a futures contract with
% exercise prices of $30 for the put and $40 for the call that expire on
% September 1, 2008. Assume that on May 1, 2008 the contract is trading at
% $35. The annualized continuously compounded risk-free rate is 5% per
% annum. Find the implied volatilities of the stock, if on that date,
% the call price is $1.14 and the put price is $0.82.
%%

% Copyright 2015 The MathWorks, Inc.

AssetPrice = 35;
Strike = [30; 40];
Rates = 0.05;
Settle = 'May-01-08';
Maturity = 'Sep-01-08';

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

StockSpec = stockspec(NaN, AssetPrice);

% define the options
OptSpec = {'put';'call'};

Price = [1.14;0.82];
Volatility = impvbyblk(RateSpec, StockSpec, Settle, Maturity, OptSpec,...
Strike, Price)
%%
% The implied volatility is 41% and 30%.