Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ public double protectionLeg(
//-------------------------------------------------------------------------
/**
* Calculates the risky annuity, which is RPV01 per unit notional.
* <p>
* Zero is returned if the CDS already expired.
*
* @param cds the product
* @param ratesProvider the rates provider
Expand All @@ -347,6 +349,36 @@ public double riskyAnnuity(
return riskyAnnuity(cds, rates.getFirst(), rates.getSecond(), referenceDate, stepinDate, effectiveStartDate, priceType);
}

/**
* Calculates the risky annuity sensitivity of the product.
* <p>
* The risky annuity sensitivity of the product is the sensitivity of risky annuity to the underlying curves.
* The resulting sensitivity is based on the currency of the CDS product.
* <p>
* Empty sensitivity is returned if the CDS already expired.
*
* @param cds the product
* @param ratesProvider the rates provider
* @param referenceDate the reference date
* @param refData the reference data
* @return the risky annuity sensitivity
*/
public PointSensitivityBuilder riskyAnnuitySensitivity(
Comment thread
jodastephen marked this conversation as resolved.
ResolvedCds cds,
CreditRatesProvider ratesProvider,
LocalDate referenceDate,
ReferenceData refData) {

if (isExpired(cds, ratesProvider)) {
return PointSensitivityBuilder.none();
}
LocalDate stepinDate = cds.getStepinDateOffset().adjust(ratesProvider.getValuationDate(), refData);
LocalDate effectiveStartDate = cds.calculateEffectiveStartDate(stepinDate);
Pair<CreditDiscountFactors, LegalEntitySurvivalProbabilities> rates = reduceDiscountFactors(cds, ratesProvider);
return riskyAnnuitySensitivity(
cds, rates.getFirst(), rates.getSecond(), referenceDate, stepinDate, effectiveStartDate);
}

//-------------------------------------------------------------------------
/**
* Calculates the risky PV01 of the CDS product.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,68 @@ public CurrencyAmount rpv01(
return CurrencyAmount.of(cds.getCurrency(), amount);
}

//-------------------------------------------------------------------------
/**
* Calculates the risky annuity, which is RPV01 per unit notional.
* <p>
* Zero is returned if the CDS index already expired.
*
* @param cdsIndex the product
* @param ratesProvider the rates provider
* @param referenceDate the reference date
* @param priceType the price type
* @param refData the reference data
* @return the risky annuity
*/
public double riskyAnnuity(
ResolvedCdsIndex cdsIndex,
CreditRatesProvider ratesProvider,
LocalDate referenceDate,
PriceType priceType,
ReferenceData refData) {

if (isExpired(cdsIndex, ratesProvider)) {
return 0d;
Comment thread
jodastephen marked this conversation as resolved.
}
ResolvedCds cds = cdsIndex.toSingleNameCds();
LocalDate stepinDate = cdsIndex.getStepinDateOffset().adjust(ratesProvider.getValuationDate(), refData);
LocalDate effectiveStartDate = cdsIndex.calculateEffectiveStartDate(stepinDate);
Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> rates = reduceDiscountFactors(cds, ratesProvider);
return underlyingPricer.riskyAnnuity(
cds, rates.getFirst(), rates.getSecond(), referenceDate, stepinDate, effectiveStartDate, priceType);
}

/**
* Calculates the risky annuity sensitivity of the product.
* <p>
* The risky annuity sensitivity of the product is the sensitivity of risky annuity to the underlying curves.
* The resulting sensitivity is based on the currency of the CDS index product.
* <p>
* Empty sensitivity is returned if the CDS index already expired.
*
* @param cdsIndex the product
* @param ratesProvider the rates provider
* @param referenceDate the reference date
* @param refData the reference data
* @return the risky annuity sensitivity
*/
public PointSensitivityBuilder riskyAnnuitySensitivity(
ResolvedCdsIndex cdsIndex,
CreditRatesProvider ratesProvider,
LocalDate referenceDate,
ReferenceData refData) {

if (isExpired(cdsIndex, ratesProvider)) {
return PointSensitivityBuilder.none();
Comment thread
jodastephen marked this conversation as resolved.
}
LocalDate stepinDate = cdsIndex.getStepinDateOffset().adjust(ratesProvider.getValuationDate(), refData);
LocalDate effectiveStartDate = cdsIndex.calculateEffectiveStartDate(stepinDate);
ResolvedCds cds = cdsIndex.toSingleNameCds();
Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> rates = reduceDiscountFactors(cds, ratesProvider);
return underlyingPricer.riskyAnnuitySensitivity(
cds, rates.getFirst(), rates.getSecond(), referenceDate, stepinDate, effectiveStartDate);
}

//-------------------------------------------------------------------------
/**
* Calculates the recovery01 of the CDS index product.
Expand Down
Loading