%% Price European Barrier Down Out and Down In Call Options
% Compute the price of European down out and down in call options using the following data:

Rates = 0.035;
Settle = '01-Jan-2015';
Maturity = '01-jan-2016';
Compounding = -1;
Basis = 1;

%
% Define a RateSpec.

RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, 'EndDates', Maturity, ...
'Rates', Rates, 'Compounding', Compounding, 'Basis', Basis)

%
% Define a StockSpec.

AssetPrice = 50;
Volatility = 0.30;
StockSpec = stockspec(Volatility, AssetPrice)

%
% Calculate the price of European barrier down out and down in call options using the Black-Scholes Option Pricing model.

Strike = 50;
OptSpec = 'Call';
Barrier = 45;
BarrierSpec = {'DO';'DI'};

Price = barrierbybls(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity,  BarrierSpec, Barrier)

% Copyright 2012 The MathWorks, Inc.