%% Set Call Exercise Policy for Option Embedded Fixed Bond Instrument
% This example shows how to use setCallExercisePolicy to maintain consistency between the exercise schedule and exercise style when using a OptionEmbeddedFixedBond instrument object.
%
%% Create OptionEmbeddedFixedBond Instrument Object
% Use fininstrument to create an OptionEmbeddedFixedBond instrument object with different exercise styles.

Maturity = datetime(2024,1,1);
Strike = [100;100];
ExerciseDates = [datetime(2020,1,1); datetime(2024,1,1)];
Period = 1;
CallSchedule =  timetable(ExerciseDates,Strike,'VariableNames',{'Strike Schedule'}); 

CallableBond = fininstrument("OptionEmbeddedFixedBond",'Maturity',Maturity,...
                              'CouponRate',0.025,'Period',Period, ...
                              'CallSchedule',CallSchedule)

%% Set the Exercise Style to Bermudan
% Use setCallExercisePolicy to define the CallExerciseStyle as Bermudan.

CallableBond = setCallExercisePolicy(CallableBond, CallSchedule, "Bermudan") 

% Use setCallExercisePolicy to modify CallSchedule and continue using a Bermudan exercise style.

Strike = [100; 101;102;103];
ExerciseDates = [datetime(2018,1,1);datetime(2020,1,1);datetime(2022,1,1);datetime(2024,1,1)];

CallSchedule =  timetable(ExerciseDates,Strike,'VariableNames',{'Strike Schedule'}); 

CallableBond = setCallExercisePolicy(CallableBond, CallSchedule)   

% Copyright 2020 The MathWorks, Inc.