public override SmileDeltaParameters withPerturbation(ParameterPerturbation perturbation) { int size = volatility.size(); DoubleArray perturbedValues = DoubleArray.of(size, i => perturbation(i, volatility.get(i), getParameterMetadata(i))); return(new SmileDeltaParameters(expiry, delta, perturbedValues, parameterMetadata)); }
public override InterpolatedNodalCurve withPerturbation(ParameterPerturbation perturbation) { int size = yValues.size(); DoubleArray perturbedValues = DoubleArray.of(size, i => perturbation(i, yValues.get(i), getParameterMetadata(i))); return(withYValues(perturbedValues)); }
public override ParameterizedFunctionalCurve withPerturbation(ParameterPerturbation perturbation) { int size = parameters.size(); DoubleArray perturbedValues = DoubleArray.of(size, i => perturbation(i, parameters.get(i), getParameterMetadata(i))); return(withParameters(perturbedValues)); }
public override ParallelShiftedCurve withPerturbation(ParameterPerturbation perturbation) { Curve bumpedCurve = underlyingCurve.withPerturbation(perturbation); int shiftIndex = underlyingCurve.ParameterCount; double bumpedShift = perturbation(shiftIndex, shiftAmount, getParameterMetadata(shiftIndex)); return(new ParallelShiftedCurve(bumpedCurve, shiftType, bumpedShift)); }
/// <summary> /// Applies a perturbation to each underlying. /// <para> /// The updated list of underlying instances is returned. /// /// </para> /// </summary> /// @param <R> the type of the underlying </param> /// <param name="underlyingType"> the type of the parameterized data at the specified index </param> /// <param name="perturbation"> the perturbation to apply </param> /// <returns> a parameterized data instance based on this with the specified parameter altered </returns> /// <exception cref="IndexOutOfBoundsException"> if the index is invalid </exception> public IList <R> withPerturbation <R>(Type <R> underlyingType, ParameterPerturbation perturbation) where R : ParameterizedData { ImmutableList.Builder <R> builder = ImmutableList.builder(); for (int i = 0; i < underlyings.Length; i++) { builder.add(underlyingWithPerturbation(i, underlyingType, perturbation)); } return(builder.build()); }
//------------------------------------------------------------------------- public virtual void test_withPerturbation() { ParameterPerturbation perturbation = (i, v, m) => v + i + 0.5d; ParameterizedDataCombiner test = ParameterizedDataCombiner.of(DATA1, DATA2, DATA3); IList <ParameterizedData> perturbed = test.withPerturbation(typeof(ParameterizedData), perturbation); assertEquals(perturbed[0], new TestingParameterizedData2(1.5d, 3.5d)); assertEquals(perturbed[1], new TestingParameterizedData(5.5d)); assertEquals(perturbed[2], new TestingParameterizedData2(7.5d, 9.5d)); }
public override CombinedCurve withPerturbation(ParameterPerturbation perturbation) { Curve newBaseCurve = baseCurve.withPerturbation((idx, value, meta) => perturbation(idx, baseCurve.getParameter(idx), baseCurve.getParameterMetadata(idx))); int offset = baseCurve.ParameterCount; Curve newSpreadCurve = spreadCurve.withPerturbation((idx, value, meta) => perturbation(idx + offset, spreadCurve.getParameter(idx), spreadCurve.getParameterMetadata(idx))); IList <ParameterMetadata> newParamMeta = Stream.concat(IntStream.range(0, newBaseCurve.ParameterCount).mapToObj(i => newBaseCurve.getParameterMetadata(i)), IntStream.range(0, newSpreadCurve.ParameterCount).mapToObj(i => newSpreadCurve.getParameterMetadata(i))).collect(toImmutableList()); return(CombinedCurve.of(newBaseCurve, newSpreadCurve, metadata.withParameterMetadata(newParamMeta))); }
//------------------------------------------------------------------------- public virtual void test_underlyingWithPerturbation() { ParameterPerturbation perturbation = (i, v, m) => v + i + 0.5d; ParameterizedDataCombiner test = ParameterizedDataCombiner.of(DATA1, DATA2, DATA3); assertEquals(test.underlyingWithPerturbation(0, typeof(TestingParameterizedData2), perturbation).getParameter(0), 1.5d); assertEquals(test.underlyingWithPerturbation(0, typeof(TestingParameterizedData2), perturbation).getParameter(1), 3.5d); assertEquals(test.underlyingWithPerturbation(1, typeof(TestingParameterizedData), perturbation).getParameter(0), 5.5d); assertEquals(test.underlyingWithPerturbation(2, typeof(TestingParameterizedData2), perturbation).getParameter(0), 7.5d); assertEquals(test.underlyingWithPerturbation(2, typeof(TestingParameterizedData2), perturbation).getParameter(1), 9.5d); }
public override AddFixedCurve withPerturbation(ParameterPerturbation perturbation) { return(new AddFixedCurve(fixedCurve, spreadCurve.withPerturbation(perturbation))); }
public NormalSwaptionExpiryStrikeVolatilities withPerturbation(ParameterPerturbation perturbation) { return(new NormalSwaptionExpiryStrikeVolatilities(convention, valuationDateTime, surface.withPerturbation(perturbation))); }
public SimplePriceIndexValues withPerturbation(ParameterPerturbation perturbation) { return(withCurve(curve.withPerturbation(perturbation))); }
public BlackBondFutureExpiryLogMoneynessVolatilities withPerturbation(ParameterPerturbation perturbation) { return(new BlackBondFutureExpiryLogMoneynessVolatilities(valuationDateTime, surface.withPerturbation(perturbation))); }
public BlackIborCapletFloorletExpiryStrikeVolatilities withPerturbation(ParameterPerturbation perturbation) { return(new BlackIborCapletFloorletExpiryStrikeVolatilities(index, valuationDateTime, surface.withPerturbation(perturbation))); }
public DiscountIborIndexRates withPerturbation(ParameterPerturbation perturbation) { return(withDiscountFactors(discountFactors.withPerturbation(perturbation))); }
public override SabrParameters withPerturbation(ParameterPerturbation perturbation) { return(new SabrParameters(paramCombiner.underlyingWithPerturbation(0, typeof(Curve), perturbation), paramCombiner.underlyingWithPerturbation(1, typeof(Curve), perturbation), paramCombiner.underlyingWithPerturbation(2, typeof(Curve), perturbation), paramCombiner.underlyingWithPerturbation(3, typeof(Curve), perturbation), paramCombiner.underlyingWithPerturbation(4, typeof(Curve), perturbation), sabrVolatilityFormula)); }
public override ConstantCurve withPerturbation(ParameterPerturbation perturbation) { return(new ConstantCurve(metadata, perturbation(0, yValue_Renamed, getParameterMetadata(0)))); }
public SimpleDiscountFactors withPerturbation(ParameterPerturbation perturbation) { return(withCurve(curve.withPerturbation(perturbation))); }
public BlackSwaptionExpiryTenorVolatilities withPerturbation(ParameterPerturbation perturbation) { return(new BlackSwaptionExpiryTenorVolatilities(convention, valuationDateTime, surface.withPerturbation(perturbation))); }
public ZeroRatePeriodicDiscountFactors withPerturbation(ParameterPerturbation perturbation) { return(withCurve(curve.withPerturbation(perturbation))); }
public override ConstantNodalCurve withPerturbation(ParameterPerturbation perturbation) { double perturbedValue = perturbation(0, yValue_Renamed, getParameterMetadata(0)); return(new ConstantNodalCurve(metadata, xValue, perturbedValue)); }
public DiscountFxForwardRates withPerturbation(ParameterPerturbation perturbation) { return(new DiscountFxForwardRates(currencyPair, fxRateProvider, paramCombiner.underlyingWithPerturbation(0, typeof(DiscountFactors), perturbation), paramCombiner.underlyingWithPerturbation(1, typeof(DiscountFactors), perturbation))); }
/// <summary> /// Applies a perturbation to the specified underlying. /// <para> /// This should be invoked once for each of the underlying instances. /// It is intended to be used to pass the result of each invocation to the /// constructor of the combined instance. /// /// </para> /// </summary> /// @param <R> the type of the underlying </param> /// <param name="underlyingIndex"> the index of the underlying instance </param> /// <param name="underlyingType"> the type of the parameterized data at the specified index </param> /// <param name="perturbation"> the perturbation to apply </param> /// <returns> a parameterized data instance based on this with the specified perturbation applied </returns> public R underlyingWithPerturbation <R>(int underlyingIndex, Type <R> underlyingType, ParameterPerturbation perturbation) where R : ParameterizedData { ParameterizedData underlying = underlyings[underlyingIndex]; // perturb using a derived perturbation that adjusts the index int adjustment = lookup[underlyingIndex]; ParameterizedData perturbed = underlying.withPerturbation((idx, value, meta) => perturbation(idx + adjustment, value, meta)); return(underlyingType.cast(perturbed)); }
public NormalIborFutureOptionExpirySimpleMoneynessVolatilities withPerturbation(ParameterPerturbation perturbation) { return(new NormalIborFutureOptionExpirySimpleMoneynessVolatilities(index, valuationDateTime, surface.withPerturbation(perturbation))); }
public ConstantRecoveryRates withPerturbation(ParameterPerturbation perturbation) { double perturbedValue = perturbation(0, recoveryRate_Renamed, getParameterMetadata(0)); return(new ConstantRecoveryRates(legalEntityId, valuationDate, perturbedValue)); }
public ForwardFxIndexRates withPerturbation(ParameterPerturbation perturbation) { return(withFxForwardRates(fxForwardRates.withPerturbation(perturbation))); }
public BlackFxOptionFlatVolatilities withPerturbation(ParameterPerturbation perturbation) { return(new BlackFxOptionFlatVolatilities(currencyPair, valuationDateTime, curve.withPerturbation(perturbation))); }
public SimpleIborIndexRates withPerturbation(ParameterPerturbation perturbation) { return(withCurve(curve.withPerturbation(perturbation))); }