@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 97440432: // first return ((Triple<?, ?, ?>) bean).getFirst(); case -906279820: // second return ((Triple<?, ?, ?>) bean).getSecond(); case 110331239: // third return ((Triple<?, ?, ?>) bean).getThird(); } return super.propertyGet(bean, propertyName, quiet); }
@Test(dataProvider = "factory") public void test_of_getters(Object first, Object second, Object third) { Triple<Object, Object, Object> test = Triple.of(first, second, third); assertEquals(test.getFirst(), first); assertEquals(test.getSecond(), second); }
double notional = ((RatePaymentPeriod) referenceLeg.getPaymentPeriods().get(0)).getNotional(); double parSpread = Math.pow(-(convertedPv - referenceConvertedPv) / (df * notional) + 1.0d, 1.0d / fixedCompounded.getSecond()) - (1.0d + fixedCompounded.getThird()); return parSpread;
Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> rates = reduceDiscountFactors(cds, ratesProvider); double protectionFull = underlyingPricer.protectionFull( cds, rates.getFirst(), rates.getSecond(), referenceDate, effectiveStartDate); double rpv01 = underlyingPricer.riskyAnnuity( cds, rates.getFirst(), rates.getSecond(), referenceDate, stepinDate, effectiveStartDate, PriceType.CLEAN); double lgd = 1d - recoveryRate; double numTotal = cdsIndex.getLegalEntityIds().size();
/** * Calculates the expected loss of the CDS index product. * <p> * The expected loss is the (undiscounted) expected default settlement value paid by the protection seller. * The resulting value is always positive. * * @param cdsIndex the product * @param ratesProvider the rates provider * @return the expected loss */ public CurrencyAmount expectedLoss( ResolvedCdsIndex cdsIndex, CreditRatesProvider ratesProvider) { if (isExpired(cdsIndex, ratesProvider)) { return CurrencyAmount.of(cdsIndex.getCurrency(), 0d); } ResolvedCds cds = cdsIndex.toSingleNameCds(); double recoveryRate = underlyingPricer.recoveryRate(cds, ratesProvider); Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> rates = reduceDiscountFactors(cds, ratesProvider); double survivalProbability = rates.getSecond().survivalProbability(cds.getProtectionEndDate()); double el = (1d - recoveryRate) * (1d - survivalProbability) * rates.getThird(); return CurrencyAmount.of(cds.getCurrency(), Math.abs(cds.getNotional()) * el); }
metadata, capletNodes.getFirst(), capletNodes.getSecond(), capletNodes.getThird(), INTERPOLATOR); DoubleMatrix penaltyMatrix = directDefinition.computePenaltyMatrix(strikes, capletExpiries); POSITIVE); InterpolatedNodalSurface resSurface = InterpolatedNodalSurface.of( metadata, capletNodes.getFirst(), capletNodes.getSecond(), res.getFitParameters(), directDefinition.getInterpolator()); return IborCapletFloorletVolatilityCalibrationResult.ofLeastSquare(volatilitiesFunction.apply(resSurface), res.getChiSq());
double df = provider.discountFactor(ccyFixedLeg, payment.getPaymentDate()); return Math.pow(-(otherLegsConvertedPv + fixedLegEventsPv) / (notional * df) + 1.0d, 1.0 / fixedCompounded.getSecond()) - 1.0d;
convertedPvDr.combinedWith(referenceConvertedPvDr.multipliedBy(-1)).multipliedBy(-1.0d / (df * notional)) .combinedWith(dfDr.multipliedBy((convertedPv - referenceConvertedPv) / (df * df * notional))) .multipliedBy(1.0d / fixedCompounded.getSecond() * Math.pow(-(convertedPv - referenceConvertedPv) / (df * notional) + 1.0d, 1.0d / fixedCompounded.getSecond() - 1.0d)); return dParSpreadDr;
cds, rates.getFirst(), rates.getSecond(), referenceDate, effectiveStartDate, recoveryRate); protectionLegSensi = protectionLegSensi.multipliedBy(signedNotional * rates.getThird()); PointSensitivityBuilder riskyAnnuitySensi = underlyingPricer.riskyAnnuitySensitivity( cds, rates.getFirst(), rates.getSecond(), referenceDate, stepinDate, effectiveStartDate); riskyAnnuitySensi = riskyAnnuitySensi.multipliedBy(-cds.getFixedRate() * signedNotional * rates.getThird());
Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> rates = reduceDiscountFactors(cds, ratesProvider); double protectionLeg = (1d - recoveryRate) * underlyingPricer.protectionFull(cds, rates.getFirst(), rates.getSecond(), referenceDate, effectiveStartDate); double rpv01 = underlyingPricer.riskyAnnuity( cds, rates.getFirst(), rates.getSecond(), referenceDate, stepinDate, effectiveStartDate, priceType); double amount = cds.getBuySell().normalize(cds.getNotional()) * rates.getThird() * (protectionLeg - rpv01 * cds.getFixedRate());
/** * Calculates the risky PV01 of the CDS index product. * <p> * RPV01 is defined as minus of the present value sensitivity to coupon rate. * * @param cdsIndex the product * @param ratesProvider the rates provider * @param referenceDate the reference date * @param priceType the price type * @param refData the reference date * @return the RPV01 */ public CurrencyAmount rpv01( ResolvedCdsIndex cdsIndex, CreditRatesProvider ratesProvider, LocalDate referenceDate, PriceType priceType, ReferenceData refData) { if (isExpired(cdsIndex, ratesProvider)) { return CurrencyAmount.of(cdsIndex.getCurrency(), 0d); } ResolvedCds cds = cdsIndex.toSingleNameCds(); LocalDate stepinDate = cds.getStepinDateOffset().adjust(ratesProvider.getValuationDate(), refData); LocalDate effectiveStartDate = cds.calculateEffectiveStartDate(stepinDate); Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> rates = reduceDiscountFactors(cds, ratesProvider); double riskyAnnuity = underlyingPricer.riskyAnnuity( cds, rates.getFirst(), rates.getSecond(), referenceDate, stepinDate, effectiveStartDate, priceType); double amount = cds.getBuySell().normalize(cds.getNotional()) * riskyAnnuity * rates.getThird(); return CurrencyAmount.of(cds.getCurrency(), amount); }
Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> rates = reduceDiscountFactors(cds, ratesProvider); double protectionFull = underlyingPricer.protectionFull(cds, rates.getFirst(), rates.getSecond(), referenceDate, effectiveStartDate); double amount = -cds.getBuySell().normalize(cds.getNotional()) * protectionFull * rates.getThird(); return CurrencyAmount.of(cds.getCurrency(), amount);