Exemplo n.º 1
0
        public virtual void test_of_noCurveMetadata()
        {
            InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA_NOPARAM, XVALUES, YVALUES, INTERPOLATOR);

            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE);
            assertThat(test.getParameter(0)).isEqualTo(YVALUES.get(0));
            assertThat(test.getParameter(1)).isEqualTo(YVALUES.get(1));
            assertThat(test.getParameterMetadata(0)).isEqualTo(SimpleCurveParameterMetadata.of(ValueType.YEAR_FRACTION, XVALUES.get(0)));
            assertThat(test.getParameterMetadata(1)).isEqualTo(SimpleCurveParameterMetadata.of(ValueType.YEAR_FRACTION, XVALUES.get(1)));
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual void test_of_CurveMetadata()
        {
            InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES, INTERPOLATOR);

            assertThat(test.Name).isEqualTo(CURVE_NAME);
            assertThat(test.ParameterCount).isEqualTo(SIZE);
            assertThat(test.getParameter(0)).isEqualTo(YVALUES.get(0));
            assertThat(test.getParameter(1)).isEqualTo(YVALUES.get(1));
            assertThat(test.getParameterMetadata(0)).isSameAs(METADATA_ENTRIES.ParameterMetadata.get().get(0));
            assertThat(test.getParameterMetadata(1)).isSameAs(METADATA_ENTRIES.ParameterMetadata.get().get(1));
            assertThat(test.withParameter(0, 2d)).isEqualTo(InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES.with(0, 2d), INTERPOLATOR));
            assertThat(test.withPerturbation((i, v, m) => v - 2d)).isEqualTo(InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES_BUMPED, INTERPOLATOR));
            assertThat(test.ExtrapolatorLeft.Name).isEqualTo(FLAT_EXTRAPOLATOR.Name);
            assertThat(test.Interpolator.Name).isEqualTo(INTERPOLATOR.Name);
            assertThat(test.ExtrapolatorRight.Name).isEqualTo(FLAT_EXTRAPOLATOR.Name);
            assertThat(test.Metadata).isEqualTo(METADATA_ENTRIES);
            assertThat(test.XValues).isEqualTo(XVALUES);
            assertThat(test.YValues).isEqualTo(YVALUES);
        }
Exemplo n.º 3
0
        public virtual void test_of_noMetadata()
        {
            IList <ParameterMetadata> combinedParamMeta = new List <ParameterMetadata>();

            ((IList <ParameterMetadata>)combinedParamMeta).AddRange(PARAM_METADATA_BASE);
            ((IList <ParameterMetadata>)combinedParamMeta).AddRange(PARAM_METADATA_SPREAD);
            CurveMetadata expectedMetadata = DefaultCurveMetadata.builder().curveName(BASE_NAME + "+" + SPREAD_NAME).xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).parameterMetadata(combinedParamMeta).build();

            assertEquals(COMBINED_CURVE.BaseCurve, BASE_CURVE);
            assertEquals(COMBINED_CURVE.SpreadCurve, SPREAD_CURVE);
            assertEquals(COMBINED_CURVE.Metadata, expectedMetadata);
            assertEquals(COMBINED_CURVE.Name, expectedMetadata.CurveName);
            assertEquals(COMBINED_CURVE.ParameterCount, BASE_CURVE.ParameterCount + SPREAD_CURVE.ParameterCount);
            assertEquals(COMBINED_CURVE.getParameter(1), BASE_CURVE.getParameter(1));
            assertEquals(COMBINED_CURVE.getParameter(6), SPREAD_CURVE.getParameter(3));
            assertEquals(COMBINED_CURVE.getParameterMetadata(0), BASE_CURVE.getParameterMetadata(0));
            assertEquals(COMBINED_CURVE.getParameterMetadata(4), SPREAD_CURVE.getParameterMetadata(1));
        }
Exemplo n.º 4
0
        public virtual void test_of()
        {
            CurveMetadata          baseMetadata     = DefaultCurveMetadata.builder().curveName(BASE_NAME).xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).build();
            CurveMetadata          spreadMetadata   = DefaultCurveMetadata.builder().curveName(SPREAD_NAME).xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).build();
            InterpolatedNodalCurve baseCurve        = InterpolatedNodalCurve.of(baseMetadata, XVALUES_BASE, YVALUES_BASE, NATURAL_CUBIC_SPLINE, LINEAR, LINEAR);
            InterpolatedNodalCurve spreadCurve      = InterpolatedNodalCurve.of(spreadMetadata, XVALUES_SPREAD, YVALUES_SPREAD, PCHIP, LINEAR, LINEAR);
            CurveMetadata          combinedMetadata = DefaultCurveMetadata.builder().curveName("CombinedCurve").xValueType(YEAR_FRACTION).yValueType(ZERO_RATE).dayCount(ACT_365F).build();
            CombinedCurve          test             = CombinedCurve.of(baseCurve, spreadCurve, combinedMetadata);

            assertEquals(test.BaseCurve, baseCurve);
            assertEquals(test.SpreadCurve, spreadCurve);
            assertEquals(test.Metadata, combinedMetadata);
            assertEquals(test.Name, combinedMetadata.CurveName);
            assertEquals(test.ParameterCount, baseCurve.ParameterCount + spreadCurve.ParameterCount);
            assertEquals(test.getParameter(1), baseCurve.getParameter(1));
            assertEquals(test.getParameter(6), spreadCurve.getParameter(3));
            assertEquals(test.getParameterMetadata(2), baseCurve.getParameterMetadata(2));
            assertEquals(test.getParameterMetadata(5), spreadCurve.getParameterMetadata(2));
        }