%% Price Convertible Bond Instrument Using Black-Scholes Model and Finite Difference Pricer
% This example shows the workflow to price a ConvertibleBond instrument when you use a BlackScholes model and a FiniteDifference pricing method.
%% Create ConvertibleBond Instrument Object
% Use fininstrument to create a ConvertibleBond instrument object.

CouponRate = 0;
Maturity = datetime(2014,10,1);
ConvRatio = 2;
Period = 1;
Spread = 0.05;

CallExDates = datetime(2014,10,1);
CallStrike = 115;
CallSchedule = timetable(CallExDates, CallStrike);

ConvBond = fininstrument("ConvertibleBond",'CouponRate',CouponRate,'Maturity',Maturity,'ConversionRatio',ConvRatio,'Period',Period,'Spread',Spread,'CallSchedule',CallSchedule,'CallExercisestyle',"american",'Name',"Convertible_Bond")

%
%% Create BlackScholes Model Object
% Use finmodel to create a BlackScholes model object.

AssetPrice = 50;
Volatility = 0.3;

BSModel = finmodel("BlackScholes",'Volatility',Volatility)

%% Create ratecurve Object
% Create a ratecurve object using ratecurve.

StartDate = datetime(2014,1,1);
EndDate = datetime(2015,1,1);
Rate = 0.1;

ZeroCurve = ratecurve('zero',StartDate,EndDate,Rate,'Compounding',-1,'Basis',1)

%% Create FiniteDifference Pricer Object
% Use finpricer to create a FiniteDifference pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

outPricer = finpricer("FiniteDifference",'Model',BSModel,'SpotPrice',AssetPrice,'DiscountCurve',ZeroCurve)

%% Price ConvertibleBond Instrument
% Use price to compute the price and sensitivities for the ConvertibleBond instrument.

[Price, outPR] = price(outPricer,ConvBond,"all")
outPR.Results

% Copyright 2020 The MathWorks, Inc.