static CapitalIndexedBondCurveDataSet()
        {
            DoubleArray   timeIssuer = DoubleArray.of(0.2493150684931507, 0.4986301369863014, 0.9397260273972603, 1.9760386256456322, 4.975342465753425, 9.850355565536344);
            DoubleArray   rateIssuer = DoubleArray.of(6.796425420368682E-5, 3.114315257821455E-4, 7.126179601599612E-4, 0.04946562985220742, 0.01404542200399637, 0.022260846895257275);
            CurveMetadata metaIssuer = Curves.zeroRates(ISSUER_CURVE_NAME, ACT_ACT_ISDA);

            ISSUER_CURVE = InterpolatedNodalCurve.of(metaIssuer, timeIssuer, rateIssuer, INTERPOLATOR);
            DoubleArray   timeRepo = DoubleArray.of(0.0027397260273972603, 0.0136986301369863, 0.1095890410958904, 0.18904109589041096, 0.27123287671232876, 0.5178082191780822, 0.7671232876712328, 1.0191780821917809, 2.025218953514485, 3.0246575342465754, 4.021917808219178, 5.019178082191781, 6.019754472640168, 7.024657534246575, 8.024657534246575, 9.024657534246575, 10.019754472640168);
            DoubleArray   rateRepo = DoubleArray.of(0.0016222186172986138, 0.001622209965572477, 7.547616096755544E-4, 9.003947315389025E-4, 9.833562990057003E-4, 9.300905368344651E-4, 0.0010774349342544426, 0.001209299356175582, 0.003243498783874946, 0.007148138535707508, 0.011417234937364525, 0.015484713638367467, 0.01894872475170524, 0.02177798040124286, 0.024146976832379798, 0.02610320121432829, 0.027814843351943817);
            CurveMetadata metaRepo = Curves.zeroRates(REPO_CURVE_NAME, ACT_ACT_ISDA);

            REPO_CURVE = InterpolatedNodalCurve.of(metaRepo, timeRepo, rateRepo, INTERPOLATOR);
            DoubleArray   timeCpi  = DoubleArray.of(10, 22, 34, 46, 58, 70, 82, 94, 106, 118, 142, 178, 238, 298, 358);
            DoubleArray   valueCpi = DoubleArray.of(242.88404516129032, 248.03712245417105, 252.98128118335094, 258.0416354687366, 263.20242369585515, 268.4653023378886, 273.83617795725064, 279.3124974961296, 284.8987721100803, 290.5954768446179, 302.3336095056465, 320.8351638061777, 354.2203489141063, 391.08797576744865, 431.7913437911175);
            CurveMetadata metaCpi  = Curves.prices("cpiCurve");

            CPI_CURVE = InterpolatedNodalCurve.of(metaCpi, timeCpi, valueCpi, INTERPOLATOR);
            DoubleArray   timeRpi  = DoubleArray.of(10, 22, 34, 46, 58, 70, 82, 94, 106, 118, 142);
            DoubleArray   valueRpi = DoubleArray.of(263.49967737807305, 270.2383424030053, 277.34957060924364, 284.992794643866, 293.2359607153748, 302.0252215004671, 311.3482439082226, 321.10465920118116, 331.44556112285863, 342.4913522908549, 366.076015086898);
            CurveMetadata metaRpi  = Curves.prices("rpiCurve");

            RPI_CURVE = InterpolatedNodalCurve.of(metaRpi, timeRpi, valueRpi, INTERPOLATOR);
            DoubleArray   timeCpij  = DoubleArray.of(10, 22, 34, 46, 58, 70, 82, 94, 106, 118, 142, 178, 238, 298, 358);
            DoubleArray   valueCpij = DoubleArray.of(103.3374833371608, 104.2306743501241, 104.3107880426369, 104.27037709028433, 104.19961127790909, 104.062704760821, 103.89860712110973, 103.73391283682416, 103.78374038315715, 103.83356515845553, 104.18698970060639, 104.72128789312038, 106.46204440686186, 108.231124353441, 110.03241679315009);
            CurveMetadata metaCpij  = Curves.prices("cpijCurve");

            CPIJ_CURVE = InterpolatedNodalCurve.of(metaCpij, timeCpij, valueCpij, INTERPOLATOR);
        }
コード例 #2
0
        static DiscountingKnownAmountPaymentPeriodPricerTest()
        {
            DoubleArray time_gbp = DoubleArray.of(0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0);
            DoubleArray rate_gbp = DoubleArray.of(0.0160, 0.0135, 0.0160, 0.0185, 0.0185, 0.0195, 0.0200, 0.0210);

            DISCOUNT_CURVE_GBP = InterpolatedNodalCurve.of(Curves.zeroRates("GBP-Discount", ACT_ACT_ISDA), time_gbp, rate_gbp, INTERPOLATOR);
        }
コード例 #3
0
        private ImmutableRatesProvider createProvider(double rateStart, double rateStartInterp, double rateEnd, double rateEndInterp)
        {
            LocalDateDoubleTimeSeries timeSeries = LocalDateDoubleTimeSeries.of(VAL_DATE.with(lastDayOfMonth()), 300);
            InterpolatedNodalCurve    curve      = InterpolatedNodalCurve.of(Curves.prices("GB-RPIX"), DoubleArray.of(4, 5, 16, 17), DoubleArray.of(rateStart, rateStartInterp, rateEnd, rateEndInterp), INTERPOLATOR);

            return(ImmutableRatesProvider.builder(VAL_DATE).priceIndexCurve(GB_RPIX, curve).timeSeries(GB_RPIX, timeSeries).build());
        }
        public virtual void test_createSabrParameterMetadata()
        {
            SabrIborCapletFloorletVolatilityBootstrapDefinition @base = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, LINEAR, FLAT, FLAT, SabrVolatilityFormula.hagan());
            ImmutableList <CurveMetadata> expected = ImmutableList.of(Curves.sabrParameterByExpiry(NAME.Name + "-Alpha", ACT_ACT_ISDA, SABR_ALPHA), Curves.sabrParameterByExpiry(NAME.Name + "-Beta", ACT_ACT_ISDA, SABR_BETA), Curves.sabrParameterByExpiry(NAME.Name + "-Rho", ACT_ACT_ISDA, SABR_RHO), Curves.sabrParameterByExpiry(NAME.Name + "-Nu", ACT_ACT_ISDA, SABR_NU));
            ImmutableList <CurveMetadata> computed = @base.createSabrParameterMetadata();

            assertEquals(computed, expected);
        }
コード例 #5
0
        static DiscountingTermDepositProductPricerTest()
        {
            CurveInterpolator      interp   = CurveInterpolators.DOUBLE_QUADRATIC;
            DoubleArray            time_eur = DoubleArray.of(0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0);
            DoubleArray            rate_eur = DoubleArray.of(0.0160, 0.0135, 0.0160, 0.0185, 0.0185, 0.0195, 0.0200, 0.0210);
            InterpolatedNodalCurve dscCurve = InterpolatedNodalCurve.of(Curves.zeroRates("EUR-Discount", ACT_360), time_eur, rate_eur, interp);

            IMM_PROV = ImmutableRatesProvider.builder(VAL_DATE).discountCurve(EUR, dscCurve).build();
        }
コード例 #6
0
        //-------------------------------------------------------------------------
        // creates a simple provider
        private SimpleRatesProvider createProvider(LocalDate valDate)
        {
            Curve               curve = ConstantCurve.of(Curves.discountFactors("Test", DAY_COUNT), DISCOUNT_FACTOR);
            DiscountFactors     df    = SimpleDiscountFactors.of(GBP, valDate, curve);
            SimpleRatesProvider prov  = new SimpleRatesProvider(valDate);

            prov.DayCount        = DAY_COUNT;
            prov.DiscountFactors = df;
            return(prov);
        }
        static DiscountingIborFixingDepositTradePricerTest()
        {
            CurveInterpolator      interp     = CurveInterpolators.DOUBLE_QUADRATIC;
            DoubleArray            time_eur   = DoubleArray.of(0.0, 0.1, 0.25, 0.5, 0.75, 1.0, 2.0);
            DoubleArray            rate_eur   = DoubleArray.of(0.0160, 0.0165, 0.0155, 0.0155, 0.0155, 0.0150, 0.014);
            InterpolatedNodalCurve dscCurve   = InterpolatedNodalCurve.of(Curves.zeroRates("EUR-Discount", ACT_ACT_ISDA), time_eur, rate_eur, interp);
            DoubleArray            time_index = DoubleArray.of(0.0, 0.25, 0.5, 1.0);
            DoubleArray            rate_index = DoubleArray.of(0.0180, 0.0180, 0.0175, 0.0165);
            InterpolatedNodalCurve indexCurve = InterpolatedNodalCurve.of(Curves.zeroRates("EUR-EURIBOR6M", ACT_ACT_ISDA), time_index, rate_index, interp);

            IMM_PROV = ImmutableRatesProvider.builder(VAL_DATE).discountCurve(EUR, dscCurve).iborIndexCurve(EUR_EURIBOR_6M, indexCurve).build();
        }
        public virtual void test_ofFixedBeta_shift()
        {
            SabrIborCapletFloorletVolatilityBootstrapDefinition test = SabrIborCapletFloorletVolatilityBootstrapDefinition.ofFixedBeta(NAME, USD_LIBOR_3M, ACT_ACT_ISDA, 0.5, 0.01, LINEAR, FLAT, FLAT, SabrVolatilityFormula.hagan());

            assertEquals(test.DayCount, ACT_ACT_ISDA);
            assertEquals(test.Index, USD_LIBOR_3M);
            assertEquals(test.Interpolator, LINEAR);
            assertEquals(test.ExtrapolatorLeft, FLAT);
            assertEquals(test.ExtrapolatorRight, FLAT);
            assertEquals(test.Name, NAME);
            assertEquals(test.BetaCurve.get(), ConstantCurve.of(Curves.sabrParameterByExpiry(NAME.Name + "-Beta", ACT_ACT_ISDA, SABR_BETA), 0.5));
            assertFalse(test.RhoCurve.Present);
            assertEquals(test.SabrVolatilityFormula, SabrVolatilityFormula.hagan());
            assertEquals(test.ShiftCurve, ConstantCurve.of("Shift curve", 0.01));
        }
コード例 #9
0
        static ImmutableRatesProviderSimpleData()
        {
            CurveInterpolator      interp     = CurveInterpolators.DOUBLE_QUADRATIC;
            DoubleArray            time_eur   = DoubleArray.of(0.0, 0.1, 0.25, 0.5, 0.75, 1.0, 2.0);
            DoubleArray            rate_eur   = DoubleArray.of(0.0160, 0.0165, 0.0155, 0.0155, 0.0155, 0.0150, 0.0140);
            InterpolatedNodalCurve dscCurve   = InterpolatedNodalCurve.of(Curves.zeroRates("EUR-Discount", ACT_365F), time_eur, rate_eur, interp);
            DoubleArray            time_index = DoubleArray.of(0.0, 0.25, 0.5, 1.0);
            DoubleArray            rate_index = DoubleArray.of(0.0180, 0.0180, 0.0175, 0.0165);
            InterpolatedNodalCurve indexCurve = InterpolatedNodalCurve.of(Curves.zeroRates("EUR-EURIBOR6M", ACT_365F), time_index, rate_index, interp);

            IMM_PROV_EUR_NOFIX = ImmutableRatesProvider.builder(VAL_DATE).discountCurve(EUR, dscCurve).iborIndexCurve(EUR_EURIBOR_6M, indexCurve).build();
            LocalDateDoubleTimeSeries tsE6 = LocalDateDoubleTimeSeries.builder().put(VAL_DATE, 0.012345).build();

            IMM_PROV_EUR_FIX = ImmutableRatesProvider.builder(VAL_DATE).discountCurve(EUR, dscCurve).iborIndexCurve(EUR_EURIBOR_6M, indexCurve, tsE6).build();
        }
        public virtual void test_builder()
        {
            Curve betaCurve = ConstantCurve.of(Curves.sabrParameterByExpiry(NAME.Name + "-Beta", ACT_ACT_ISDA, SABR_BETA), 0.65);
            SabrIborCapletFloorletVolatilityBootstrapDefinition test = SabrIborCapletFloorletVolatilityBootstrapDefinition.builder().index(USD_LIBOR_3M).name(NAME).interpolator(LINEAR).extrapolatorLeft(FLAT).extrapolatorRight(CurveExtrapolators.LINEAR).dayCount(ACT_ACT_ISDA).sabrVolatilityFormula(SabrVolatilityFormula.hagan()).betaCurve(betaCurve).build();

            assertEquals(test.DayCount, ACT_ACT_ISDA);
            assertEquals(test.Index, USD_LIBOR_3M);
            assertEquals(test.Interpolator, LINEAR);
            assertEquals(test.ExtrapolatorLeft, FLAT);
            assertEquals(test.ExtrapolatorRight, CurveExtrapolators.LINEAR);
            assertEquals(test.Name, NAME);
            assertEquals(test.BetaCurve.get(), betaCurve);
            assertFalse(test.RhoCurve.Present);
            assertEquals(test.SabrVolatilityFormula, SabrVolatilityFormula.hagan());
            assertEquals(test.ShiftCurve, ConstantCurve.of("Zero shift", 0d));
        }
コード例 #11
0
        static CreditDataSet()
        {
            ImmutableList.Builder <StandardId> builder = ImmutableList.builder();
            for (int i = 0; i < 97; ++i)
            {
                builder.add(StandardId.of("OG", i.ToString()));
            }
            LEGAL_ENTITIES = builder.build();
            double flatRate = 0.05;
            double t        = 20.0;
            IsdaCreditDiscountFactors yieldCurve = IsdaCreditDiscountFactors.of(USD, VALUATION_DATE, CurveName.of("discount"), DoubleArray.of(t), DoubleArray.of(flatRate), ACT_365F);

            DISCOUNT_CURVE = yieldCurve.Curve;
            RecoveryRates recoveryRate = ConstantRecoveryRates.of(LEGAL_ENTITY, VALUATION_DATE, RECOVERY_RATE);
            // create the curve nodes and input market quotes
            ImmutableMarketDataBuilder marketQuoteBuilder = ImmutableMarketData.builder(VALUATION_DATE);

            ImmutableList.Builder <CdsIsdaCreditCurveNode>         nodesBuilder            = ImmutableList.builder();
            ImmutableList.Builder <ResolvedTradeParameterMetadata> cdsMetadataBuilder      = ImmutableList.builder();
            ImmutableList.Builder <ResolvedTradeParameterMetadata> cdsIndexMetadataBuilder = ImmutableList.builder();
            for (int i = 0; i < NUM_MARKET_CDS; i++)
            {
                QuoteId quoteId             = QuoteId.of(StandardId.of("OG", PAR_SPD_DATES[i].ToString()));
                CdsIsdaCreditCurveNode node = CdsIsdaCreditCurveNode.ofParSpread(DatesCdsTemplate.of(VALUATION_DATE, PAR_SPD_DATES[i], CDS_CONV), quoteId, LEGAL_ENTITY);
                MARKET_CDS[i]       = CdsTrade.builder().product(Cds.of(BUY, LEGAL_ENTITY, USD, NOTIONAL, VALUATION_DATE, PAR_SPD_DATES[i], P3M, SAT_SUN, PAR_SPREADS[i] * ONE_BP)).info(TradeInfo.of(VALUATION_DATE)).build().resolve(REF_DATA);
                MARKET_CDS_INDEX[i] = CdsIndexTrade.builder().product(CdsIndex.of(BuySell.BUY, INDEX_ID, LEGAL_ENTITIES, USD, NOTIONAL, VALUATION_DATE, PAR_SPD_DATES[i], P3M, SAT_SUN, PAR_SPREADS[i] * ONE_BP)).info(TradeInfo.of(VALUATION_DATE)).build().resolve(REF_DATA);
                marketQuoteBuilder.addValue(quoteId, PAR_SPREADS[i] * ONE_BP);
                nodesBuilder.add(node);
                cdsMetadataBuilder.add(ResolvedTradeParameterMetadata.of(MARKET_CDS[i], MARKET_CDS[i].Product.ProtectionEndDate.ToString()));
                cdsIndexMetadataBuilder.add(ResolvedTradeParameterMetadata.of(MARKET_CDS_INDEX[i], MARKET_CDS_INDEX[i].Product.ProtectionEndDate.ToString()));
            }
            ImmutableMarketData marketQuotes             = marketQuoteBuilder.build();
            ImmutableList <CdsIsdaCreditCurveNode> nodes = nodesBuilder.build();

            CDS_METADATA       = cdsMetadataBuilder.build();
            CDS_INDEX_METADATA = cdsIndexMetadataBuilder.build();
            ImmutableCreditRatesProvider rates      = ImmutableCreditRatesProvider.builder().valuationDate(VALUATION_DATE).recoveryRateCurves(ImmutableMap.of(LEGAL_ENTITY, recoveryRate)).discountCurves(ImmutableMap.of(USD, yieldCurve)).build();
            IsdaCreditCurveDefinition    definition = IsdaCreditCurveDefinition.of(CREDIT_CURVE_NAME, USD, VALUATION_DATE, ACT_365F, nodes, true, true);
            // calibrate
            LegalEntitySurvivalProbabilities calibrated = BUILDER.calibrate(definition, marketQuotes, rates, REF_DATA);
            NodalCurve underlyingCurve = ((IsdaCreditDiscountFactors)calibrated.SurvivalProbabilities).Curve;

            CDS_CREDIT_CURVE    = underlyingCurve;
            INDEX_CREDIT_CURVE  = underlyingCurve.withMetadata(underlyingCurve.Metadata.withInfo(CurveInfoType.CDS_INDEX_FACTOR, INDEX_FACTOR).withParameterMetadata(CDS_INDEX_METADATA));    // replace parameter metadata
            CDS_RECOVERY_RATE   = ConstantCurve.of(Curves.recoveryRates("CDS recovery rate", ACT_365F), RECOVERY_RATE);
            INDEX_RECOVERY_RATE = ConstantCurve.of(Curves.recoveryRates("Index recovery rate", ACT_365F), RECOVERY_RATE);
        }
        public virtual void test_bondDiscountingProvider()
        {
            ImmutableMap <SecurityId, RepoGroup>               repoSecurityGroups = ImmutableMap.of(SEC_A1, GROUP_REPO_X);
            ImmutableMap <LegalEntityId, RepoGroup>            repoGroups         = ImmutableMap.of(ISSUER_B, GROUP_REPO_X);
            ImmutableMap <Pair <RepoGroup, Currency>, CurveId> repoCurves         = ImmutableMap.of(Pair.of(GROUP_REPO_X, USD), CURVE_ID_USD1);

            ImmutableMap <LegalEntityId, LegalEntityGroup>            issuerGroups = ImmutableMap.of(ISSUER_A, GROUP_ISSUER_M);
            ImmutableMap <Pair <LegalEntityGroup, Currency>, CurveId> issuerCurves = ImmutableMap.of(Pair.of(GROUP_ISSUER_M, USD), CURVE_ID_USD3);

            LegalEntityDiscountingMarketDataLookup test = LegalEntityDiscountingMarketDataLookup.of(repoSecurityGroups, repoGroups, repoCurves, issuerGroups, issuerCurves);
            LocalDate  valDate     = date(2015, 6, 30);
            Curve      repoCurve   = ConstantCurve.of(Curves.discountFactors(CURVE_ID_USD1.CurveName, ACT_360), 1d);
            Curve      issuerCurve = ConstantCurve.of(Curves.discountFactors(CURVE_ID_USD3.CurveName, ACT_360), 2d);
            MarketData md          = ImmutableMarketData.of(valDate, ImmutableMap.of(CURVE_ID_USD1, repoCurve, CURVE_ID_USD3, issuerCurve));
            LegalEntityDiscountingProvider provider = test.discountingProvider(md);

            assertEquals(provider.ValuationDate, valDate);
            assertEquals(provider.findData(CURVE_ID_USD1.CurveName), repoCurve);
            assertEquals(provider.findData(CURVE_ID_USD3.CurveName), issuerCurve);
            assertEquals(provider.findData(CurveName.of("Rubbish")), null);
            // check repo
            RepoCurveDiscountFactors rcdf = provider.repoCurveDiscountFactors(SEC_A1, ISSUER_A, USD);
            SimpleDiscountFactors    rdf  = (SimpleDiscountFactors)rcdf.DiscountFactors;

            assertEquals(rdf.Curve.Name, repoCurve.Name);
            assertEquals(rcdf, provider.repoCurveDiscountFactors(SEC_B1, ISSUER_B, USD));
            assertThrowsIllegalArg(() => provider.repoCurveDiscountFactors(SEC_A1, ISSUER_A, GBP));
            assertThrowsIllegalArg(() => provider.repoCurveDiscountFactors(SEC_C1, ISSUER_C, USD));
            // check issuer
            IssuerCurveDiscountFactors icdf = provider.issuerCurveDiscountFactors(ISSUER_A, USD);
            SimpleDiscountFactors      idf  = (SimpleDiscountFactors)icdf.DiscountFactors;

            assertEquals(idf.Curve.Name, issuerCurve.Name);
            assertThrowsIllegalArg(() => provider.issuerCurveDiscountFactors(ISSUER_A, GBP));
            assertThrowsIllegalArg(() => provider.issuerCurveDiscountFactors(ISSUER_C, USD));
        }