Exemplo n.º 1
0
        public virtual void relative()
        {
            IList <LabelDateParameterMetadata> nodeMetadata = ImmutableList.of(LabelDateParameterMetadata.of(date(2011, 3, 8), TNR_1M), LabelDateParameterMetadata.of(date(2011, 5, 8), TNR_3M), LabelDateParameterMetadata.of(date(2011, 8, 8), TNR_6M));

            // This should create 4 scenarios. Scenario zero has no shifts and scenario 3 doesn't have shifts on all nodes
            PointShifts shift = PointShifts.builder(ShiftType.RELATIVE).addShift(1, TNR_1W, 0.1).addShift(1, TNR_1M, 0.2).addShift(1, TNR_3M, 0.3).addShift(2, TNR_1M, 0.4).addShift(2, TNR_3M, 0.5).addShift(2, TNR_6M, 0.6).addShift(3, TNR_3M, 0.7).build();

            Curve curve = InterpolatedNodalCurve.of(Curves.zeroRates(CurveName.of("curve"), DayCounts.ACT_365F, nodeMetadata), DoubleArray.of(1, 2, 3), DoubleArray.of(5, 6, 7), INTERPOLATOR);

            MarketDataBox <ParameterizedData> shiftedCurveBox = shift.applyTo(MarketDataBox.ofSingleValue(curve), REF_DATA);

            Curve scenario1Curve = InterpolatedNodalCurve.of(Curves.zeroRates(CurveName.of("curve"), DayCounts.ACT_365F, nodeMetadata), DoubleArray.of(1, 2, 3), DoubleArray.of(6, 7.8, 7), INTERPOLATOR);

            Curve scenario2Curve = InterpolatedNodalCurve.of(Curves.zeroRates(CurveName.of("curve"), DayCounts.ACT_365F, nodeMetadata), DoubleArray.of(1, 2, 3), DoubleArray.of(7, 9, 11.2), INTERPOLATOR);

            Curve scenario3Curve = InterpolatedNodalCurve.of(Curves.zeroRates(CurveName.of("curve"), DayCounts.ACT_365F, nodeMetadata), DoubleArray.of(1, 2, 3), DoubleArray.of(5, 10.2, 7), INTERPOLATOR);

            // Scenario zero has no perturbations so the expected curve is the same as the input
            IList <Curve> expectedCurves = ImmutableList.of(curve, scenario1Curve, scenario2Curve, scenario3Curve);

            for (int scenarioIndex = 0; scenarioIndex < 4; scenarioIndex++)
            {
                // Check every point from 0 to 4 in steps of 0.1 is the same on the bumped curve and the expected curve
                for (int xIndex = 0; xIndex <= 40; xIndex++)
                {
                    double xValue        = xIndex * 0.1;
                    Curve  expectedCurve = expectedCurves[scenarioIndex];
                    Curve  shiftedCurve  = (Curve)shiftedCurveBox.getValue(scenarioIndex);
                    double shiftedY      = shiftedCurve.yValue(xValue);
                    double expectedY     = expectedCurve.yValue(xValue);
                    assertThat(shiftedY).overridingErrorMessage("Curve differed in scenario %d at x value %f, expected %f, actual %f", scenarioIndex, xValue, expectedY, shiftedY).isEqualTo(expectedY);
                }
            }
        }
Exemplo n.º 2
0
        public virtual void test_of_2args()
        {
            LabelDateParameterMetadata test = LabelDateParameterMetadata.of(DATE, "Label");

            assertEquals(test.Date, DATE);
            assertEquals(test.Label, "Label");
            assertEquals(test.Identifier, "Label");
        }
Exemplo n.º 3
0
        //-------------------------------------------------------------------------
        public virtual void test_of_1arg()
        {
            LabelDateParameterMetadata test = LabelDateParameterMetadata.of(DATE);

            assertEquals(test.Date, DATE);
            assertEquals(test.Label, DATE.ToString());
            assertEquals(test.Identifier, DATE.ToString());
        }
Exemplo n.º 4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            LabelDateParameterMetadata test = LabelDateParameterMetadata.of(DATE, "Label");

            coverImmutableBean(test);
            LabelDateParameterMetadata test2 = LabelDateParameterMetadata.of(date(2014, 1, 1), "Label2");

            coverBeanEquals(test, test2);
        }
Exemplo n.º 5
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         LabelDateParameterMetadata other = (LabelDateParameterMetadata)obj;
         return(JodaBeanUtils.equal(date, other.date) && JodaBeanUtils.equal(label, other.label));
     }
     return(false);
 }
Exemplo n.º 6
0
        public virtual void test_serialization()
        {
            LabelDateParameterMetadata test = LabelDateParameterMetadata.of(DATE, "Label");

            assertSerialization(test);
        }