public virtual void test_before() { LocalDate startDate = date(2018, 2, 1); LocalDate endDate = date(2018, 2, 28); OvernightAveragedDailyRateComputation cmp = OvernightAveragedDailyRateComputation.of(USD_FED_FUND, startDate, endDate, REF_DATA); ImmutableRatesProvider rates = getRatesProvider(date(2018, 1, 24)); double computedRate = FUNCTION.rate(cmp, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, rates); PointSensitivityBuilder sensiComputed = FUNCTION.rateSensitivity(cmp, startDate, endDate, rates); ExplainMapBuilder builder = ExplainMap.builder(); double explainRate = FUNCTION.explainRate(cmp, startDate, endDate, rates, builder); double expectedRate = 0d; PointSensitivityBuilder sensiExpected = PointSensitivityBuilder.none(); LocalDate date = startDate; while (!date.isAfter(endDate)) { OvernightIndexObservation obs = OvernightIndexObservation.of(USD_FED_FUND, date, REF_DATA); double rate = rates.overnightIndexRates(USD_FED_FUND).rate(obs); PointSensitivityBuilder rateSensi = rates.overnightIndexRates(USD_FED_FUND).ratePointSensitivity(obs); LocalDate nextDate = cmp.FixingCalendar.next(date); long days = DAYS.between(date, nextDate); expectedRate += rate * days; sensiExpected = sensiComputed.combinedWith(rateSensi.multipliedBy(days)); date = nextDate; } double nDays = 28d; expectedRate /= nDays; sensiExpected = sensiExpected.multipliedBy(1d / nDays); assertEquals(computedRate, expectedRate, TOL); assertTrue(sensiComputed.build().equalWithTolerance(sensiExpected.build(), TOL)); assertEquals(explainRate, computedRate, TOL); assertEquals(builder.build().get(ExplainKey.COMBINED_RATE).Value, expectedRate, TOL); }
//------------------------------------------------------------------------- public virtual void test_rate() { ImmutableRatesProvider prov = createProvider(RATE_START, RATE_END); InflationMonthlyRateComputation ro = InflationMonthlyRateComputation.of(GB_RPIX, REFERENCE_START_MONTH, REFERENCE_END_MONTH); ForwardInflationMonthlyRateComputationFn obsFn = ForwardInflationMonthlyRateComputationFn.DEFAULT; double rateExpected = RATE_END / RATE_START - 1.0; assertEquals(obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, prov), rateExpected, EPS); // explain ExplainMapBuilder builder = ExplainMap.builder(); assertEquals(obsFn.explainRate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, prov, builder), rateExpected, EPS); ExplainMap built = builder.build(); assertEquals(built.get(ExplainKey.OBSERVATIONS).Present, true); assertEquals(built.get(ExplainKey.OBSERVATIONS).get().size(), 2); ExplainMap explain0 = built.get(ExplainKey.OBSERVATIONS).get().get(0); assertEquals(explain0.get(ExplainKey.FIXING_DATE), REFERENCE_START_MONTH.atEndOfMonth()); assertEquals(explain0.get(ExplainKey.INDEX), GB_RPIX); assertEquals(explain0.get(ExplainKey.INDEX_VALUE), RATE_START); ExplainMap explain1 = built.get(ExplainKey.OBSERVATIONS).get().get(1); assertEquals(explain1.get(ExplainKey.FIXING_DATE), REFERENCE_END_MONTH.atEndOfMonth()); assertEquals(explain1.get(ExplainKey.INDEX), GB_RPIX); assertEquals(explain1.get(ExplainKey.INDEX_VALUE), RATE_END); assertEquals(built.get(ExplainKey.COMBINED_RATE).Value.doubleValue(), rateExpected, EPS); }
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_rateSensitivity() { ImmutableRatesProvider prov = createProvider(RATE_START, RATE_START_INTERP, RATE_END, RATE_END_INTERP); ImmutableRatesProvider provSrtUp = createProvider(RATE_START + EPS_FD, RATE_START_INTERP, RATE_END, RATE_END_INTERP); ImmutableRatesProvider provSrtDw = createProvider(RATE_START - EPS_FD, RATE_START_INTERP, RATE_END, RATE_END_INTERP); ImmutableRatesProvider provSrtIntUp = createProvider(RATE_START, RATE_START_INTERP + EPS_FD, RATE_END, RATE_END_INTERP); ImmutableRatesProvider provSrtIntDw = createProvider(RATE_START, RATE_START_INTERP - EPS_FD, RATE_END, RATE_END_INTERP); ImmutableRatesProvider provEndUp = createProvider(RATE_START, RATE_START_INTERP, RATE_END + EPS_FD, RATE_END_INTERP); ImmutableRatesProvider provEndDw = createProvider(RATE_START, RATE_START_INTERP, RATE_END - EPS_FD, RATE_END_INTERP); ImmutableRatesProvider provEndIntUp = createProvider(RATE_START, RATE_START_INTERP, RATE_END, RATE_END_INTERP + EPS_FD); ImmutableRatesProvider provEndIntDw = createProvider(RATE_START, RATE_START_INTERP, RATE_END, RATE_END_INTERP - EPS_FD); InflationInterpolatedRateComputation ro = InflationInterpolatedRateComputation.of(GB_RPIX, REF_START_MONTH, REF_END_MONTH, WEIGHT); ForwardInflationInterpolatedRateComputationFn obsFn = ForwardInflationInterpolatedRateComputationFn.DEFAULT; double rateSrtUp = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provSrtUp); double rateSrtDw = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provSrtDw); double rateSrtIntUp = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provSrtIntUp); double rateSrtIntDw = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provSrtIntDw); double rateEndUp = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provEndUp); double rateEndDw = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provEndDw); double rateEndIntUp = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provEndIntUp); double rateEndIntDw = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provEndIntDw); PointSensitivityBuilder sensSrt = InflationRateSensitivity.of(PriceIndexObservation.of(GB_RPIX, REF_START_MONTH), 0.5 * (rateSrtUp - rateSrtDw) / EPS_FD); PointSensitivityBuilder sensSrtInt = InflationRateSensitivity.of(PriceIndexObservation.of(GB_RPIX, REF_START_MONTH_INTERP), 0.5 * (rateSrtIntUp - rateSrtIntDw) / EPS_FD); PointSensitivityBuilder sensEnd = InflationRateSensitivity.of(PriceIndexObservation.of(GB_RPIX, REF_END_MONTH), 0.5 * (rateEndUp - rateEndDw) / EPS_FD); PointSensitivityBuilder sensEndInt = InflationRateSensitivity.of(PriceIndexObservation.of(GB_RPIX, REF_END_MONTH_INTERP), 0.5 * (rateEndIntUp - rateEndIntDw) / EPS_FD); PointSensitivityBuilder sensiExpected = sensSrt.combinedWith(sensSrtInt).combinedWith(sensEnd).combinedWith(sensEndInt); PointSensitivityBuilder sensiComputed = obsFn.rateSensitivity(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, prov); assertTrue(sensiComputed.build().normalized().equalWithTolerance(sensiExpected.build().normalized(), EPS_FD)); }
public virtual void test_currentCash_onPayment() { ImmutableRatesProvider prov = ImmutableRatesProvider.builder(PERIOD.PaymentDate).discountCurve(GBP, DISCOUNT_CURVE_GBP).build(); double computed = PRICER.currentCash(PERIOD, prov); assertEquals(computed, AMOUNT_1000); }
public virtual void test_currentCash_zero() { ImmutableRatesProvider prov = ImmutableRatesProvider.builder(VAL_DATE).discountCurve(GBP, DISCOUNT_CURVE_GBP).build(); double computed = PRICER.currentCash(PERIOD, prov); assertEquals(computed, 0d); }
//------------------------------------------------------------------------- public virtual void test_rate() { ImmutableRatesProvider prov = createProvider(RATE_END, RATE_END_INTERP); InflationEndInterpolatedRateComputation ro = InflationEndInterpolatedRateComputation.of(GB_RPIX, START_INDEX_VALUE, REF_END_MONTH, WEIGHT); ForwardInflationEndInterpolatedRateComputationFn obsFn = ForwardInflationEndInterpolatedRateComputationFn.DEFAULT; // rate double rateExpected = (WEIGHT * RATE_END + (1.0 - WEIGHT) * RATE_END_INTERP) / START_INDEX_VALUE - 1; assertEquals(obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, prov), rateExpected, EPS); // explain ExplainMapBuilder builder = ExplainMap.builder(); assertEquals(obsFn.explainRate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, prov, builder), rateExpected, EPS); ExplainMap built = builder.build(); assertEquals(built.get(ExplainKey.OBSERVATIONS).Present, true); assertEquals(built.get(ExplainKey.OBSERVATIONS).get().size(), 2); ExplainMap explain0 = built.get(ExplainKey.OBSERVATIONS).get().get(0); assertEquals(explain0.get(ExplainKey.FIXING_DATE), REF_END_MONTH.atEndOfMonth()); assertEquals(explain0.get(ExplainKey.INDEX), GB_RPIX); assertEquals(explain0.get(ExplainKey.INDEX_VALUE), RATE_END); assertEquals(explain0.get(ExplainKey.WEIGHT), WEIGHT); ExplainMap explain1 = built.get(ExplainKey.OBSERVATIONS).get().get(1); assertEquals(explain1.get(ExplainKey.FIXING_DATE), REF_END_MONTH_INTERP.atEndOfMonth()); assertEquals(explain1.get(ExplainKey.INDEX), GB_RPIX); assertEquals(explain1.get(ExplainKey.INDEX_VALUE), RATE_END_INTERP); assertEquals(explain1.get(ExplainKey.WEIGHT), (1d - WEIGHT)); assertEquals(built.get(ExplainKey.COMBINED_RATE).Value.doubleValue(), rateExpected, EPS); }
//------------------------------------------------------------------------- public virtual void test_currencyExposure() { ImmutableRatesProvider prov = ImmutableRatesProvider.builder(VAL_DATE).discountCurve(GBP, DISCOUNT_CURVE_GBP).build(); MultiCurrencyAmount computed = PRICER.currencyExposure(PERIOD, prov); PointSensitivities point = PRICER.presentValueSensitivity(PERIOD, prov).build(); MultiCurrencyAmount expected = prov.currencyExposure(point).plus(CurrencyAmount.of(GBP, PRICER.presentValue(PERIOD, prov))); assertEquals(computed, expected); }
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(); }
public virtual void test_currentCash_onPaymentDate() { LocalDate paymentDate = RFRA.PaymentDate; double publishedRate = 0.025; ResolvedFraTrade trade = FraTrade.builder().info(TradeInfo.builder().tradeDate(paymentDate).build()).product(FRA).build().resolve(REF_DATA); ImmutableRatesProvider ratesProvider = RatesProviderDataSets.multiGbp(paymentDate).toBuilder().timeSeries(GBP_LIBOR_3M, LocalDateDoubleTimeSeries.of(paymentDate, publishedRate)).build(); assertEquals(PRICER_TRADE.currentCash(trade, ratesProvider), CurrencyAmount.of(FRA.Currency, (publishedRate - FRA.FixedRate) / (1d + publishedRate * RFRA.YearFraction) * RFRA.YearFraction * RFRA.Notional)); }
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_after_regression() { LocalDate startDate = date(2018, 3, 1); LocalDate endDate = date(2018, 3, 31); OvernightAveragedDailyRateComputation cmp = OvernightAveragedDailyRateComputation.of(USD_FED_FUND, startDate, endDate, REF_DATA); ImmutableRatesProvider rates = getRatesProvider(date(2018, 4, 28)); double computed = FUNCTION.rate(cmp, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, rates); double expected = 0.0150612903225806; assertEquals(computed, expected, TOL); assertEquals(FUNCTION.rateSensitivity(cmp, startDate, endDate, rates), PointSensitivityBuilder.none()); }
//------------------------------------------------------------------------- public virtual void test_rateSensitivity() { ImmutableRatesProvider prov = createProvider(RATE_END); ImmutableRatesProvider provEndUp = createProvider(RATE_END + EPS_FD); ImmutableRatesProvider provEndDw = createProvider(RATE_END - EPS_FD); InflationEndMonthRateComputation ro = InflationEndMonthRateComputation.of(GB_RPIX, START_INDEX_VALUE, REFERENCE_END_MONTH); ForwardInflationEndMonthRateComputationFn obsFn = ForwardInflationEndMonthRateComputationFn.DEFAULT; double rateEndUp = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provEndUp); double rateEndDw = obsFn.rate(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, provEndDw); PointSensitivityBuilder sensiExpected = InflationRateSensitivity.of(PriceIndexObservation.of(GB_RPIX, REFERENCE_END_MONTH), 0.5 * (rateEndUp - rateEndDw) / EPS_FD); PointSensitivityBuilder sensiComputed = obsFn.rateSensitivity(ro, DUMMY_ACCRUAL_START_DATE, DUMMY_ACCRUAL_END_DATE, prov); assertTrue(sensiComputed.build().normalized().equalWithTolerance(sensiExpected.build().normalized(), EPS_FD)); }
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 semiParallelGammaValue() { ImmutableRatesProvider provider = SINGLE; Currency curveCurrency = SINGLE_CURRENCY; DoubleArray y = USD_SINGLE_CURVE.YValues; int nbNode = y.size(); DoubleArray gammaExpected = DoubleArray.of(nbNode, i => { //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java: //ORIGINAL LINE: double[][][] yBumped = new double[2][2][nbNode]; double[][][] yBumped = RectangularArrays.ReturnRectangularDoubleArray(2, 2, nbNode); //JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java: //ORIGINAL LINE: double[][] pv = new double[2][2]; double[][] pv = RectangularArrays.ReturnRectangularDoubleArray(2, 2); for (int pmi = 0; pmi < 2; pmi++) { for (int pmP = 0; pmP < 2; pmP++) { yBumped[pmi][pmP] = y.toArray(); yBumped[pmi][pmP][i] += (pmi == 0 ? 1.0 : -1.0) * FD_SHIFT; for (int j = 0; j < nbNode; j++) { yBumped[pmi][pmP][j] += (pmP == 0 ? 1.0 : -1.0) * FD_SHIFT; } Curve curveBumped = USD_SINGLE_CURVE.withYValues(DoubleArray.copyOf(yBumped[pmi][pmP])); ImmutableRatesProvider providerBumped = provider.toBuilder().discountCurves(provider.DiscountCurves.Keys.collect(toImmutableMap(Function.identity(), k => curveBumped))).indexCurves(provider.IndexCurves.Keys.collect(toImmutableMap(Function.identity(), k => curveBumped))).build(); pv[pmi][pmP] = PRICER_SWAP.presentValue(SWAP, providerBumped).getAmount(USD).Amount; } } return((pv[1][1] - pv[1][0] - pv[0][1] + pv[0][0]) / (4 * FD_SHIFT * FD_SHIFT)); }); CurrencyParameterSensitivity sensitivityComputed = GAMMA_CAL.calculateSemiParallelGamma(USD_SINGLE_CURVE, curveCurrency, c => buildSensitivities(c, provider)); assertEquals(sensitivityComputed.MarketDataName, USD_SINGLE_CURVE.Name); DoubleArray gammaComputed = sensitivityComputed.Sensitivity; assertTrue(gammaComputed.equalWithTolerance(gammaExpected, TOLERANCE_GAMMA)); }
// Checks that different finite difference types and shifts give similar results. public virtual void semiParallelGammaCoherency() { ImmutableRatesProvider provider = SINGLE; Curve curve = Iterables.getOnlyElement(provider.DiscountCurves.values()); Currency curveCurrency = SINGLE_CURRENCY; double toleranceCoherency = 1.0E+5; CurveGammaCalculator calculatorForward5 = CurveGammaCalculator.ofForwardDifference(FD_SHIFT); CurveGammaCalculator calculatorBackward5 = CurveGammaCalculator.ofBackwardDifference(FD_SHIFT); CurveGammaCalculator calculatorCentral4 = CurveGammaCalculator.ofCentralDifference(1.0E-4); DoubleArray gammaCentral5 = GAMMA_CAL.calculateSemiParallelGamma(curve, curveCurrency, c => buildSensitivities(c, provider)).Sensitivity; DoubleArray gammaForward5 = calculatorForward5.calculateSemiParallelGamma(curve, curveCurrency, c => buildSensitivities(c, provider)).Sensitivity; assertTrue(gammaForward5.equalWithTolerance(gammaCentral5, toleranceCoherency)); DoubleArray gammaBackward5 = calculatorBackward5.calculateSemiParallelGamma(curve, curveCurrency, c => buildSensitivities(c, provider)).Sensitivity; assertTrue(gammaForward5.equalWithTolerance(gammaBackward5, toleranceCoherency)); DoubleArray gammaCentral4 = calculatorCentral4.calculateSemiParallelGamma(curve, curveCurrency, c => buildSensitivities(c, provider)).Sensitivity; assertTrue(gammaForward5.equalWithTolerance(gammaCentral4, toleranceCoherency)); }
//------------------------------------------------------------------------- /// <summary> /// Provides rates for USD Discounting, Overnight FedFund and Libor 1/3/6 month. /// </summary> /// <returns> the rates provider </returns> public static ImmutableRatesProvider providerUsdDscOnL1L3L6() { // data from group 1 return(ImmutableRatesProvider.builder(VAL_DATE_2014_01_22).fxRateProvider(FX_MATRIX).discountCurve(USD, GROUP1_USD_DSC).overnightIndexCurve(USD_FED_FUND, GROUP1_USD_ON).iborIndexCurve(USD_LIBOR_1M, GROUP1_USD_L1M).iborIndexCurve(USD_LIBOR_3M, GROUP1_USD_L3M).iborIndexCurve(USD_LIBOR_6M, GROUP1_USD_L6M).build()); }
/// <summary> /// Create a yield curve bundle with three curves. /// One called "Discounting EUR" with a constant rate of 2.50%, one called "Discounting USD" /// with a constant rate of 1.00% and one called "Discounting GBP" with a constant rate of 2.00%; /// "Discounting KRW" with a constant rate of 3.21%; /// </summary> /// <returns> the provider </returns> public static RatesProvider createProvider() { return(ImmutableRatesProvider.builder(VAL_DATE_2014_01_22).discountCurve(EUR, EUR_DSC).discountCurve(USD, USD_DSC).discountCurve(GBP, GBP_DSC).discountCurve(KRW, KRW_DSC).fxRateProvider(FX_MATRIX).build()); }
/// <summary> /// Creates rates provider with specified valuation date. /// </summary> /// <param name="valuationDate"> the valuation date </param> /// <returns> the rates provider </returns> public static ImmutableRatesProvider createRatesProvider(LocalDate valuationDate) { return(ImmutableRatesProvider.builder(valuationDate).discountCurves(ImmutableMap.of(EUR, DSC_CURVE)).indexCurves(ImmutableMap.of(EUR_EURIBOR_3M, FWD3_CURVE, EUR_EURIBOR_6M, FWD6_CURVE)).fxRateProvider(FxMatrix.empty()).build()); }
/// <summary> /// Create a yield curve bundle with three curves. /// One called "Discounting EUR" with a constant rate of 2.50%, one called "Discounting USD" /// with a constant rate of 1.00% and one called "Discounting GBP" with a constant rate of 2.00%; /// "Discounting KRW" with a constant rate of 3.21%; /// </summary> /// <param name="valuationDate"> the valuation date </param> /// <param name="fxIndex"> the FX index </param> /// <param name="spotRate"> the spot rate for the index </param> /// <returns> the provider </returns> public static RatesProvider createProvider(LocalDate valuationDate, FxIndex fxIndex, double spotRate) { return(ImmutableRatesProvider.builder(valuationDate).discountCurve(EUR, EUR_DSC).discountCurve(USD, USD_DSC).discountCurve(GBP, GBP_DSC).discountCurve(KRW, KRW_DSC).fxRateProvider(FX_MATRIX).timeSeries(fxIndex, LocalDateDoubleTimeSeries.of(fxIndex.calculateFixingFromMaturity(valuationDate, REF_DATA), spotRate)).build()); }
/// <summary> /// Creates rates provider for EUR, USD with FX matrix. /// <para> /// The discount curves are flat. /// /// </para> /// </summary> /// <param name="valuationDate"> the valuation date </param> /// <returns> the rates provider </returns> public static ImmutableRatesProvider createProviderEurUsdFlat(LocalDate valuationDate) { FxMatrix fxMatrix = FxMatrix.builder().addRate(USD, EUR, 1.0d / EUR_USD).build(); return(ImmutableRatesProvider.builder(valuationDate).discountCurve(EUR, EUR_DSC_FLAT).discountCurve(USD, USD_DSC_FLAT).fxRateProvider(fxMatrix).build()); }
// computes sensitivity with finite difference approximation private CurrencyParameterSensitivities fdSensitivityWithZSpread(CapitalIndexedBondPaymentPeriod period, ImmutableRatesProvider ratesProvider, LegalEntityDiscountingProvider issuerRatesProvider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { CurrencyParameterSensitivities sensi1 = FD_CAL.sensitivity(issuerRatesProvider, p => CurrencyAmount.of(USD, PRICER.presentValueWithZSpread(period, ratesProvider, p.issuerCurveDiscountFactors(CapitalIndexedBondCurveDataSet.IssuerId, USD), zSpread, compoundedRateType, periodsPerYear))); CurrencyParameterSensitivities sensi2 = FD_CAL.sensitivity(ratesProvider, p => CurrencyAmount.of(USD, PRICER.presentValueWithZSpread(period, p, issuerRatesProvider.issuerCurveDiscountFactors(CapitalIndexedBondCurveDataSet.IssuerId, USD), zSpread, compoundedRateType, periodsPerYear))); return(sensi1.combinedWith(sensi2)); }
/// <summary> /// Obtains an immutable rates providers with valuation date and time series. /// <para> /// The time series must contain historical data for the price index. /// /// </para> /// </summary> /// <param name="valuationDate"> the valuation date </param> /// <param name="timeSeries"> the time series </param> /// <returns> the rates provider </returns> public static ImmutableRatesProvider getRatesProvider(LocalDate valuationDate, LocalDateDoubleTimeSeries timeSeries) { return(ImmutableRatesProvider.builder(valuationDate).fxRateProvider(FxMatrix.empty()).priceIndexCurve(US_CPI_U, CPI_CURVE).timeSeries(US_CPI_U, timeSeries).build()); }
public virtual void test_currentCash_onEndDate() { RatesProvider prov = ImmutableRatesProvider.builder(RDEPOSIT_TRADE.Product.EndDate).discountCurve(EUR, CURVE).build(); assertEquals(PRICER_TRADE.currentCash(RDEPOSIT_TRADE, prov), CurrencyAmount.of(EUR, NOTIONAL + INTEREST)); }
//------------------------------------------------------------------------- private static CurrencyParameterSensitivity buildSensitivities(Curve bumpedCurve, ImmutableRatesProvider ratesProvider) { //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: RatesProvider bumpedRatesProvider = ratesProvider.toBuilder().discountCurves(ratesProvider.DiscountCurves.Keys.collect(toImmutableMap(System.Func.identity(), k => bumpedCurve))).indexCurves(ratesProvider.IndexCurves.Keys.collect(toImmutableMap(System.Func.identity(), k => bumpedCurve))).build(); PointSensitivities pointSensitivities = PRICER_SWAP.presentValueSensitivity(SWAP, bumpedRatesProvider).build(); CurrencyParameterSensitivities paramSensitivities = bumpedRatesProvider.parameterSensitivity(pointSensitivities); return(Iterables.getOnlyElement(paramSensitivities.Sensitivities)); }
private static ImmutableRatesProvider getRatesProvider(LocalDate valuationDate) { return(ImmutableRatesProvider.builder(valuationDate).indexCurve(USD_FED_FUND, CURVE).timeSeries(USD_FED_FUND, TIME_SERIES).build()); }
private static RatesProvider getRatesProvider(LocalDate valuationDate) { return ImmutableRatesProvider.builder(valuationDate).indexCurve(USD_FED_FUND, CURVE).build(); }
//------------------------------------------------------------------------- /// <summary> /// Provides rates for USD and EUR Discounting, Libor 3 month and Euribor 3M. /// </summary> /// <returns> the rates provider </returns> public static ImmutableRatesProvider providerUsdEurDscL3() { // data from group 2 return(ImmutableRatesProvider.builder(VAL_DATE_2014_01_22).fxRateProvider(FX_MATRIX_EUR_USD).discountCurve(EUR, GROUP2_EUR_DSC).discountCurve(USD, GROUP2_USD_DSC).overnightIndexCurve(EUR_EONIA, GROUP2_EUR_ON).iborIndexCurve(EUR_EURIBOR_3M, GROUP2_EUR_L3M).overnightIndexCurve(USD_FED_FUND, GROUP2_USD_ON).iborIndexCurve(USD_LIBOR_3M, GROUP2_USD_L3M).build()); }