Оцените портфель инструментов — каждый с их собственным связанным калькулятором цен. Этот рабочий процесс распространен в ситуациях с риском, где у вас может быть портфель ценных бумаг, которые должны быть оценены.
Используйте finportfolio и pricePortfolio создать и оценить портфель инструментов акции и процентной ставки. Портфель содержит ваниль FixedBond, OptionEmbeddedFixedBond, Vanilla Европейский колл-опцион, Vanilla Американский колл-опцион и Asian колл-опцион.
Создайте ratecurve Объект
Создайте ratecurve объект с помощью ratecurve.
Settle = datetime(2018,9,15);
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;
ZeroCurve = ratecurve("zero",Settle,ZeroDates,ZeroRates);Создайте инструментальные объекты
Используйте fininstrument создать инструментальные объекты.
% Vanilla FixedBond CouponRate = 0.0325; Maturity = datetime(2038,3,15); Period = 1; VanillaBond = fininstrument("FixedBond",'Maturity',Maturity,'CouponRate',CouponRate,... 'Period',Period,'Name',"VanillaBond")
VanillaBond =
FixedBond with properties:
CouponRate: 0.0325
Period: 1
Basis: 0
EndMonthRule: 1
Principal: 100
DaycountAdjustedCashFlow: 0
BusinessDayConvention: "actual"
Holidays: NaT
IssueDate: NaT
FirstCouponDate: NaT
LastCouponDate: NaT
StartDate: NaT
Maturity: 15-Mar-2038
Name: "VanillaBond"
% OptionEmbeddedBond Maturity = datetime(2024,9,15); CouponRate = 0.035; Strike = 100; ExerciseDates = datetime(2023,9,15); CallSchedule = timetable(ExerciseDates,Strike,'VariableNames',{'Strike Schedule'}); Period = 1; CallableBond = fininstrument("OptionEmbeddedFixedBond", "Maturity",Maturity,... 'CouponRate',CouponRate,'Period',Period, ... 'CallSchedule',CallSchedule,... 'Name',"CallableBond"); % Vanilla European call option ExerciseDate = datetime(2022,1,1); Strike = 96; OptionType = 'call'; CallOpt = fininstrument("Vanilla",'ExerciseDate',ExerciseDate,'Strike',Strike,... 'OptionType',OptionType, 'Name',"EuropeanCallOption")
CallOpt =
Vanilla with properties:
OptionType: "call"
ExerciseStyle: "european"
ExerciseDate: 01-Jan-2022
Strike: 96
Name: "EuropeanCallOption"
% Vanilla American call option ExerciseDate = datetime(2023,1,1); Strike = 97; OptionType = 'call'; CallOpt_American = fininstrument("Vanilla",'ExerciseDate',ExerciseDate,'Strike',Strike,... 'OptionType',OptionType, 'ExerciseStyle', "american", ... 'Name',"AmericanCallOption")
CallOpt_American =
Vanilla with properties:
OptionType: "call"
ExerciseStyle: "american"
ExerciseDate: 01-Jan-2023
Strike: 97
Name: "AmericanCallOption"
% Asian call option ExerciseDate = datetime(2023,1,1); Strike = 102; OptionType = 'call'; CallOpt_Asian = fininstrument("Asian",'ExerciseDate',ExerciseDate,'Strike',Strike,... 'OptionType',OptionType,'Name',"AsianCall")
CallOpt_Asian =
Asian with properties:
OptionType: "call"
Strike: 102
AverageType: "arithmetic"
AveragePrice: 0
AverageStartDate: NaT
ExerciseStyle: "european"
ExerciseDate: 01-Jan-2023
Name: "AsianCall"
Создайте объекты модели
Используйте finmodel создать HullWhite и BlackScholes объекты модели.
% Create Hull-White model Vol = 0.01; Alpha = 0.1; HWModel = finmodel("hullwhite",'alpha',Alpha,'sigma',Vol); % Create Black-Scholes model Vol = .1; SpotPrice = 95; BlackScholesModel = finmodel("BlackScholes",'Volatility',Vol);
Создайте объекты калькулятора цен
Используйте finpricer создать Discount, IRTree, BlackScholes, Levy, и BjerksundStensland объекты калькулятора цен и использование ratecurve объект для 'DiscountCurve' аргумент пары "имя-значение".
% Create Discount pricer DiscPricer = finpricer("Discount","DiscountCurve",ZeroCurve); % Create Hull-White tree pricer TreeDates = Settle + calyears(1:30); HWTreePricer = finpricer("IRTree",'Model',HWModel,'DiscountCurve',ZeroCurve,... 'TreeDates',TreeDates'); % Create BlackScholes, Levy, and BjerksundStensland pricers BLSPricer = finpricer("analytic",'DiscountCurve',ZeroCurve,'Model',BlackScholesModel,'SpotPrice',SpotPrice); LevyPricer = finpricer("analytic",'DiscountCurve',ZeroCurve,'Model',BlackScholesModel,... 'SpotPrice',SpotPrice,'PricingMethod',"Levy"); BJSpricer = finpricer("analytic",'DiscountCurve',ZeroCurve,'Model',BlackScholesModel,... 'SpotPrice',SpotPrice,'PricingMethod',"BjerksundStensland");
Создайте finportfolio Объект
Создайте finportfolio объект, который содержит весь инструмент и объекты калькулятора цен с помощью finportfolio.
myPort = finportfolio([VanillaBond CallableBond CallOpt CallOpt_American CallOpt_Asian]',...
[DiscPricer HWTreePricer BLSPricer BJSpricer LevyPricer]')myPort =
finportfolio with properties:
Instruments: [5x1 fininstrument.FinInstrument]
Pricers: [5x1 finpricer.FinPricer]
PricerIndex: [5x1 double]
Quantity: [5x1 double]
Ценовой портфель
Используйте pricePortfolio вычислить цену и чувствительность для портфеля и инструментов в портфеле.
[PortPrice,InstPrice,PortSens,InstSens] = pricePortfolio(myPort)
PortPrice = 237.3275
InstPrice = 5×1
107.4220
110.8389
7.5838
8.8705
2.6123
PortSens=1×8 table
Price Delta Gamma Lambda Vega Theta Rho DV01
______ _______ _____ ______ ______ _______ ______ ______
237.33 -546.39 2840 26.354 124.28 -4.0673 418.68 0.1579
InstSens=5×8 table
Price Delta Gamma Lambda Vega Theta Rho DV01
______ _______ ________ ______ _______ ________ ______ ______
VanillaBond 107.42 NaN NaN NaN NaN NaN NaN 0.1579
CallableBond 110.84 -547.9 2839.9 NaN -62.532 NaN NaN NaN
EuropeanCallOption 7.5838 0.57026 0.022762 7.1435 67.763 -1.3962 153.68 NaN
AmericanCallOption 8.8705 0.5845 0.019797 6.2597 76.808 -1.8677 200.68 NaN
AsianCall 2.6123 0.35611 0.032053 12.95 42.238 -0.80342 64.31 NaN
fininstrument | finmodel | finpricer