%% Set Exercise Policy for a Specific Fixed Bond Option Instrument
% This example shows how to use setExercisePolicy to maintain consistency between the exercise schedule and exercise style when using a FixedBondOption instrument object with three Fixed Bond instruments.
%% Create FixedBond Instrument Object
% Use fininstrument to create a FixedBond instrument object as the underlying bond.

BondInst = fininstrument("FixedBond",'Maturity',datetime(2029,9,15),'CouponRate',.021,'Period',1,'Name',"bond_instrument");

%% Create FixedBondOption Instrument Object
% Use fininstrument to create a callable FixedBondOption instrument object for three Fixed Bond Option instruments with European exercises.

FixedBOption = fininstrument("FixedBondOption",'ExerciseDate',datetime([2025,9,15 ; 2025,10,15 ; 2025,11,15]),'Strike',98,'Bond',BondInst,'OptionType',"call",'ExerciseStyle',"european",'Name',"fixed_bond_option")

%% Set the Exercise Style to American
% Use setExercisePolicy to define ExerciseStyle as American for the second (FixedBOption(2)) instrument.

FixedBOption(2) = setExercisePolicy(FixedBOption(2),datetime(2025,9,15),98,"American")
FixedBOption(2).ExerciseStyle
FixedBOption.ExerciseStyle

% Copyright 2021 The MathWorks, Inc.