Exemple #1
0
        public virtual void test_sensitivities()
        {
            ParameterizedFunctionalCurve test = ParameterizedFunctionalCurve.of(METADATA, PARAMETERS, VALUE_FUNCTION, DERIVATIVE_FUNCTION, SENSITIVITY_FUNCTION);
            DoubleArray sensiVal = DoubleArray.of(1d, 2d, 3d);

            assertEquals(test.createParameterSensitivity(sensiVal), UnitParameterSensitivity.of(METADATA.CurveName, METADATA.ParameterMetadata.get(), sensiVal));
            assertEquals(test.createParameterSensitivity(USD, sensiVal), CurrencyParameterSensitivity.of(METADATA.CurveName, METADATA.ParameterMetadata.get(), USD, sensiVal));
        }
Exemple #2
0
        //-------------------------------------------------------------------------
        public virtual void test_values()
        {
            ParameterizedFunctionalCurve test = ParameterizedFunctionalCurve.of(METADATA, PARAMETERS, VALUE_FUNCTION, DERIVATIVE_FUNCTION, SENSITIVITY_FUNCTION);
            double x = 5.2;

            assertEquals(test.yValue(x), VALUE_FUNCTION.apply(PARAMETERS, x));
            assertEquals(test.firstDerivative(x), DERIVATIVE_FUNCTION.apply(PARAMETERS, x));
            assertEquals(test.yValueParameterSensitivity(x), UnitParameterSensitivity.of(METADATA.CurveName, METADATA.ParameterMetadata.get(), SENSITIVITY_FUNCTION.apply(PARAMETERS, x)));
        }
Exemple #3
0
        public UnitParameterSensitivity yValueParameterSensitivity(double x)
        {
            int    i                = seasonalityIndex(x);
            double adjustment       = seasonality.get(i);
            double derivativeFactor = 0d;

            if (adjustmentType.Equals(ShiftType.ABSOLUTE))
            {
                derivativeFactor = 1d;
            }
            else if (adjustmentType.Equals(ShiftType.SCALED))
            {
                derivativeFactor = adjustment;
            }
            else
            {
                throw new System.ArgumentException("ShiftType " + adjustmentType + " is not supported for sensitivities");
            }
            // remove the first point from the underlying sensitivity
            UnitParameterSensitivity u  = underlying.yValueParameterSensitivity(x);
            UnitParameterSensitivity u2 = UnitParameterSensitivity.of(u.MarketDataName, u.ParameterMetadata.subList(1, u.ParameterMetadata.size()), u.Sensitivity.subArray(1));

            return(u2.multipliedBy(derivativeFactor));
        }
        public UnitParameterSensitivity yValueParameterSensitivity(double x)
        {
            ImmutableList <ParameterMetadata> paramMeta = ImmutableList.of(getParameterMetadata(0));

            return(UnitParameterSensitivity.of(metadata.CurveName, paramMeta, SENSITIVITY));
        }
 //-------------------------------------------------------------------------
 public override UnitParameterSensitivity createParameterSensitivity(DoubleArray sensitivities)
 {
     return(UnitParameterSensitivity.of(Name, parameterMetadata, sensitivities));
 }
Exemple #6
0
 public UnitParameterSensitivity zValueParameterSensitivity(double x, double y)
 {
     return(Metadata.ParameterMetadata.Present ? UnitParameterSensitivity.of(Metadata.SurfaceName, Metadata.ParameterMetadata.get(), deformationFunction.apply(DoublesPair.of(x, y)).Derivatives) : UnitParameterSensitivity.of(Metadata.SurfaceName, deformationFunction.apply(DoublesPair.of(x, y)).Derivatives));
 }
Exemple #7
0
        //-------------------------------------------------------------------------
        public virtual void test_createParameterSensitivity()
        {
            InterpolatedNodalCurve test = InterpolatedNodalCurve.of(METADATA_ENTRIES, XVALUES, YVALUES, INTERPOLATOR);

            assertThat(test.createParameterSensitivity(DoubleArray.of(2d, 3d, 4d))).isEqualTo(UnitParameterSensitivity.of(CURVE_NAME, DoubleArray.of(2d, 3d, 4d)));
            assertThat(test.createParameterSensitivity(Currency.GBP, DoubleArray.of(2d, 3d, 4d))).isEqualTo(CurrencyParameterSensitivity.of(CURVE_NAME, Currency.GBP, DoubleArray.of(2d, 3d, 4d)));
        }