From d5ebed3d85143d5ad12e10bef45624771fff0abe Mon Sep 17 00:00:00 2001 From: ntaylorSolum Date: Wed, 15 May 2024 15:15:54 +0100 Subject: [PATCH] SXSD-7850: Allow for overriding cds/cdx product/trade pricers --- examples/pom.xml | 2 +- modules/basics/pom.xml | 2 +- modules/calc/pom.xml | 2 +- modules/collect/pom.xml | 2 +- modules/data/pom.xml | 2 +- modules/loader/pom.xml | 2 +- modules/market/pom.xml | 2 +- modules/math/pom.xml | 2 +- modules/measure/pom.xml | 2 +- modules/pom.xml | 2 +- modules/pricer/pom.xml | 2 +- .../pricer/credit/IsdaCdsProductPricer.java | 16 ++++++++-------- .../strata/pricer/credit/IsdaCdsTradePricer.java | 9 +++++++++ .../IsdaCompliantCreditCurveCalibrator.java | 2 +- .../IsdaHomogenousCdsIndexProductPricer.java | 9 +++++++++ .../IsdaHomogenousCdsIndexTradePricer.java | 10 ++++++++++ .../credit/SpreadSensitivityCalculator.java | 2 +- modules/product/pom.xml | 2 +- modules/report/pom.xml | 2 +- pom.xml | 2 +- 20 files changed, 52 insertions(+), 24 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index 00aeddc62a..404ebaad5e 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -10,7 +10,7 @@ com.opengamma.strata strata-examples - 2.12.22-xplain-3 + 2.12.22-xplain-4 jar Strata-Examples Example code to demonstrate use of Strata diff --git a/modules/basics/pom.xml b/modules/basics/pom.xml index 76e0e56a70..b628188a06 100644 --- a/modules/basics/pom.xml +++ b/modules/basics/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-basics diff --git a/modules/calc/pom.xml b/modules/calc/pom.xml index 3173c50eb2..bb8058f6b1 100644 --- a/modules/calc/pom.xml +++ b/modules/calc/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-calc diff --git a/modules/collect/pom.xml b/modules/collect/pom.xml index 053d791e78..335b71f659 100644 --- a/modules/collect/pom.xml +++ b/modules/collect/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-collect diff --git a/modules/data/pom.xml b/modules/data/pom.xml index 080595495b..197e07948c 100644 --- a/modules/data/pom.xml +++ b/modules/data/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-data diff --git a/modules/loader/pom.xml b/modules/loader/pom.xml index 99b1536188..bc23b9b139 100644 --- a/modules/loader/pom.xml +++ b/modules/loader/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-loader diff --git a/modules/market/pom.xml b/modules/market/pom.xml index bcc4fcaca3..fa776d7e46 100644 --- a/modules/market/pom.xml +++ b/modules/market/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-market diff --git a/modules/math/pom.xml b/modules/math/pom.xml index 6cce21d600..47af3da6b5 100644 --- a/modules/math/pom.xml +++ b/modules/math/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-math diff --git a/modules/measure/pom.xml b/modules/measure/pom.xml index 4823de9778..7c1a71c3f7 100644 --- a/modules/measure/pom.xml +++ b/modules/measure/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-measure diff --git a/modules/pom.xml b/modules/pom.xml index 6ebc2541b2..e5aee95364 100644 --- a/modules/pom.xml +++ b/modules/pom.xml @@ -10,7 +10,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 pom Strata-Parent OpenGamma Strata Parent diff --git a/modules/pricer/pom.xml b/modules/pricer/pom.xml index a8a8dd9e65..0a09bd5c35 100644 --- a/modules/pricer/pom.xml +++ b/modules/pricer/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-pricer diff --git a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCdsProductPricer.java b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCdsProductPricer.java index f3ef991a9e..c2347a974c 100644 --- a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCdsProductPricer.java +++ b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCdsProductPricer.java @@ -44,7 +44,7 @@ public class IsdaCdsProductPricer { *

* 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 @@ -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, @@ -554,7 +554,7 @@ private double protectionLeg( } // computes risky annuity - double riskyAnnuity( + protected double riskyAnnuity( ResolvedCds cds, CreditDiscountFactors discountFactors, LegalEntitySurvivalProbabilities survivalProbabilities, @@ -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, @@ -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; } @@ -793,7 +793,7 @@ PointSensitivityBuilder riskyAnnuitySensitivity( return dfSensi.combinedWith(pvSensi); } - private Pair singlePeriodAccrualOnDefaultSensitivity( + protected Pair singlePeriodAccrualOnDefaultSensitivity( CreditCouponPaymentPeriod coupon, LocalDate effectiveStartDate, DoubleArray integrationSchedule, @@ -899,7 +899,7 @@ private Pair singlePeriodAccrualOnDefaultSensit } //------------------------------------------------------------------------- - private boolean isExpired(ResolvedCds cds, CreditRatesProvider ratesProvider) { + protected boolean isExpired(ResolvedCds cds, CreditRatesProvider ratesProvider) { return !cds.getProtectionEndDate().isAfter(ratesProvider.getValuationDate()); } @@ -914,7 +914,7 @@ void validateRecoveryRates(ResolvedCds cds, CreditRatesProvider ratesProvider) { ArgChecker.isTrue(recoveryRates instanceof ConstantRecoveryRates, "recoveryRates must be ConstantRecoveryRates"); } - private Pair reduceDiscountFactors( + protected Pair reduceDiscountFactors( ResolvedCds cds, CreditRatesProvider ratesProvider) { diff --git a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCdsTradePricer.java b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCdsTradePricer.java index 53db215149..a7e886bacc 100644 --- a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCdsTradePricer.java +++ b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCdsTradePricer.java @@ -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. diff --git a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCompliantCreditCurveCalibrator.java b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCompliantCreditCurveCalibrator.java index 7f5580e50d..1f8783136f 100644 --- a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCompliantCreditCurveCalibrator.java +++ b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaCompliantCreditCurveCalibrator.java @@ -324,7 +324,7 @@ public abstract NodalCurve calibrate( RecoveryRates recoveryRates, ReferenceData refData); - private double[] getStandardQuoteForm(ResolvedCdsTrade calibrationCds, CdsQuote marketQuote, LocalDate valuationDate, + private double[] getStandardQuoteForm(ResolvedCdsTrade calibrationCds, CdsQuote marketQuote, LocalDate valuationDate, CreditDiscountFactors discountFactors, RecoveryRates recoveryRates, boolean computeJacobian, ReferenceData refData) { double[] res = new double[3]; diff --git a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaHomogenousCdsIndexProductPricer.java b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaHomogenousCdsIndexProductPricer.java index 564b6edfe2..b8d22ee544 100644 --- a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaHomogenousCdsIndexProductPricer.java +++ b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaHomogenousCdsIndexProductPricer.java @@ -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. diff --git a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaHomogenousCdsIndexTradePricer.java b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaHomogenousCdsIndexTradePricer.java index 043153dc57..942947ace5 100644 --- a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaHomogenousCdsIndexTradePricer.java +++ b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/IsdaHomogenousCdsIndexTradePricer.java @@ -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. diff --git a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/SpreadSensitivityCalculator.java b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/SpreadSensitivityCalculator.java index 0169c01785..3355c26ca6 100644 --- a/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/SpreadSensitivityCalculator.java +++ b/modules/pricer/src/main/java/com/opengamma/strata/pricer/credit/SpreadSensitivityCalculator.java @@ -149,7 +149,7 @@ public CurrencyParameterSensitivity bucketedCs01( * @param refData the reference data * @return the bucketed CS01 */ - public CurrencyParameterSensitivity bucketedCs01( + public CurrencyParameterSensitivity bucketedCs01( ResolvedCdsTrade trade, List bucketCds, CreditRatesProvider ratesProvider, diff --git a/modules/product/pom.xml b/modules/product/pom.xml index 3f7c1fe0f1..dc1289f51e 100644 --- a/modules/product/pom.xml +++ b/modules/product/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-product diff --git a/modules/report/pom.xml b/modules/report/pom.xml index 75b3fd5cc0..bb736e81eb 100644 --- a/modules/report/pom.xml +++ b/modules/report/pom.xml @@ -5,7 +5,7 @@ com.opengamma.strata strata-parent - 2.12.22-xplain-3 + 2.12.22-xplain-4 .. strata-report diff --git a/pom.xml b/pom.xml index ae5279538a..bee3389862 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.opengamma.strata strata-root - 2.12.22-xplain-3 + 2.12.22-xplain-4 pom Strata-Root OpenGamma Strata root