Bootstrapping ZeroDiscountFactors


#1

Hi All,

We are using strata 1.6 jar for creating zero discount factors from rates and tenors. However the results seem incorrect.

The code snippet is given below
ImmutableMap<QuoteId, Double> quotes = QuotesCsvLoader.load(VAL_DATE, QUOTES_RESOURCE);

    // create the market data
    MarketData marketData = MarketData.of(VAL_DATE, quotes);

    // the reference data, such as holidays and securities
    ReferenceData refData = ReferenceData.standard();

    // load the curve definition
    Map<CurveGroupName, CurveGroupDefinition> defns = RatesCalibrationCsvLoader.load(GROUPS_RESOURCE,
            SETTINGS_RESOURCE, CALIBRATION_RESOURCE);
    CurveGroupDefinition curveGroupDefinition = defns.get(CURVE_GROUP_NAME).filtered(VAL_DATE, refData);

    // calibrate the curves

    CalibrationMeasures calibrationMeasures = CalibrationMeasures.MARKET_QUOTE;

    CurveCalibrator calibrator = CurveCalibrator.of(1e-9, 1e-9, 1000, calibrationMeasures);

    RatesProvider provider = calibrator.calibrate(curveGroupDefinition, marketData, refData);

    // Discount Factors
    ZeroRateDiscountFactors df = (ZeroRateDiscountFactors) provider.discountFactors(Currency.USD);
    InterpolatedNodalCurve curve = (InterpolatedNodalCurve) df.getCurve();
    curve.getXValues();
    curve.getYValues();

    // O/N Forward Rates
    DiscountOvernightIndexRates ratesON = (DiscountOvernightIndexRates) provider
            .overnightIndexRates(OvernightIndices.USD_FED_FUND);
    ZeroRateDiscountFactors df2 = (ZeroRateDiscountFactors) ratesON.getDiscountFactors();
    InterpolatedNodalCurve curve2 = (InterpolatedNodalCurve) df2.getCurve();
    curve2.getXValues();
    curve2.getYValues();

    // 3M Forward Rates
    DiscountIborIndexRates rates = (DiscountIborIndexRates) provider.iborIndexRates(IborIndices.USD_LIBOR_3M);
    ZeroRateDiscountFactors df1 = (ZeroRateDiscountFactors) rates.getDiscountFactors();
    InterpolatedNodalCurve curve1 = (InterpolatedNodalCurve) df1.getCurve();
    curve1.getXValues();
    curve1.getYValues();

Input
Valuation Date,Symbology,Ticker,Field Name,Value
2018-07-24,GS-INSTRUMENT,USD-FIXING-USD-LIBOR-3M,MarketValue,0.0233488
2018-07-24,GS-INSTRUMENT,USD-FUTURES-USD-LIBOR-3M-F1,SettlementPrice,0.97575
2018-07-24,GS-INSTRUMENT,USD-FUTURES-USD-LIBOR-3M-F2,SettlementPrice,0.97345
2018-07-24,GS-INSTRUMENT,USD-FUTURES-USD-LIBOR-3M-F3,SettlementPrice,0.9719
2018-07-24,GS-INSTRUMENT,USD-FUTURES-USD-LIBOR-3M-F4,SettlementPrice,0.9708
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-2Y,MarketValue,0.028213
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-3Y,MarketValue,0.028911
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-4Y,MarketValue,0.029157
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-5Y,MarketValue,0.02911
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-7Y,MarketValue,0.02929
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-10Y,MarketValue,0.0296
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-12Y,MarketValue,0.02981
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-15Y,MarketValue,0.02992
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-20Y,MarketValue,0.02994
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-25Y,MarketValue,0.02981
2018-07-24,GS-INSTRUMENT,USD-IRS-USD-LIBOR-3M-30Y,MarketValue,0.02966
2018-07-24,GS-INSTRUMENT,USD-DEP-ON,MarketValue,0.019
2018-07-24,GS-INSTRUMENT,USD-DEP-TN,MarketValue,0.0202
2018-07-24,GS-INSTRUMENT,USD-DEP-SN,MarketValue,0.0205
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-1M,MarketValue,0.01923
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-2M,MarketValue,0.01924
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-3M,MarketValue,0.01996
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-6M,MarketValue,0.02116
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-9M,MarketValue,0.02216
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-1Y,MarketValue,0.02308
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-2Y,MarketValue,0.02517
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-3Y,MarketValue,0.02583
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-4Y,MarketValue,0.0261
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-5Y,MarketValue,0.02622
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-6Y,MarketValue,0.02631
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-7Y,MarketValue,0.02636
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-8Y,MarketValue,0.02644
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-9Y,MarketValue,0.02655
2018-07-24,GS-INSTRUMENT,USD-OIS-FED-FUND-10Y,MarketValue,0.02655

Discount
[0.0027397260273972603, 0.010958904109589041, 0.019178082191780823, 0.030136986301369864, 0.0958904109589041, 0.18356164383561643, 0.26301369863013696, 0.34794520547945207, 0.4246575342465753, 0.5095890410958904, 0.5917808219178082, 0.6821917808219178, 0.7589041095890411, 0.8438356164383561, 0.9315068493150684, 1.010958904109589, 2.010958904109589, 3.0136986301369864, 4.019178082191781, 5.016438356164383, 6.013698630136986, 7.016438356164383, 8.016438356164384, 9.016438356164384, 10.021917808219179, 11.01917808219178, 12.01917808219178, 13.01917808219178, 14.01917808219178, 15.027397260273972, 16.024657534246575, 17.02191780821918, 18.02191780821918, 19.024657534246575, 20.024657534246575, 21.03013698630137, 22.027397260273972, 23.027397260273972, 24.027397260273972, 25.027397260273972, 26.027397260273972, 27.03287671232877, 28.03013698630137, 29.03013698630137, 30.03013698630137, 31.03287671232877, 32.038356164383565, 33.035616438356165, 34.032876712328765, 35.035616438356165, 36.035616438356165, 37.035616438356165, 38.04109589041096, 39.038356164383565, 40.038356164383565, 41.038356164383565, 42.038356164383565, 43.04657534246575, 44.04383561643836, 45.04109589041096, 46.04109589041096, 47.04383561643836, 48.04383561643836, 49.04931506849315, 50.04657534246575, 60.057534246575344]
[-7.749838445510934E-15, -6.815940864126042E-15, 2.3162936775369078E-15, -1.0073730387179145E-15, -1.0709960794063545E-15, -1.0734500935929188E-17, -4.237092926264387E-16, -3.2180163338049965E-16, -6.257817049839902E-17, -2.0175430085621443E-16, -2.969487327531747E-16, -3.3975943442002505E-16, -4.788813464286616E-16, -4.648983065283115E-16, -6.871512702582177E-16, -8.712572500169096E-16, -5.667028464837249E-16, -2.758599261635802E-16, 1.1168464735827063E-15, 8.461516015338297E-15, 3.488739430804568E-14, 1.0490912420807029E-13, 2.585391747073715E-13, 5.468793704674556E-13, 1.0295837824192268E-12, 1.7500705530744017E-12, 2.707174323497222E-12, 3.968228181669056E-12, 5.502356010521369E-12, 7.300238428032322E-12, 9.330878391724812E-12, 1.150871548916447E-11, 1.3658212021458509E-11, 1.5637238919636275E-11, 1.707922263359477E-11, 1.782672265953999E-11, 1.7335512906464836E-11, 1.568356336901481E-11, 1.2857823287378182E-11, 8.539750942146783E-12, 4.030551085964654E-12, -3.145451300278635E-12, -8.729317129194534E-12, -1.5710383256853485E-11, -2.442310215416541E-11, -3.6972715224452874E-11, -4.873986852616228E-11, -5.852007107466594E-11, -6.681503957961814E-11, -7.3582460587041E-11, -8.362279936918196E-11, -9.259192933212078E-11, -1.0056850806427471E-10, -1.079958785445789E-10, -1.1334027952254654E-10, -7.869736900217711E-11, -4.617021824724234E-11, -1.6417311689236754E-11, 1.3991559315912054E-11, 4.4241199363096314E-11, 7.444255257187879E-11, 1.0383440016168289E-10, 1.313493021738126E-10, 1.5951226833043218E-10, 1.8166786132745131E-10, -2.160485802346492E-10]

Forward
[0.0027397260273972603, 0.010958904109589041, 0.019178082191780823, 0.030136986301369864, 0.0958904109589041, 0.18356164383561643, 0.26301369863013696, 0.34794520547945207, 0.4246575342465753, 0.5095890410958904, 0.5917808219178082, 0.6821917808219178, 0.7589041095890411, 0.8438356164383561, 0.9315068493150684, 1.010958904109589, 2.010958904109589, 3.0136986301369864, 4.019178082191781, 5.016438356164383, 6.013698630136986, 7.016438356164383, 8.016438356164384, 9.016438356164384, 10.021917808219179, 11.01917808219178, 12.01917808219178, 13.01917808219178, 14.01917808219178, 15.027397260273972, 16.024657534246575, 17.02191780821918, 18.02191780821918, 19.024657534246575, 20.024657534246575, 21.03013698630137, 22.027397260273972, 23.027397260273972, 24.027397260273972, 25.027397260273972, 26.027397260273972, 27.03287671232877, 28.03013698630137, 29.03013698630137, 30.03013698630137, 31.03287671232877, 32.038356164383565, 33.035616438356165, 34.032876712328765, 35.035616438356165, 36.035616438356165, 37.035616438356165, 38.04109589041096, 39.038356164383565, 40.038356164383565, 41.038356164383565, 42.038356164383565, 43.04657534246575, 44.04383561643836, 45.04109589041096, 46.04109589041096, 47.04383561643836, 48.04383561643836, 49.04931506849315, 50.04657534246575, 60.057534246575344]
[-7.749838445510934E-15, -6.815940864126042E-15, 2.3162936775369078E-15, -1.0073730387179145E-15, -1.0709960794063545E-15, -1.0734500935929188E-17, -4.237092926264387E-16, -3.2180163338049965E-16, -6.257817049839902E-17, -2.0175430085621443E-16, -2.969487327531747E-16, -3.3975943442002505E-16, -4.788813464286616E-16, -4.648983065283115E-16, -6.871512702582177E-16, -8.712572500169096E-16, -5.667028464837249E-16, -2.758599261635802E-16, 1.1168464735827063E-15, 8.461516015338297E-15, 3.488739430804568E-14, 1.0490912420807029E-13, 2.585391747073715E-13, 5.468793704674556E-13, 1.0295837824192268E-12, 1.7500705530744017E-12, 2.707174323497222E-12, 3.968228181669056E-12, 5.502356010521369E-12, 7.300238428032322E-12, 9.330878391724812E-12, 1.150871548916447E-11, 1.3658212021458509E-11, 1.5637238919636275E-11, 1.707922263359477E-11, 1.782672265953999E-11, 1.7335512906464836E-11, 1.568356336901481E-11, 1.2857823287378182E-11, 8.539750942146783E-12, 4.030551085964654E-12, -3.145451300278635E-12, -8.729317129194534E-12, -1.5710383256853485E-11, -2.442310215416541E-11, -3.6972715224452874E-11, -4.873986852616228E-11, -5.852007107466594E-11, -6.681503957961814E-11, -7.3582460587041E-11, -8.362279936918196E-11, -9.259192933212078E-11, -1.0056850806427471E-10, -1.079958785445789E-10, -1.1334027952254654E-10, -7.869736900217711E-11, -4.617021824724234E-11, -1.6417311689236754E-11, 1.3991559315912054E-11, 4.4241199363096314E-11, 7.444255257187879E-11, 1.0383440016168289E-10, 1.313493021738126E-10, 1.5951226833043218E-10, 1.8166786132745131E-10, -2.160485802346492E-10]


#2

I think you want CalibrationMeasures.PAR_SPREAD