Skip to content

Commit

Permalink
SXSD-7850: Allow for overriding cds/cdx product/trade pricers
Browse files Browse the repository at this point in the history
  • Loading branch information
ntaylorSolum committed May 24, 2024
1 parent f3f18f2 commit f62d153
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-examples</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<packaging>jar</packaging>
<name>Strata-Examples</name>
<description>Example code to demonstrate use of Strata</description>
Expand Down
2 changes: 1 addition & 1 deletion modules/basics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-basics</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/calc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-calc</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/collect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-collect</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-data</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-loader</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/market/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-market</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/math/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-math</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/measure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-measure</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<packaging>pom</packaging>
<name>Strata-Parent</name>
<description>OpenGamma Strata Parent</description>
Expand Down
2 changes: 1 addition & 1 deletion modules/pricer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-pricer</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class IsdaCdsProductPricer {
* <p>
* An approximation formula is used if a certain variable is smaller than this parameter.
*/
private static final double SMALL = 1.0e-5;
protected static final double SMALL = 1.0e-5;

/**
* The formula
Expand Down Expand Up @@ -496,7 +496,7 @@ public CurrencyAmount expectedLoss(

//-------------------------------------------------------------------------
// computes protection leg pv per unit notional
private double protectionLeg(
protected double protectionLeg(
ResolvedCds cds,
CreditDiscountFactors discountFactors,
LegalEntitySurvivalProbabilities survivalProbabilities,
Expand Down Expand Up @@ -554,7 +554,7 @@ private double protectionLeg(
}

// computes risky annuity
double riskyAnnuity(
protected double riskyAnnuity(
ResolvedCds cds,
CreditDiscountFactors discountFactors,
LegalEntitySurvivalProbabilities survivalProbabilities,
Expand Down Expand Up @@ -597,7 +597,7 @@ private double protectionLeg(
}

// computes accrual-on-default pv per unit notional for a single payment period
private double singlePeriodAccrualOnDefault(
protected double singlePeriodAccrualOnDefault(
CreditCouponPaymentPeriod coupon,
LocalDate effectiveStartDate,
DoubleArray integrationSchedule,
Expand Down Expand Up @@ -740,7 +740,7 @@ PointSensitivityBuilder protectionLegSensitivity(
return dfSensi.combinedWith(pvSensi);
}

private double computeExtendedEpsilon(double dhrt, double pn, double qn, double pd, double qd) {
protected double computeExtendedEpsilon(double dhrt, double pn, double qn, double pd, double qd) {
if (Math.abs(dhrt) < SMALL) {
return -0.5 - dhrt / 6d - dhrt * dhrt / 24d;
}
Expand Down Expand Up @@ -793,7 +793,7 @@ PointSensitivityBuilder riskyAnnuitySensitivity(
return dfSensi.combinedWith(pvSensi);
}

private Pair<Double, PointSensitivityBuilder> singlePeriodAccrualOnDefaultSensitivity(
protected Pair<Double, PointSensitivityBuilder> singlePeriodAccrualOnDefaultSensitivity(
CreditCouponPaymentPeriod coupon,
LocalDate effectiveStartDate,
DoubleArray integrationSchedule,
Expand Down Expand Up @@ -899,7 +899,7 @@ private Pair<Double, PointSensitivityBuilder> singlePeriodAccrualOnDefaultSensit
}

//-------------------------------------------------------------------------
private boolean isExpired(ResolvedCds cds, CreditRatesProvider ratesProvider) {
protected boolean isExpired(ResolvedCds cds, CreditRatesProvider ratesProvider) {
return !cds.getProtectionEndDate().isAfter(ratesProvider.getValuationDate());
}

Expand All @@ -914,7 +914,7 @@ void validateRecoveryRates(ResolvedCds cds, CreditRatesProvider ratesProvider) {
ArgChecker.isTrue(recoveryRates instanceof ConstantRecoveryRates, "recoveryRates must be ConstantRecoveryRates");
}

private Pair<CreditDiscountFactors, LegalEntitySurvivalProbabilities> reduceDiscountFactors(
protected Pair<CreditDiscountFactors, LegalEntitySurvivalProbabilities> reduceDiscountFactors(
ResolvedCds cds,
CreditRatesProvider ratesProvider) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ public IsdaCdsTradePricer(AccrualOnDefaultFormula formula) {
this.upfrontPricer = DiscountingPaymentPricer.DEFAULT;
}

/**
* The constructor with the product pricer specified.
* @param productPricer the product pricer
*/
public IsdaCdsTradePricer(IsdaCdsProductPricer productPricer) {
this.productPricer = productPricer;
this.upfrontPricer = DiscountingPaymentPricer.DEFAULT;
}

//-------------------------------------------------------------------------
/**
* Gets the accrual-on-default formula used in this pricer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public IsdaHomogenousCdsIndexProductPricer(AccrualOnDefaultFormula formula) {
this.underlyingPricer = new IsdaCdsProductPricer(formula);
}

/**
* The constructor with the product pricer specified.
*
* @param underlyingPricer the underlying CDS pricer
*/
public IsdaHomogenousCdsIndexProductPricer(IsdaCdsProductPricer underlyingPricer) {
this.underlyingPricer = underlyingPricer;
}

//-------------------------------------------------------------------------
/**
* Gets the accrual-on-default formula used in this pricer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ public IsdaHomogenousCdsIndexTradePricer(AccrualOnDefaultFormula formula) {
this.upfrontPricer = DiscountingPaymentPricer.DEFAULT;
}

/**
* The constructor with the product pricer specified.
*
* @param productPricer the product pricer
*/
public IsdaHomogenousCdsIndexTradePricer(IsdaHomogenousCdsIndexProductPricer productPricer) {
this.productPricer = productPricer;
this.upfrontPricer = DiscountingPaymentPricer.DEFAULT;
}

//-------------------------------------------------------------------------
/**
* Gets the accrual-on-default formula used in this pricer.
Expand Down
2 changes: 1 addition & 1 deletion modules/product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-product</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-report</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-root</artifactId>
<version>2.12.22-xplain-3</version>
<version>2.12.22-xplain-4</version>
<packaging>pom</packaging>
<name>Strata-Root</name>
<description>OpenGamma Strata root</description>
Expand Down

0 comments on commit f62d153

Please sign in to comment.