Skip to content

Commit 14160de

Browse files
committed
Features:
- Period Collateral Group Path Adjustment (1, 2) - Credit Debt Group Path UCVA (3, 4) - Credit Debt Group Path FTDCVA (5) - Credit Debt Group Path UDVA (6, 7) - Credit Debt Group Path FTDDVA (8) - Credit Debt Group Path FTDCOLVA (9, 10, 11) - Credit Debt Group Period UCVA (12, 13) - Credit Debt Group Period FTDCVA (14) - Credit Debt Group Period UDVA (15, 16) - Credit Debt Group Period FTDDVA (17) Bug Fixes/Clean-up: Samples:
1 parent b19956a commit 14160de

File tree

3 files changed

+123
-90
lines changed

3 files changed

+123
-90
lines changed

ReleaseNotes/03_29_2018.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
Features:
3+
4+
- Period Collateral Group Path Adjustment (1, 2)
5+
- Credit Debt Group Path UCVA (3, 4)
6+
- Credit Debt Group Path FTDCVA (5)
7+
- Credit Debt Group Path UDVA (6, 7)
8+
- Credit Debt Group Path FTDDVA (8)
9+
- Credit Debt Group Path FTDCOLVA (9, 10, 11)
10+
- Credit Debt Group Period UCVA (12, 13)
11+
- Credit Debt Group Period FTDCVA (14)
12+
- Credit Debt Group Period UDVA (15, 16)
13+
- Credit Debt Group Period FTDDVA (17)
14+
15+
16+
Bug Fixes/Clean-up:
17+
18+
Samples:

src/main/java/org/drip/xva/netting/CollateralGroupPath.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,7 @@ public double[] periodCollateralValueAdjustment()
827827
double[] collateralBalance = collateralBalance();
828828

829829
int vertexCount = collateralBalance.length;
830-
double[] periodCollateralValueAdjustment = new double[vertexCount];
831-
periodCollateralValueAdjustment[0] = 0.;
830+
double[] periodCollateralValueAdjustment = new double[vertexCount - 1];
832831

833832
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
834833
{
@@ -840,7 +839,7 @@ public double[] periodCollateralValueAdjustment()
840839
marketVertexArray[vertexIndex].csaSpread() *
841840
marketVertexArray[vertexIndex].overnightReplicator();
842841

843-
periodCollateralValueAdjustment[vertexIndex] =
842+
periodCollateralValueAdjustment[vertexIndex - 1] =
844843
-0.5 * (periodIntegrandStart + periodIntegrandEnd)
845844
* (marketVertexArray[vertexIndex].anchorDate().julian() -
846845
marketVertexArray[vertexIndex - 1].anchorDate().julian()) / 365.25;

src/main/java/org/drip/xva/netting/CreditDebtGroupPath.java

Lines changed: 103 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ public double unilateralCreditAdjustment()
103103

104104
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
105105
{
106-
unilateralCreditAdjustment -=
107-
0.5 * (creditExposure[vertexIndex - 1] + creditExposure[vertexIndex]) *
108-
0.5 * (marketVertexArray[vertexIndex - 1].client().seniorRecoveryRate() +
109-
marketVertexArray[vertexIndex].client().seniorRecoveryRate()) *
110-
0.5 * (marketVertexArray[vertexIndex - 1].overnightReplicator() +
111-
marketVertexArray[vertexIndex].overnightReplicator()) *
106+
double periodIntegrandStart = creditExposure[vertexIndex - 1] *
107+
marketVertexArray[vertexIndex - 1].client().seniorRecoveryRate() *
108+
marketVertexArray[vertexIndex - 1].overnightReplicator();
109+
110+
double periodIntegrandEnd = creditExposure[vertexIndex] *
111+
marketVertexArray[vertexIndex].client().seniorRecoveryRate() *
112+
marketVertexArray[vertexIndex].overnightReplicator();
113+
114+
unilateralCreditAdjustment -= 0.5 * (periodIntegrandStart + periodIntegrandEnd) *
112115
(marketVertexArray[vertexIndex - 1].client().survivalProbability() -
113116
marketVertexArray[vertexIndex].client().survivalProbability());
114117
}
@@ -136,14 +139,17 @@ public double bilateralCreditAdjustment()
136139

137140
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
138141
{
139-
bilateralCreditAdjustment -=
140-
0.5 * (creditExposure[vertexIndex - 1] + creditExposure[vertexIndex]) *
141-
0.5 * (marketVertexArray[vertexIndex - 1].client().seniorRecoveryRate() +
142-
marketVertexArray[vertexIndex].client().seniorRecoveryRate()) *
143-
0.5 * (marketVertexArray[vertexIndex - 1].overnightReplicator() +
144-
marketVertexArray[vertexIndex].overnightReplicator()) *
145-
0.5 * (marketVertexArray[vertexIndex - 1].dealer().survivalProbability() +
146-
marketVertexArray[vertexIndex].dealer().survivalProbability()) *
142+
double periodIntegrandStart = creditExposure[vertexIndex - 1] *
143+
marketVertexArray[vertexIndex - 1].client().seniorRecoveryRate() *
144+
marketVertexArray[vertexIndex - 1].dealer().survivalProbability() *
145+
marketVertexArray[vertexIndex - 1].overnightReplicator();
146+
147+
double periodIntegrandEnd = creditExposure[vertexIndex] *
148+
marketVertexArray[vertexIndex].client().seniorRecoveryRate() *
149+
marketVertexArray[vertexIndex].dealer().survivalProbability() *
150+
marketVertexArray[vertexIndex].overnightReplicator();
151+
152+
bilateralCreditAdjustment -= 0.5 * (periodIntegrandStart + periodIntegrandEnd) *
147153
(marketVertexArray[vertexIndex - 1].client().survivalProbability() -
148154
marketVertexArray[vertexIndex].client().survivalProbability());
149155
}
@@ -182,12 +188,15 @@ public double unilateralDebtAdjustment()
182188

183189
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
184190
{
185-
unilateralDebtAdjustment -=
186-
0.5 * (debtExposure[vertexIndex - 1] + debtExposure[vertexIndex]) *
187-
0.5 * (marketVertexArray[vertexIndex - 1].dealer().seniorRecoveryRate() +
188-
marketVertexArray[vertexIndex].dealer().seniorRecoveryRate()) *
189-
0.5 * (marketVertexArray[vertexIndex - 1].overnightReplicator() +
190-
marketVertexArray[vertexIndex].overnightReplicator()) *
191+
double periodIntegrandStart = debtExposure[vertexIndex - 1] *
192+
marketVertexArray[vertexIndex - 1].dealer().seniorRecoveryRate() *
193+
marketVertexArray[vertexIndex - 1].overnightReplicator();
194+
195+
double periodIntegrandEnd = debtExposure[vertexIndex] *
196+
marketVertexArray[vertexIndex].dealer().seniorRecoveryRate() *
197+
marketVertexArray[vertexIndex].overnightReplicator();
198+
199+
unilateralDebtAdjustment -= 0.5 * (periodIntegrandStart + periodIntegrandEnd) *
191200
(marketVertexArray[vertexIndex - 1].dealer().survivalProbability() -
192201
marketVertexArray[vertexIndex].dealer().survivalProbability());
193202
}
@@ -215,14 +224,17 @@ public double bilateralDebtAdjustment()
215224

216225
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
217226
{
218-
bilateralDebtAdjustment -=
219-
0.5 * (debtExposure[vertexIndex - 1] + debtExposure[vertexIndex]) *
220-
0.5 * (marketVertexArray[vertexIndex - 1].dealer().seniorRecoveryRate() +
221-
marketVertexArray[vertexIndex].dealer().seniorRecoveryRate()) *
222-
0.5 * (marketVertexArray[vertexIndex - 1].overnightReplicator() +
223-
marketVertexArray[vertexIndex].overnightReplicator()) *
224-
0.5 * (marketVertexArray[vertexIndex - 1].client().survivalProbability() +
225-
marketVertexArray[vertexIndex].client().survivalProbability()) *
227+
double periodIntegrandStart = debtExposure[vertexIndex - 1] *
228+
marketVertexArray[vertexIndex - 1].dealer().seniorRecoveryRate() *
229+
marketVertexArray[vertexIndex - 1].client().survivalProbability() *
230+
marketVertexArray[vertexIndex - 1].overnightReplicator();
231+
232+
double periodIntegrandEnd = debtExposure[vertexIndex] *
233+
marketVertexArray[vertexIndex].dealer().seniorRecoveryRate() *
234+
marketVertexArray[vertexIndex].client().survivalProbability() *
235+
marketVertexArray[vertexIndex].overnightReplicator();
236+
237+
bilateralDebtAdjustment -= 0.5 * (periodIntegrandStart + periodIntegrandEnd) *
226238
(marketVertexArray[vertexIndex - 1].dealer().survivalProbability() -
227239
marketVertexArray[vertexIndex].dealer().survivalProbability());
228240
}
@@ -243,28 +255,19 @@ public double bilateralCollateralAdjustment()
243255
{
244256
org.drip.xva.universe.MarketVertex[] marketVertexArray = marketPath().vertexes();
245257

246-
double[] collateralBalance = collateralBalance();
258+
double[] periodCollateralValueAdjustment = periodCollateralValueAdjustment();
247259

248260
double bilateralCollateralValueAdjustment = 0.;
249-
int vertexCount = collateralBalance.length;
261+
int vertexCount = periodCollateralValueAdjustment.length;
250262

251-
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
263+
for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
252264
{
253-
double periodIntegrandStart = collateralBalance[vertexIndex - 1] *
254-
marketVertexArray[vertexIndex - 1].dealer().survivalProbability() *
255-
marketVertexArray[vertexIndex - 1].client().survivalProbability() *
256-
marketVertexArray[vertexIndex - 1].csaSpread() *
257-
marketVertexArray[vertexIndex - 1].overnightReplicator();
258-
259-
double periodIntegrandEnd = collateralBalance[vertexIndex] *
265+
bilateralCollateralValueAdjustment += 0.5 * periodCollateralValueAdjustment[vertexIndex] * (
260266
marketVertexArray[vertexIndex].dealer().survivalProbability() *
261-
marketVertexArray[vertexIndex].client().survivalProbability() *
262-
marketVertexArray[vertexIndex].csaSpread() *
263-
marketVertexArray[vertexIndex].overnightReplicator();
264-
265-
bilateralCollateralValueAdjustment -= 0.5 * (periodIntegrandStart + periodIntegrandEnd) *
266-
(marketVertexArray[vertexIndex].anchorDate().julian() -
267-
marketVertexArray[vertexIndex - 1].anchorDate().julian()) / 365.25;
267+
marketVertexArray[vertexIndex].client().survivalProbability() +
268+
marketVertexArray[vertexIndex + 1].dealer().survivalProbability() *
269+
marketVertexArray[vertexIndex + 1].client().survivalProbability()
270+
);
268271
}
269272

270273
return bilateralCollateralValueAdjustment;
@@ -278,7 +281,7 @@ public double bilateralCollateralAdjustment()
278281
* @throws java.lang.Exception Thrown if the Inputs are Invalid
279282
*/
280283

281-
public double collateralAdjustment()
284+
public double collateralValueAdjustment()
282285
throws java.lang.Exception
283286
{
284287
return bilateralCollateralAdjustment();
@@ -297,19 +300,22 @@ public double[] periodUnilateralCreditAdjustment()
297300
double[] creditExposure = creditExposure();
298301

299302
int vertexCount = creditExposure.length;
300-
double[] periodUnilateralCreditAdjustment = new double[vertexCount];
301-
periodUnilateralCreditAdjustment[0] = 0.;
303+
double[] periodUnilateralCreditAdjustment = new double[vertexCount - 1];
302304

303305
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
304306
{
305-
periodUnilateralCreditAdjustment[vertexIndex] =
306-
-0.5 * (creditExposure[vertexIndex - 1] + creditExposure[vertexIndex]) *
307-
0.5 * (marketVertexArray[vertexIndex - 1].client().seniorRecoveryRate() +
308-
marketVertexArray[vertexIndex].client().seniorRecoveryRate()) *
309-
0.5 * (marketVertexArray[vertexIndex - 1].overnightReplicator() +
310-
marketVertexArray[vertexIndex].overnightReplicator()) *
307+
double periodIntegrandStart = creditExposure[vertexIndex - 1] *
308+
marketVertexArray[vertexIndex - 1].client().seniorRecoveryRate() *
309+
marketVertexArray[vertexIndex - 1].overnightReplicator();
310+
311+
double periodIntegrandEnd = creditExposure[vertexIndex] *
312+
marketVertexArray[vertexIndex].client().seniorRecoveryRate() *
313+
marketVertexArray[vertexIndex].overnightReplicator();
314+
315+
periodUnilateralCreditAdjustment[vertexIndex - 1] =
316+
-0.5 * (periodIntegrandStart + periodIntegrandEnd) *
311317
(marketVertexArray[vertexIndex - 1].client().survivalProbability() -
312-
marketVertexArray[vertexIndex].client().survivalProbability());
318+
marketVertexArray[vertexIndex].client().survivalProbability());
313319
}
314320

315321
return periodUnilateralCreditAdjustment;
@@ -328,21 +334,24 @@ public double[] periodBilateralCreditAdjustment()
328334
double[] creditExposure = creditExposure();
329335

330336
int vertexCount = creditExposure.length;
331-
double[] periodBilateralCreditAdjustment = new double[vertexCount];
332-
periodBilateralCreditAdjustment[0] = 0.;
337+
double[] periodBilateralCreditAdjustment = new double[vertexCount - 1];
333338

334339
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
335340
{
336-
periodBilateralCreditAdjustment[vertexIndex] =
337-
-0.5 * (creditExposure[vertexIndex - 1] + creditExposure[vertexIndex]) *
338-
0.5 * (marketVertexArray[vertexIndex - 1].client().seniorRecoveryRate() +
339-
marketVertexArray[vertexIndex].client().seniorRecoveryRate()) *
340-
0.5 * (marketVertexArray[vertexIndex - 1].overnightReplicator() +
341-
marketVertexArray[vertexIndex].overnightReplicator()) *
342-
0.5 * (marketVertexArray[vertexIndex - 1].dealer().survivalProbability() +
343-
marketVertexArray[vertexIndex].dealer().survivalProbability()) *
341+
double periodIntegrandStart = creditExposure[vertexIndex - 1] *
342+
marketVertexArray[vertexIndex - 1].client().seniorRecoveryRate() *
343+
marketVertexArray[vertexIndex - 1].dealer().survivalProbability() *
344+
marketVertexArray[vertexIndex - 1].overnightReplicator();
345+
346+
double periodIntegrandEnd = creditExposure[vertexIndex] *
347+
marketVertexArray[vertexIndex].client().seniorRecoveryRate() *
348+
marketVertexArray[vertexIndex].dealer().survivalProbability() *
349+
marketVertexArray[vertexIndex].overnightReplicator();
350+
351+
periodBilateralCreditAdjustment[vertexIndex - 1] =
352+
-0.5 * (periodIntegrandStart + periodIntegrandEnd) *
344353
(marketVertexArray[vertexIndex - 1].client().survivalProbability() -
345-
marketVertexArray[vertexIndex].client().survivalProbability());
354+
marketVertexArray[vertexIndex].client().survivalProbability());
346355
}
347356

348357
return periodBilateralCreditAdjustment;
@@ -366,7 +375,8 @@ public double[] periodContraLiabilityCreditAdjustment()
366375
for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
367376
{
368377
periodContraLiabilityCreditAdjustment[vertexIndex] =
369-
periodUnilateralCreditAdjustment[vertexIndex] - periodBilateralCreditAdjustment[vertexIndex];
378+
periodUnilateralCreditAdjustment[vertexIndex] -
379+
periodBilateralCreditAdjustment[vertexIndex];
370380
}
371381

372382
return periodContraLiabilityCreditAdjustment;
@@ -385,19 +395,22 @@ public double[] periodUnilateralDebtAdjustment()
385395
double[] debtExposure = debtExposure();
386396

387397
int vertexCount = debtExposure.length;
388-
double[] periodUnilateralDebtAdjustment = new double[vertexCount];
389-
periodUnilateralDebtAdjustment[0] = 0.;
398+
double[] periodUnilateralDebtAdjustment = new double[vertexCount - 1];
390399

391400
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
392401
{
393-
periodUnilateralDebtAdjustment[vertexCount] =
394-
-0.5 * (debtExposure[vertexIndex - 1] + debtExposure[vertexIndex]) *
395-
0.5 * (marketVertexArray[vertexIndex - 1].dealer().seniorRecoveryRate() +
396-
marketVertexArray[vertexIndex].dealer().seniorRecoveryRate()) *
397-
0.5 * (marketVertexArray[vertexIndex - 1].overnightReplicator() +
398-
marketVertexArray[vertexIndex].overnightReplicator()) *
402+
double periodIntegrandStart = debtExposure[vertexIndex - 1] *
403+
marketVertexArray[vertexIndex - 1].dealer().seniorRecoveryRate() *
404+
marketVertexArray[vertexIndex - 1].overnightReplicator();
405+
406+
double periodIntegrandEnd = debtExposure[vertexIndex] *
407+
marketVertexArray[vertexIndex].dealer().seniorRecoveryRate() *
408+
marketVertexArray[vertexIndex].overnightReplicator();
409+
410+
periodUnilateralDebtAdjustment[vertexIndex - 1] =
411+
-0.5 * (periodIntegrandStart + periodIntegrandEnd) *
399412
(marketVertexArray[vertexIndex - 1].dealer().survivalProbability() -
400-
marketVertexArray[vertexIndex].dealer().survivalProbability());
413+
marketVertexArray[vertexIndex].dealer().survivalProbability());
401414
}
402415

403416
return periodUnilateralDebtAdjustment;
@@ -416,21 +429,24 @@ public double[] periodBilateralDebtAdjustment()
416429
double[] debtExposure = debtExposure();
417430

418431
int vertexCount = debtExposure.length;
419-
double[] periodBilateralDebtAdjustment = new double[vertexCount];
420-
periodBilateralDebtAdjustment[0] = 0.;
432+
double[] periodBilateralDebtAdjustment = new double[vertexCount - 1];
421433

422434
for (int vertexIndex = 1; vertexIndex < vertexCount; ++vertexIndex)
423435
{
424-
periodBilateralDebtAdjustment[vertexIndex] =
425-
-0.5 * (debtExposure[vertexIndex - 1] + debtExposure[vertexIndex]) *
426-
0.5 * (marketVertexArray[vertexIndex - 1].dealer().seniorRecoveryRate() +
427-
marketVertexArray[vertexIndex].dealer().seniorRecoveryRate()) *
428-
0.5 * (marketVertexArray[vertexIndex - 1].overnightReplicator() +
429-
marketVertexArray[vertexIndex].overnightReplicator()) *
430-
0.5 * (marketVertexArray[vertexIndex - 1].client().survivalProbability() +
431-
marketVertexArray[vertexIndex].client().survivalProbability()) *
436+
double periodIntegrandStart = debtExposure[vertexIndex - 1] *
437+
marketVertexArray[vertexIndex - 1].dealer().seniorRecoveryRate() *
438+
marketVertexArray[vertexIndex - 1].client().survivalProbability() *
439+
marketVertexArray[vertexIndex - 1].overnightReplicator();
440+
441+
double periodIntegrandEnd = debtExposure[vertexIndex] *
442+
marketVertexArray[vertexIndex].dealer().seniorRecoveryRate() *
443+
marketVertexArray[vertexIndex].client().survivalProbability() *
444+
marketVertexArray[vertexIndex].overnightReplicator();
445+
446+
periodBilateralDebtAdjustment[vertexIndex - 1] =
447+
-0.5 * (periodIntegrandStart + periodIntegrandEnd) *
432448
(marketVertexArray[vertexIndex - 1].dealer().survivalProbability() -
433-
marketVertexArray[vertexIndex].dealer().survivalProbability());
449+
marketVertexArray[vertexIndex].dealer().survivalProbability());
434450
}
435451

436452
return periodBilateralDebtAdjustment;

0 commit comments

Comments
 (0)