public void test_compareKey() { ZeroRateSensitivity a1 = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d); ZeroRateSensitivity a2 = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d); ZeroRateSensitivity b = ZeroRateSensitivity.of(USD, YEARFRAC, 32d); ZeroRateSensitivity c = ZeroRateSensitivity.of(GBP, YEARFRAC2, 32d); IborRateSensitivity other = IborRateSensitivity.of(IborIndexObservation.of(GBP_LIBOR_3M, date(2014, 6, 30), REF_DATA), 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(b.compareKey(a1) > 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) > 0, true); assertEquals(other.compareKey(a1) < 0, true); }
public void test_zeroRatePointSensitivityWithSpread_smallYearFraction() { ZeroRatePeriodicDiscountFactors test = ZeroRatePeriodicDiscountFactors.of(GBP, DATE_VAL, CURVE); ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, 0d, 0.0d); ZeroRateSensitivity computed = test.zeroRatePointSensitivityWithSpread(DATE_VAL, SPREAD, CONTINUOUS, 0); assertTrue(computed.compareKey(expected) == 0); assertEquals(computed.getSensitivity(), expected.getSensitivity(), TOLERANCE_DELTA_FD); }
public void test_zeroRatePointSensitivityWithSpread_sensitivityCurrency_smallYearFraction() { ZeroRatePeriodicDiscountFactors test = ZeroRatePeriodicDiscountFactors.of(GBP, DATE_VAL, CURVE); ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, 0d, USD, 0.0d); ZeroRateSensitivity computed = test.zeroRatePointSensitivityWithSpread(DATE_VAL, USD, SPREAD, CONTINUOUS, 0); assertTrue(computed.compareKey(expected) == 0); assertEquals(computed.getSensitivity(), expected.getSensitivity(), TOLERANCE_DELTA_FD); }
public void test_zeroRatePointSensitivityWithSpread_periodic() { int periodPerYear = 4; ZeroRatePeriodicDiscountFactors test = ZeroRatePeriodicDiscountFactors.of(GBP, DATE_VAL, CURVE); double relativeYearFraction = ACT_365F.relativeYearFraction(DATE_VAL, DATE_AFTER); double df = test.discountFactor(DATE_AFTER); double z = -1.0/relativeYearFraction*Math.log(df); double shift = 1.0E-6; double zP = z + shift; double zM = z - shift; double dfSP = Math.pow( Math.pow(Math.exp(-zP * relativeYearFraction), -1.0 / (relativeYearFraction * periodPerYear)) + SPREAD / periodPerYear, -relativeYearFraction * periodPerYear); double dfSM = Math.pow( Math.pow(Math.exp(-zM * relativeYearFraction), -1.0 / (relativeYearFraction * periodPerYear)) + SPREAD / periodPerYear, -relativeYearFraction * periodPerYear); double ddfSdz = (dfSP - dfSM) / (2 * shift); ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, relativeYearFraction, ddfSdz); ZeroRateSensitivity computed = test.zeroRatePointSensitivityWithSpread(DATE_AFTER, SPREAD, PERIODIC, periodPerYear); assertTrue(computed.compareKey(expected) == 0); assertEquals(computed.getSensitivity(), expected.getSensitivity(), TOLERANCE_DELTA_FD); }
public void test_zeroRatePointSensitivityWithSpread_sensitivityCurrency_periodic() { int periodPerYear = 4; ZeroRatePeriodicDiscountFactors test = ZeroRatePeriodicDiscountFactors.of(GBP, DATE_VAL, CURVE); double relativeYearFraction = ACT_365F.relativeYearFraction(DATE_VAL, DATE_AFTER); double df = test.discountFactor(DATE_AFTER); double z = -1.0/relativeYearFraction*Math.log(df); double shift = 1.0E-6; double zP = z + shift; double zM = z - shift; double dfSP = Math.pow( Math.pow(Math.exp(-zP * relativeYearFraction), -1.0 / (relativeYearFraction * periodPerYear)) + SPREAD / periodPerYear, -relativeYearFraction * periodPerYear); double dfSM = Math.pow( Math.pow(Math.exp(-zM * relativeYearFraction), -1.0 / (relativeYearFraction * periodPerYear)) + SPREAD / periodPerYear, -relativeYearFraction * periodPerYear); double ddfSdz = (dfSP - dfSM) / (2 * shift); ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, relativeYearFraction, USD, ddfSdz); ZeroRateSensitivity computed = test.zeroRatePointSensitivityWithSpread(DATE_AFTER, USD, SPREAD, PERIODIC, periodPerYear); assertTrue(computed.compareKey(expected) == 0); assertEquals(computed.getSensitivity(), expected.getSensitivity(), TOLERANCE_DELTA_FD); }
public void test_zeroRatePointSensitivityWithSpread_continous() { ZeroRatePeriodicDiscountFactors test = ZeroRatePeriodicDiscountFactors.of(GBP, DATE_VAL, CURVE); double relativeYearFraction = ACT_365F.relativeYearFraction(DATE_VAL, DATE_AFTER); double df = test.discountFactorWithSpread(DATE_AFTER, SPREAD, CONTINUOUS, 0); ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, relativeYearFraction, -df * relativeYearFraction); ZeroRateSensitivity computed = test.zeroRatePointSensitivityWithSpread(DATE_AFTER, SPREAD, CONTINUOUS, 0); assertTrue(computed.compareKey(expected) == 0); assertEquals(computed.getSensitivity(), expected.getSensitivity(), TOLERANCE_DELTA); }
public void test_zeroRatePointSensitivityWithSpread_sensitivityCurrency_continous() { ZeroRatePeriodicDiscountFactors test = ZeroRatePeriodicDiscountFactors.of(GBP, DATE_VAL, CURVE); double relativeYearFraction = ACT_365F.relativeYearFraction(DATE_VAL, DATE_AFTER); double df = test.discountFactorWithSpread(DATE_AFTER, SPREAD, CONTINUOUS, 0); ZeroRateSensitivity expected = ZeroRateSensitivity.of(GBP, relativeYearFraction, USD, -df * relativeYearFraction); ZeroRateSensitivity computed = test.zeroRatePointSensitivityWithSpread(DATE_AFTER, USD, SPREAD, CONTINUOUS, 0); assertTrue(computed.compareKey(expected) == 0); assertEquals(computed.getSensitivity(), expected.getSensitivity(), TOLERANCE_DELTA); }
public void test_compareKey() { IborCapletFloorletSabrSensitivity a1 = IborCapletFloorletSabrSensitivity.of( NAME, EXPIRY, SabrParameterType.ALPHA, GBP, 32d); IborCapletFloorletSabrSensitivity a2 = IborCapletFloorletSabrSensitivity.of( NAME, EXPIRY, SabrParameterType.ALPHA, GBP, 32d); IborCapletFloorletSabrSensitivity b = IborCapletFloorletSabrSensitivity.of( NAME, EXPIRY, SabrParameterType.ALPHA, USD, 32d); IborCapletFloorletSabrSensitivity c = IborCapletFloorletSabrSensitivity.of( NAME, EXPIRY + 1, SabrParameterType.ALPHA, GBP, 32d); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(a1.compareKey(b) < 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { IborRateSensitivity a1 = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d); IborRateSensitivity a2 = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d); IborRateSensitivity b = IborRateSensitivity.of(IborIndexObservation.of(USD_LIBOR_3M, DATE2, REF_DATA), 32d); IborRateSensitivity c = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, USD, 32d); IborRateSensitivity d = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION2, 32d); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(b.compareKey(a1) > 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { SwaptionSabrSensitivity a1 = SwaptionSabrSensitivity.of( NAME, EXPIRY, TENOR, SabrParameterType.ALPHA, GBP, 32d); SwaptionSabrSensitivity a2 = SwaptionSabrSensitivity.of( NAME, EXPIRY, TENOR, SabrParameterType.ALPHA, GBP, 32d); SwaptionSabrSensitivity b = SwaptionSabrSensitivity.of( NAME, EXPIRY, TENOR, SabrParameterType.ALPHA, USD, 32d); SwaptionSabrSensitivity c = SwaptionSabrSensitivity.of( NAME, EXPIRY + 1, TENOR, SabrParameterType.ALPHA, GBP, 32d); SwaptionSabrSensitivity d = SwaptionSabrSensitivity.of( NAME, EXPIRY, TENOR + 1, SabrParameterType.ALPHA, GBP, 32d); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(a1.compareKey(b) < 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { InflationRateSensitivity a1 = InflationRateSensitivity.of(GB_HICP_OBS, 32d); InflationRateSensitivity a2 = InflationRateSensitivity.of(GB_HICP_OBS, 32d); InflationRateSensitivity b = InflationRateSensitivity.of(CH_CPI_OBS, 32d); InflationRateSensitivity c = InflationRateSensitivity.of(GB_HICP_OBS, USD, 32d); InflationRateSensitivity d = InflationRateSensitivity.of(PriceIndexObservation.of(GB_HICP, YearMonth.of(2015, 10)), 32d); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) > 0, true); assertEquals(b.compareKey(a1) < 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { FxIndexSensitivity a1 = FxIndexSensitivity.of(GBP_USD_WM_OBS, GBP, USD, SENSITIVITY_VALUE); FxIndexSensitivity a2 = FxIndexSensitivity.of(GBP_USD_WM_OBS, GBP, USD, SENSITIVITY_VALUE); FxIndexSensitivity b = FxIndexSensitivity.of(EUR_GBP_ECB_OBS, USD, SENSITIVITY_VALUE); FxIndexSensitivity c = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE); FxIndexSensitivity d = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, JPY, SENSITIVITY_VALUE); FxIndexSensitivity e = FxIndexSensitivity.of(GBP_USD_WM_OBS2, USD, SENSITIVITY_VALUE); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, SENSITIVITY_VALUE); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) > 0, true); assertEquals(b.compareKey(a1) < 0, true); assertEquals(a1.compareKey(c) > 0, true); assertEquals(c.compareKey(a1) < 0, true); assertEquals(a1.compareKey(d) > 0, true); assertEquals(d.compareKey(a1) < 0, true); assertEquals(a1.compareKey(e) > 0, true); assertEquals(e.compareKey(a1) < 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { SwaptionSensitivity a1 = SwaptionSensitivity.of(NAME, EXPIRY, TENOR, STRIKE, FORWARD, GBP, 32d); SwaptionSensitivity a2 = SwaptionSensitivity.of(NAME, EXPIRY, TENOR, STRIKE, FORWARD, GBP, 32d); SwaptionSensitivity b = SwaptionSensitivity.of(NAME, EXPIRY, TENOR, STRIKE, FORWARD, USD, 32d); SwaptionSensitivity c = SwaptionSensitivity.of(NAME, EXPIRY + 1, TENOR, STRIKE, FORWARD, GBP, 32d); SwaptionSensitivity d = SwaptionSensitivity.of(NAME, EXPIRY, TENOR + 1, STRIKE, FORWARD, GBP, 32d); SwaptionSensitivity e = SwaptionSensitivity.of(NAME, EXPIRY, TENOR, STRIKE + 1, FORWARD, GBP, 32d); SwaptionSensitivity f = SwaptionSensitivity.of(NAME, EXPIRY, TENOR, STRIKE, FORWARD + 1, GBP, 32d); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(a1.compareKey(b) < 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(a1.compareKey(e) < 0, true); assertEquals(a1.compareKey(f) < 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { FxForwardSensitivity a1 = FxForwardSensitivity.of(CURRENCY_PAIR, GBP, REFERENCE_DATE, EUR, SENSITIVITY); FxForwardSensitivity a2 = FxForwardSensitivity.of(CURRENCY_PAIR, GBP, REFERENCE_DATE, EUR, SENSITIVITY); FxForwardSensitivity b = FxForwardSensitivity.of(CurrencyPair.of(GBP, USD), GBP, REFERENCE_DATE, EUR, SENSITIVITY); FxForwardSensitivity c = FxForwardSensitivity.of(CURRENCY_PAIR, EUR, REFERENCE_DATE, GBP, SENSITIVITY); FxForwardSensitivity d = FxForwardSensitivity.of(CURRENCY_PAIR, GBP, REFERENCE_DATE, JPY, SENSITIVITY); FxForwardSensitivity e = FxForwardSensitivity.of(CURRENCY_PAIR, GBP, date(2015, 9, 27), SENSITIVITY); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, SENSITIVITY); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(b.compareKey(a1) > 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(e) > 0, true); assertEquals(e.compareKey(a1) < 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareExcludingSensitivity() { FxOptionSensitivity a1 = FxOptionSensitivity.of(NAME, PAIR, EXPIRY, STRIKE, FORWARD, GBP, SENSI_VALUE); FxOptionSensitivity a2 = FxOptionSensitivity.of(NAME, PAIR, EXPIRY, STRIKE, FORWARD, GBP, SENSI_VALUE); FxOptionSensitivity b = FxOptionSensitivity.of( NAME, CurrencyPair.of(EUR, USD), EXPIRY, STRIKE, FORWARD, GBP, SENSI_VALUE); FxOptionSensitivity c = FxOptionSensitivity.of(NAME, PAIR, EXPIRY + 1, STRIKE, FORWARD, GBP, SENSI_VALUE); FxOptionSensitivity d = FxOptionSensitivity.of(NAME, PAIR, EXPIRY, 0.96, FORWARD, GBP, SENSI_VALUE); FxOptionSensitivity e = FxOptionSensitivity.of(NAME, PAIR, EXPIRY, STRIKE, 0.81, GBP, SENSI_VALUE); FxOptionSensitivity f = FxOptionSensitivity.of(NAME, PAIR, EXPIRY, STRIKE, FORWARD, EUR, SENSI_VALUE); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(b.compareKey(a1) > 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(e) < 0, true); assertEquals(e.compareKey(a1) > 0, true); assertEquals(a1.compareKey(f) > 0, true); assertEquals(f.compareKey(a1) < 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { IborCapletFloorletSensitivity a1 = IborCapletFloorletSensitivity.of(NAME, EXPIRY, STRIKE, FORWARD, GBP, SENSITIVITY); IborCapletFloorletSensitivity a2 = IborCapletFloorletSensitivity.of(NAME, EXPIRY, STRIKE, FORWARD, GBP, SENSITIVITY); IborCapletFloorletSensitivity b = IborCapletFloorletSensitivity.of(NAME2, EXPIRY, STRIKE, FORWARD, GBP, SENSITIVITY); IborCapletFloorletSensitivity c = IborCapletFloorletSensitivity.of(NAME, EXPIRY + 1, STRIKE, FORWARD, GBP, SENSITIVITY); IborCapletFloorletSensitivity d = IborCapletFloorletSensitivity.of(NAME, EXPIRY, 0.009, FORWARD, GBP, SENSITIVITY); IborCapletFloorletSensitivity e = IborCapletFloorletSensitivity.of(NAME, EXPIRY, STRIKE, 0.005, GBP, SENSITIVITY); IborCapletFloorletSensitivity f = IborCapletFloorletSensitivity.of(NAME, EXPIRY, STRIKE, FORWARD, USD, SENSITIVITY); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(b.compareKey(a1) > 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(e) > 0, true); assertEquals(e.compareKey(a1) < 0, true); assertEquals(a1.compareKey(f) < 0, true); assertEquals(f.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
public void test_compareKey() { OvernightRateSensitivity a1 = OvernightRateSensitivity.ofPeriod(GBP_SONIA_OBSERVATION, date(2015, 10, 27), GBP, 32d); OvernightRateSensitivity a2 = OvernightRateSensitivity.ofPeriod(GBP_SONIA_OBSERVATION, date(2015, 10, 27), GBP, 32d); OvernightRateSensitivity b = OvernightRateSensitivity.ofPeriod(USD_FED_FUND_OBSERVATION2, date(2015, 10, 27), GBP, 32d); OvernightRateSensitivity c = OvernightRateSensitivity.ofPeriod(GBP_SONIA_OBSERVATION, date(2015, 10, 27), USD, 32d); OvernightRateSensitivity d = OvernightRateSensitivity.ofPeriod(GBP_SONIA_OBSERVATION2, date(2015, 10, 27), GBP, 32d); OvernightRateSensitivity e = OvernightRateSensitivity.ofPeriod(GBP_SONIA_OBSERVATION, date(2015, 11, 27), GBP, 32d); ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d); assertEquals(a1.compareKey(a2), 0); assertEquals(a1.compareKey(b) < 0, true); assertEquals(b.compareKey(a1) > 0, true); assertEquals(a1.compareKey(c) < 0, true); assertEquals(c.compareKey(a1) > 0, true); assertEquals(a1.compareKey(e) < 0, true); assertEquals(d.compareKey(a1) > 0, true); assertEquals(a1.compareKey(d) < 0, true); assertEquals(e.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true); }
assertEquals(g.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true);
assertEquals(g.compareKey(a1) > 0, true); assertEquals(a1.compareKey(other) < 0, true); assertEquals(other.compareKey(a1) > 0, true);