创建和分析工作流ratecurve
而且parametercurve
使用ratecurve
或irbootstrap
要创建ratecurve
对象。
创建一个比率曲线Settle = datetime(2019,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;比率曲线(“零”、结算、ZeroDates ZeroRates)
myRC =带有属性的利率曲线:类型:“零”复合:-1基础:0日期:[10×1 datetime]利率:[10×1 double]结算:15-Sep-2019 InterpMethod:“线性”ShortExtrapMethod:“下一个”LongExtrapMethod:“前一个”
使用zerorates
,forwardrates
,或discountfactors
与ratecurve
对象。
CurveSettle = datetime(2019,9,15);% zeroratesoutZeroRates = zerorates(myRC,CurveSettle+30:30:CurveSettle+720)% forwardratesoutForwardRates = forwardrates(myRC,datetime(2019,12,15),datetime(2021,9,15),6,7)% discountfactorsoutDiscountFactors =折扣因子(myRC,CurveSettle+30:30:CurveSettle+720)
outZeroRates =列1至14 0.0052 0.0052 0.0052 0.0052 0.0052 0.0052 0.0052 0.0052 0.0053 0.0053 0.0054 0.0055 0.0055 0.0056列15至24 0.0056 0.0057 0.0057 0.0058 0.0059 0.0059 0.0059 0.0060 0.0060 0.0061 outForwardRates = 0.0062 outDiscountFactors =列1至14 0.9996 0.9991 0.9987 0.9983 0.9979 0.9974 0.9970 0.9965 0.9961 0.9961 0.9961 0.9956 0.9956 0.9951 0.9946 0.9941 0.9936列15至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参数曲线(“零”datetime(2019、9、15),@ (t) polyval (-0.0001 0.003 0.02, t),“参数”,[-0.0001 0.003 0.02])
myPC =参数曲线与属性:类型:“零”结算:15-Sep-2019复合:-1基础:0 FunctionHandle: @(t)polyval([-0.0001,0.003,0.02],t)参数:[-1.0000 -04 0.0030 0.0200]
% fitNelsonSiegelSettle = datetime(2017,9,15);成熟度= [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 =数字(CouponRate);债券(nInst,1) = fininstrument.FinInstrument;为ii=1: nst债券(ii) = fininstrument(“FixedBond”,“成熟”成熟度(ii),...“CouponRate”CouponRate (ii));结束NSModel = fitNelsonSiegel(结算,债券,清洁价格)
NSModel =参数曲线与属性:类型:“零”结算:15-Sep-2017复合:-1基础:0 FunctionHandle: @(t)fitF(Params,t)参数:[1.2473 -05 0.0362 0.0903 16.4263]
% fitSvenssonSettle = datetime(2017,9,15);成熟度= [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 =数字(CouponRate);债券(nInst,1) = fininstrument.FinInstrument;为ii=1: nst债券(ii) = fininstrument(“FixedBond”,“成熟”成熟度(ii),...“CouponRate”CouponRate (ii));结束SvenModel = fitSvensson(结算,债券,清洁价格)
SvenModel =参数曲线与属性:类型:“零”结算:15-Sep-2017复合:-1基础:0 FunctionHandle: @(t)fitF(Params,t)参数:[2.2821 -41.8873 41.4090 -5.9589 0.3255 3.2356]
使用zerorates
,discountfactors
,forwardrates
与myPC
parametercurve
对象。
% zeroratesCurveSettle =日期时间(“15 - 9 - 2019”);outZeroRates = zerorates(myPC,CurveSettle+30:30:CurveSettle+720)% discountfactorsCurveSettle =日期时间(“15 - 9 - 2019”);outDiscountFactors =折扣因子(myPC,CurveSettle+30:30:CurveSettle+720)% forwardratesoutForwardRates = forwardrates(myPC,datetime(2019,9,15),datetime(2020,9,15),6,7)
outZeroRates =列1至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列15至24 0.0235 0.0238 0.0240 0.0242 0.0244 0.0246 0.0249 0.0249 0.0253 0.0255 outDiscountFactors =列1至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列15至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
对象。
假设有一个RateSpec结算=日期时间(01 - 10月- 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;基= 1;RateSpec = intenvset(startdate可以的解决,“EndDates”ZeroDates,...“利率”ZeroRates,“基础”基础)
RateSpec = struct with fields: FinObj: 'RateSpec'复合: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
将RateSpec转换为利率曲线比率曲线(“零”, RateSpec.EndDates RateSpec.ValuationDate RateSpec.Rates,...“复合”, RateSpec。复合,“基础”RateSpec.Basis)
myRC =利率曲线与属性:类型:“零”复合:2基础:1日期:[10×1 datetime]利率:[10×1 double]结算:01-Oct-2019 InterpMethod:“线性”ShortExtrapMethod:“下一个”LongExtrapMethod:“前一个”
检查折扣因素OldDF = intenvget(intenvset(RateSpec,“EndDates”datetime (01 - 10月- 2024的)),“盘”) NewDF =折扣因子(myRC,datetime(01 - 10月- 2024的))
oldddf = 0.9424 NewDF = 0.9424
在这种情况下,RateSpec
而且ratecurve
都是相同的。这可能并不总是如此,因为yearfrac
用于计算时间在ratecurve
而date2time
用于计算aRateSpec
.有关更多信息,请参见yearfrac和date2time之间的差异.
另请参阅
fininstrument
|finmodel
|finpricer