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

    %% Compute OAS and OAD Using the Black-Karasinski (BK) Model
% This example shows how to compute OAS and OAD using the Black-Karasinski
% (BK) model using the following data.
%%
ValuationDate = 'Aug-2-2010';
Rates = [0.0355; 0.0382; 0.0427; 0.0489];
StartDates = ValuationDate;
EndDates = datemnth(ValuationDate, 12:12:48)';
Compounding = 1;

% define RateSpec
RateSpec = intenvset('ValuationDate', ValuationDate,...
'StartDates', StartDates,'EndDates', EndDates, ...
'Rates', Rates,'Compounding', Compounding); 

% specify VolSpec and TimeSpec
Sigma = 0.10;
Alpha = 0.01;
VS = bkvolspec(ValuationDate, EndDates, Sigma*ones(size(EndDates)),...
EndDates, Alpha*ones(size(EndDates)));
TS = bktimespec(ValuationDate, EndDates, Compounding);

% build the BK tree
BKTree = bktree(VS, RateSpec, TS);

% instrument information
CouponRate = 0.045;
Settle = ValuationDate;
Maturity = '02-Aug-2014';
OptSpec = 'put';
Strike = 100;
ExerciseDates ='02-Aug-2013';
Period = 1;
AmericanOpt = 1;
Price = 101;

% compute OAS and OAD
[OAS, OAD] = oasbybk(BKTree, Price, CouponRate, Settle, Maturity,...
OptSpec, Strike, ExerciseDates, 'Period', Period, 'AmericanOpt', AmericanOpt)