/** * Returns an immutable version of this object. * <p> * The result is an instance of the immutable {@link PointSensitivities}. * It will contain the same individual point sensitivities. * * @return the immutable sensitivity instance, not null */ public PointSensitivities toImmutable() { return PointSensitivities.of(sensitivities); }
/** * Obtains an instance from an array of sensitivity entries. * * @param sensitivity the sensitivity entry * @return the sensitivities instance */ public static PointSensitivities of(PointSensitivity... sensitivity) { return PointSensitivities.of(ImmutableList.copyOf(sensitivity)); }
/** * Calculates the parameter sensitivity. * <p> * This computes the {@link CurrencyParameterSensitivities} associated with the {@link PointSensitivities}. * This corresponds to the projection of the point sensitivity to the internal parameters representation. * * @param pointSensitivities the point sensitivities * @return the sensitivity to the underlying parameters */ public default CurrencyParameterSensitivities parameterSensitivity(PointSensitivity... pointSensitivities) { return parameterSensitivity(PointSensitivities.of(pointSensitivities)); }
/** * Calculates the parameter sensitivity. * <p> * This computes the {@link CurrencyParameterSensitivities} associated with the {@link PointSensitivities}. * This corresponds to the projection of the point sensitivity to the internal parameters representation. * * @param pointSensitivities the point sensitivities * @return the sensitivity to the underlying parameters */ public default CurrencyParameterSensitivities parameterSensitivity(PointSensitivity... pointSensitivities) { return parameterSensitivity(PointSensitivities.of(pointSensitivities)); }
/** * Calculates the parameter sensitivity. * <p> * This computes the {@link CurrencyParameterSensitivities} associated with the {@link PointSensitivities}. * This corresponds to the projection of the point sensitivity to the internal parameters representation. * * @param pointSensitivities the point sensitivities * @return the sensitivity to the underlying parameters */ public default CurrencyParameterSensitivities parameterSensitivity(PointSensitivity... pointSensitivities) { return parameterSensitivity(PointSensitivities.of(pointSensitivities)); }
/** * Calculates the parameter sensitivity. * <p> * This computes the {@link CurrencyParameterSensitivities} associated with the {@link PointSensitivities}. * This corresponds to the projection of the point sensitivity to the internal parameters representation. * * @param pointSensitivities the point sensitivities * @return the sensitivity to the underlying parameters */ public default CurrencyParameterSensitivities parameterSensitivity(PointSensitivity... pointSensitivities) { return parameterSensitivity(PointSensitivities.of(pointSensitivities)); }
public void test_of_List() { PointSensitivities test = PointSensitivities.of(Lists.newArrayList(CS1, CS2)); assertEquals(test.getSensitivities(), ImmutableList.of(CS1, CS2)); assertEquals(test.size(), 2); }
public void test_of_array() { PointSensitivities test = PointSensitivities.of(CS1, CS2); assertEquals(test.getSensitivities(), ImmutableList.of(CS1, CS2)); assertEquals(test.size(), 2); }
public void test_toImmutable() { MutablePointSensitivities test = new MutablePointSensitivities(); test.addAll(Lists.newArrayList(CS3, CS2, CS1)); assertEquals(test.toImmutable(), PointSensitivities.of(ImmutableList.of(CS3, CS2, CS1))); }
public void test_equalWithTolerance_true() { PointSensitivity cs1b = DummyPointSensitivity.of(GBP, date(2015, 6, 30), 12.1d); PointSensitivities test1 = PointSensitivities.of(Lists.newArrayList(CS3, CS1)).normalized(); PointSensitivities test2 = PointSensitivities.of(Lists.newArrayList(CS3, cs1b)).normalized(); assertTrue(test1.equalWithTolerance(test2, 1.0E-1)); }
public void test_mapSensitivities() { PointSensitivities test = PointSensitivities.of(Lists.newArrayList(CS3, CS2, CS1)); assertEquals( test.mapSensitivities(s -> s / 2).getSensitivities(), ImmutableList.of(CS3.withSensitivity(16d), CS2.withSensitivity(11d), CS1.withSensitivity(6d))); }
public void test_multipliedBy() { PointSensitivities test = PointSensitivities.of(Lists.newArrayList(CS3, CS2, CS1)); assertEquals( test.multipliedBy(2d).getSensitivities(), ImmutableList.of(CS3.withSensitivity(64d), CS2.withSensitivity(44d), CS1.withSensitivity(24d))); }
public void test_priceSensitivity() { IborIndexRates mockIbor = mock(IborIndexRates.class); SimpleRatesProvider prov = new SimpleRatesProvider(); prov.setIborRates(mockIbor); PointSensitivities sensiExpected = PointSensitivities.of(IborRateSensitivity.of(FUTURE.getIborRate().getObservation(), -1d)); PointSensitivities sensiComputed = PRICER.priceSensitivity(FUTURE, prov); assertTrue(sensiComputed.equalWithTolerance(sensiExpected, TOLERANCE_PRICE_DELTA)); }
public void test_presentValueSensitivity() { SimpleRatesProvider prov = createProvider(NOTIONAL_EXCHANGE_REC_GBP); DiscountingNotionalExchangePricer test = DiscountingNotionalExchangePricer.DEFAULT; PointSensitivities senseComputed = test.presentValueSensitivity(NOTIONAL_EXCHANGE_REC_GBP, prov).build(); double eps = 1.0e-7; PointSensitivities senseExpected = PointSensitivities.of(dscSensitivityFD(prov, NOTIONAL_EXCHANGE_REC_GBP, eps)); assertTrue(senseComputed.equalWithTolerance( senseExpected, NOTIONAL_EXCHANGE_REC_GBP.getPaymentAmount().getAmount() * eps)); }
public void test_marginIndexSensitivity() { double notional = FUTURE.getNotional(); double accrualFactor = FUTURE.getAccrualFactor(); PointSensitivities sensiExpected = PointSensitivities.of( IborRateSensitivity.of(FUTURE.getIborRate().getObservation(), -notional * accrualFactor)); PointSensitivities priceSensitivity = PRICER.priceSensitivity(FUTURE, new MockRatesProvider()); PointSensitivities sensiComputed = PRICER.marginIndexSensitivity(FUTURE, priceSensitivity).normalized(); assertTrue(sensiComputed.equalWithTolerance(sensiExpected, 1e-5)); }