/** * Computes the first order sensitivities of a function of a LegalEntityDiscountingProvider to a double by finite difference. * <p> * The finite difference is computed by forward type. * The function should return a value in the same currency for any rates provider of LegalEntityDiscountingProvider. * * @param provider the rates provider * @param valueFn the function from a rate provider to a currency amount for which the sensitivity should be computed * @return the curve sensitivity */ public CurrencyParameterSensitivities sensitivity( LegalEntityDiscountingProvider provider, Function<ImmutableLegalEntityDiscountingProvider, CurrencyAmount> valueFn) { ImmutableLegalEntityDiscountingProvider immProv = provider.toImmutableLegalEntityDiscountingProvider(); CurrencyAmount valueInit = valueFn.apply(immProv); CurrencyParameterSensitivities discounting = sensitivity( immProv, valueFn, ImmutableLegalEntityDiscountingProvider.meta().repoCurves(), valueInit); CurrencyParameterSensitivities forward = sensitivity( immProv, valueFn, ImmutableLegalEntityDiscountingProvider.meta().issuerCurves(), valueInit); return discounting.combinedWith(forward); }