Пример #1
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            GenericDoubleShifts test1 = GenericDoubleShifts.of(ShiftType.ABSOLUTE, SHIFT_AMOUNT);

            coverImmutableBean(test1);
            GenericDoubleShifts test2 = GenericDoubleShifts.of(ShiftType.SCALED, DoubleArray.of(3.5d, 2d), SPREAD);

            coverBeanEquals(test1, test2);
        }
Пример #2
0
        public virtual void test_of_spread()
        {
            GenericDoubleShifts test = GenericDoubleShifts.of(ShiftType.RELATIVE, SHIFT_AMOUNT, SPREAD);

            assertEquals(test.ScenarioCount, 3);
            assertEquals(test.ShiftAmount, SHIFT_AMOUNT);
            assertEquals(test.ShiftType, ShiftType.RELATIVE);
            assertEquals(test.Spread, SPREAD);
        }
Пример #3
0
        public virtual void test_of()
        {
            GenericDoubleShifts test = GenericDoubleShifts.of(ShiftType.ABSOLUTE, SHIFT_AMOUNT);

            assertEquals(test.ScenarioCount, 3);
            assertEquals(test.ShiftAmount, SHIFT_AMOUNT);
            assertEquals(test.ShiftType, ShiftType.ABSOLUTE);
            assertEquals(test.Spread, 0d);
        }
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         GenericDoubleShifts other = (GenericDoubleShifts)obj;
         return(JodaBeanUtils.equal(shiftType, other.shiftType) && JodaBeanUtils.equal(shiftAmount, other.shiftAmount) && JodaBeanUtils.equal(spread, other.spread));
     }
     return(false);
 }
Пример #5
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);
        }