//------------------------------------------------------------------------- public virtual void coverage() { FxRateShifts test1 = FxRateShifts.of(ShiftType.SCALED, SHIFT_AMOUNT_2, EURUSD); coverImmutableBean(test1); FxRateShifts test2 = FxRateShifts.of(ShiftType.ABSOLUTE, SHIFT_AMOUNT_1, USDEUR); coverBeanEquals(test1, test2); }
public virtual void test_of() { FxRateShifts test = FxRateShifts.of(ShiftType.SCALED, SHIFT_AMOUNT_2, EURUSD); assertEquals(test.CurrencyPair, EURUSD); assertEquals(test.ScenarioCount, 3); assertEquals(test.ShiftAmount, SHIFT_AMOUNT_2); assertEquals(test.ShiftType, ShiftType.SCALED); }
public virtual void test_applyTo() { MarketDataBox <FxRate> marketData = MarketDataBox.ofSingleValue(FX_RATE); FxRateShifts testScaled = FxRateShifts.of(ShiftType.SCALED, SHIFT_AMOUNT_2, EURUSD); MarketDataBox <FxRate> computedScaled = testScaled.applyTo(marketData, REF_DATA); MarketDataBox <FxRate> expectedScaled = MarketDataBox.ofScenarioValues(ImmutableList.of(FxRate.of(EURUSD, BASE_RATE * SHIFT_AMOUNT_2.get(0)), FxRate.of(EURUSD, BASE_RATE * SHIFT_AMOUNT_2.get(1)), FxRate.of(EURUSD, BASE_RATE * SHIFT_AMOUNT_2.get(2)))); assertEquals(computedScaled, expectedScaled); FxRateShifts testScaledInv = FxRateShifts.of(ShiftType.SCALED, SHIFT_AMOUNT_2, USDEUR); MarketDataBox <FxRate> computedScaledInv = testScaledInv.applyTo(marketData, REF_DATA); MarketDataBox <FxRate> expectedScaledInv = MarketDataBox.ofScenarioValues(ImmutableList.of(FxRate.of(USDEUR, 1d / BASE_RATE * SHIFT_AMOUNT_2.get(0)), FxRate.of(USDEUR, 1d / BASE_RATE * SHIFT_AMOUNT_2.get(1)), FxRate.of(USDEUR, 1d / BASE_RATE * SHIFT_AMOUNT_2.get(2)))); assertEquals(computedScaledInv, expectedScaledInv); FxRateShifts testAbsolute = FxRateShifts.of(ShiftType.ABSOLUTE, SHIFT_AMOUNT_1, EURUSD); MarketDataBox <FxRate> computedAbsolute = testAbsolute.applyTo(marketData, REF_DATA); MarketDataBox <FxRate> expectedAbsolute = MarketDataBox.ofScenarioValues(ImmutableList.of(FxRate.of(EURUSD, BASE_RATE + SHIFT_AMOUNT_1.get(0)), FxRate.of(EURUSD, BASE_RATE + SHIFT_AMOUNT_1.get(1)), FxRate.of(EURUSD, BASE_RATE + SHIFT_AMOUNT_1.get(2)))); assertEquals(computedAbsolute, expectedAbsolute); FxRateShifts testRelative = FxRateShifts.of(ShiftType.RELATIVE, SHIFT_AMOUNT_1, EURUSD); MarketDataBox <FxRate> computedRelative = testRelative.applyTo(marketData, REF_DATA); MarketDataBox <FxRate> expectedRelative = MarketDataBox.ofScenarioValues(ImmutableList.of(FxRate.of(EURUSD, BASE_RATE * (1d + SHIFT_AMOUNT_1.get(0))), FxRate.of(EURUSD, BASE_RATE * (1d + SHIFT_AMOUNT_1.get(1))), FxRate.of(EURUSD, BASE_RATE * (1d + SHIFT_AMOUNT_1.get(2))))); assertEquals(computedRelative, expectedRelative); }