diff --git a/ReleaseNotes/01_25_2018.txt b/ReleaseNotes/01_25_2018.txt new file mode 100644 index 000000000000..fa540961208d --- /dev/null +++ b/ReleaseNotes/01_25_2018.txt @@ -0,0 +1,47 @@ + +Features: + + - BK Hedge Error Dual Bond (1) + - BK Semi Replication Dual Bond (2) + - Gold Plated Two Way CSA (3) + - Burgard Kjaer One Way CSA (4) + - Burgard Kjaer Set Off Scheme (5) + - XVA Dynamics Path Simulator Scheme (6) + - Path Simulator Position Replicator Scheme (7, 8) + - Path Simulator Vertex Generation Scheme (9, 10) + - Albanese Andersen Vertex Generation Scheme (11, 12) + - Path Simulator Scheme Hedge Error (14) + - Path Simulator Scheme Close Out (15) + - Path Simulator Scheme Constructor Annotation (16, 17, 18) + - Path Simulator Scheme Albanese Andersen (19, 20) + - Albanese Andersen Unit Position Value (21) + - Path Simulator Collateral Group Vertex (23) + - Burgard Kjaer Hedge Error Dual (24) + - Burgard Kjaer Semi Replication Dual (25) + - Burgard Kjaer Two Way CSA (26) + - Burgard Kjaer One Way CSA (27) + - Burgard Kjaer Two Way CSA (28) + - Dynamics Adjustment Digest Scheme (31) + - Path Simulator Adjustment Scheme #1 (32, 33) + - Dynamics Broken Date Interpolation Scheme (36, 37, 38) + - Path Simulator Interpolator Scheme #1 (39, 40) + - Path Simulator Interpolator Scheme #2 (41, 42) + - Position Value Collateral Balance Array (43, 44) + - Path Simulator Interpolator Scheme #3 (45, 46) + - Path Simulator Interpolator Scheme #4 (47, 48) + - Path Simulator Interpolator Scheme #5 (49, 50) + - Path Simulator Interpolator Scheme #6 (51, 52) + - Path Simulator Three Point Brownian (53) + - Market Vertex Generator Correlation #1 (55, 56) + - Market Vertex Generator Correlation #2 (57, 58) + + +Bug Fixes/Clean-up: + +Samples: + + - Basel Fix Float Digest #1 (13) + - Basel Fix Float Digest #2 (22) + - Albanese Andersen Basel Proxy #1 (29, 30) + - Albanese Andersen Basel Proxy #2 (34, 35) + - Albanese Andersen Basel Proxy #3 (54) diff --git a/gradle.properties b/gradle.properties index 225f3423bc74..91d781f237b2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ release.scope=patch -release.version=3.27.0-SNAPSHOT +release.version=3.28.0-SNAPSHOT org.gradle.jvmargs=-Xmx4000m diff --git a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAAttribution.java b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAAttribution.java index f5a9e499986c..b36987b30667 100644 --- a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAAttribution.java +++ b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAAttribution.java @@ -409,7 +409,6 @@ public static final void main ( MarketVertexGenerator mvg = new MarketVertexGenerator ( iSpotDate, aiVertexDate, - aadblCorrelationMatrix, tc, deBankHazardRate, deBankSeniorRecoveryRate, @@ -462,7 +461,10 @@ public static final void main ( ) ); - MarketVertex[] aMV = mvg.marketVertex (mvInitial); + MarketVertex[] aMV = mvg.marketVertex ( + mvInitial, + aadblCorrelationMatrix + ); double dblDerivativeValue = dblTerminalXVADerivativeValue; double dblDerivativeXVAValue = dblTerminalXVADerivativeValue; diff --git a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAExplain.java b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAExplain.java index a8bd810c2d95..092f5e415225 100644 --- a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAExplain.java +++ b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAExplain.java @@ -410,7 +410,6 @@ public static final void main ( MarketVertexGenerator mvg = new MarketVertexGenerator ( iSpotDate, aiVertexDate, - aadblCorrelationMatrix, tc, deBankHazardRate, deBankSeniorRecoveryRate, @@ -463,7 +462,10 @@ public static final void main ( ) ); - MarketVertex[] aMV = mvg.marketVertex (mvInitial); + MarketVertex[] aMV = mvg.marketVertex ( + mvInitial, + aadblCorrelationMatrix + ); double dblDerivativeValue = dblTerminalXVADerivativeValue; double dblDerivativeXVAValue = dblTerminalXVADerivativeValue; diff --git a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAGreeks.java b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAGreeks.java index 7ad9cf076560..13a2b6a6f0ce 100644 --- a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAGreeks.java +++ b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAGreeks.java @@ -408,7 +408,6 @@ public static final void main ( MarketVertexGenerator mvg = new MarketVertexGenerator ( iSpotDate, aiVertexDate, - aadblCorrelationMatrix, tc, deBankHazardRate, deBankSeniorRecoveryRate, @@ -461,7 +460,10 @@ public static final void main ( ) ); - MarketVertex[] aMV = mvg.marketVertex (mvInitial); + MarketVertex[] aMV = mvg.marketVertex ( + mvInitial, + aadblCorrelationMatrix + ); double dblDerivativeValue = dblTerminalXVADerivativeValue; double dblDerivativeXVAValue = dblTerminalXVADerivativeValue; diff --git a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAReplicationPortfolio.java b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAReplicationPortfolio.java index 2f3f16f53844..c6937a768314 100644 --- a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAReplicationPortfolio.java +++ b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAReplicationPortfolio.java @@ -408,7 +408,6 @@ public static final void main ( MarketVertexGenerator mvg = new MarketVertexGenerator ( iSpotDate, aiVertexDate, - aadblCorrelationMatrix, tc, deBankHazardRate, deBankSeniorRecoveryRate, @@ -461,7 +460,10 @@ public static final void main ( ) ); - MarketVertex[] aMV = mvg.marketVertex (mvInitial); + MarketVertex[] aMV = mvg.marketVertex ( + mvInitial, + aadblCorrelationMatrix + ); double dblDerivativeValue = dblTerminalXVADerivativeValue; double dblDerivativeXVAValue = dblTerminalXVADerivativeValue; diff --git a/src/main/java/org/drip/sample/burgard2011/XVAExplain.java b/src/main/java/org/drip/sample/burgard2011/XVAExplain.java index 25a85f3bfe7c..1cf1f63f2862 100644 --- a/src/main/java/org/drip/sample/burgard2011/XVAExplain.java +++ b/src/main/java/org/drip/sample/burgard2011/XVAExplain.java @@ -410,7 +410,6 @@ public static void main ( MarketVertexGenerator mvg = new MarketVertexGenerator ( iSpotDate, aiVertexDate, - aadblCorrelationMatrix, tc, deBankHazardRate, deBankSeniorRecoveryRate, @@ -463,7 +462,10 @@ public static void main ( ) ); - MarketVertex[] aMV = mvg.marketVertex (mvInitial); + MarketVertex[] aMV = mvg.marketVertex ( + mvInitial, + aadblCorrelationMatrix + ); double dblDerivativeValue = dblTerminalXVADerivativeValue; double dblDerivativeXVAValue = dblTerminalXVADerivativeValue; diff --git a/src/main/java/org/drip/sample/burgard2011/XVAGreeks.java b/src/main/java/org/drip/sample/burgard2011/XVAGreeks.java index 827f34748c6a..bbb7a6f2e04d 100644 --- a/src/main/java/org/drip/sample/burgard2011/XVAGreeks.java +++ b/src/main/java/org/drip/sample/burgard2011/XVAGreeks.java @@ -399,7 +399,6 @@ public static void main ( MarketVertexGenerator mvg = new MarketVertexGenerator ( iSpotDate, aiVertexDate, - aadblCorrelationMatrix, tc, deBankHazardRate, deBankSeniorRecoveryRate, @@ -452,7 +451,10 @@ public static void main ( ) ); - MarketVertex[] aMV = mvg.marketVertex (mvInitial); + MarketVertex[] aMV = mvg.marketVertex ( + mvInitial, + aadblCorrelationMatrix + ); double dblDerivativeValue = dblTerminalXVADerivativeValue; double dblDerivativeXVAValue = dblTerminalXVADerivativeValue; diff --git a/src/main/java/org/drip/sample/burgard2011/XVAMarketGeneration.java b/src/main/java/org/drip/sample/burgard2011/XVAMarketGeneration.java index 52d85bb17486..db01ebea1d1a 100644 --- a/src/main/java/org/drip/sample/burgard2011/XVAMarketGeneration.java +++ b/src/main/java/org/drip/sample/burgard2011/XVAMarketGeneration.java @@ -267,7 +267,6 @@ public static final void main ( MarketVertexGenerator mvg = new MarketVertexGenerator ( iSpotDate, aiVertexDate, - aadblCorrelationMatrix, new TradeablesContainer ( tAsset, tOvernightIndex, @@ -327,7 +326,10 @@ public static final void main ( ) ); - MarketVertex[] aMV = mvg.marketVertex (mvInitial); + MarketVertex[] aMV = mvg.marketVertex ( + mvInitial, + aadblCorrelationMatrix + ); System.out.println(); diff --git a/src/main/java/org/drip/sample/burgard2011/XVAReplicationPortfolio.java b/src/main/java/org/drip/sample/burgard2011/XVAReplicationPortfolio.java index d7027122f187..444e3a36b204 100644 --- a/src/main/java/org/drip/sample/burgard2011/XVAReplicationPortfolio.java +++ b/src/main/java/org/drip/sample/burgard2011/XVAReplicationPortfolio.java @@ -409,7 +409,6 @@ public static void main ( MarketVertexGenerator mvg = new MarketVertexGenerator ( iSpotDate, aiVertexDate, - aadblCorrelationMatrix, tc, deBankHazardRate, deBankSeniorRecoveryRate, @@ -462,7 +461,10 @@ public static void main ( ) ); - MarketVertex[] aMV = mvg.marketVertex (mvInitial); + MarketVertex[] aMV = mvg.marketVertex ( + mvInitial, + aadblCorrelationMatrix + ); double dblDerivativeValue = dblTerminalXVADerivativeValue; double dblDerivativeXVAValue = dblTerminalXVADerivativeValue; diff --git a/src/main/java/org/drip/sample/burgard2012/EulerTrajectoryEvolutionScheme.java b/src/main/java/org/drip/sample/burgard2012/EulerTrajectoryEvolutionScheme.java index 965eb8029d6a..c49fcfd68811 100644 --- a/src/main/java/org/drip/sample/burgard2012/EulerTrajectoryEvolutionScheme.java +++ b/src/main/java/org/drip/sample/burgard2012/EulerTrajectoryEvolutionScheme.java @@ -284,7 +284,6 @@ public static final void main ( MarketVertexGenerator mvg = new MarketVertexGenerator ( iSpotDate, aiVertexDate, - aadblCorrelationMatrix, tc, deBankHazardRate, deBankSeniorRecoveryRate, @@ -337,7 +336,10 @@ public static final void main ( ) ); - MarketVertex[] aMVBase = mvg.marketVertex (mvInitial); + MarketVertex[] aMVBase = mvg.marketVertex ( + mvInitial, + aadblCorrelationMatrix + ); MarketVertex[] aMV = new MarketVertex[aMVBase.length]; double dblDerivativeValue = dblTerminalXVADerivativeValue; diff --git a/src/main/java/org/drip/sample/xvasimulation/BaselFixFloatDigest.java b/src/main/java/org/drip/sample/xvafixfloat/AlbaneseAndersenBaselProxy.java similarity index 97% rename from src/main/java/org/drip/sample/xvasimulation/BaselFixFloatDigest.java rename to src/main/java/org/drip/sample/xvafixfloat/AlbaneseAndersenBaselProxy.java index d19588525fb8..3903aacd188c 100644 --- a/src/main/java/org/drip/sample/xvasimulation/BaselFixFloatDigest.java +++ b/src/main/java/org/drip/sample/xvafixfloat/AlbaneseAndersenBaselProxy.java @@ -1,5 +1,5 @@ -package org.drip.sample.xvasimulation; +package org.drip.sample.xvafixfloat; import org.drip.analytics.date.*; import org.drip.function.definition.R1ToR1; @@ -59,8 +59,9 @@ */ /** - * BaselFixFloatDigest simulates for various Latent States and Exposures for an Fix Float Swap and computes - * the XVA Metrics using the Basel Proxy-Style Fading Swap Volatility. The References are: + * AlbaneseAndersenBaselProxy simulates for various Latent States and Exposures for an Fix Float Swap and + * computes the XVA Metrics using the Basel Proxy-Style Exposure Generator using Albanese Andersen + * Vertexes. The References are: * * - Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party Risk * and Funding Costs, Journal of Credit Risk, 7 (3) 1-19. @@ -79,7 +80,7 @@ * @author Lakshmi Krishnamurthy */ -public class BaselFixFloatDigest +public class AlbaneseAndersenBaselProxy { private static final TradeablesContainer GenerateTradeablesContainer ( @@ -227,19 +228,6 @@ private static final MarketVertexGenerator ConstructMarketVertexGenerator ( spotDate.julian(), periodTenor, periodCount, - new double[][] { - {1.00, 0.00, 0.20, 0.15, 0.05, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #0 ASSET NUMERAIRE - {0.00, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #1 OVERNIGHT POLICY INDEX NUMERAIRE - {0.20, 0.00, 1.00, 0.13, 0.25, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #2 COLLATERAL SCHEME NUMERAIRE - {0.15, 0.00, 0.13, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #3 BANK HAZARD RATE - {0.05, 0.00, 0.25, 0.00, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #4 BANK SENIOR FUNDING NUMERAIRE - {0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #5 BANK SENIOR RECOVERY RATE - {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00, 0.00, 0.00, 0.00}, // #6 BANK SUBORDINATE FUNDING NUMERAIRE - {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00, 0.00, 0.00}, // #7 BANK SUBORDINATE RECOVERY RATE - {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00, 0.00}, // #8 COUNTER PARTY HAZARD RATE - {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00}, // #9 COUNTER PARTY FUNDING NUMERAIRE - {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00} // #10 COUNTER PARTY RECOVERY RATE - }, GenerateTradeablesContainer ( periodTenor, periodCount, @@ -387,6 +375,7 @@ public static final void main ( ), CounterPartyGroupSpecification.Standard ("CPGROUP") ), + PathSimulatorScheme.AlbaneseAndersenVertex(), new R1ToR1 (null) { @Override public double evaluate ( @@ -413,7 +402,22 @@ public static final void main ( 0.030 / (1 - 0.30) // dblCounterPartyFundingSpread ); - ExposureAdjustmentAggregator eaa = fixFloatPathSimulator.simulate (initialMarketVertex); + ExposureAdjustmentAggregator eaa = fixFloatPathSimulator.simulate ( + initialMarketVertex, + new double[][] { + {1.00, 0.00, 0.20, 0.15, 0.05, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #0 ASSET NUMERAIRE + {0.00, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #1 OVERNIGHT POLICY INDEX NUMERAIRE + {0.20, 0.00, 1.00, 0.13, 0.25, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #2 COLLATERAL SCHEME NUMERAIRE + {0.15, 0.00, 0.13, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #3 BANK HAZARD RATE + {0.05, 0.00, 0.25, 0.00, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #4 BANK SENIOR FUNDING NUMERAIRE + {0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00, 0.00, 0.00, 0.00, 0.00}, // #5 BANK SENIOR RECOVERY RATE + {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00, 0.00, 0.00, 0.00}, // #6 BANK SUBORDINATE FUNDING NUMERAIRE + {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00, 0.00, 0.00}, // #7 BANK SUBORDINATE RECOVERY RATE + {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00, 0.00}, // #8 COUNTER PARTY HAZARD RATE + {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00, 0.00}, // #9 COUNTER PARTY FUNDING NUMERAIRE + {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00} // #10 COUNTER PARTY RECOVERY RATE + } + ); ExposureAdjustmentDigest ead = eaa.digest(); diff --git a/src/main/java/org/drip/sample/xvasimulation/package-info.java b/src/main/java/org/drip/sample/xvafixfloat/package-info.java similarity index 68% rename from src/main/java/org/drip/sample/xvasimulation/package-info.java rename to src/main/java/org/drip/sample/xvafixfloat/package-info.java index d52c69fe0d43..662540395c10 100644 --- a/src/main/java/org/drip/sample/xvasimulation/package-info.java +++ b/src/main/java/org/drip/sample/xvafixfloat/package-info.java @@ -5,4 +5,4 @@ * @author Lakshmi Krishnamurthy */ -package org.drip.sample.xvasimulation; +package org.drip.sample.xvafixfloat; diff --git a/src/main/java/org/drip/xva/dynamics/AdjustmentDigestScheme.java b/src/main/java/org/drip/xva/dynamics/AdjustmentDigestScheme.java new file mode 100644 index 000000000000..9c5cc49202d2 --- /dev/null +++ b/src/main/java/org/drip/xva/dynamics/AdjustmentDigestScheme.java @@ -0,0 +1,79 @@ + +package org.drip.xva.dynamics; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2018 Lakshmi Krishnamurthy + * + * This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model + * libraries targeting analysts and developers + * https://lakshmidrip.github.io/DRIP/ + * + * DRIP is composed of four main libraries: + * + * - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/ + * - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/ + * - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/ + * - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/ + * + * - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options, + * Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA + * Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV + * Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM + * Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics. + * + * - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy + * Incorporator, Holdings Constraint, and Transaction Costs. + * + * - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality. + * + * - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * AdjustmentDigestScheme contains Settings to the Schemes that generate Aggregated Valuation Adjustment + * Metrics. The References are: + * + * - Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party Risk + * and Funding Costs, Journal of Credit Risk, 7 (3) 1-19. + * + * - Burgard, C., and M. Kjaer (2014): In the Balance, Risk, 24 (11) 72-75. + * + * - Albanese, C., and L. Andersen (2014): Accounting for OTC Derivatives: Funding Adjustments and the + * Re-Hypothecation Option, eSSRN, https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2482955. + * + * - Burgard, C., and M. Kjaer (2017): Derivatives Funding, Netting, and Accounting, eSSRN, + * https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2534011. + * + * - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk + * 21 (2) 97-102. + * + * @author Lakshmi Krishnamurthy + */ + +public class AdjustmentDigestScheme +{ + + /** + * Albanese Andersen Metrics Pointer Scheme + */ + + public static final int ALBANESE_ANDERSEN_METRICS_POINTER = 1; + +} diff --git a/src/main/java/org/drip/xva/dynamics/BrokenDateScheme.java b/src/main/java/org/drip/xva/dynamics/BrokenDateScheme.java new file mode 100644 index 000000000000..2f70a30c28ba --- /dev/null +++ b/src/main/java/org/drip/xva/dynamics/BrokenDateScheme.java @@ -0,0 +1,91 @@ + +package org.drip.xva.dynamics; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2018 Lakshmi Krishnamurthy + * + * This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model + * libraries targeting analysts and developers + * https://lakshmidrip.github.io/DRIP/ + * + * DRIP is composed of four main libraries: + * + * - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/ + * - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/ + * - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/ + * - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/ + * + * - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options, + * Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA + * Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV + * Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM + * Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics. + * + * - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy + * Incorporator, Holdings Constraint, and Transaction Costs. + * + * - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality. + * + * - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * BrokenDateScheme holds the Broken Date Interpolation Scheme to generate Intermediate Values for the Path + * Exposures and Collateral Balances. The References are: + * + * - Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party Risk + * and Funding Costs, Journal of Credit Risk, 7 (3) 1-19. + * + * - Burgard, C., and M. Kjaer (2014): In the Balance, Risk, 24 (11) 72-75. + * + * - Albanese, C., and L. Andersen (2014): Accounting for OTC Derivatives: Funding Adjustments and the + * Re-Hypothecation Option, eSSRN, https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2482955. + * + * - Burgard, C., and M. Kjaer (2017): Derivatives Funding, Netting, and Accounting, eSSRN, + * https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2534011. + * + * - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk + * 21 (2) 97-102. + * + * @author Lakshmi Krishnamurthy + */ + +public class BrokenDateScheme +{ + + /** + * Three Point Brownian Bridge Based Broken Date Interpolation Scheme + */ + + public static final int THREE_POINT_BROWNIAN_BRIDGE = 1; + + /** + * Linear Time Based Broken Date Interpolation Scheme + */ + + public static final int LINEAR_TIME = 2; + + /** + * Square Root of Time Based Broken Date Interpolation Scheme + */ + + public static final int SQUARE_ROOT_OF_TIME = 3; + +} diff --git a/src/main/java/org/drip/xva/dynamics/PathSimulator.java b/src/main/java/org/drip/xva/dynamics/PathSimulator.java index e9400c27c072..f8fcb04258e4 100644 --- a/src/main/java/org/drip/xva/dynamics/PathSimulator.java +++ b/src/main/java/org/drip/xva/dynamics/PathSimulator.java @@ -70,6 +70,7 @@ public class PathSimulator { private int _iCount = -1; private org.drip.xva.dynamics.GroupSettings _groupSettings = null; + private org.drip.xva.dynamics.PathSimulatorScheme _simulatorScheme = null; private org.drip.xva.universe.MarketVertexGenerator _marketVertexGenerator = null; private org.drip.function.definition.R1ToR1 _r1ToR1PositionGroupValueGenerator = null; @@ -97,29 +98,72 @@ private double[] positionGroupValueArray ( return positionGroupValueArray; } - private double collateralBalance ( - final org.drip.xva.universe.MarketVertex marketVertexLeft, - final org.drip.xva.universe.MarketVertex marketVertexRight, - final double positionValue) + private org.drip.measure.bridge.BrokenDateInterpolator brokenDateInterpolator ( + final org.drip.xva.universe.MarketVertex[] marketVertexArray, + final double[] positionValueArray, + final int index) throws java.lang.Exception { - org.drip.analytics.date.JulianDate vertexDateRightJulian = marketVertexRight.anchorDate(); + int brokenDateScheme = _simulatorScheme.brokenDateScheme(); + + if (org.drip.xva.dynamics.BrokenDateScheme.LINEAR_TIME == brokenDateScheme) + { + return 0 == index ? null : new org.drip.measure.bridge.BrokenDateInterpolatorLinearT ( + marketVertexArray[index - 1].anchorDate().julian(), + marketVertexArray[index].anchorDate().julian(), + positionValueArray[index - 1], + positionValueArray[index] + ); + } + + if (org.drip.xva.dynamics.BrokenDateScheme.SQUARE_ROOT_OF_TIME == brokenDateScheme) + { + return 0 == index ? null : new org.drip.measure.bridge.BrokenDateInterpolatorSqrtT ( + marketVertexArray[index - 1].anchorDate().julian(), + marketVertexArray[index].anchorDate().julian(), + positionValueArray[index - 1], + positionValueArray[index] + ); + } + + if (org.drip.xva.dynamics.BrokenDateScheme.THREE_POINT_BROWNIAN_BRIDGE == brokenDateScheme) + { + return 0 == index || 1 == index ? null : new + org.drip.measure.bridge.BrokenDateInterpolatorBrownian3P ( + marketVertexArray[index - 2].anchorDate().julian(), + marketVertexArray[index - 1].anchorDate().julian(), + marketVertexArray[index].anchorDate().julian(), + positionValueArray[index - 2], + positionValueArray[index - 1], + positionValueArray[index] + ); + } + + return null; + } - int vertexDateLeft = marketVertexLeft.anchorDate().julian(); + private double collateralBalance ( + final org.drip.xva.universe.MarketVertex[] marketVertexArray, + final double[] positionValueArray, + final int index) + throws java.lang.Exception + { + org.drip.measure.bridge.BrokenDateInterpolator brokenDateInterpolator = brokenDateInterpolator ( + marketVertexArray, + positionValueArray, + index + ); - return new org.drip.xva.hypothecation.CollateralAmountEstimator ( + return null == brokenDateInterpolator ? 0. : new org.drip.xva.hypothecation.CollateralAmountEstimator ( _groupSettings.collateralGroupSpecification(), _groupSettings.counterPartyGroupSpecification(), - new org.drip.measure.bridge.BrokenDateInterpolatorLinearT ( - vertexDateLeft, - vertexDateRightJulian.julian(), - marketVertexLeft.positionManifestValue() * - (null == _r1ToR1PositionGroupValueGenerator ? 1. : - _r1ToR1PositionGroupValueGenerator.evaluate (vertexDateLeft)), - positionValue + brokenDateInterpolator ( + marketVertexArray, + positionValueArray, + index ), java.lang.Double.NaN - ).postingRequirement (vertexDateRightJulian); + ).postingRequirement (marketVertexArray[index].anchorDate()); } private double[] collateralBalanceArray ( @@ -133,10 +177,10 @@ private double[] collateralBalanceArray ( { try { - collateralBalanceArray[i] = 0 == i ? 0. : collateralBalance ( - marketVertexArray[i - 1], - marketVertexArray[i], - positionValueArray[i] + collateralBalanceArray[i] = collateralBalance ( + marketVertexArray, + positionValueArray, + i ); } catch (java.lang.Exception e) @@ -155,18 +199,83 @@ private org.drip.xva.hypothecation.CollateralGroupVertex collateralGroupVertex ( final double positionGroupValue, final double realizedCashFlow, final double collateralBalance, - final double hedgeError, - final org.drip.xva.universe.MarketEdge marketEdge, - final org.drip.xva.definition.CloseOutGeneral closeOutScheme) + final org.drip.xva.universe.MarketEdge marketEdge) { try { - return new org.drip.xva.hypothecation.AlbaneseAndersenVertex ( - anchorDate, - positionGroupValue, - realizedCashFlow, - collateralBalance - ); + if (org.drip.xva.dynamics.PositionReplicationScheme.ALBANESE_ANDERSEN_VERTEX == + _simulatorScheme.positionReplicationScheme()) + { + return new org.drip.xva.hypothecation.AlbaneseAndersenVertex ( + anchorDate, + positionGroupValue, + realizedCashFlow, + collateralBalance + ); + } + + if (org.drip.xva.dynamics.PositionReplicationScheme.BURGARD_KJAER_HEDGE_ERROR_DUAL_BOND_VERTEX == + _simulatorScheme.positionReplicationScheme()) + { + return org.drip.xva.hypothecation.BurgardKjaerVertexBuilder.HedgeErrorDualBond ( + anchorDate, + positionGroupValue, + realizedCashFlow, + collateralBalance, + _simulatorScheme.hedgeError(), + marketEdge, + _simulatorScheme.closeOutScheme() + ); + } + + if (org.drip.xva.dynamics.PositionReplicationScheme.BURGARD_KJAER_SEMI_REPLICATION_DUAL_BOND_VERTEX + == _simulatorScheme.positionReplicationScheme()) + { + return org.drip.xva.hypothecation.BurgardKjaerVertexBuilder.SemiReplicationDualBond ( + anchorDate, + positionGroupValue, + realizedCashFlow, + collateralBalance, + marketEdge, + _simulatorScheme.closeOutScheme() + ); + } + + if (org.drip.xva.dynamics.PositionReplicationScheme.BURGARD_KJAER_GOLD_PLATED_TWO_WAY_CSA_VERTEX + == _simulatorScheme.positionReplicationScheme()) + { + return org.drip.xva.hypothecation.BurgardKjaerVertexBuilder.GoldPlatedTwoWayCSA ( + anchorDate, + positionGroupValue, + realizedCashFlow, + marketEdge, + _simulatorScheme.closeOutScheme() + ); + } + + if (org.drip.xva.dynamics.PositionReplicationScheme.BURGARD_KJAER_ONE_WAY_CSA_VERTEX == + _simulatorScheme.positionReplicationScheme()) + { + return org.drip.xva.hypothecation.BurgardKjaerVertexBuilder.OneWayCSA ( + anchorDate, + positionGroupValue, + realizedCashFlow, + marketEdge, + _simulatorScheme.closeOutScheme() + ); + } + + if (org.drip.xva.dynamics.PositionReplicationScheme.BURGARD_KJAER_SET_OFF_VERTEX == + _simulatorScheme.positionReplicationScheme()) + { + return org.drip.xva.hypothecation.BurgardKjaerVertexBuilder.SetOff ( + anchorDate, + positionGroupValue, + realizedCashFlow, + collateralBalance, + marketEdge + ); + } } catch (java.lang.Exception e) { @@ -203,12 +312,10 @@ private org.drip.xva.hypothecation.CollateralGroupVertex[] collateralGroupVertex positionGroupValueArray[j], 0., collateralBalanceArray[j], - 0., 0 == j ? null : new org.drip.xva.universe.MarketEdge ( marketVertexArray[j - 1], marketVertexArray[j] - ), - null + ) ); } catch (java.lang.Exception e) @@ -248,32 +355,41 @@ private org.drip.xva.hypothecation.CollateralGroupPath[] collateralGroupPathArra } private org.drip.xva.cpty.PathExposureAdjustment singleTrajectory ( - final org.drip.xva.universe.MarketVertex initialMarketVertex) + final org.drip.xva.universe.MarketVertex initialMarketVertex, + final double[][] correlationMatrix) { try { - org.drip.xva.universe.MarketPath marketPath = new org.drip.xva.universe.MarketPath - (_marketVertexGenerator.marketVertex (initialMarketVertex)); + org.drip.xva.universe.MarketPath marketPath = new org.drip.xva.universe.MarketPath ( + _marketVertexGenerator.marketVertex ( + initialMarketVertex, + correlationMatrix + ) + ); org.drip.xva.hypothecation.CollateralGroupPath[] collateralGroupPathArray = collateralGroupPathArray (marketPath); - return new org.drip.xva.cpty.MonoPathExposureAdjustment ( - new org.drip.xva.strategy.AlbaneseAndersenNettingGroupPath[] - { - new org.drip.xva.strategy.AlbaneseAndersenNettingGroupPath ( - collateralGroupPathArray, - marketPath - ) - }, - new org.drip.xva.strategy.AlbaneseAndersenFundingGroupPath[] - { - new org.drip.xva.strategy.AlbaneseAndersenFundingGroupPath ( - collateralGroupPathArray, - marketPath - ) - } - ); + if (org.drip.xva.dynamics.AdjustmentDigestScheme.ALBANESE_ANDERSEN_METRICS_POINTER == + _simulatorScheme.adjustmentDigestScheme()) + { + return new org.drip.xva.cpty.MonoPathExposureAdjustment ( + new org.drip.xva.strategy.AlbaneseAndersenNettingGroupPath[] + { + new org.drip.xva.strategy.AlbaneseAndersenNettingGroupPath ( + collateralGroupPathArray, + marketPath + ) + }, + new org.drip.xva.strategy.AlbaneseAndersenFundingGroupPath[] + { + new org.drip.xva.strategy.AlbaneseAndersenFundingGroupPath ( + collateralGroupPathArray, + marketPath + ) + } + ); + } } catch (java.lang.Exception e) { @@ -305,6 +421,7 @@ public static final PathSimulator UnitPositionGroupValue ( iCount, marketVertexGenerator, groupSettings, + org.drip.xva.dynamics.PathSimulatorScheme.AlbaneseAndersenVertex(), new org.drip.function.r1tor1.FlatUnivariate (1.) ); } @@ -322,6 +439,7 @@ public static final PathSimulator UnitPositionGroupValue ( * @param iCount Path Count * @param marketVertexGenerator Market Vertex Generator * @param groupSettings Group Settings + * @param simulatorScheme Path Simulator Scheme * @param r1ToR1PositionGroupValueGenerator R^1 To R^1 Position Group Value Generator * * @throws java.lang.Exception Thrown if the Inputs are Invalid @@ -331,12 +449,14 @@ public PathSimulator ( final int iCount, final org.drip.xva.universe.MarketVertexGenerator marketVertexGenerator, final org.drip.xva.dynamics.GroupSettings groupSettings, + final org.drip.xva.dynamics.PathSimulatorScheme simulatorScheme, final org.drip.function.definition.R1ToR1 r1ToR1PositionGroupValueGenerator) throws java.lang.Exception { if (0 >= (_iCount = iCount) || null == (_marketVertexGenerator = marketVertexGenerator) || null == (_groupSettings = groupSettings) || + null == (_simulatorScheme = simulatorScheme) || null == (_r1ToR1PositionGroupValueGenerator = r1ToR1PositionGroupValueGenerator)) { throw new java.lang.Exception ("PathSimulator Constructor => Invalid Inputs"); @@ -376,6 +496,17 @@ public org.drip.xva.dynamics.GroupSettings groupSettings() return _groupSettings; } + /** + * Retrieve the Path Simulator Scheme + * + * @return The Path Simulator Scheme + */ + + public org.drip.xva.dynamics.PathSimulatorScheme scheme() + { + return _simulatorScheme; + } + /** * Retrieve the R^1 -> R^1 Position Group Value Generator * @@ -391,19 +522,23 @@ public org.drip.function.definition.R1ToR1 positionGroupValueGenerator() * Simulate the Realized State/Entity Values and their Aggregates over the Paths * * @param initialMarketVertex The Initial Market Vertex + * @param correlationMatrix The Correlation Matrix * * @return The Exposure Adjustment Aggregator - Simulation Result */ public org.drip.xva.cpty.ExposureAdjustmentAggregator simulate ( - final org.drip.xva.universe.MarketVertex initialMarketVertex) + final org.drip.xva.universe.MarketVertex initialMarketVertex, + final double[][] correlationMatrix) { org.drip.xva.cpty.PathExposureAdjustment[] pathExposureAdjustmentArray = new org.drip.xva.cpty.PathExposureAdjustment[_iCount]; for (int i = 0; i < _iCount; ++i) { - if (null == (pathExposureAdjustmentArray[i] = singleTrajectory (initialMarketVertex))) + if (null == (pathExposureAdjustmentArray[i] = singleTrajectory ( + initialMarketVertex, + correlationMatrix))) { return null; } diff --git a/src/main/java/org/drip/xva/dynamics/PathSimulatorScheme.java b/src/main/java/org/drip/xva/dynamics/PathSimulatorScheme.java new file mode 100644 index 000000000000..8cd2778d1ce9 --- /dev/null +++ b/src/main/java/org/drip/xva/dynamics/PathSimulatorScheme.java @@ -0,0 +1,189 @@ + +package org.drip.xva.dynamics; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2018 Lakshmi Krishnamurthy + * + * This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model + * libraries targeting analysts and developers + * https://lakshmidrip.github.io/DRIP/ + * + * DRIP is composed of four main libraries: + * + * - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/ + * - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/ + * - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/ + * - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/ + * + * - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options, + * Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA + * Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV + * Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM + * Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics. + * + * - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy + * Incorporator, Holdings Constraint, and Transaction Costs. + * + * - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality. + * + * - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PathSimulatorScheme specifies the Hypothecation Vertex Generation Schemes for the Simulation. The + * References are: + * + * - Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party Risk + * and Funding Costs, Journal of Credit Risk, 7 (3) 1-19. + * + * - Burgard, C., and M. Kjaer (2014): In the Balance, Risk, 24 (11) 72-75. + * + * - Albanese, C., and L. Andersen (2014): Accounting for OTC Derivatives: Funding Adjustments and the + * Re-Hypothecation Option, eSSRN, https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2482955. + * + * - Burgard, C., and M. Kjaer (2017): Derivatives Funding, Netting, and Accounting, eSSRN, + * https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2534011. + * + * - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk + * 21 (2) 97-102. + * + * @author Lakshmi Krishnamurthy + */ + +public class PathSimulatorScheme +{ + private int _brokenDateScheme = -1; + private int _adjustmentDigestScheme = -1; + private int _positionReplicationScheme = -1; + private double _hedgeError = java.lang.Double.NaN; + private org.drip.xva.definition.CloseOutGeneral _closeOutScheme = null; + + /** + * Construct an Albanese Andersen Vertex Generator Based Path Simulator Scheme + * + * @return The Albanese Andersen Vertex Generator Based Path Simulator Scheme + */ + + public static PathSimulatorScheme AlbaneseAndersenVertex() + { + try + { + return new PathSimulatorScheme ( + org.drip.xva.dynamics.PositionReplicationScheme.ALBANESE_ANDERSEN_VERTEX, + org.drip.xva.dynamics.BrokenDateScheme.LINEAR_TIME, + org.drip.xva.dynamics.AdjustmentDigestScheme.ALBANESE_ANDERSEN_METRICS_POINTER, + 0., + null + ); + } + catch (java.lang.Exception e) + { + e.printStackTrace(); + } + + return null; + } + + /** + * PathSimulatorScheme Constructor + * + * @param positionReplicationScheme Position Replication Scheme + * @param brokenDateScheme Broken Date Interpolation Scheme + * @param adjustmentDigestScheme Adjustment Digest Scheme + * @param hedgeError Hedge Error + * @param closeoutScheme Close Out Scheme + * + * @throws java.lang.Exception Thrown if the Inputs are Invalid + */ + + public PathSimulatorScheme ( + final int positionReplicationScheme, + final int brokenDateScheme, + final int adjustmentDigestScheme, + final double hedgeError, + final org.drip.xva.definition.CloseOutGeneral closeOutScheme) + throws java.lang.Exception + { + if (!org.drip.quant.common.NumberUtil.IsValid (_hedgeError = hedgeError)) + { + throw new java.lang.Exception ("PathSimulatorScheme Constructor => Invalid Inputs!"); + } + + _closeOutScheme = closeOutScheme; + _brokenDateScheme = brokenDateScheme; + _adjustmentDigestScheme = adjustmentDigestScheme; + _positionReplicationScheme = positionReplicationScheme; + } + + /** + * Retrieve the Position Replication Scheme + * + * @return The Position Replication Scheme + */ + + public int positionReplicationScheme() + { + return _positionReplicationScheme; + } + + /** + * Retrieve the Broken Date Interpolation Scheme + * + * @return The Broken Date Interpolation Scheme + */ + + public int brokenDateScheme() + { + return _brokenDateScheme; + } + + /** + * Retrieve the Adjustment Digest Scheme + * + * @return The Adjustment Digest Scheme + */ + + public int adjustmentDigestScheme() + { + return _adjustmentDigestScheme; + } + + /** + * Retrieve the Hedge Error + * + * @return The Hedge Error + */ + + public double hedgeError() + { + return _hedgeError; + } + + /** + * Retrieve the Close Out Scheme + * + * @return The Close Out Scheme + */ + + public org.drip.xva.definition.CloseOutGeneral closeOutScheme() + { + return _closeOutScheme; + } +} diff --git a/src/main/java/org/drip/xva/dynamics/PositionReplicationScheme.java b/src/main/java/org/drip/xva/dynamics/PositionReplicationScheme.java index b12e608e09c4..4313735460ee 100644 --- a/src/main/java/org/drip/xva/dynamics/PositionReplicationScheme.java +++ b/src/main/java/org/drip/xva/dynamics/PositionReplicationScheme.java @@ -71,8 +71,38 @@ public class PositionReplicationScheme { /** - * The Albanese Andersen Vertex Generator Scheme + * Albanese Andersen Vertex Generator Scheme */ - public static final int ALBANESE_ANDERSEN_VERTEX_GENERATOR = 1; + public static final int ALBANESE_ANDERSEN_VERTEX = 1; + + /** + * Burgard Kjaer Hedge Error Dual Bond Vertex Generator Scheme + */ + + public static final int BURGARD_KJAER_HEDGE_ERROR_DUAL_BOND_VERTEX = 2; + + /** + * Burgard Kjaer Semi Replication Dual Bond Vertex Generator Scheme + */ + + public static final int BURGARD_KJAER_SEMI_REPLICATION_DUAL_BOND_VERTEX = 3; + + /** + * Burgard Kjaer Gold Plated Two Way CSA Vertex Generator Scheme + */ + + public static final int BURGARD_KJAER_GOLD_PLATED_TWO_WAY_CSA_VERTEX = 4; + + /** + * Burgard Kjaer One Way CSA Vertex Generator Scheme + */ + + public static final int BURGARD_KJAER_ONE_WAY_CSA_VERTEX = 5; + + /** + * Burgard Kjaer One Way CSA Vertex Generator Scheme + */ + + public static final int BURGARD_KJAER_SET_OFF_VERTEX = 6; } diff --git a/src/main/java/org/drip/xva/universe/MarketVertexGenerator.java b/src/main/java/org/drip/xva/universe/MarketVertexGenerator.java index 5a820d215be3..260f28b51159 100644 --- a/src/main/java/org/drip/xva/universe/MarketVertexGenerator.java +++ b/src/main/java/org/drip/xva/universe/MarketVertexGenerator.java @@ -140,7 +140,6 @@ public class MarketVertexGenerator private int _spotDate = -1; private double[] _ycfWidth = null; private int[] _eventDateArray = null; - private double[][] _correlationMatrix = null; private org.drip.xva.universe.TradeablesContainer _tradeablesContainer = null; private org.drip.measure.process.DiffusionEvolver _bankHazardRateEvolver = null; private org.drip.measure.process.DiffusionEvolver _bankSeniorRecoveryRateEvolver = null; @@ -154,7 +153,6 @@ public class MarketVertexGenerator * @param spotDate The Spot Date * @param periodTenor The Period Tenor * @param periodCount The Period Count - * @param correlationMatrix The Correlation Matrix * @param tradeablesContainer The Tradeables Container Instance * @param bankHazardRateEvolver The Bank Hazard Rate Diffusive Evolver * @param bankSeniorRecoveryRateEvolver The Bank Senior Recovery Rate Diffusive Evolver @@ -169,7 +167,6 @@ public static final MarketVertexGenerator PeriodHorizon ( final int spotDate, final java.lang.String periodTenor, final int periodCount, - final double[][] correlationMatrix, final org.drip.xva.universe.TradeablesContainer tradeablesContainer, final org.drip.measure.process.DiffusionEvolver bankHazardRateEvolver, final org.drip.measure.process.DiffusionEvolver bankSeniorRecoveryRateEvolver, @@ -186,7 +183,6 @@ public static final MarketVertexGenerator PeriodHorizon ( periodTenor, periodCount ), - correlationMatrix, tradeablesContainer, bankHazardRateEvolver, bankSeniorRecoveryRateEvolver, @@ -208,7 +204,6 @@ public static final MarketVertexGenerator PeriodHorizon ( * * @param spotDate The Spot Date * @param eventDateArray Array of the Event Dates - * @param correlationMatrix The Correlation Matrix * @param tradeablesContainer The Tradeables Container Instance * @param bankHazardRateEvolver The Bank Hazard Rate Diffusive Evolver * @param bankSeniorRecoveryRateEvolver The Bank Senior Recovery Rate Diffusive Evolver @@ -222,7 +217,6 @@ public static final MarketVertexGenerator PeriodHorizon ( public MarketVertexGenerator ( final int spotDate, final int[] eventDateArray, - final double[][] correlationMatrix, final org.drip.xva.universe.TradeablesContainer tradeablesContainer, final org.drip.measure.process.DiffusionEvolver bankHazardRateEvolver, final org.drip.measure.process.DiffusionEvolver bankSeniorRecoveryRateEvolver, @@ -233,7 +227,6 @@ public MarketVertexGenerator ( { if (0 >= (_spotDate = spotDate) || null == (_eventDateArray = eventDateArray) || - null == (_correlationMatrix = correlationMatrix) || null == (_tradeablesContainer = tradeablesContainer) || null == (_bankHazardRateEvolver = bankHazardRateEvolver) || null == (_bankSeniorRecoveryRateEvolver = bankSeniorRecoveryRateEvolver) || @@ -245,12 +238,10 @@ public MarketVertexGenerator ( } int eventVertexCount = _eventDateArray.length; - int dimensionCount = _correlationMatrix.length; _ycfWidth = 0 == eventVertexCount ? null : new double[eventVertexCount]; _bankSubordinateRecoveryRateEvolver = bankSubordinateRecoveryRateEvolver; if (0 == eventVertexCount || - 11 != dimensionCount || 0. >= (_ycfWidth[0] = ((double) (_eventDateArray[0] - _spotDate)) / 365.25)) { throw new java.lang.Exception ("MarketVertexGenerator Constructor => Invalid Inputs"); @@ -264,16 +255,6 @@ public MarketVertexGenerator ( throw new java.lang.Exception ("MarketVertexGenerator Constructor => Invalid Inputs"); } } - - for (int dimensionIndex = 0; dimensionIndex < dimensionCount; ++dimensionIndex) - { - if (null == _correlationMatrix[dimensionIndex] || - 11 != _correlationMatrix[dimensionIndex].length || - !org.drip.quant.common.NumberUtil.IsValid (_correlationMatrix[dimensionIndex])) - { - throw new java.lang.Exception ("MarketVertexGenerator Constructor => Invalid Inputs"); - } - } } /** @@ -316,17 +297,6 @@ public double[] timeWidth() return _ycfWidth; } - /** - * Retrieve the Latent State Correlation Matrix - * - * @return The Latent State Correlation Matrix - */ - - public double[][] correlationMatrix() - { - return _correlationMatrix; - } - /** * Retrieve the Bank Hazard Rate Evolver * @@ -391,13 +361,31 @@ public org.drip.measure.process.DiffusionEvolver counterPartyRecoveryRateEvolver */ public org.drip.xva.universe.MarketVertex[] marketVertex ( - final org.drip.xva.universe.MarketVertex initialMarketVertex) + final org.drip.xva.universe.MarketVertex initialMarketVertex, + final double[][] correlationMatrix) { - if (null == initialMarketVertex) + if (null == initialMarketVertex || null == correlationMatrix) { return null; } + int dimensionCount = correlationMatrix.length; + + if (11 != dimensionCount) + { + return null; + } + + for (int dimensionIndex = 0; dimensionIndex < dimensionCount; ++dimensionIndex) + { + if (null == correlationMatrix[dimensionIndex] || + 11 != correlationMatrix[dimensionIndex].length || + !org.drip.quant.common.NumberUtil.IsValid (correlationMatrix[dimensionIndex])) + { + return null; + } + } + org.drip.xva.universe.Tradeable positionManifest = _tradeablesContainer.positionManifest(); org.drip.xva.universe.Tradeable bankSubordinateFundingNumeraire = @@ -425,7 +413,7 @@ public org.drip.xva.universe.MarketVertex[] marketVertex ( double[][] unitEvolverSequence = org.drip.quant.linearalgebra.Matrix.Transpose ( org.drip.measure.discrete.SequenceGenerator.GaussianJoint ( eventVertexCount, - _correlationMatrix + correlationMatrix ) );