/** * Gets the currency. * <p> * The currency that discount factors are provided for. * * @return the currency */ public Currency getCurrency() { return discountFactors.getCurrency(); }
/** * Gets the currency. * <p> * The currency that discount factors are provided for. * * @return the currency */ public Currency getCurrency() { return discountFactors.getCurrency(); }
/** * Calculates the zero rate point sensitivity at the specified year fraction. * <p> * This returns a sensitivity instance referring to the zero rate sensitivity of the * points that were queried in the market data. * The sensitivity typically has the value {@code (-discountFactor * yearFraction)}. * The sensitivity refers to the result of {@link #discountFactor(LocalDate)}. * <p> * The year fraction must be based on {@code #relativeYearFraction(LocalDate)}. * * @param yearFraction the year fraction * @return the point sensitivity of the zero rate * @throws RuntimeException if the result cannot be calculated */ public default ZeroRateSensitivity zeroRatePointSensitivity(double yearFraction) { return zeroRatePointSensitivity(yearFraction, getCurrency()); }
private DiscountFactors createDiscountFactors(DiscountFactors originalDsc, Curve bumpedCurve) { if (originalDsc instanceof ZeroRateDiscountFactors) { return ZeroRateDiscountFactors.of(originalDsc.getCurrency(), originalDsc.getValuationDate(), bumpedCurve); } else if (originalDsc instanceof SimpleDiscountFactors) { return SimpleDiscountFactors.of(originalDsc.getCurrency(), originalDsc.getValuationDate(), bumpedCurve); } throw new IllegalArgumentException("Not supported"); }
/** * Calculates the zero rate point sensitivity with z-spread at the specified year fraction. * <p> * This returns a sensitivity instance referring to the zero rate sensitivity of the * points that were queried in the market data. * The sensitivity refers to the result of {@link #discountFactorWithSpread(LocalDate, double, CompoundedRateType, int)}. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or periodic * compounded rates of the discounting curve. * <p> * The year fraction must be based on {@code #relativeYearFraction(LocalDate)}. * * @param yearFraction the year fraction * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodsPerYear the number of periods per year * @return the point sensitivity of the zero rate * @throws RuntimeException if the result cannot be calculated */ public default ZeroRateSensitivity zeroRatePointSensitivityWithSpread( double yearFraction, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { return zeroRatePointSensitivityWithSpread(yearFraction, getCurrency(), zSpread, compoundedRateType, periodsPerYear); }
@Override public ImmutableSet<Currency> getDiscountCurrencies() { if (discountFactors != null) { return ImmutableSet.of(discountFactors.getCurrency()); } return ImmutableSet.of(); }
public void test_of_zeroRate() { DiscountFactors test = DiscountFactors.of(GBP, DATE_VAL, CURVE_ZERO); assertEquals(test instanceof ZeroRateDiscountFactors, true); assertEquals(test.getCurrency(), GBP); assertEquals(test.getValuationDate(), DATE_VAL); }
public void test_of_discountFactors() { DiscountFactors test = DiscountFactors.of(GBP, DATE_VAL, CURVE_DF); assertEquals(test instanceof SimpleDiscountFactors, true); assertEquals(test.getCurrency(), GBP); assertEquals(test.getValuationDate(), DATE_VAL); }
public void test_of_zeroRatePeriodic() { DiscountFactors test = DiscountFactors.of(GBP, DATE_VAL, CURVE_ZERO_PERIODIC); assertEquals(test instanceof ZeroRatePeriodicDiscountFactors, true); assertEquals(test.getCurrency(), GBP); assertEquals(test.getValuationDate(), DATE_VAL); }
JodaBeanUtils.notNull(baseCurrencyDiscountFactors, "baseCurrencyDiscountFactors"); JodaBeanUtils.notNull(counterCurrencyDiscountFactors, "counterCurrencyDiscountFactors"); if (!baseCurrencyDiscountFactors.getCurrency().equals(currencyPair.getBase())) { throw new IllegalArgumentException(Messages.format( "Index base currency {} did not match discount factor base currency {}", currencyPair.getBase(), baseCurrencyDiscountFactors.getCurrency())); if (!counterCurrencyDiscountFactors.getCurrency().equals(currencyPair.getCounter())) { throw new IllegalArgumentException(Messages.format( "Index counter currency {} did not match discount factor counter currency {}", currencyPair.getCounter(), counterCurrencyDiscountFactors.getCurrency()));
public void test_discountFactors() { ImmutableRatesProvider test = ImmutableRatesProvider.builder(VAL_DATE) .discountCurve(GBP, DISCOUNT_CURVE_GBP) .discountCurve(USD, DISCOUNT_CURVE_USD) .build(); assertEquals(test.discountFactors(GBP).getCurrency(), GBP); }
private CurrencyParameterSensitivities sensiFnBond(ImmutableLegalEntityDiscountingProvider provider) { CurrencyParameterSensitivities sensi = CurrencyParameterSensitivities.empty(); double sum = sum(provider); // repo curves ImmutableMap<Pair<RepoGroup, Currency>, DiscountFactors> mapRepoCurves = provider.getRepoCurves(); for (Entry<Pair<RepoGroup, Currency>, DiscountFactors> entry : mapRepoCurves.entrySet()) { DiscountFactors discountFactors = entry.getValue(); InterpolatedNodalCurve curve = (InterpolatedNodalCurve) getCurve(discountFactors); sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(curve.getName(), discountFactors.getCurrency(), DoubleArray.of(discountFactors.getParameterCount(), i -> 2d * curve.getXValues().get(i) * sum))); } // issuer curves ImmutableMap<Pair<LegalEntityGroup, Currency>, DiscountFactors> mapIssuerCurves = provider.getIssuerCurves(); for (Entry<Pair<LegalEntityGroup, Currency>, DiscountFactors> entry : mapIssuerCurves.entrySet()) { DiscountFactors discountFactors = entry.getValue(); InterpolatedNodalCurve curve = (InterpolatedNodalCurve) getCurve(discountFactors); sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(curve.getName(), discountFactors.getCurrency(), DoubleArray.of(discountFactors.getParameterCount(), i -> 2d * curve.getXValues().get(i) * sum))); } return sensi; }