Exemple #1
0
        public virtual void createScenarioValue()
        {
            MarketDataBox <double> box         = MarketDataBox.ofScenarioValues(1d, 2d, 3d);
            QuoteScenarioArray     quotesArray = KEY.createScenarioValue(box, 3);

            assertThat(quotesArray.Quotes).isEqualTo(DoubleArray.of(1d, 2d, 3d));
        }
        public virtual void test_toZonedDateTime_scenario_long()
        {
            ValuationZoneTimeDefinition   test     = ValuationZoneTimeDefinition.of(LOCAL_TIME_1, ZONE_ID, LOCAL_TIME_1, LOCAL_TIME_2);
            MarketDataBox <LocalDate>     dates    = MarketDataBox.ofScenarioValues(LocalDate.of(2016, 10, 21), LocalDate.of(2016, 10, 22), LocalDate.of(2016, 10, 23));
            MarketDataBox <ZonedDateTime> computed = test.toZonedDateTime(dates);
            MarketDataBox <ZonedDateTime> expected = MarketDataBox.ofScenarioValue(ScenarioArray.of(dates.getValue(0).atTime(LOCAL_TIME_1).atZone(ZONE_ID), dates.getValue(1).atTime(LOCAL_TIME_2).atZone(ZONE_ID), dates.getValue(2).atTime(LOCAL_TIME_1).atZone(ZONE_ID)));

            assertEquals(computed, expected);
        }
Exemple #3
0
        public virtual void test_applyTo()
        {
            double baseValue = 3d;
            MarketDataBox <double> marketData     = MarketDataBox.ofSingleValue(baseValue);
            GenericDoubleShifts    testScaled     = GenericDoubleShifts.of(ShiftType.SCALED, SHIFT_AMOUNT, SPREAD);
            MarketDataBox <double> computedScaled = testScaled.applyTo(marketData, REF_DATA);
            MarketDataBox <double> expectedScaled = MarketDataBox.ofScenarioValues(ImmutableList.of((baseValue + SPREAD) * SHIFT_AMOUNT.get(0) - SPREAD, (baseValue + SPREAD) * SHIFT_AMOUNT.get(1) - SPREAD, (baseValue + SPREAD) * SHIFT_AMOUNT.get(2) - SPREAD));

            assertEquals(computedScaled, expectedScaled);
            GenericDoubleShifts    testRelative     = GenericDoubleShifts.of(ShiftType.RELATIVE, SHIFT_AMOUNT, SPREAD);
            MarketDataBox <double> computedRelative = testRelative.applyTo(marketData, REF_DATA);
            MarketDataBox <double> expectedRelative = MarketDataBox.ofScenarioValues(ImmutableList.of((baseValue + SPREAD) * (1d + SHIFT_AMOUNT.get(0)) - SPREAD, (baseValue + SPREAD) * (1d + SHIFT_AMOUNT.get(1)) - SPREAD, (baseValue + SPREAD) * (1d + SHIFT_AMOUNT.get(2)) - SPREAD));

            assertEquals(computedRelative, expectedRelative);
            GenericDoubleShifts    testAbsolute     = GenericDoubleShifts.of(ShiftType.ABSOLUTE, SHIFT_AMOUNT);
            MarketDataBox <double> computedAbsolute = testAbsolute.applyTo(marketData, REF_DATA);
            MarketDataBox <double> expectedAbsolute = MarketDataBox.ofScenarioValues(ImmutableList.of(baseValue + SHIFT_AMOUNT.get(0), baseValue + SHIFT_AMOUNT.get(1), baseValue + SHIFT_AMOUNT.get(2)));

            assertEquals(computedAbsolute, expectedAbsolute);
        }
Exemple #4
0
        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);
        }