Рабочий процесс для создания и анализа ratecurve и parametercurve

Использование ratecurve или irbootstrap для создания ratecurve объект.

% Create a ratecurve
Settle = datetime(2019,9,15);
Type = "zero";
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;
myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 

  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10×1 datetime]
                Rates: [10×1 double]
               Settle: 15-Sep-2019
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Использовать zerorates, forwardrates, или discountfactors с ratecurve объект.

CurveSettle = datetime(2019,9,15);

% zerorates
outZeroRates = zerorates(myRC,CurveSettle+30:30:CurveSettle+720)

% forwardrates
outForwardRates = forwardrates(myRC,datetime(2019,12,15),datetime(2021,9,15),6,7)

% discountfactors
outDiscountFactors = discountfactors(myRC,CurveSettle+30:30:CurveSettle+720)
outZeroRates =

  Columns 1 through 14

    0.0052    0.0052    0.0052    0.0052    0.0052    0.0052    0.0052    0.0053    0.0053    0.0054    0.0054    0.0055    0.0055    0.0056

  Columns 15 through 24

    0.0056    0.0057    0.0057    0.0058    0.0058    0.0059    0.0059    0.0060    0.0060    0.0061


outForwardRates =

    0.0062


outDiscountFactors =

  Columns 1 through 14

    0.9996    0.9991    0.9987    0.9983    0.9979    0.9974    0.9970    0.9965    0.9961    0.9956    0.9951    0.9946    0.9941    0.9936

  Columns 15 through 24

    0.9931    0.9926    0.9920    0.9915    0.9910    0.9904    0.9898    0.9893    0.9887    0.9881

Использование parametercurve, fitNelsonSiegel, или fitSvensson для создания parametercurve объект.

% parametercurve
myPC = parametercurve('zero',datetime(2019,9,15),@(t) polyval([-0.0001 0.003 0.02],t),'Parameters',[-0.0001 0.003 0.02])
myPC = 

  parametercurve with properties:

              Type: "zero"
            Settle: 15-Sep-2019
       Compounding: -1
             Basis: 0
    FunctionHandle: @(t)polyval([-0.0001,0.003,0.02],t)
        Parameters: [-1.0000e-04 0.0030 0.0200]
% fitNelsonSiegel
Settle = datetime(2017,9,15);
  Maturity = [datetime(2019,9,15);datetime(2021,9,15);...
      datetime(2023,9,15);datetime(2026,9,7);...
      datetime(2035,9,15);datetime(2047,9,15)];
  
  CleanPrice = [100.1;100.1;100.8;96.6;103.3;96.3];
  CouponRate = [0.0400;0.0425;0.0450;0.0400;0.0500;0.0425];
  
  nInst = numel(CouponRate);
Bonds(nInst,1) = fininstrument.FinInstrument;
for ii=1:nInst
    Bonds(ii) = fininstrument("FixedBond","Maturity",Maturity(ii),...
        "CouponRate",CouponRate(ii));
end

NSModel = fitNelsonSiegel(Settle,Bonds,CleanPrice)
NSModel = 

  parametercurve with properties:

              Type: "zero"
            Settle: 15-Sep-2017
       Compounding: -1
             Basis: 0
    FunctionHandle: @(t)fitF(Params,t)
        Parameters: [1.2473e-05 0.0362 0.0903 16.4263]
% fitSvensson
Settle = datetime(2017,9,15);
  Maturity = [datetime(2019,9,15);datetime(2021,9,15);...
      datetime(2023,9,15);datetime(2026,9,7);...
      datetime(2035,9,15);datetime(2047,9,15)];
  
  CleanPrice = [100.1;100.1;100.8;96.6;103.3;96.3];
  CouponRate = [0.0400;0.0425;0.0450;0.0400;0.0500;0.0425];
  
  nInst = numel(CouponRate);
Bonds(nInst,1) = fininstrument.FinInstrument;
for ii=1:nInst
    Bonds(ii) = fininstrument("FixedBond","Maturity",Maturity(ii),...
        "CouponRate",CouponRate(ii));
end

SvenModel = fitSvensson(Settle,Bonds,CleanPrice)
SvenModel = 

  parametercurve with properties:

              Type: "zero"
            Settle: 15-Sep-2017
       Compounding: -1
             Basis: 0
    FunctionHandle: @(t)fitF(Params,t)
        Parameters: [2.2821 -41.8873 41.4090 -5.9589 0.3255 3.2356]

Использовать zerorates, discountfactors, forwardrates с myPC parametercurve объект.

% zerorates
CurveSettle = datetime('15-Sep-2019');
outZeroRates = zerorates(myPC,CurveSettle+30:30:CurveSettle+720)

% discountfactors
CurveSettle = datetime('15-Sep-2019');
outDiscountFactors = discountfactors(myPC,CurveSettle+30:30:CurveSettle+720)

% forwardrates
outForwardRates = forwardrates(myPC,datetime(2019,9,15),datetime(2020,9,15),6,7)
outZeroRates =

  Columns 1 through 14

    0.0202    0.0205    0.0207    0.0210    0.0212    0.0215    0.0217    0.0219    0.0222    0.0224    0.0226    0.0229    0.0231    0.0233

  Columns 15 through 24

    0.0235    0.0238    0.0240    0.0242    0.0244    0.0246    0.0249    0.0251    0.0253    0.0255


outDiscountFactors =

  Columns 1 through 14

    0.9983    0.9966    0.9949    0.9931    0.9913    0.9895    0.9876    0.9857    0.9838    0.9818    0.9798    0.9778    0.9757    0.9736

  Columns 15 through 24

    0.9715    0.9693    0.9671    0.9649    0.9627    0.9604    0.9581    0.9558    0.9534    0.9510


outForwardRates =

    0.0229

Преобразование RateSpec в ratecurve Объект

Можно создать RateSpec использование intenvset или toRateSpec от IRDataCurve объект. Затем можно скрыть это ранее созданное RateSpec в ratecurve объект.

% Assume there is a RateSpec
Settle = datetime('01-Oct-2019');
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;
Basis = 1;
RateSpec = intenvset('StartDates', Settle, 'EndDates', ZeroDates, ...
    'Rates', ZeroRates, 'Basis', Basis)
RateSpec = 

  struct with fields:

           FinObj: 'RateSpec'
      Compounding: 2
             Disc: [10×1 double]
            Rates: [10×1 double]
         EndTimes: [10×1 double]
       StartTimes: [10×1 double]
         EndDates: [10×1 double]
       StartDates: 737699
    ValuationDate: 737699
            Basis: 1
     EndMonthRule: 1
% Convert the RateSpec to a ratecurve
myRC = ratecurve("zero",RateSpec.ValuationDate,RateSpec.EndDates,RateSpec.Rates,...
"Compounding",RateSpec.Compounding,"Basis",RateSpec.Basis)
myRC = 

  ratecurve with properties:

                 Type: "zero"
          Compounding: 2
                Basis: 1
                Dates: [10×1 datetime]
                Rates: [10×1 double]
               Settle: 01-Oct-2019
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"
% Check the discount factors
OldDF = intenvget(intenvset(RateSpec,'EndDates',datetime('01-Oct-2024')),'Disc')
NewDF = discountfactors(myRC,datetime('01-Oct-2024'))
OldDF =

    0.9424

NewDF =

    0.9424

В этом случае RateSpec и ratecurve идентичны. Это может быть не всегда, потому что yearfrac используется для вычисления времени в ratecurve в то время как date2time используется при вычислении RateSpec. Для получения дополнительной информации смотрите Различие между yearfrac и date2time.

См. также

| |

Похожие темы

Для просмотра документации необходимо авторизоваться на сайте