Этот пример показывает рабочий процесс, чтобы создать и оценить портфель инструментов опции связи и связи. Можно использовать finportfolio и pricePortfolio оценивать FixedBond, FixedBondOption, OptionEmbeddedFixedBond, и FloatBond инструменты с помощью IRTree метод ценообразования.
ratecurve ОбъектСоздайте ratecurve объект с помощью ratecurve.
Settle = datetime(2018, 1, 1); ZeroTimes = calyears(1:4)'; ZeroRates = [0.035; 0.042147; 0.047345; 0.052707]; ZeroDates = Settle + ZeroTimes; Compounding = 1; ZeroCurve = ratecurve("zero",Settle,ZeroDates,ZeroRates, "Compounding",Compounding)
ZeroCurve =
ratecurve with properties:
Type: "zero"
Compounding: 1
Basis: 0
Dates: [4x1 datetime]
Rates: [4x1 double]
Settle: 01-Jan-2018
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"
Используйте fininstrument создать FixedBond, FixedBondOption, OptionEmbeddedFixedBond, и FloatBond инструментальные объекты.
CDates = datetime([2020,1,1 ; 2022,1,1]); CRates = [.0425; .0750]; CouponRate = timetable(CDates,CRates); Maturity = datetime(2022,1,1); Period = 1; % Vanilla FixedBond VBond = fininstrument("FixedBond",'Maturity',Maturity,'CouponRate',0.0425,'Period',Period,'Name',"vanilla_fixed")
VBond =
FixedBond with properties:
CouponRate: 0.0425
Period: 1
Basis: 0
EndMonthRule: 1
Principal: 100
DaycountAdjustedCashFlow: 0
BusinessDayConvention: "actual"
Holidays: NaT
IssueDate: NaT
FirstCouponDate: NaT
LastCouponDate: NaT
StartDate: NaT
Maturity: 01-Jan-2022
Name: "vanilla_fixed"
% Stepped coupon bond SBond = fininstrument("FixedBond",'Maturity',Maturity,'CouponRate',CouponRate,'Period',Period,'Name',"stepped_coupon_bond")
SBond =
FixedBond with properties:
CouponRate: [2x1 timetable]
Period: 1
Basis: 0
EndMonthRule: 1
Principal: 100
DaycountAdjustedCashFlow: 0
BusinessDayConvention: "actual"
Holidays: NaT
IssueDate: NaT
FirstCouponDate: NaT
LastCouponDate: NaT
StartDate: NaT
Maturity: 01-Jan-2022
Name: "stepped_coupon_bond"
% FloatBond Spread = 0; Reset = 1; Float = fininstrument("FloatBond",'Maturity',Maturity,'Spread',Spread,'Reset', Reset,... 'ProjectionCurve',ZeroCurve,'Name',"floatbond")
Float =
FloatBond with properties:
Spread: 0
ProjectionCurve: [1x1 ratecurve]
ResetOffset: 0
Reset: 1
Basis: 0
EndMonthRule: 1
Principal: 100
DaycountAdjustedCashFlow: 0
BusinessDayConvention: "actual"
LatestFloatingRate: NaN
Holidays: NaT
IssueDate: NaT
FirstCouponDate: NaT
LastCouponDate: NaT
StartDate: NaT
Maturity: 01-Jan-2022
Name: "floatbond"
% Call option Strike = 100; ExerciseDates = datetime(2020,1,1); OptionType ='call'; Period = 1; CallOption = fininstrument("FixedBondOption",'Strike',Strike,'ExerciseDate',ExerciseDates,... 'OptionType',OptionType,'ExerciseStyle',"american",'Bond', VBond,'Name',"fixed_bond_option")
CallOption =
FixedBondOption with properties:
OptionType: "call"
ExerciseStyle: "american"
ExerciseDate: 01-Jan-2020
Strike: 100
Bond: [1x1 fininstrument.FixedBond]
Name: "fixed_bond_option"
% Option for embedded bond (callable bond) CDates = datetime([2020,1,1 ; 2022,1,1]); CRates = [.0425; .0750]; CouponRate = timetable(CDates,CRates); StrikeOE = [100; 100]; ExerciseDatesOE = [datetime(2020,1,1); datetime(2021,1,1)]; CallSchedule = timetable(ExerciseDatesOE,StrikeOE,'VariableNames',{'Strike Schedule'}); CallableBond = fininstrument("OptionEmbeddedFixedBond", 'Maturity',Maturity,... 'CouponRate',CouponRate,'Period', Period, ... 'CallSchedule',CallSchedule,'Name',"option_embedded_fixedbond")
CallableBond =
OptionEmbeddedFixedBond with properties:
CouponRate: [2x1 timetable]
Period: 1
Basis: 0
EndMonthRule: 1
Principal: 100
DaycountAdjustedCashFlow: 0
BusinessDayConvention: "actual"
Holidays: NaT
IssueDate: NaT
FirstCouponDate: NaT
LastCouponDate: NaT
StartDate: NaT
Maturity: 01-Jan-2022
CallDates: [2x1 datetime]
PutDates: [0x1 datetime]
CallSchedule: [2x1 timetable]
PutSchedule: [0x0 timetable]
CallExerciseStyle: "american"
PutExerciseStyle: [0x0 string]
Name: "option_embedded_fixedbond"
HullWhite МодельИспользуйте finmodel создать HullWhite объект модели.
VolCurve = 0.01; AlphaCurve = 0.1; HWModel = finmodel("hullwhite",'alpha',AlphaCurve,'sigma',VolCurve)
HWModel =
HullWhite with properties:
Alpha: 0.1000
Sigma: 0.0100
IRTree Калькулятор цен для HullWhite МодельИспользуйте finpricer создать IRTree объект калькулятора цен для HullWhite модель и использование ratecurve объект для 'DiscountCurve' аргумент пары "имя-значение".
HWTreePricer = finpricer("IRTree",'Model',HWModel,'DiscountCurve',ZeroCurve,'TreeDates',ZeroDates)
HWTreePricer =
HWBKTree with properties:
Tree: [1x1 struct]
TreeDates: [4x1 datetime]
Model: [1x1 finmodel.HullWhite]
DiscountCurve: [1x1 ratecurve]
finportfolio Возразите и добавьте вызываемый инструмент связиСоздайте finportfolio объект со связью ванили, продвинутой облигацией на предъявителя, пускает в ход связь и колл-опцион.
myportfolio = finportfolio([VBond,SBond,Float,CallOption],HWTreePricer, [1,2,2,1])
myportfolio =
finportfolio with properties:
Instruments: [4x1 fininstrument.FinInstrument]
Pricers: [1x1 finpricer.irtree.HWBKTree]
PricerIndex: [4x1 double]
Quantity: [4x1 double]
Используйте addInstrument добавить вызываемый инструмент связи в существующий портфель.
myportfolio = addInstrument(myportfolio,CallableBond,HWTreePricer,1)
myportfolio =
finportfolio with properties:
Instruments: [5x1 fininstrument.FinInstrument]
Pricers: [1x1 finpricer.irtree.HWBKTree]
PricerIndex: [5x1 double]
Quantity: [5x1 double]
myportfolio.PricerIndex
ans = 5×1
1
1
1
1
1
PricerIndex свойство имеет длину, равную длине инструментальных объектов в finportfolio объект и хранилища, индекс которых калькулятор цен используется для каждого инструментального объекта. В этом случае, потому что существует только один калькулятор цен, каждый инструмент должен использовать тот калькулятор цен.
Используйте pricePortfolio вычислить цену и чувствительность для портфеля и связи и инструментов опции в портфеле.
format bank
[PortPrice,InstPrice,PortSens,InstSens] = pricePortfolio(myportfolio)PortPrice =
600.55
InstPrice = 5×1
96.5943
204.1377
200.0000
0.0487
99.7738
PortSens=1×4 table
Price Vega Gamma Delta
______ ______ _______ ________
600.55 -63.40 5759.65 -1297.48
InstSens=5×4 table
Price Vega Gamma Delta
______ ______ _______ _______
vanilla_fixed 96.59 -0.00 1603.49 -344.81
stepped_coupon_bond 204.14 0.00 3364.60 -725.96
floatbond 200.00 -0.00 -0.00 0.00
fixed_bond_option 0.05 12.48 24.15 -3.69
option_embedded_fixedbond 99.77 -75.88 767.41 -223.03