@@ -214,30 +214,14 @@ public double[] collateralizedExposurePV()
214
214
215
215
public double [] collateralizedPositiveExposure ()
216
216
{
217
- int vertexCount = anchorDates ().length ;
218
-
219
- int positionGroupCount = _positionGroupPathArray .length ;
220
- double [] collateralizedPositiveExposure = new double [vertexCount ];
217
+ double [] collateralizedPositiveExposure = collateralizedExposure ();
221
218
222
- for (int j = 0 ; j < vertexCount ; ++j )
223
- {
224
- collateralizedPositiveExposure [j ] = 0. ;
225
- }
219
+ int vertexCount = collateralizedPositiveExposure .length ;
226
220
227
- for (int positionGroupIndex = 0 ; positionGroupIndex < positionGroupCount ; ++positionGroupIndex )
221
+ for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
228
222
{
229
- double [] positionGroupCollateralizedExposure =
230
- _positionGroupPathArray [positionGroupIndex ].collateralizedExposure ();
231
-
232
- for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
233
- {
234
- double collateralizedExposure = positionGroupCollateralizedExposure [vertexIndex ];
235
-
236
- if (0. < collateralizedExposure )
237
- {
238
- collateralizedPositiveExposure [vertexIndex ] += collateralizedExposure ;
239
- }
240
- }
223
+ if (0. > collateralizedPositiveExposure [vertexIndex ])
224
+ collateralizedPositiveExposure [vertexIndex ] = 0. ;
241
225
}
242
226
243
227
return collateralizedPositiveExposure ;
@@ -251,33 +235,14 @@ public double[] collateralizedPositiveExposure()
251
235
252
236
public double [] collateralizedPositiveExposurePV ()
253
237
{
254
- int vertexCount = anchorDates (). length ;
238
+ double [] collateralizedPositiveExposurePV = collateralizedExposurePV () ;
255
239
256
- int positionGroupCount = _positionGroupPathArray .length ;
257
- double [] collateralizedPositiveExposurePV = new double [vertexCount ];
240
+ int vertexCount = collateralizedPositiveExposurePV .length ;
258
241
259
- for (int j = 0 ; j < vertexCount ; ++j )
242
+ for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
260
243
{
261
- collateralizedPositiveExposurePV [j ] = 0. ;
262
- }
263
-
264
- for (int positionGroupIndex = 0 ; positionGroupIndex < positionGroupCount ; ++positionGroupIndex )
265
- {
266
- double [] positionGroupCollateralizedExposure =
267
- _positionGroupPathArray [positionGroupIndex ].collateralizedExposure ();
268
-
269
- org .drip .xva .universe .MarketVertex [] marketVertexArray = _marketPath .vertexes ();
270
-
271
- for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
272
- {
273
- double collateralizedExposure = positionGroupCollateralizedExposure [vertexIndex ];
274
-
275
- if (0. < collateralizedExposure )
276
- {
277
- collateralizedPositiveExposurePV [vertexIndex ] += collateralizedExposure *
278
- marketVertexArray [vertexIndex ].overnightReplicator ();
279
- }
280
- }
244
+ if (0. > collateralizedPositiveExposurePV [vertexIndex ])
245
+ collateralizedPositiveExposurePV [vertexIndex ] = 0. ;
281
246
}
282
247
283
248
return collateralizedPositiveExposurePV ;
@@ -291,30 +256,14 @@ public double[] collateralizedPositiveExposurePV()
291
256
292
257
public double [] collateralizedNegativeExposure ()
293
258
{
294
- int vertexCount = anchorDates (). length ;
259
+ double [] collateralizedNegativeExposure = collateralizedExposure () ;
295
260
296
- int positionGroupCount = _positionGroupPathArray .length ;
297
- double [] collateralizedNegativeExposure = new double [vertexCount ];
261
+ int vertexCount = collateralizedNegativeExposure .length ;
298
262
299
- for (int j = 0 ; j < vertexCount ; ++j )
263
+ for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
300
264
{
301
- collateralizedNegativeExposure [j ] = 0. ;
302
- }
303
-
304
- for (int positionGroupIndex = 0 ; positionGroupIndex < positionGroupCount ; ++positionGroupIndex )
305
- {
306
- double [] positionGroupCollateralizedExposure =
307
- _positionGroupPathArray [positionGroupIndex ].collateralizedExposure ();
308
-
309
- for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
310
- {
311
- double collateralizedExposure = positionGroupCollateralizedExposure [vertexIndex ];
312
-
313
- if (0. > collateralizedExposure )
314
- {
315
- collateralizedNegativeExposure [vertexIndex ] += collateralizedExposure ;
316
- }
317
- }
265
+ if (0. < collateralizedNegativeExposure [vertexIndex ])
266
+ collateralizedNegativeExposure [vertexIndex ] = 0. ;
318
267
}
319
268
320
269
return collateralizedNegativeExposure ;
@@ -328,33 +277,14 @@ public double[] collateralizedNegativeExposure()
328
277
329
278
public double [] collateralizedNegativeExposurePV ()
330
279
{
331
- int vertexCount = anchorDates ().length ;
332
-
333
- int positionGroupCount = _positionGroupPathArray .length ;
334
- double [] collateralizedNegativeExposurePV = new double [vertexCount ];
280
+ double [] collateralizedNegativeExposurePV = collateralizedExposurePV ();
335
281
336
- for (int j = 0 ; j < vertexCount ; ++j )
337
- {
338
- collateralizedNegativeExposurePV [j ] = 0. ;
339
- }
282
+ int vertexCount = collateralizedNegativeExposurePV .length ;
340
283
341
- for (int positionGroupIndex = 0 ; positionGroupIndex < positionGroupCount ; ++positionGroupIndex )
284
+ for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
342
285
{
343
- double [] positionGroupCollateralizedExposure =
344
- _positionGroupPathArray [positionGroupIndex ].collateralizedExposure ();
345
-
346
- org .drip .xva .universe .MarketVertex [] marketVertexArray = _marketPath .vertexes ();
347
-
348
- for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
349
- {
350
- double collateralizedExposure = positionGroupCollateralizedExposure [vertexIndex ];
351
-
352
- if (0. > collateralizedExposure )
353
- {
354
- collateralizedNegativeExposurePV [vertexIndex ] += collateralizedExposure *
355
- marketVertexArray [vertexIndex ].overnightReplicator ();
356
- }
357
- }
286
+ if (0. < collateralizedNegativeExposurePV [vertexIndex ])
287
+ collateralizedNegativeExposurePV [vertexIndex ] = 0. ;
358
288
}
359
289
360
290
return collateralizedNegativeExposurePV ;
@@ -433,29 +363,14 @@ public double[] uncollateralizedExposurePV()
433
363
434
364
public double [] uncollateralizedPositiveExposure ()
435
365
{
436
- int vertexCount = anchorDates ().length ;
437
-
438
- int positionGroupCount = _positionGroupPathArray .length ;
439
- double [] uncollateralizedPositiveExposure = new double [vertexCount ];
366
+ double [] uncollateralizedPositiveExposure = uncollateralizedExposure ();
440
367
441
- for (int j = 0 ; j < vertexCount ; ++j )
442
- {
443
- uncollateralizedPositiveExposure [j ] = 0. ;
444
- }
368
+ int vertexCount = uncollateralizedPositiveExposure .length ;
445
369
446
- for (int positionGroupIndex = 0 ; positionGroupIndex < positionGroupCount ; ++positionGroupIndex )
370
+ for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
447
371
{
448
- double [] positionGroupCollateralizedExposure =
449
- _positionGroupPathArray [positionGroupIndex ].uncollateralizedExposure ();
450
-
451
- for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex ) {
452
- double uncollateralizedExposure = positionGroupCollateralizedExposure [vertexIndex ];
453
-
454
- if (0. < uncollateralizedExposure )
455
- {
456
- uncollateralizedPositiveExposure [vertexIndex ] += uncollateralizedExposure ;
457
- }
458
- }
372
+ if (0. > uncollateralizedPositiveExposure [vertexIndex ])
373
+ uncollateralizedPositiveExposure [vertexIndex ] = 0. ;
459
374
}
460
375
461
376
return uncollateralizedPositiveExposure ;
@@ -469,33 +384,14 @@ public double[] uncollateralizedPositiveExposure()
469
384
470
385
public double [] uncollateralizedPositiveExposurePV ()
471
386
{
472
- int vertexCount = anchorDates (). length ;
387
+ double [] uncollateralizedPositiveExposurePV = uncollateralizedExposurePV () ;
473
388
474
- int positionGroupCount = _positionGroupPathArray .length ;
475
- double [] uncollateralizedPositiveExposurePV = new double [vertexCount ];
389
+ int vertexCount = uncollateralizedPositiveExposurePV .length ;
476
390
477
- for (int j = 0 ; j < vertexCount ; ++j )
391
+ for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
478
392
{
479
- uncollateralizedPositiveExposurePV [j ] = 0. ;
480
- }
481
-
482
- for (int positionGroupIndex = 0 ; positionGroupIndex < positionGroupCount ; ++positionGroupIndex )
483
- {
484
- double [] positionGroupCollateralizedExposure =
485
- _positionGroupPathArray [positionGroupIndex ].uncollateralizedExposure ();
486
-
487
- org .drip .xva .universe .MarketVertex [] marketVertexArray = _marketPath .vertexes ();
488
-
489
- for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
490
- {
491
- double uncollateralizedExposure = positionGroupCollateralizedExposure [vertexIndex ];
492
-
493
- if (0. < uncollateralizedExposure )
494
- {
495
- uncollateralizedPositiveExposurePV [vertexIndex ] += uncollateralizedExposure *
496
- marketVertexArray [vertexIndex ].overnightReplicator ();
497
- }
498
- }
393
+ if (0. > uncollateralizedPositiveExposurePV [vertexIndex ])
394
+ uncollateralizedPositiveExposurePV [vertexIndex ] = 0. ;
499
395
}
500
396
501
397
return uncollateralizedPositiveExposurePV ;
@@ -509,30 +405,14 @@ public double[] uncollateralizedPositiveExposurePV()
509
405
510
406
public double [] uncollateralizedNegativeExposure ()
511
407
{
512
- int vertexCount = anchorDates (). length ;
408
+ double [] uncollateralizedNegativeExposure = uncollateralizedExposure () ;
513
409
514
- int positionGroupCount = _positionGroupPathArray .length ;
515
- double [] uncollateralizedNegativeExposure = new double [vertexCount ];
410
+ int vertexCount = uncollateralizedNegativeExposure .length ;
516
411
517
- for (int j = 0 ; j < vertexCount ; ++j )
412
+ for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
518
413
{
519
- uncollateralizedNegativeExposure [j ] = 0. ;
520
- }
521
-
522
- for (int positionGroupIndex = 0 ; positionGroupIndex < positionGroupCount ; ++positionGroupIndex )
523
- {
524
- double [] positionGroupUncollateralizedExposure =
525
- _positionGroupPathArray [positionGroupIndex ].uncollateralizedExposure ();
526
-
527
- for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
528
- {
529
- double uncollateralizedExposure = positionGroupUncollateralizedExposure [vertexIndex ];
530
-
531
- if (0. > uncollateralizedExposure )
532
- {
533
- uncollateralizedNegativeExposure [vertexIndex ] += uncollateralizedExposure ;
534
- }
535
- }
414
+ if (0. > uncollateralizedNegativeExposure [vertexIndex ])
415
+ uncollateralizedNegativeExposure [vertexIndex ] = 0. ;
536
416
}
537
417
538
418
return uncollateralizedNegativeExposure ;
@@ -546,33 +426,14 @@ public double[] uncollateralizedNegativeExposure()
546
426
547
427
public double [] uncollateralizedNegativeExposurePV ()
548
428
{
549
- int vertexCount = anchorDates (). length ;
429
+ double [] uncollateralizedNegativeExposurePV = uncollateralizedExposurePV () ;
550
430
551
- int positionGroupCount = _positionGroupPathArray .length ;
552
- double [] uncollateralizedNegativeExposurePV = new double [vertexCount ];
431
+ int vertexCount = uncollateralizedNegativeExposurePV .length ;
553
432
554
- for (int j = 0 ; j < vertexCount ; ++j )
433
+ for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
555
434
{
556
- uncollateralizedNegativeExposurePV [j ] = 0. ;
557
- }
558
-
559
- for (int positionGroupIndex = 0 ; positionGroupIndex < positionGroupCount ; ++positionGroupIndex )
560
- {
561
- double [] positionGroupCollateralizedExposure =
562
- _positionGroupPathArray [positionGroupIndex ].uncollateralizedExposure ();
563
-
564
- org .drip .xva .universe .MarketVertex [] marketVertexArray = _marketPath .vertexes ();
565
-
566
- for (int vertexIndex = 0 ; vertexIndex < vertexCount ; ++vertexIndex )
567
- {
568
- double uncollateralizedExposure = positionGroupCollateralizedExposure [vertexIndex ];
569
-
570
- if (0. > uncollateralizedExposure )
571
- {
572
- uncollateralizedNegativeExposurePV [vertexIndex ] += uncollateralizedExposure *
573
- marketVertexArray [vertexIndex ].overnightReplicator ();
574
- }
575
- }
435
+ if (0. > uncollateralizedNegativeExposurePV [vertexIndex ])
436
+ uncollateralizedNegativeExposurePV [vertexIndex ] = 0. ;
576
437
}
577
438
578
439
return uncollateralizedNegativeExposurePV ;
@@ -841,25 +702,27 @@ public double[] collateralBalancePV()
841
702
842
703
public double [] periodCollateralValueAdjustment ()
843
704
{
844
- org .drip .xva .universe .MarketVertex [] marketVertexArray = _marketPath .vertexes ();
845
-
846
- double [] collateralBalancePV = collateralBalancePV ();
705
+ int vertexCount = anchorDates ().length ;
847
706
848
- int vertexCount = collateralBalancePV .length ;
849
- double [] periodCollateralValueAdjustment = new double [vertexCount - 1 ];
707
+ int periodCount = vertexCount - 1 ;
708
+ int positionGroupCount = _positionGroupPathArray .length ;
709
+ double [] periodCollateralValueAdjustment = new double [periodCount ];
850
710
851
- for (int vertexIndex = 1 ; vertexIndex < vertexCount ; ++vertexIndex )
711
+ for (int periodIndex = 0 ; periodIndex < periodCount ; ++periodIndex )
852
712
{
853
- double periodIntegrandStart = collateralBalancePV [ vertexIndex - 1 ] *
854
- marketVertexArray [ vertexIndex - 1 ]. csaSpread ();
713
+ periodCollateralValueAdjustment [ periodIndex ] = 0. ;
714
+ }
855
715
856
- double periodIntegrandEnd = collateralBalancePV [vertexIndex ] *
857
- marketVertexArray [vertexIndex ].csaSpread ();
716
+ for (int positionGroupIndex = 0 ; positionGroupIndex < positionGroupCount ; ++positionGroupIndex )
717
+ {
718
+ double [] positionPeriodCollateralValueAdjustment =
719
+ _positionGroupPathArray [positionGroupIndex ].periodCollateralValueAdjustment ();
858
720
859
- periodCollateralValueAdjustment [vertexIndex - 1 ] =
860
- -0.5 * (periodIntegrandStart + periodIntegrandEnd )
861
- * (marketVertexArray [vertexIndex ].anchorDate ().julian () -
862
- marketVertexArray [vertexIndex - 1 ].anchorDate ().julian ()) / 365.25 ;
721
+ for (int periodIndex = 0 ; periodIndex < periodCount ; ++periodIndex )
722
+ {
723
+ periodCollateralValueAdjustment [periodIndex ] +=
724
+ positionPeriodCollateralValueAdjustment [periodIndex ];
725
+ }
863
726
}
864
727
865
728
return periodCollateralValueAdjustment ;
0 commit comments