From e966f8305af7ac2dda01e91b1790d10d6411438d Mon Sep 17 00:00:00 2001 From: Lakshmi Krishnamurthy Date: Thu, 1 Mar 2018 18:19:04 -0500 Subject: [PATCH] Features: - CDGS Bank Hazard Rate Label (7) - CDGS Bank Recovery Rate Label (8, 9) - CDGS Counter Party Hazard Label (10) - CDGS Counter Party Recovery Label (11) - Credit Debt Group Specification Constructor (12, 13, 14) - Credit Debt Group Specification Static (17) Bug Fixes/Clean-up: - Eliminate Position Group Specification Container (1) - Eliminate XVA Group Specification Container (2, 3) - Set Into Proto Package Transform (4) - Credit Debt Netting Group Sepcification (5) - Market Entity Evolver Dynamics Container (6) Samples: - Albanese Andersen Basel Proxy (15, 16) - Set Off Basel Proxy (18) - Semi Replication Basel Proxy (19) - One Way Basel Proxy (20) - Hedge Error Basel Proxy (21) - Gold Plated Basel Proxy (22) - USD Broken Date LIBOR Forward (23) - EUR Broken Date LIBOR #1 (24, 25) - EUR Broken Date LIBOR #2 (26, 27) - EUR Broken Date LIBOR #3 (28, 29) - Bond Sink Metrics IchalKaranji #1 (30, 31) - Bond Sink Metrics IchalKaranji #2 (32, 33) - Bond Sink Metrics IchalKaranji #3 (34, 35) - Bond Sink Metrics IchalKaranji #4 (36, 37) - Bond Sink Metrics IchalKaranji #5 (38, 39) - Bond Sink Metrics IchalKaranji #6 (40, 41) - Bond Sink Metrics IchalKaranji #7 (42, 43) - Bond Sink Metrics IchalKaranji #8 (44, 45) - Bond Sink Metrics IchalKaranji #9 (46, 47) - Bond Sink Metrics IchalKaranji #10 (48, 49) - Bond Sink Metrics IchalKaranji #11 (50, 51) - Bond Sink Metrics IchalKaranji #12 (52, 53) - Bond Sink Metrics IchalKaranji #13 (54, 55) - Bond Sink Metrics IchalKaranji #14 (56, 57) - Bond Sink Metrics IchalKaranji #15 (58, 59) - Bond Sink Metrics IchalKaranji #16 (60, 61) - Bond Sink Metrics IchalKaranji #17 (62, 63) - Bond Sink Metrics IchalKaranji #18 (64, 65) - Bond Sink Metrics Aligarh #1 (66, 67) - Bond Sink Metrics Aligarh #2 (68, 69) - Bond Sink Metrics Amaravati #1 (70, 71) - Bond Sink Metrics Amaravati #2 (72, 73) - Bond Sink Metrics Amaravati #3 (74, 75) - Bond Sink Metrics Amaravati #4 (76, 77) - Bond Sink Metrics Amaravati #5 (78, 79) - Bond Sink Metrics Bhavnagar #1 (80, 81) - Bond Sink Metrics Bhavnagar #2 (82, 83) - Bond Sink Metrics Bhiwandi #1 (84, 85) - Bond Sink Metrics Bhiwandi #2 (86, 87) - Bond Sink Metrics Bhubaneshwar #1 (88, 89) - Bond Sink Metrics Bhubaneshwar #2 (90, 91) - Bond Sink Metrics Bikaner #1 (92, 93) - Bond Sink Metrics Bikaner #2 (94, 95) - Bond Sink Metrics Cuttack #1 (96, 97) - Bond Sink Metrics Cuttack #2 (98, 99) - Bond Sink Metrics Dehradun #1 (100, 101) - Bond Sink Metrics Dehradun #2 (102, 103) - Bond Sink Metrics Firozabad #1 (104, 105) - Bond Sink Metrics Firozabad #2 (106, 107) - Bond Sink Metrics Gorakhpur #1 (108, 109) - Bond Sink Metrics Gorakhpur #2 (110, 111) - Bond Sink Metrics Guntur #1 (112, 113) - Bond Sink Metrics Guntur #2 (114, 115) - Bond Sink Metrics Mira Bhayandar #1 (116, 117) - Bond Sink Metrics Mira Bhayandar #2 (118, 119) - Bond Sink Metrics Nellore #1 (120, 121) - Bond Sink Metrics Nellore #2 (122, 123) - Bond Sink Metrics Saharanpur #1 (124, 125) - Bond Sink Metrics Saharanpur #2 (126, 127) - Bond Sink Metrics Salem #1 (128, 129) - Bond Sink Metrics Salem #2 (130, 131) - Bond Sink Metrics Warangal #1 (132, 133) - Bond Sink Metrics Warangal #2 (134, 135) --- ReleaseNotes/03_12_2018.txt | 85 ++ .../org/drip/product/creator/BondBuilder.java | 4 +- .../drip/product/credit/BondComponent.java | 39 +- .../java/org/drip/quant/common/Array2D.java | 6 + .../org/drip/sample/bondsink/Aligarh.java | 613 +++-------- .../org/drip/sample/bondsink/Amaravati.java | 953 +++++++++--------- .../org/drip/sample/bondsink/Bhavnagar.java | 619 +++--------- .../org/drip/sample/bondsink/Bhiwandi.java | 647 ++++-------- .../org/drip/sample/bondsink/Bhubaneswar.java | 643 ++++-------- .../org/drip/sample/bondsink/Bikaner.java | 623 +++--------- .../org/drip/sample/bondsink/Cuttack.java | 619 +++--------- .../org/drip/sample/bondsink/Dehradun.java | 684 ++++--------- .../org/drip/sample/bondsink/Firozabad.java | 611 +++-------- .../org/drip/sample/bondsink/Gorakhpur.java | 659 ++++-------- .../java/org/drip/sample/bondsink/Guntur.java | 631 +++--------- .../drip/sample/bondsink/Ichalkaranji.java | 266 +++++ .../drip/sample/bondsink/MiraBhayander.java | 622 +++--------- .../org/drip/sample/bondsink/Nellore.java | 643 ++++-------- .../org/drip/sample/bondsink/Saharanpur.java | 688 ++++--------- .../java/org/drip/sample/bondsink/Salem.java | 637 ++++-------- .../org/drip/sample/bondsink/Warangal.java | 641 ++++-------- .../CorrelatedNumeraireXVAAttribution.java | 2 +- .../CorrelatedNumeraireXVAExplain.java | 2 +- .../CorrelatedNumeraireXVAGreeks.java | 2 +- ...latedNumeraireXVAReplicationPortfolio.java | 2 +- .../drip/sample/burgard2011/XVAExplain.java | 2 +- .../drip/sample/burgard2011/XVAGreeks.java | 2 +- .../burgard2011/XVAMarketGeneration.java | 2 +- .../burgard2011/XVAReplicationPortfolio.java | 2 +- .../EulerTrajectoryEvolutionScheme.java | 2 +- ...rfectReplicationCollateralizedFunding.java | 2 +- ...cationCollateralizedFundingStochastic.java | 2 +- ...erfectReplicationZeroThresholdFunding.java | 2 +- ...icationZeroThresholdFundingStochastic.java | 2 +- .../SemiReplicationCollateralizedFunding.java | 2 +- ...cationCollateralizedFundingStochastic.java | 2 +- .../SemiReplicationZeroThresholdFunding.java | 2 +- ...icationZeroThresholdFundingStochastic.java | 2 +- .../SetOffCollateralizedFunding.java | 2 +- ...SetOffCollateralizedFundingStochastic.java | 2 +- .../SetOffZeroThresholdFunding.java | 2 +- .../SetOffZeroThresholdFundingStochastic.java | 2 +- .../sample/intexfeed/BrokenDateLIBOREUR.java | 188 ++++ ...ORForward.java => BrokenDateLIBORUSD.java} | 4 +- .../xva/CollateralizedCollateralGroup.java | 2 +- ...llateralizedCollateralGroupCorrelated.java | 2 +- .../xva/PortfolioCollateralEstimate.java | 2 +- .../xva/ZeroThresholdCollateralGroup.java | 2 +- ...eroThresholdCollateralGroupCorrelated.java | 2 +- .../CollateralizedCollateralNeutral.java | 2 +- ...ateralizedCollateralNeutralStochastic.java | 2 +- .../CollateralizedCollateralPayable.java | 2 +- ...ateralizedCollateralPayableStochastic.java | 2 +- .../CollateralizedCollateralReceivable.java | 2 +- ...ralizedCollateralReceivableStochastic.java | 2 +- .../CollateralizedFundingNeutral.java | 2 +- ...ollateralizedFundingNeutralStochastic.java | 2 +- .../CollateralizedFundingPayable.java | 2 +- ...ollateralizedFundingPayableStochastic.java | 2 +- .../CollateralizedFundingReceivable.java | 2 +- ...ateralizedFundingReceivableStochastic.java | 2 +- .../CollateralizedNettingNeutral.java | 2 +- ...ollateralizedNettingNeutralStochastic.java | 2 +- .../CollateralizedNettingPayable.java | 2 +- ...ollateralizedNettingPayableStochastic.java | 2 +- .../CollateralizedNettingReceivable.java | 2 +- ...ateralizedNettingReceivableStochastic.java | 2 +- .../ZeroThresholdCollateralNeutral.java | 2 +- ...oThresholdCollateralNeutralStochastic.java | 2 +- .../ZeroThresholdCollateralPayable.java | 2 +- ...oThresholdCollateralPayableStochastic.java | 2 +- .../ZeroThresholdCollateralReceivable.java | 2 +- ...resholdCollateralReceivableStochastic.java | 2 +- .../xvabasel/ZeroThresholdFundingNeutral.java | 2 +- ...ZeroThresholdFundingNeutralStochastic.java | 2 +- .../xvabasel/ZeroThresholdFundingPayable.java | 2 +- ...ZeroThresholdFundingPayableStochastic.java | 2 +- .../ZeroThresholdFundingReceivable.java | 2 +- ...oThresholdFundingReceivableStochastic.java | 2 +- .../xvabasel/ZeroThresholdNettingNeutral.java | 2 +- ...ZeroThresholdNettingNeutralStochastic.java | 2 +- .../xvabasel/ZeroThresholdNettingPayable.java | 2 +- ...ZeroThresholdNettingPayableStochastic.java | 2 +- .../ZeroThresholdNettingReceivable.java | 2 +- ...oThresholdNettingReceivableStochastic.java | 2 +- .../sample/xvadigest/CPGACollateralized.java | 2 +- .../CPGACollateralizedCorrelated.java | 2 +- .../sample/xvadigest/CPGAZeroThreshold.java | 2 +- .../CPGAZeroThresholdCorrelated.java | 2 +- .../AlbaneseAndersenBaselProxy.java | 25 +- .../xvafixfloat/GoldPlatedBaselProxy.java | 28 +- .../xvafixfloat/HedgeErrorBaselProxy.java | 28 +- .../sample/xvafixfloat/OneWayBaselProxy.java | 28 +- .../SemiReplicationBaselProxy.java | 28 +- .../sample/xvafixfloat/SetOffBaselProxy.java | 28 +- .../org/drip/service/env/BuildManager.java | 5 + .../org/drip/xva/dynamics/PathSimulator.java | 2 +- ...iner.java => EntityDynamicsContainer.java} | 16 +- .../xva/evolver/LatentStateNodeContainer.java | 40 +- .../org/drip/xva/holdings/PositionGroup.java | 6 +- .../CollateralAmountEstimator.java | 6 +- .../xva/hypothecation/CollateralGroup.java | 6 +- .../CollateralGroupSpecification.java | 4 +- .../proto/CreditDebtGroupSpecification.java | 247 +++++ .../PositionGroupSpecification.java | 22 +- .../RollUpGroupSpecification.java | 2 +- .../drip/xva/{set => proto}/package-info.java | 2 +- .../xva/set/GroupSpecificationContainer.java | 285 ------ .../xva/set/NettingGroupSpecification.java | 152 --- .../PositionGroupSpecificationContainer.java | 72 -- .../xva/universe/MarketVertexGenerator.java | 8 +- 111 files changed, 4210 insertions(+), 8087 deletions(-) create mode 100644 ReleaseNotes/03_12_2018.txt create mode 100644 src/main/java/org/drip/sample/bondsink/Ichalkaranji.java create mode 100644 src/main/java/org/drip/sample/intexfeed/BrokenDateLIBOREUR.java rename src/main/java/org/drip/sample/intexfeed/{BrokenDateLIBORForward.java => BrokenDateLIBORUSD.java} (98%) rename src/main/java/org/drip/xva/evolver/{MarketDynamicsContainer.java => EntityDynamicsContainer.java} (94%) rename src/main/java/org/drip/xva/{set => proto}/CollateralGroupSpecification.java (98%) create mode 100644 src/main/java/org/drip/xva/proto/CreditDebtGroupSpecification.java rename src/main/java/org/drip/xva/{set => proto}/PositionGroupSpecification.java (83%) rename src/main/java/org/drip/xva/{set => proto}/RollUpGroupSpecification.java (99%) rename src/main/java/org/drip/xva/{set => proto}/package-info.java (76%) delete mode 100644 src/main/java/org/drip/xva/set/GroupSpecificationContainer.java delete mode 100644 src/main/java/org/drip/xva/set/NettingGroupSpecification.java delete mode 100644 src/main/java/org/drip/xva/set/PositionGroupSpecificationContainer.java diff --git a/ReleaseNotes/03_12_2018.txt b/ReleaseNotes/03_12_2018.txt new file mode 100644 index 000000000000..ef9ff23e45ba --- /dev/null +++ b/ReleaseNotes/03_12_2018.txt @@ -0,0 +1,85 @@ + +Features: + + - CDGS Bank Hazard Rate Label (7) + - CDGS Bank Recovery Rate Label (8, 9) + - CDGS Counter Party Hazard Label (10) + - CDGS Counter Party Recovery Label (11) + - Credit Debt Group Specification Constructor (12, 13, 14) + - Credit Debt Group Specification Static (17) + + +Bug Fixes/Clean-up: + + - Eliminate Position Group Specification Container (1) + - Eliminate XVA Group Specification Container (2, 3) + - Set Into Proto Package Transform (4) + - Credit Debt Netting Group Sepcification (5) + - Market Entity Evolver Dynamics Container (6) + + +Samples: + + - Albanese Andersen Basel Proxy (15, 16) + - Set Off Basel Proxy (18) + - Semi Replication Basel Proxy (19) + - One Way Basel Proxy (20) + - Hedge Error Basel Proxy (21) + - Gold Plated Basel Proxy (22) + - USD Broken Date LIBOR Forward (23) + - EUR Broken Date LIBOR #1 (24, 25) + - EUR Broken Date LIBOR #2 (26, 27) + - EUR Broken Date LIBOR #3 (28, 29) + - Bond Sink Metrics IchalKaranji #1 (30, 31) + - Bond Sink Metrics IchalKaranji #2 (32, 33) + - Bond Sink Metrics IchalKaranji #3 (34, 35) + - Bond Sink Metrics IchalKaranji #4 (36, 37) + - Bond Sink Metrics IchalKaranji #5 (38, 39) + - Bond Sink Metrics IchalKaranji #6 (40, 41) + - Bond Sink Metrics IchalKaranji #7 (42, 43) + - Bond Sink Metrics IchalKaranji #8 (44, 45) + - Bond Sink Metrics IchalKaranji #9 (46, 47) + - Bond Sink Metrics IchalKaranji #10 (48, 49) + - Bond Sink Metrics IchalKaranji #11 (50, 51) + - Bond Sink Metrics IchalKaranji #12 (52, 53) + - Bond Sink Metrics IchalKaranji #13 (54, 55) + - Bond Sink Metrics IchalKaranji #14 (56, 57) + - Bond Sink Metrics IchalKaranji #15 (58, 59) + - Bond Sink Metrics IchalKaranji #16 (60, 61) + - Bond Sink Metrics IchalKaranji #17 (62, 63) + - Bond Sink Metrics IchalKaranji #18 (64, 65) + - Bond Sink Metrics Aligarh #1 (66, 67) + - Bond Sink Metrics Aligarh #2 (68, 69) + - Bond Sink Metrics Amaravati #1 (70, 71) + - Bond Sink Metrics Amaravati #2 (72, 73) + - Bond Sink Metrics Amaravati #3 (74, 75) + - Bond Sink Metrics Amaravati #4 (76, 77) + - Bond Sink Metrics Amaravati #5 (78, 79) + - Bond Sink Metrics Bhavnagar #1 (80, 81) + - Bond Sink Metrics Bhavnagar #2 (82, 83) + - Bond Sink Metrics Bhiwandi #1 (84, 85) + - Bond Sink Metrics Bhiwandi #2 (86, 87) + - Bond Sink Metrics Bhubaneshwar #1 (88, 89) + - Bond Sink Metrics Bhubaneshwar #2 (90, 91) + - Bond Sink Metrics Bikaner #1 (92, 93) + - Bond Sink Metrics Bikaner #2 (94, 95) + - Bond Sink Metrics Cuttack #1 (96, 97) + - Bond Sink Metrics Cuttack #2 (98, 99) + - Bond Sink Metrics Dehradun #1 (100, 101) + - Bond Sink Metrics Dehradun #2 (102, 103) + - Bond Sink Metrics Firozabad #1 (104, 105) + - Bond Sink Metrics Firozabad #2 (106, 107) + - Bond Sink Metrics Gorakhpur #1 (108, 109) + - Bond Sink Metrics Gorakhpur #2 (110, 111) + - Bond Sink Metrics Guntur #1 (112, 113) + - Bond Sink Metrics Guntur #2 (114, 115) + - Bond Sink Metrics Mira Bhayandar #1 (116, 117) + - Bond Sink Metrics Mira Bhayandar #2 (118, 119) + - Bond Sink Metrics Nellore #1 (120, 121) + - Bond Sink Metrics Nellore #2 (122, 123) + - Bond Sink Metrics Saharanpur #1 (124, 125) + - Bond Sink Metrics Saharanpur #2 (126, 127) + - Bond Sink Metrics Salem #1 (128, 129) + - Bond Sink Metrics Salem #2 (130, 131) + - Bond Sink Metrics Warangal #1 (132, 133) + - Bond Sink Metrics Warangal #2 (134, 135) diff --git a/src/main/java/org/drip/product/creator/BondBuilder.java b/src/main/java/org/drip/product/creator/BondBuilder.java index e93a630805c6..3dd68ed33098 100644 --- a/src/main/java/org/drip/product/creator/BondBuilder.java +++ b/src/main/java/org/drip/product/creator/BondBuilder.java @@ -240,7 +240,7 @@ public static final org.drip.product.credit.BondComponent CreateSimpleFixed ( 100., strCurrency, fsPrincipalOutstanding, - org.drip.product.params.NotionalSetting.PERIOD_AMORT_AT_END, + org.drip.product.params.NotionalSetting.PERIOD_AMORT_AT_START, false ) ); @@ -369,7 +369,7 @@ public static final org.drip.product.credit.BondComponent CreateSimpleFixedFP ( 100., strCurrency, fsPrincipalOutstanding, - org.drip.product.params.NotionalSetting.PERIOD_AMORT_AT_END, + org.drip.product.params.NotionalSetting.PERIOD_AMORT_AT_START, false ) ); diff --git a/src/main/java/org/drip/product/credit/BondComponent.java b/src/main/java/org/drip/product/credit/BondComponent.java index f488a0d8b571..d9854b286d82 100644 --- a/src/main/java/org/drip/product/credit/BondComponent.java +++ b/src/main/java/org/drip/product/credit/BondComponent.java @@ -432,14 +432,37 @@ else if (org.drip.product.params.NotionalSetting.PERIOD_AMORT_EFFECTIVE == iCashPayDate = valParams.cashPayDate(); } - return (((dblCumulativePeriodPV + dblWorkoutFactor * org.drip.analytics.support.Helper.Yield2DF - (iFrequency, dblYield, s_bYieldDFOffofCouponAccrualDCF ? dblPeriodYearFract : - org.drip.analytics.daycount.Convention.YearFraction (iValueDate, terminationAdjust - (iWorkoutDate), strDC, bApplyCpnEOMAdj, aap, strCalendar)) * notional (iWorkoutDate)) / - org.drip.analytics.support.Helper.Yield2DF (iFrequency, dblYield, - org.drip.analytics.daycount.Convention.YearFraction (iValueDate, iCashPayDate, - strDC, bApplyCpnEOMAdj, aap, strCalendar))) - accrued (iValueDate, csqc)) / - dblScalingNotional; + double dblCleanPrice = (((dblCumulativePeriodPV + dblWorkoutFactor * org.drip.analytics.support.Helper.Yield2DF ( + iFrequency, + dblYield, + s_bYieldDFOffofCouponAccrualDCF ? dblPeriodYearFract : + org.drip.analytics.daycount.Convention.YearFraction ( + iValueDate, + terminationAdjust (iWorkoutDate), + strDC, + bApplyCpnEOMAdj, + aap, + strCalendar + ) + ) * notional (iWorkoutDate)) / + org.drip.analytics.support.Helper.Yield2DF ( + iFrequency, + dblYield, + org.drip.analytics.daycount.Convention.YearFraction ( + iValueDate, + iCashPayDate, + strDC, + bApplyCpnEOMAdj, + aap, + strCalendar + ) + ) + ) - accrued ( + iValueDate, + csqc + )) / dblScalingNotional; + + return dblCleanPrice; } @Override public org.drip.analytics.support.CaseInsensitiveTreeMap calibMeasures ( diff --git a/src/main/java/org/drip/quant/common/Array2D.java b/src/main/java/org/drip/quant/common/Array2D.java index 65cf7a830578..be444189033d 100644 --- a/src/main/java/org/drip/quant/common/Array2D.java +++ b/src/main/java/org/drip/quant/common/Array2D.java @@ -224,6 +224,10 @@ public static final Array2D FromDateFactorVertex ( adblVertexDate[iNumVertex - 1] = iMaturityDate; + for (int i = 0; i < iNumVertex - 1; ++i) { + System.out.println (new org.drip.analytics.date.JulianDate ((int) adblVertexDate[i]) + " | " + adblVertexFactor[i]); + } + return FromArray (adblVertexDate, adblVertexFactor); } @@ -380,6 +384,8 @@ private Array2D ( throw new java.lang.Exception ("Array2D ctr => Invalid params"); for (int i = 0; i < iLength; ++i) { + // System.out.println (new org.drip.analytics.date.JulianDate ((int) _adblX[i]) + " | " + _adblY[i]); + if (!org.drip.quant.common.NumberUtil.IsValid (_adblX[i] = adblX[i]) || !org.drip.quant.common.NumberUtil.IsValid (_adblY[i] = adblY[i])) throw new java.lang.Exception ("Array2D ctr => Invalid params"); diff --git a/src/main/java/org/drip/sample/bondsink/Aligarh.java b/src/main/java/org/drip/sample/bondsink/Aligarh.java index 86c675857964..b7a21fa4919f 100644 --- a/src/main/java/org/drip/sample/bondsink/Aligarh.java +++ b/src/main/java/org/drip/sample/bondsink/Aligarh.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Aligarh demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Aligarh. + * Aligarh generates the Full Suite of Replication Metrics for the Sinker Bond Aligarh. * * @author Lakshmi Krishnamurthy */ public class Aligarh { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.NOVEMBER, + 17 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,155 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2011, 1, 25); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2021, 1, 31); - double dblCoupon = 0.0525; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Aligarh"; double dblCleanPrice = 1.075498; - int iFreq = 2; - String strCUSIP = "Aligarh"; - String strDayCount = "30/360"; - String strDateFactor = "1/25/2011;1;7/31/2011;0.998521611;1/31/2012;0.970816825;7/31/2012;0.947274843;1/31/2013;0.9017163;7/31/2013;0.856344;1/31/2014;0.8121407;7/31/2014;0.7670462;1/31/2015;0.7227887;7/31/2015;0.679846005;1/31/2016;0.636022108;7/31/2016;0.59296243;1/31/2017;0.550518728;7/31/2017;0.509633528;1/31/2018;0.470306832;7/31/2018;0.432538639;1/31/2019;0.396328948;7/31/2019;0.360213154;1/31/2020;0.325458203;7/31/2020;0.29240767"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.0525; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2011, + 1, + 25 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2021, + 1, + 31 + ); + + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2018, 1, 31).julian(), + DateUtil.CreateFromYMD (2018, 7, 31).julian(), + DateUtil.CreateFromYMD (2019, 1, 31).julian(), + DateUtil.CreateFromYMD (2019, 7, 31).julian(), + DateUtil.CreateFromYMD (2020, 1, 31).julian(), + DateUtil.CreateFromYMD (2020, 7, 31).julian(), + DateUtil.CreateFromYMD (2021, 1, 31).julian(), + }, + new double[] { + 0.509633528, + 0.470306832, + 0.432538639, + 0.396328948, + 0.360213154, + 0.325458203, + 0.29240767 + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Amaravati.java b/src/main/java/org/drip/sample/bondsink/Amaravati.java index aa0e7c4f4fb1..13e4b8ff1d1e 100644 --- a/src/main/java/org/drip/sample/bondsink/Amaravati.java +++ b/src/main/java/org/drip/sample/bondsink/Amaravati.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Amaravati demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Amaravati. + * Amaravati generates the Full Suite of Replication Metrics for the Sinker Bond Amaravati. * * @author Lakshmi Krishnamurthy */ public class Amaravati { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,495 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2009, 12, 22); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2032, 1, 10); - double dblCoupon = 0.07507; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 12; + String strName = "Amaravati"; double dblCleanPrice = 1.233069; - int iFreq = 12; - String strCUSIP = "Amaravati"; - String strDayCount = "30/360"; - String strDateFactor = "12/22/2009;1;2/10/2010;0.999034198;3/10/2010;0.997909758;4/10/2010;0.996672483;5/10/2010;0.995266021;6/10/2010;0.99379564;7/10/2010;0.992285536;8/10/2010;0.990700723;9/10/2010;0.989105996;10/10/2010;0.987501293;11/10/2010;0.985886551;12/10/2010;0.984261707;1/10/2011;0.982626699;2/10/2011;0.980981462;3/10/2011;0.979325933;4/10/2011;0.977660047;5/10/2011;0.97598374;6/10/2011;0.974296946;7/10/2011;0.9725996;8/10/2011;0.970891635;9/10/2011;0.969172986;10/10/2011;0.967443585;11/10/2011;0.965703365;12/10/2011;0.963952259;1/10/2012;0.962190198;2/10/2012;0.960417114;3/10/2012;0.958632938;4/10/2012;0.9568376;5/10/2012;0.955031031;6/10/2012;0.953213161;7/10/2012;0.951383918;8/10/2012;0.949543232;9/10/2012;0.94769103;10/10/2012;0.945827242;11/10/2012;0.943951794;12/10/2012;0.942064613;1/10/2013;0.940165627;2/10/2013;0.938254761;3/10/2013;0.936331941;4/10/2013;0.934397092;5/10/2013;0.932450139;6/10/2013;0.930491006;7/10/2013;0.928519617;8/10/2013;0.926535895;9/10/2013;0.924539764;10/10/2013;0.922531145;11/10/2013;0.920509961;12/10/2013;0.918476132;1/10/2014;0.91642958;2/10/2014;0.914370225;3/10/2014;0.912297987;4/10/2014;0.910212786;5/10/2014;0.90811454;6/10/2014;0.906003167;7/10/2014;0.903878587;8/10/2014;0.901740715;9/10/2014;0.899589469;10/10/2014;0.897424765;11/10/2014;0.895246519;12/10/2014;0.893054647;1/10/2015;0.890849062;2/10/2015;0.88862968;3/10/2015;0.886396414;4/10/2015;0.884149176;5/10/2015;0.881887881;6/10/2015;0.879612439;7/10/2015;0.877322762;8/10/2015;0.875018761;9/10/2015;0.872700347;10/10/2015;0.87036743;11/10/2015;0.868019918;12/10/2015;0.86565772;1/10/2016;0.863280745;2/10/2016;0.8608889;3/10/2016;0.858482092;4/10/2016;0.856060227;5/10/2016;0.853623212;6/10/2016;0.851170951;7/10/2016;0.848703349;8/10/2016;0.84622031;9/10/2016;0.843721738;10/10/2016;0.841207535;11/10/2016;0.838677603;12/10/2016;0.836131845;1/10/2017;0.833570161;2/10/2017;0.830992451;3/10/2017;0.828398616;4/10/2017;0.825788554;5/10/2017;0.823162164;6/10/2017;0.820519344;7/10/2017;0.81785999;8/10/2017;0.815184001;9/10/2017;0.81249127;10/10/2017;0.809781695;11/10/2017;0.807055169;12/10/2017;0.804311586;1/10/2018;0.801550839;2/10/2018;0.798772822;3/10/2018;0.795977426;4/10/2018;0.793164543;5/10/2018;0.790334062;6/10/2018;0.787485875;7/10/2018;0.78461987;8/10/2018;0.781735936;9/10/2018;0.77883396;10/10/2018;0.77591383;11/10/2018;0.772975432;12/10/2018;0.770018652;1/10/2019;0.767043374;2/10/2019;0.764049484;3/10/2019;0.761036865;4/10/2019;0.758005399;5/10/2019;0.754954969;6/10/2019;0.751885456;7/10/2019;0.74879674;8/10/2019;0.745688703;9/10/2019;0.742561221;10/10/2019;0.739414175;11/10/2019;0.736247441;12/10/2019;0.733060897;1/10/2020;0.729854418;2/10/2020;0.72662788;3/10/2020;0.723381158;4/10/2020;0.720114124;5/10/2020;0.716826652;6/10/2020;0.713518615;7/10/2020;0.710189883;8/10/2020;0.706840327;9/10/2020;0.703469816;10/10/2020;0.700078221;11/10/2020;0.696665408;12/10/2020;0.693231245;1/10/2021;0.689775599;2/10/2021;0.686298334;3/10/2021;0.682799317;4/10/2021;0.67927841;5/10/2021;0.675735477;6/10/2021;0.67217038;7/10/2021;0.66858298;8/10/2021;0.664973138;9/10/2021;0.661340714;10/10/2021;0.657685566;11/10/2021;0.654007551;12/10/2021;0.650306528;1/10/2022;0.646582352;2/10/2022;0.642834878;3/10/2022;0.63906396;4/10/2022;0.635269452;5/10/2022;0.631451206;6/10/2022;0.627609074;7/10/2022;0.623742906;8/10/2022;0.619852552;9/10/2022;0.615937861;10/10/2022;0.61199868;11/10/2022;0.608034856;12/10/2022;0.604046235;1/10/2023;0.600032662;2/10/2023;0.595993981;3/10/2023;0.591930035;4/10/2023;0.587840665;5/10/2023;0.583725712;6/10/2023;0.579585018;7/10/2023;0.575418419;8/10/2023;0.571225756;9/10/2023;0.567006863;10/10/2023;0.562761578;11/10/2023;0.558489735;12/10/2023;0.554191168;1/10/2024;0.54986571;2/10/2024;0.545513193;3/10/2024;0.541133447;4/10/2024;0.536726302;5/10/2024;0.532291587;6/10/2024;0.527829129;7/10/2024;0.523338754;8/10/2024;0.518820289;9/10/2024;0.514273556;10/10/2024;0.50969838;11/10/2024;0.505094583;12/10/2024;0.500461985;1/10/2025;0.495800406;2/10/2025;0.491109665;3/10/2025;0.48638958;4/10/2025;0.481639967;5/10/2025;0.47686064;6/10/2025;0.472051416;7/10/2025;0.467212105;8/10/2025;0.46234252;9/10/2025;0.457442473;10/10/2025;0.452511771;11/10/2025;0.447550224;12/10/2025;0.442557638;1/10/2026;0.437533819;2/10/2026;0.432478572;3/10/2026;0.4273917;4/10/2026;0.422273006;5/10/2026;0.41712229;6/10/2026;0.411939352;7/10/2026;0.40672399;8/10/2026;0.401476002;9/10/2026;0.396195184;10/10/2026;0.390881329;11/10/2026;0.385534232;12/10/2026;0.380153684;1/10/2027;0.374739477;2/10/2027;0.369291399;3/10/2027;0.363809239;4/10/2027;0.358292783;5/10/2027;0.352741818;6/10/2027;0.347156126;7/10/2027;0.341535492;8/10/2027;0.335879695;9/10/2027;0.330188517;10/10/2027;0.324461736;11/10/2027;0.318699129;12/10/2027;0.312900472;1/10/2028;0.307065539;2/10/2028;0.301194105;3/10/2028;0.295285939;4/10/2028;0.289340813;5/10/2028;0.283358496;6/10/2028;0.277338754;7/10/2028;0.271281353;8/10/2028;0.265186058;9/10/2028;0.259052633;10/10/2028;0.252880837;11/10/2028;0.246670432;12/10/2028;0.240421176;1/10/2029;0.234132825;2/10/2029;0.227805135;3/10/2029;0.221437861;4/10/2029;0.215030753;5/10/2029;0.208583564;6/10/2029;0.202096043;7/10/2029;0.195567936;8/10/2029;0.188998991;9/10/2029;0.182388952;10/10/2029;0.175737561;11/10/2029;0.169044561;12/10/2029;0.162309733;1/10/2030;0.156072928;2/10/2030;0.150025552;3/10/2030;0.143940344;4/10/2030;0.137817068;5/10/2030;0.131655486;6/10/2030;0.125455359;7/10/2030;0.119216444;8/10/2030;0.1129385;9/10/2030;0.106621281;10/10/2030;0.100264544;11/10/2030;0.09386804;12/10/2030;0.08743152;1/10/2031;0.080954734;2/10/2031;0.074437431;3/10/2031;0.067879357;4/10/2031;0.061280256;5/10/2031;0.054639873;6/10/2031;0.047957948;7/10/2031;0.041234222;8/10/2031;0.034468434;9/10/2031;0.027660321;10/10/2031;0.020809616;11/10/2031;0.013916055;12/10/2031;0.006979369"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.07507; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2009, + DateUtil.DECEMBER, + 22 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2032, + DateUtil.JANUARY, + 10 + ); + + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 4, 10).julian(), + DateUtil.CreateFromYMD (2017, 5, 10).julian(), + DateUtil.CreateFromYMD (2017, 6, 10).julian(), + DateUtil.CreateFromYMD (2017, 7, 10).julian(), + DateUtil.CreateFromYMD (2017, 8, 10).julian(), + DateUtil.CreateFromYMD (2017, 9, 10).julian(), + DateUtil.CreateFromYMD (2017, 10, 10).julian(), + DateUtil.CreateFromYMD (2017, 11, 10).julian(), + DateUtil.CreateFromYMD (2017, 12, 10).julian(), + DateUtil.CreateFromYMD (2018, 1, 10).julian(), + DateUtil.CreateFromYMD (2018, 2, 10).julian(), + DateUtil.CreateFromYMD (2018, 3, 10).julian(), + DateUtil.CreateFromYMD (2018, 4, 10).julian(), + DateUtil.CreateFromYMD (2018, 5, 10).julian(), + DateUtil.CreateFromYMD (2018, 6, 10).julian(), + DateUtil.CreateFromYMD (2018, 7, 10).julian(), + DateUtil.CreateFromYMD (2018, 8, 10).julian(), + DateUtil.CreateFromYMD (2018, 9, 10).julian(), + DateUtil.CreateFromYMD (2018, 10, 10).julian(), + DateUtil.CreateFromYMD (2018, 11, 10).julian(), + DateUtil.CreateFromYMD (2018, 12, 10).julian(), + DateUtil.CreateFromYMD (2019, 1, 10).julian(), + DateUtil.CreateFromYMD (2019, 2, 10).julian(), + DateUtil.CreateFromYMD (2019, 3, 10).julian(), + DateUtil.CreateFromYMD (2019, 4, 10).julian(), + DateUtil.CreateFromYMD (2019, 5, 10).julian(), + DateUtil.CreateFromYMD (2019, 6, 10).julian(), + DateUtil.CreateFromYMD (2019, 7, 10).julian(), + DateUtil.CreateFromYMD (2019, 8, 10).julian(), + DateUtil.CreateFromYMD (2019, 9, 10).julian(), + DateUtil.CreateFromYMD (2019, 10, 10).julian(), + DateUtil.CreateFromYMD (2019, 11, 10).julian(), + DateUtil.CreateFromYMD (2019, 12, 10).julian(), + DateUtil.CreateFromYMD (2020, 1, 10).julian(), + DateUtil.CreateFromYMD (2020, 2, 10).julian(), + DateUtil.CreateFromYMD (2020, 3, 10).julian(), + DateUtil.CreateFromYMD (2020, 4, 10).julian(), + DateUtil.CreateFromYMD (2020, 5, 10).julian(), + DateUtil.CreateFromYMD (2020, 6, 10).julian(), + DateUtil.CreateFromYMD (2020, 7, 10).julian(), + DateUtil.CreateFromYMD (2020, 8, 10).julian(), + DateUtil.CreateFromYMD (2020, 9, 10).julian(), + DateUtil.CreateFromYMD (2020, 10, 10).julian(), + DateUtil.CreateFromYMD (2020, 11, 10).julian(), + DateUtil.CreateFromYMD (2020, 12, 10).julian(), + DateUtil.CreateFromYMD (2021, 1, 10).julian(), + DateUtil.CreateFromYMD (2021, 2, 10).julian(), + DateUtil.CreateFromYMD (2021, 3, 10).julian(), + DateUtil.CreateFromYMD (2021, 4, 10).julian(), + DateUtil.CreateFromYMD (2021, 5, 10).julian(), + DateUtil.CreateFromYMD (2021, 6, 10).julian(), + DateUtil.CreateFromYMD (2021, 7, 10).julian(), + DateUtil.CreateFromYMD (2021, 8, 10).julian(), + DateUtil.CreateFromYMD (2021, 9, 10).julian(), + DateUtil.CreateFromYMD (2021, 10, 10).julian(), + DateUtil.CreateFromYMD (2021, 11, 10).julian(), + DateUtil.CreateFromYMD (2021, 12, 10).julian(), + DateUtil.CreateFromYMD (2022, 1, 10).julian(), + DateUtil.CreateFromYMD (2022, 2, 10).julian(), + DateUtil.CreateFromYMD (2022, 3, 10).julian(), + DateUtil.CreateFromYMD (2022, 4, 10).julian(), + DateUtil.CreateFromYMD (2022, 5, 10).julian(), + DateUtil.CreateFromYMD (2022, 6, 10).julian(), + DateUtil.CreateFromYMD (2022, 7, 10).julian(), + DateUtil.CreateFromYMD (2022, 8, 10).julian(), + DateUtil.CreateFromYMD (2022, 9, 10).julian(), + DateUtil.CreateFromYMD (2022, 10, 10).julian(), + DateUtil.CreateFromYMD (2022, 11, 10).julian(), + DateUtil.CreateFromYMD (2022, 12, 10).julian(), + DateUtil.CreateFromYMD (2023, 1, 10).julian(), + DateUtil.CreateFromYMD (2023, 2, 10).julian(), + DateUtil.CreateFromYMD (2023, 3, 10).julian(), + DateUtil.CreateFromYMD (2023, 4, 10).julian(), + DateUtil.CreateFromYMD (2023, 5, 10).julian(), + DateUtil.CreateFromYMD (2023, 6, 10).julian(), + DateUtil.CreateFromYMD (2023, 7, 10).julian(), + DateUtil.CreateFromYMD (2023, 8, 10).julian(), + DateUtil.CreateFromYMD (2023, 9, 10).julian(), + DateUtil.CreateFromYMD (2023, 10, 10).julian(), + DateUtil.CreateFromYMD (2023, 11, 10).julian(), + DateUtil.CreateFromYMD (2023, 12, 10).julian(), + DateUtil.CreateFromYMD (2024, 1, 10).julian(), + DateUtil.CreateFromYMD (2024, 2, 10).julian(), + DateUtil.CreateFromYMD (2024, 3, 10).julian(), + DateUtil.CreateFromYMD (2024, 4, 10).julian(), + DateUtil.CreateFromYMD (2024, 5, 10).julian(), + DateUtil.CreateFromYMD (2024, 6, 10).julian(), + DateUtil.CreateFromYMD (2024, 7, 10).julian(), + DateUtil.CreateFromYMD (2024, 8, 10).julian(), + DateUtil.CreateFromYMD (2024, 9, 10).julian(), + DateUtil.CreateFromYMD (2024, 10, 10).julian(), + DateUtil.CreateFromYMD (2024, 11, 10).julian(), + DateUtil.CreateFromYMD (2024, 12, 10).julian(), + DateUtil.CreateFromYMD (2025, 1, 10).julian(), + DateUtil.CreateFromYMD (2025, 2, 10).julian(), + DateUtil.CreateFromYMD (2025, 3, 10).julian(), + DateUtil.CreateFromYMD (2025, 4, 10).julian(), + DateUtil.CreateFromYMD (2025, 5, 10).julian(), + DateUtil.CreateFromYMD (2025, 6, 10).julian(), + DateUtil.CreateFromYMD (2025, 7, 10).julian(), + DateUtil.CreateFromYMD (2025, 8, 10).julian(), + DateUtil.CreateFromYMD (2025, 9, 10).julian(), + DateUtil.CreateFromYMD (2025, 10, 10).julian(), + DateUtil.CreateFromYMD (2025, 11, 10).julian(), + DateUtil.CreateFromYMD (2025, 12, 10).julian(), + DateUtil.CreateFromYMD (2026, 1, 10).julian(), + DateUtil.CreateFromYMD (2026, 2, 10).julian(), + DateUtil.CreateFromYMD (2026, 3, 10).julian(), + DateUtil.CreateFromYMD (2026, 4, 10).julian(), + DateUtil.CreateFromYMD (2026, 5, 10).julian(), + DateUtil.CreateFromYMD (2026, 6, 10).julian(), + DateUtil.CreateFromYMD (2026, 7, 10).julian(), + DateUtil.CreateFromYMD (2026, 8, 10).julian(), + DateUtil.CreateFromYMD (2026, 9, 10).julian(), + DateUtil.CreateFromYMD (2026, 10, 10).julian(), + DateUtil.CreateFromYMD (2026, 11, 10).julian(), + DateUtil.CreateFromYMD (2026, 12, 10).julian(), + DateUtil.CreateFromYMD (2027, 1, 10).julian(), + DateUtil.CreateFromYMD (2027, 2, 10).julian(), + DateUtil.CreateFromYMD (2027, 3, 10).julian(), + DateUtil.CreateFromYMD (2027, 4, 10).julian(), + DateUtil.CreateFromYMD (2027, 5, 10).julian(), + DateUtil.CreateFromYMD (2027, 6, 10).julian(), + DateUtil.CreateFromYMD (2027, 7, 10).julian(), + DateUtil.CreateFromYMD (2027, 8, 10).julian(), + DateUtil.CreateFromYMD (2027, 9, 10).julian(), + DateUtil.CreateFromYMD (2027, 10, 10).julian(), + DateUtil.CreateFromYMD (2027, 11, 10).julian(), + DateUtil.CreateFromYMD (2027, 12, 10).julian(), + DateUtil.CreateFromYMD (2028, 1, 10).julian(), + DateUtil.CreateFromYMD (2028, 2, 10).julian(), + DateUtil.CreateFromYMD (2028, 3, 10).julian(), + DateUtil.CreateFromYMD (2028, 4, 10).julian(), + DateUtil.CreateFromYMD (2028, 5, 10).julian(), + DateUtil.CreateFromYMD (2028, 6, 10).julian(), + DateUtil.CreateFromYMD (2028, 7, 10).julian(), + DateUtil.CreateFromYMD (2028, 8, 10).julian(), + DateUtil.CreateFromYMD (2028, 9, 10).julian(), + DateUtil.CreateFromYMD (2028, 10, 10).julian(), + DateUtil.CreateFromYMD (2028, 11, 10).julian(), + DateUtil.CreateFromYMD (2028, 12, 10).julian(), + DateUtil.CreateFromYMD (2029, 1, 10).julian(), + DateUtil.CreateFromYMD (2029, 2, 10).julian(), + DateUtil.CreateFromYMD (2029, 3, 10).julian(), + DateUtil.CreateFromYMD (2029, 4, 10).julian(), + DateUtil.CreateFromYMD (2029, 5, 10).julian(), + DateUtil.CreateFromYMD (2029, 6, 10).julian(), + DateUtil.CreateFromYMD (2029, 7, 10).julian(), + DateUtil.CreateFromYMD (2029, 8, 10).julian(), + DateUtil.CreateFromYMD (2029, 9, 10).julian(), + DateUtil.CreateFromYMD (2029, 10, 10).julian(), + DateUtil.CreateFromYMD (2029, 11, 10).julian(), + DateUtil.CreateFromYMD (2029, 12, 10).julian(), + DateUtil.CreateFromYMD (2030, 1, 10).julian(), + DateUtil.CreateFromYMD (2030, 2, 10).julian(), + DateUtil.CreateFromYMD (2030, 3, 10).julian(), + DateUtil.CreateFromYMD (2030, 4, 10).julian(), + DateUtil.CreateFromYMD (2030, 5, 10).julian(), + DateUtil.CreateFromYMD (2030, 6, 10).julian(), + DateUtil.CreateFromYMD (2030, 7, 10).julian(), + DateUtil.CreateFromYMD (2030, 8, 10).julian(), + DateUtil.CreateFromYMD (2030, 9, 10).julian(), + DateUtil.CreateFromYMD (2030, 10, 10).julian(), + DateUtil.CreateFromYMD (2030, 11, 10).julian(), + DateUtil.CreateFromYMD (2030, 12, 10).julian(), + DateUtil.CreateFromYMD (2031, 1, 10).julian(), + DateUtil.CreateFromYMD (2031, 2, 10).julian(), + DateUtil.CreateFromYMD (2031, 3, 10).julian(), + DateUtil.CreateFromYMD (2031, 4, 10).julian(), + DateUtil.CreateFromYMD (2031, 5, 10).julian(), + DateUtil.CreateFromYMD (2031, 6, 10).julian(), + DateUtil.CreateFromYMD (2031, 7, 10).julian(), + DateUtil.CreateFromYMD (2031, 8, 10).julian(), + DateUtil.CreateFromYMD (2031, 9, 10).julian(), + DateUtil.CreateFromYMD (2031, 10, 10).julian(), + DateUtil.CreateFromYMD (2031, 11, 10).julian(), + DateUtil.CreateFromYMD (2031, 12, 10).julian(), + }, + new double[] { + 0.825788554, + 0.823162164, + 0.820519344, + 0.817859990, + 0.815184001, + 0.812491270, + 0.809781695, + 0.807055169, + 0.804311586, + 0.801550839, + 0.798772822, + 0.795977426, + 0.793164543, + 0.790334062, + 0.787485875, + 0.784619870, + 0.781735936, + 0.778833960, + 0.775913830, + 0.772975432, + 0.770018652, + 0.767043374, + 0.764049484, + 0.761036865, + 0.758005399, + 0.754954969, + 0.751885456, + 0.748796740, + 0.745688703, + 0.742561221, + 0.739414175, + 0.736247441, + 0.733060897, + 0.729854418, + 0.726627880, + 0.723381158, + 0.720114124, + 0.716826652, + 0.713518615, + 0.710189883, + 0.706840327, + 0.703469816, + 0.700078221, + 0.696665408, + 0.693231245, + 0.689775599, + 0.686298334, + 0.682799317, + 0.679278410, + 0.675735477, + 0.672170380, + 0.668582980, + 0.664973138, + 0.661340714, + 0.657685566, + 0.654007551, + 0.650306528, + 0.646582352, + 0.642834878, + 0.639063960, + 0.635269452, + 0.631451206, + 0.627609074, + 0.623742906, + 0.619852552, + 0.615937861, + 0.611998680, + 0.608034856, + 0.604046235, + 0.600032662, + 0.595993981, + 0.591930035, + 0.587840665, + 0.583725712, + 0.579585018, + 0.575418419, + 0.571225756, + 0.567006863, + 0.562761578, + 0.558489735, + 0.554191168, + 0.549865710, + 0.545513193, + 0.541133447, + 0.536726302, + 0.532291587, + 0.527829129, + 0.523338754, + 0.518820289, + 0.514273556, + 0.509698380, + 0.505094583, + 0.500461985, + 0.495800406, + 0.491109665, + 0.486389580, + 0.481639967, + 0.476860640, + 0.472051416, + 0.467212105, + 0.462342520, + 0.457442473, + 0.452511771, + 0.447550224, + 0.442557638, + 0.437533819, + 0.432478572, + 0.427391700, + 0.422273006, + 0.417122290, + 0.411939352, + 0.406723990, + 0.401476002, + 0.396195184, + 0.390881329, + 0.385534232, + 0.380153684, + 0.374739477, + 0.369291399, + 0.363809239, + 0.358292783, + 0.352741818, + 0.347156126, + 0.341535492, + 0.335879695, + 0.330188517, + 0.324461736, + 0.318699129, + 0.312900472, + 0.307065539, + 0.301194105, + 0.295285939, + 0.289340813, + 0.283358496, + 0.277338754, + 0.271281353, + 0.265186058, + 0.259052633, + 0.252880837, + 0.246670432, + 0.240421176, + 0.234132825, + 0.227805135, + 0.221437861, + 0.215030753, + 0.208583564, + 0.202096043, + 0.195567936, + 0.188998991, + 0.182388952, + 0.175737561, + 0.169044561, + 0.162309733, + 0.156072928, + 0.150025552, + 0.143940344, + 0.137817068, + 0.131655486, + 0.125455359, + 0.119216444, + 0.112938500, + 0.106621281, + 0.100264544, + 0.093868040, + 0.087431520, + 0.080954734, + 0.074437431, + 0.067879357, + 0.061280256, + 0.054639873, + 0.047957948, + 0.041234222, + 0.034468434, + 0.027660321, + 0.020809616, + 0.013916055, + 0.006979369, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Bhavnagar.java b/src/main/java/org/drip/sample/bondsink/Bhavnagar.java index e3681951e0d2..06a1c3309ceb 100644 --- a/src/main/java/org/drip/sample/bondsink/Bhavnagar.java +++ b/src/main/java/org/drip/sample/bondsink/Bhavnagar.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Bhavnagar demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Bhavnagar. + * Bhavnagar generates the Full Suite of Replication Metrics for the Sinker Bond Bhavnagar. * * @author Lakshmi Krishnamurthy */ public class Bhavnagar { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,161 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2008, 4, 14); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2022, 8, 10); - double dblCoupon = 0.06821; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Bhavnagar"; double dblCleanPrice = 1.147226; - int iFreq = 2; - String strCUSIP = "Bhavnagar"; - String strDayCount = "30/360"; - String strDateFactor = "10/11/2007;1;2/10/2008;0.972839083;8/10/2008;0.934935872;2/10/2009;0.907560633;8/10/2009;0.875351942;2/10/2010;0.842697473;8/10/2010;0.812558338;2/10/2011;0.78489711;8/10/2011;0.756340442;2/10/2012;0.73293392;8/10/2012;0.709694923;2/10/2013;0.688072178;8/10/2013;0.672749676;2/10/2014;0.650604228;8/10/2014;0.62904105;2/10/2015;0.605123804;8/10/2015;0.581120398;2/10/2016;0.55444157;8/10/2016;0.527401949;2/10/2017;0.502811219;8/10/2017;0.484278245;2/10/2018;0.466296928;8/10/2018;0.443896553;2/10/2019;0.427682881;8/10/2019;0.412042048;2/10/2020;0.396456608;8/10/2020;0.366515548;2/10/2021;0.336961444;8/10/2021;0.306898138;2/10/2022;0.277389771"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.06821; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2008, + DateUtil.APRIL, + 14 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2022, + DateUtil.AUGUST, + 10 + ); + + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 8, 10).julian(), + DateUtil.CreateFromYMD (2018, 2, 10).julian(), + DateUtil.CreateFromYMD (2018, 8, 10).julian(), + DateUtil.CreateFromYMD (2019, 2, 10).julian(), + DateUtil.CreateFromYMD (2019, 8, 10).julian(), + DateUtil.CreateFromYMD (2020, 2, 10).julian(), + DateUtil.CreateFromYMD (2020, 8, 10).julian(), + DateUtil.CreateFromYMD (2021, 2, 10).julian(), + DateUtil.CreateFromYMD (2021, 8, 10).julian(), + DateUtil.CreateFromYMD (2022, 2, 10).julian(), + }, + new double[] { + 0.484278245, + 0.466296928, + 0.443896553, + 0.427682881, + 0.412042048, + 0.396456608, + 0.366515548, + 0.336961444, + 0.306898138, + 0.277389771, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Bhiwandi.java b/src/main/java/org/drip/sample/bondsink/Bhiwandi.java index 96a661a502b2..c0bf08378d72 100644 --- a/src/main/java/org/drip/sample/bondsink/Bhiwandi.java +++ b/src/main/java/org/drip/sample/bondsink/Bhiwandi.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Bhiwandi demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Bhiwandi. + * Bhiwandi generates the Full Suite of Replication Metrics for the Sinker Bond Bhiwandi. * * @author Lakshmi Krishnamurthy */ public class Bhiwandi { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,189 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2016, 10, 3); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2028, 10, 15); - double dblCoupon = 0.0325; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Bhiwandi"; double dblCleanPrice = 0.9629359; - int iFreq = 2; - String strCUSIP = "Bhiwandi"; - String strDayCount = "30/360"; - String strDateFactor = "10/3/2016;1;10/15/2017;0.972448178;4/15/2018;0.947831911;10/15/2018;0.921569102;4/15/2019;0.897078765;10/15/2019;0.871827983;4/15/2020;0.846661086;10/15/2020;0.821578093;4/15/2021;0.797318958;10/15/2021;0.771663905;4/15/2022;0.746832755;10/15/2022;0.721408298;4/15/2023;0.696766045;10/15/2023;0.672843401;4/15/2024;0.647733735;10/15/2024;0.622749942;4/15/2025;0.597892058;10/15/2025;0.573160123;4/15/2026;0.549085357;10/15/2026;0.52458458;4/15/2027;0.500209897;10/15/2027;0.475492815;4/15/2028;0.451391366"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.0325; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2016, + DateUtil.OCTOBER, + 3 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2028, + DateUtil.OCTOBER, + 15 + ); + + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 4, 15).julian(), + DateUtil.CreateFromYMD (2017, 10, 15).julian(), + DateUtil.CreateFromYMD (2018, 4, 15).julian(), + DateUtil.CreateFromYMD (2018, 10, 15).julian(), + DateUtil.CreateFromYMD (2019, 4, 15).julian(), + DateUtil.CreateFromYMD (2019, 10, 15).julian(), + DateUtil.CreateFromYMD (2020, 4, 15).julian(), + DateUtil.CreateFromYMD (2020, 10, 15).julian(), + DateUtil.CreateFromYMD (2021, 4, 15).julian(), + DateUtil.CreateFromYMD (2021, 10, 15).julian(), + DateUtil.CreateFromYMD (2022, 4, 15).julian(), + DateUtil.CreateFromYMD (2022, 10, 15).julian(), + DateUtil.CreateFromYMD (2023, 4, 15).julian(), + DateUtil.CreateFromYMD (2023, 10, 15).julian(), + DateUtil.CreateFromYMD (2024, 4, 15).julian(), + DateUtil.CreateFromYMD (2024, 10, 15).julian(), + DateUtil.CreateFromYMD (2025, 4, 15).julian(), + DateUtil.CreateFromYMD (2025, 10, 15).julian(), + DateUtil.CreateFromYMD (2026, 4, 15).julian(), + DateUtil.CreateFromYMD (2026, 10, 15).julian(), + DateUtil.CreateFromYMD (2027, 4, 15).julian(), + DateUtil.CreateFromYMD (2027, 10, 15).julian(), + DateUtil.CreateFromYMD (2028, 4, 15).julian(), + DateUtil.CreateFromYMD (2028, 10, 15).julian(), + }, + new double[] { + 1., + 0.972448178, + 0.947831911, + 0.921569102, + 0.897078765, + 0.871827983, + 0.846661086, + 0.821578093, + 0.797318958, + 0.771663905, + 0.746832755, + 0.721408298, + 0.696766045, + 0.672843401, + 0.647733735, + 0.622749942, + 0.597892058, + 0.573160123, + 0.549085357, + 0.52458458, + 0.500209897, + 0.475492815, + 0.451391366, + 0.427292049, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Bhubaneswar.java b/src/main/java/org/drip/sample/bondsink/Bhubaneswar.java index 3c8a802e0719..8245a530612b 100644 --- a/src/main/java/org/drip/sample/bondsink/Bhubaneswar.java +++ b/src/main/java/org/drip/sample/bondsink/Bhubaneswar.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Bhubaneswar demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Bhubaneswar. + * Bhubaneswar generates the Full Suite of Replication Metrics for the Sinker Bond Bhubaneswar. * * @author Lakshmi Krishnamurthy */ public class Bhubaneswar { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,185 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2016, 1, 19); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2028, 1, 15); - double dblCoupon = 0.041; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Bhubaneswar"; double dblCleanPrice = 1.019933; - int iFreq = 2; - String strCUSIP = "Bhubaneswar"; - String strDayCount = "30/360"; - String strDateFactor = "1/19/2016;1;7/15/2016;0.996959469;1/15/2017;0.974197066;7/15/2017;0.951275164;1/15/2018;0.928098079;7/15/2018;0.904352596;1/15/2019;0.880606358;7/15/2019;0.856859495;1/15/2020;0.833111873;7/15/2020;0.809363354;1/15/2021;0.785614111;7/15/2021;0.761863915;1/15/2022;0.738112689;7/15/2022;0.71436057;1/15/2023;0.69060727;7/15/2023;0.666852848;1/15/2024;0.643097228;7/15/2024;0.619340247;1/15/2025;0.595581909;7/15/2025;0.571822018;1/15/2026;0.548083781;7/15/2026;0.52436507;1/15/2027;0.500644216;7/15/2027;0.478957989"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.0410; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2016, + DateUtil.JANUARY, + 19 + ); + + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2028, + DateUtil.JANUARY, + 15 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 7, 15).julian(), + DateUtil.CreateFromYMD (2018, 1, 15).julian(), + DateUtil.CreateFromYMD (2018, 7, 15).julian(), + DateUtil.CreateFromYMD (2019, 1, 15).julian(), + DateUtil.CreateFromYMD (2019, 7, 15).julian(), + DateUtil.CreateFromYMD (2020, 1, 15).julian(), + DateUtil.CreateFromYMD (2020, 7, 15).julian(), + DateUtil.CreateFromYMD (2021, 1, 15).julian(), + DateUtil.CreateFromYMD (2021, 7, 15).julian(), + DateUtil.CreateFromYMD (2022, 1, 15).julian(), + DateUtil.CreateFromYMD (2022, 7, 15).julian(), + DateUtil.CreateFromYMD (2023, 1, 15).julian(), + DateUtil.CreateFromYMD (2023, 7, 15).julian(), + DateUtil.CreateFromYMD (2024, 1, 15).julian(), + DateUtil.CreateFromYMD (2024, 7, 15).julian(), + DateUtil.CreateFromYMD (2025, 1, 15).julian(), + DateUtil.CreateFromYMD (2025, 7, 15).julian(), + DateUtil.CreateFromYMD (2026, 1, 15).julian(), + DateUtil.CreateFromYMD (2026, 7, 15).julian(), + DateUtil.CreateFromYMD (2027, 1, 15).julian(), + DateUtil.CreateFromYMD (2027, 7, 15).julian(), + DateUtil.CreateFromYMD (2028, 1, 15).julian(), + }, + new double[] { + 0.951275164, + 0.928098079, + 0.904352596, + 0.880606358, + 0.856859495, + 0.833111873, + 0.809363354, + 0.785614111, + 0.761863915, + 0.738112689, + 0.714360570, + 0.690607270, + 0.666852848, + 0.643097228, + 0.619340247, + 0.595581909, + 0.571822018, + 0.548083781, + 0.524365070, + 0.500644216, + 0.478957989, + 0.457151104, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Bikaner.java b/src/main/java/org/drip/sample/bondsink/Bikaner.java index 95b5725767bc..bc64ed7aa0a6 100644 --- a/src/main/java/org/drip/sample/bondsink/Bikaner.java +++ b/src/main/java/org/drip/sample/bondsink/Bikaner.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Bikaner demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Bikaner. + * Bikaner generates the Full Suite of Replication Metrics for the Sinker Bond Bikaner. * * @author Lakshmi Krishnamurthy */ public class Bikaner { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,165 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2015, 9, 24); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2023, 9, 22); - double dblCoupon = 0.044; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Bikaner"; double dblCleanPrice = 0.9981809; - int iFreq = 2; - String strCUSIP = "Bikaner"; - String strDayCount = "30/360"; - String strDateFactor = "9/24/2015;1;9/22/2016;0.9405132;3/22/2017;0.887144535;9/22/2017;0.847083494;3/22/2018;0.79787361;9/22/2018;0.754628343;3/22/2019;0.71156993;9/22/2019;0.668698262;3/22/2020;0.639276488;9/22/2020;0.614779698;3/22/2021;0.597482529;9/22/2021;0.581937821;3/22/2022;0.555685151;9/22/2022;0.516874695"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.044; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2015, + DateUtil.SEPTEMBER, + 24 + ); + + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2023, + DateUtil.SEPTEMBER, + 22 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 3, 22).julian(), + DateUtil.CreateFromYMD (2017, 9, 22).julian(), + DateUtil.CreateFromYMD (2018, 3, 22).julian(), + DateUtil.CreateFromYMD (2018, 9, 22).julian(), + DateUtil.CreateFromYMD (2019, 3, 22).julian(), + DateUtil.CreateFromYMD (2019, 9, 22).julian(), + DateUtil.CreateFromYMD (2020, 3, 22).julian(), + DateUtil.CreateFromYMD (2020, 9, 22).julian(), + DateUtil.CreateFromYMD (2021, 3, 22).julian(), + DateUtil.CreateFromYMD (2021, 9, 22).julian(), + DateUtil.CreateFromYMD (2022, 3, 22).julian(), + DateUtil.CreateFromYMD (2022, 9, 22).julian(), + }, + new double[] { + 0.887144535, + 0.847083494, + 0.797873610, + 0.754628343, + 0.711569930, + 0.668698262, + 0.639276488, + 0.614779698, + 0.597482529, + 0.581937821, + 0.555685151, + 0.516874695, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Cuttack.java b/src/main/java/org/drip/sample/bondsink/Cuttack.java index 4f7a128cea55..d5bfe8a950c8 100644 --- a/src/main/java/org/drip/sample/bondsink/Cuttack.java +++ b/src/main/java/org/drip/sample/bondsink/Cuttack.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Cuttack demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Cuttack. + * Cuttack generates the Full Suite of Replication Metrics for the Sinker Bond Cuttack. * * @author Lakshmi Krishnamurthy */ public class Cuttack { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,161 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2007, 4, 10); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2022, 4, 19); - double dblCoupon = 0.05983; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Cuttack"; double dblCleanPrice = 1.1175; - int iFreq = 2; - String strCUSIP = "Cuttack"; - String strDayCount = "30/360"; - String strDateFactor = "4/10/2007;1;4/19/2010;0.982290349;10/19/2010;0.964621289;4/19/2011;0.947016908;10/19/2011;0.929477203;4/19/2012;0.912002175;10/19/2012;0.894591825;4/19/2013;0.877246152;10/19/2013;0.859965156;4/19/2014;0.842748837;10/19/2014;0.825597196;4/19/2015;0.808510231;10/19/2015;0.790382291;4/19/2016;0.772361827;10/19/2016;0.754448839;4/19/2017;0.736643329;10/19/2017;0.718945295;4/19/2018;0.701354738;10/19/2018;0.683871658;4/19/2019;0.666496054;10/19/2019;0.64720945;4/19/2020;0.607138654;10/19/2020;0.518776192;4/19/2021;0.358884783;10/19/2021;0.150205598"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.05983; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2007, + DateUtil.APRIL, + 10 + ); + + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2022, + DateUtil.APRIL, + 19 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 4, 19).julian(), + DateUtil.CreateFromYMD (2017, 10, 19).julian(), + DateUtil.CreateFromYMD (2018, 4, 19).julian(), + DateUtil.CreateFromYMD (2018, 10, 19).julian(), + DateUtil.CreateFromYMD (2019, 5, 19).julian(), + DateUtil.CreateFromYMD (2019, 10, 19).julian(), + DateUtil.CreateFromYMD (2020, 4, 19).julian(), + DateUtil.CreateFromYMD (2020, 10, 19).julian(), + DateUtil.CreateFromYMD (2021, 4, 19).julian(), + DateUtil.CreateFromYMD (2021, 10, 19).julian(), + }, + new double[] { + 0.736643329, + 0.718945295, + 0.701354738, + 0.683871658, + 0.666496054, + 0.647209450, + 0.607138654, + 0.518776192, + 0.358884783, + 0.150205598, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Dehradun.java b/src/main/java/org/drip/sample/bondsink/Dehradun.java index 82281c1f6bdd..4d04e6c92f97 100644 --- a/src/main/java/org/drip/sample/bondsink/Dehradun.java +++ b/src/main/java/org/drip/sample/bondsink/Dehradun.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Dehradun demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Dehradun. + * Dehradun generates the Full Suite of Replication Metrics for the Sinker Bond Dehradun. * * @author Lakshmi Krishnamurthy */ public class Dehradun { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,473 +114,223 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2016, 7, 20); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2038, 3, 1); - double dblCoupon = 0.04125; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Dehradun"; double dblCleanPrice = 0.9467973; - int iFreq = 2; - String strCUSIP = "Dehradun"; - String strDayCount = "30/360"; - String strDateFactor = "7/20/2016;1;9/30/2019;0.9863;3/31/2020;0.9708;9/30/2020;0.9544;3/31/2021;0.9376;9/30/2021;0.9198;3/31/2022;0.9031;9/30/2022;0.8839;3/31/2023;0.8644;9/30/2023;0.8441;3/31/2024;0.8233;9/30/2024;0.8013;3/31/2025;0.7821;9/30/2025;0.7593;3/31/2026;0.7366;9/30/2026;0.7135;3/31/2027;0.6901;9/30/2027;0.6659;3/31/2028;0.6435;9/30/2028;0.6185;3/31/2029;0.5931;9/30/2029;0.5668;3/31/2030;0.5401;9/30/2030;0.5124;3/31/2031;0.4868;9/30/2031;0.4577;3/31/2032;0.428;9/30/2032;0.397;3/31/2033;0.3655;9/30/2033;0.3327;3/31/2034;0.3014;9/30/2034;0.2666;3/31/2035;0.2312;9/30/2035;0.1945;3/31/2036;0.157;9/30/2036;0.1179;3/31/2037;0.0814;9/30/2037;0.0402"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.04125; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, /* Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() - ), */ - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2016, + DateUtil.JULY, + 20 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2038, + DateUtil.MARCH, + 1 + ); + + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 9, 1).julian(), + DateUtil.CreateFromYMD (2018, 3, 1).julian(), + DateUtil.CreateFromYMD (2018, 9, 1).julian(), + DateUtil.CreateFromYMD (2019, 3, 1).julian(), + DateUtil.CreateFromYMD (2019, 9, 1).julian(), + DateUtil.CreateFromYMD (2020, 3, 1).julian(), + DateUtil.CreateFromYMD (2020, 9, 1).julian(), + DateUtil.CreateFromYMD (2021, 3, 1).julian(), + DateUtil.CreateFromYMD (2021, 9, 1).julian(), + DateUtil.CreateFromYMD (2022, 3, 1).julian(), + DateUtil.CreateFromYMD (2022, 9, 1).julian(), + DateUtil.CreateFromYMD (2023, 3, 1).julian(), + DateUtil.CreateFromYMD (2023, 9, 1).julian(), + DateUtil.CreateFromYMD (2024, 3, 1).julian(), + DateUtil.CreateFromYMD (2024, 9, 1).julian(), + DateUtil.CreateFromYMD (2025, 3, 1).julian(), + DateUtil.CreateFromYMD (2025, 9, 1).julian(), + DateUtil.CreateFromYMD (2026, 3, 1).julian(), + DateUtil.CreateFromYMD (2026, 9, 1).julian(), + DateUtil.CreateFromYMD (2027, 3, 1).julian(), + DateUtil.CreateFromYMD (2027, 9, 1).julian(), + DateUtil.CreateFromYMD (2028, 3, 1).julian(), + DateUtil.CreateFromYMD (2028, 9, 1).julian(), + DateUtil.CreateFromYMD (2029, 3, 1).julian(), + DateUtil.CreateFromYMD (2029, 9, 1).julian(), + DateUtil.CreateFromYMD (2030, 3, 1).julian(), + DateUtil.CreateFromYMD (2030, 9, 1).julian(), + DateUtil.CreateFromYMD (2031, 3, 1).julian(), + DateUtil.CreateFromYMD (2031, 9, 1).julian(), + DateUtil.CreateFromYMD (2032, 3, 1).julian(), + DateUtil.CreateFromYMD (2032, 9, 1).julian(), + DateUtil.CreateFromYMD (2033, 3, 1).julian(), + DateUtil.CreateFromYMD (2033, 9, 1).julian(), + DateUtil.CreateFromYMD (2034, 3, 1).julian(), + DateUtil.CreateFromYMD (2034, 9, 1).julian(), + DateUtil.CreateFromYMD (2035, 3, 1).julian(), + DateUtil.CreateFromYMD (2035, 9, 1).julian(), + DateUtil.CreateFromYMD (2036, 3, 1).julian(), + DateUtil.CreateFromYMD (2036, 9, 1).julian(), + DateUtil.CreateFromYMD (2037, 3, 1).julian(), + DateUtil.CreateFromYMD (2037, 9, 1).julian(), + }, + new double[] { + 1., + 1., + 1., + 1., + 0.9863, + 0.9708, + 0.9544, + 0.9376, + 0.9198, + 0.9031, + 0.8839, + 0.8644, + 0.8441, + 0.8233, + 0.8013, + 0.7821, + 0.7593, + 0.7366, + 0.7135, + 0.6901, + 0.6659, + 0.6435, + 0.6185, + 0.5931, + 0.5668, + 0.5401, + 0.5124, + 0.4868, + 0.4577, + 0.4280, + 0.3970, + 0.3655, + 0.3327, + 0.3014, + 0.2666, + 0.2312, + 0.1945, + 0.1570, + 0.1179, + 0.0814, + 0.0402, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Firozabad.java b/src/main/java/org/drip/sample/bondsink/Firozabad.java index 305829b7abde..0156a48728bb 100644 --- a/src/main/java/org/drip/sample/bondsink/Firozabad.java +++ b/src/main/java/org/drip/sample/bondsink/Firozabad.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Firozabad demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Firozabad. + * Firozabad generates the Full Suite of Replication Metrics for the Sinker Bond Firozabad. * * @author Lakshmi Krishnamurthy */ public class Firozabad { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 15 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,153 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 15 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2002, 4, 30); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2023, 1, 2); - double dblCoupon = 0.06718; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Firozabad"; double dblCleanPrice = 1.1275; - int iFreq = 2; - String strCUSIP = "Firozabad"; - String strDayCount = "30/360"; - String strDateFactor = "4/30/2002;1;1/2/2003;0.943220003;1/2/2004;0.887539097;1/2/2005;0.8307589;1/2/2006;0.7739787;1/2/2007;0.7171985;1/2/2008;0.660418245;1/2/2009;0.603638032;1/2/2010;0.546857819;1/2/2011;0.490077606;1/2/2012;0.433208722;1/2/2013;0.414642634;1/2/2014;0.396076546;7/2/2014;0.388603404;1/2/2015;0.370387619;1/2/2016;0.352171835;1/2/2017;0.33395605;1/2/2018;0.315740266;1/2/2019;0.276766084;1/2/2020;0.246567856;1/2/2021;0.12664895;7/2/2021;0.082279581;1/2/2022;0.010439822"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.06718; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2002, + DateUtil.APRIL, + 30 + ); + + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2023, + DateUtil.JANUARY, + 2 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2018, 1, 2).julian(), + DateUtil.CreateFromYMD (2019, 1, 2).julian(), + DateUtil.CreateFromYMD (2020, 1, 2).julian(), + DateUtil.CreateFromYMD (2021, 1, 2).julian(), + DateUtil.CreateFromYMD (2021, 7, 2).julian(), + DateUtil.CreateFromYMD (2022, 1, 2).julian(), + }, + new double[] { + 0.315740266, + 0.276766084, + 0.246567856, + 0.126648950, + 0.082279581, + 0.010439822, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Gorakhpur.java b/src/main/java/org/drip/sample/bondsink/Gorakhpur.java index 075e05356528..11cd6e50caca 100644 --- a/src/main/java/org/drip/sample/bondsink/Gorakhpur.java +++ b/src/main/java/org/drip/sample/bondsink/Gorakhpur.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Gorakhpur demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Gorakhpur. + * Gorakhpur generates the Full Suite of Replication Metrics for the Sinker Bond Gorakhpur. * * @author Lakshmi Krishnamurthy */ public class Gorakhpur { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,201 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2007, 5, 10); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2037, 5, 10); - double dblCoupon = 0.05951; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Gorakhpur"; double dblCleanPrice = 1.0887; - int iFreq = 2; - String strCUSIP = "Gorakhpur"; - String strDayCount = "30/360"; - String strDateFactor = "5/10/2007;1;11/10/2022;0.978897;5/10/2023;0.957166;11/10/2023;0.934789;5/10/2024;0.911746;11/10/2024;0.888017;5/10/2025;0.863582;11/10/2025;0.83842;5/10/2026;0.812509;11/10/2026;0.785827;5/10/2027;0.758351;11/10/2027;0.730058;5/10/2028;0.700923;11/10/2028;0.670921;5/10/2029;0.640026;11/10/2029;0.608212;5/10/2030;0.575452;11/10/2030;0.541717;5/10/2031;0.506978;11/10/2031;0.471205;5/10/2032;0.434368;11/10/2032;0.396435;5/10/2033;0.357373;11/10/2033;0.317149;5/10/2034;0.275728;11/10/2034;0.233075;5/10/2035;0.189152;11/10/2035;0.143922;5/10/2036;0.097347;11/10/2036;0.049386"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.05951; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2007, + DateUtil.MAY, + 10 + ); + + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2037, + DateUtil.MAY, + 10 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2022, 5, 10).julian(), + DateUtil.CreateFromYMD (2022, 11, 10).julian(), + DateUtil.CreateFromYMD (2023, 5, 10).julian(), + DateUtil.CreateFromYMD (2023, 11, 10).julian(), + DateUtil.CreateFromYMD (2024, 5, 10).julian(), + DateUtil.CreateFromYMD (2024, 11, 10).julian(), + DateUtil.CreateFromYMD (2025, 5, 10).julian(), + DateUtil.CreateFromYMD (2025, 11, 10).julian(), + DateUtil.CreateFromYMD (2026, 5, 10).julian(), + DateUtil.CreateFromYMD (2026, 11, 10).julian(), + DateUtil.CreateFromYMD (2027, 5, 10).julian(), + DateUtil.CreateFromYMD (2027, 11, 10).julian(), + DateUtil.CreateFromYMD (2028, 5, 10).julian(), + DateUtil.CreateFromYMD (2028, 11, 10).julian(), + DateUtil.CreateFromYMD (2029, 5, 10).julian(), + DateUtil.CreateFromYMD (2029, 11, 10).julian(), + DateUtil.CreateFromYMD (2030, 5, 10).julian(), + DateUtil.CreateFromYMD (2030, 11, 10).julian(), + DateUtil.CreateFromYMD (2031, 5, 10).julian(), + DateUtil.CreateFromYMD (2031, 11, 10).julian(), + DateUtil.CreateFromYMD (2032, 5, 10).julian(), + DateUtil.CreateFromYMD (2032, 11, 10).julian(), + DateUtil.CreateFromYMD (2033, 5, 10).julian(), + DateUtil.CreateFromYMD (2033, 11, 10).julian(), + DateUtil.CreateFromYMD (2034, 5, 10).julian(), + DateUtil.CreateFromYMD (2034, 11, 10).julian(), + DateUtil.CreateFromYMD (2035, 5, 10).julian(), + DateUtil.CreateFromYMD (2035, 11, 10).julian(), + DateUtil.CreateFromYMD (2036, 5, 10).julian(), + DateUtil.CreateFromYMD (2036, 11, 10).julian(), + }, + new double[] { + 1., + 0.978897, + 0.957166, + 0.934789, + 0.911746, + 0.888017, + 0.863582, + 0.838420, + 0.812509, + 0.785827, + 0.758351, + 0.730058, + 0.700923, + 0.670921, + 0.640026, + 0.608212, + 0.575452, + 0.541717, + 0.506978, + 0.471205, + 0.434368, + 0.396435, + 0.357373, + 0.317149, + 0.275728, + 0.233075, + 0.189152, + 0.143922, + 0.097347, + 0.049386, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Guntur.java b/src/main/java/org/drip/sample/bondsink/Guntur.java index 61f80cb8163c..e5561f4b7041 100644 --- a/src/main/java/org/drip/sample/bondsink/Guntur.java +++ b/src/main/java/org/drip/sample/bondsink/Guntur.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Guntur demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Guntur. + * Guntur generates the Full Suite of Replication Metrics for the Sinker Bond Guntur. * * @author Lakshmi Krishnamurthy */ public class Guntur { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,173 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2016, 10, 17); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2021, 9, 20); - double dblCoupon = 0.0336; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 4; + String strName = "Guntur"; double dblCleanPrice = 1.00125; - int iFreq = 4; - String strCUSIP = "Guntur"; - String strDayCount = "30/360"; - String strDateFactor = "10/27/2016;1;12/20/2017;0.9375;3/20/2018;0.875;6/20/2018;0.8125;9/20/2018;0.75;12/20/2018;0.6875;3/20/2019;0.625;6/20/2019;0.5625;9/20/2019;0.5;12/20/2019;0.4375;3/20/2020;0.375;6/20/2020;0.3125;9/20/2020;0.25;12/20/2020;0.1875;3/20/2021;0.125;6/20/2021;0.0625"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.0336; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2016, + DateUtil.OCTOBER, + 17 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2021, + DateUtil.SEPTEMBER, + 20 + ); + + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 9, 20).julian(), + DateUtil.CreateFromYMD (2017, 12, 20).julian(), + DateUtil.CreateFromYMD (2018, 3, 20).julian(), + DateUtil.CreateFromYMD (2018, 6, 20).julian(), + DateUtil.CreateFromYMD (2018, 9, 20).julian(), + DateUtil.CreateFromYMD (2018, 12, 20).julian(), + DateUtil.CreateFromYMD (2019, 3, 20).julian(), + DateUtil.CreateFromYMD (2019, 6, 20).julian(), + DateUtil.CreateFromYMD (2019, 9, 20).julian(), + DateUtil.CreateFromYMD (2019, 12, 20).julian(), + DateUtil.CreateFromYMD (2020, 3, 20).julian(), + DateUtil.CreateFromYMD (2020, 6, 20).julian(), + DateUtil.CreateFromYMD (2020, 9, 20).julian(), + DateUtil.CreateFromYMD (2020, 12, 20).julian(), + DateUtil.CreateFromYMD (2021, 3, 20).julian(), + DateUtil.CreateFromYMD (2021, 6, 20).julian(), + }, + new double[] { + 1., + 0.9375, + 0.8750, + 0.8125, + 0.7500, + 0.6875, + 0.6250, + 0.5625, + 0.5000, + 0.4375, + 0.3750, + 0.3125, + 0.2500, + 0.1875, + 0.1250, + 0.0625, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Ichalkaranji.java b/src/main/java/org/drip/sample/bondsink/Ichalkaranji.java new file mode 100644 index 000000000000..62a67a3f3bc9 --- /dev/null +++ b/src/main/java/org/drip/sample/bondsink/Ichalkaranji.java @@ -0,0 +1,266 @@ + +package org.drip.sample.bondsink; + +import org.drip.analytics.date.*; +import org.drip.product.creator.BondBuilder; +import org.drip.product.credit.BondComponent; +import org.drip.quant.common.Array2D; +import org.drip.service.env.EnvManager; +import org.drip.service.scenario.*; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2018 Lakshmi Krishnamurthy + * Copyright (C) 2017 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. + */ + +/** + * Ichalkaranji generates the Full Suite of Replication Metrics for the Sinker Bond Ichalkaranji. + * + * @author Lakshmi Krishnamurthy + */ + +public class Ichalkaranji { + + public static final void main ( + final String[] astArgs) + throws Exception + { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2018, + DateUtil.FEBRUARY, + 22 + ); + + String[] astrDepositTenor = new String[] { + "2D" + }; + + double[] adblDepositQuote = new double[] { + 0.0130411 // 2D + }; + + double[] adblFuturesQuote = new double[] { + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 + }; + + String[] astrFixFloatTenor = new String[] { + "02Y", + "03Y", + "04Y", + "05Y", + "06Y", + "07Y", + "08Y", + "09Y", + "10Y", + "11Y", + "12Y", + "15Y", + "20Y", + "25Y", + "30Y", + "40Y", + "50Y" + }; + + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" + }; + + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y + }; + + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y + }; + + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" + }; + + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y + }; + + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Ichalkaranji"; + double dblCleanPrice = 1.0480; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.0525; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; + + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2011, + 1, + 25 + ); + + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2021, + 1, + 31 + ); + + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, + strCurrency, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, + dtEffective, + dtMaturity, + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2018, 7, 31).julian(), + DateUtil.CreateFromYMD (2019, 1, 31).julian(), + DateUtil.CreateFromYMD (2019, 7, 31).julian(), + DateUtil.CreateFromYMD (2020, 1, 31).julian(), + DateUtil.CreateFromYMD (2020, 7, 31).julian(), + DateUtil.CreateFromYMD (2021, 1, 31).julian(), + }, + new double[] { + 0.470306832, + 0.432538639, + 0.396328948, + 0.360213154, + 0.325458203, + 0.29240767 + } + ), + null + ); + + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, + dtSpot, + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond + ); + + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + + EnvManager.TerminateEnv(); + } +} diff --git a/src/main/java/org/drip/sample/bondsink/MiraBhayander.java b/src/main/java/org/drip/sample/bondsink/MiraBhayander.java index b6dc0c28ad20..b4acc64db925 100644 --- a/src/main/java/org/drip/sample/bondsink/MiraBhayander.java +++ b/src/main/java/org/drip/sample/bondsink/MiraBhayander.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * MiraBhayander demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation - * for MiraBhayander. + * MiraBhayander generates the Full Suite of Replication Metrics for the Sinker Bond MiraBhayander. * * @author Lakshmi Krishnamurthy */ public class MiraBhayander { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,473 +114,161 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2007, 6, 26); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2022, 7, 2); - double dblCoupon = 0.06636; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "MiraBhayander"; double dblCleanPrice = 1.078125; - int iFreq = 2; - String strCUSIP = "MiraBhayander"; - String strDayCount = "30/360"; - String strDateFactor = "6/26/2007;1;1/2/2008;0.972816211;7/2/2008;0.951458635;1/2/2009;0.931030563;7/2/2009;0.91025115;1/2/2010;0.889523324;7/2/2010;0.868845342;1/2/2011;0.848178458;7/2/2011;0.800729638;1/2/2012;0.779238088;7/2/2012;0.758085403;1/2/2013;0.737551668;7/2/2013;0.716205563;1/2/2014;0.692227315;7/2/2014;0.65615862;1/2/2015;0.634228696;7/2/2015;0.617831483;1/2/2016;0.592408137;7/2/2016;0.566109149;1/2/2017;0.539302655;7/2/2017;0.511947522;1/2/2018;0.484362899;7/2/2018;0.472862971;1/2/2019;0.441382889;7/2/2019;0.420917403;1/2/2020;0.38896116;7/2/2020;0.355435929;1/2/2021;0.322034893;7/2/2021;0.278274491;1/2/2022;0.237425683"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.06636; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, /* Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() - ), */ - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2007, + DateUtil.JUNE, + 26 + ); + + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2022, + DateUtil.JULY, + 2 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 7, 2).julian(), + DateUtil.CreateFromYMD (2018, 1, 2).julian(), + DateUtil.CreateFromYMD (2018, 7, 2).julian(), + DateUtil.CreateFromYMD (2019, 1, 2).julian(), + DateUtil.CreateFromYMD (2019, 7, 2).julian(), + DateUtil.CreateFromYMD (2020, 1, 2).julian(), + DateUtil.CreateFromYMD (2020, 7, 2).julian(), + DateUtil.CreateFromYMD (2021, 1, 2).julian(), + DateUtil.CreateFromYMD (2021, 7, 2).julian(), + DateUtil.CreateFromYMD (2022, 1, 2).julian(), + }, + new double[] { + 0.511947522, + 0.484362899, + 0.472862971, + 0.441382889, + 0.420917403, + 0.388961160, + 0.355435929, + 0.322034893, + 0.278274491, + 0.237425683, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Nellore.java b/src/main/java/org/drip/sample/bondsink/Nellore.java index fbeced660c20..066692c949c8 100644 --- a/src/main/java/org/drip/sample/bondsink/Nellore.java +++ b/src/main/java/org/drip/sample/bondsink/Nellore.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Nellore demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Nellore. + * Nellore generates the Full Suite of Replication Metrics for the Sinker Bond Nellore. * * @author Lakshmi Krishnamurthy */ public class Nellore { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,185 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2016, 5, 18); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2028, 5, 10); - double dblCoupon = 0.04875; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Nellore"; double dblCleanPrice = 1.00005; - int iFreq = 2; - String strCUSIP = "Nellore"; - String strDayCount = "30/360"; - String strDateFactor = "5/18/2016;1;5/10/2017;0.976275687;11/10/2017;0.952560487;5/10/2018;0.928845291;11/10/2018;0.905130091;5/10/2019;0.881414892;11/10/2019;0.857699692;5/10/2020;0.833984496;11/10/2020;0.810269296;5/10/2021;0.786554097;11/10/2021;0.762838897;5/10/2022;0.739123697;11/10/2022;0.715408501;5/10/2023;0.691693301;11/10/2023;0.667978102;5/10/2024;0.644262902;11/10/2024;0.620547702;5/10/2025;0.596832506;11/10/2025;0.573117307;5/10/2026;0.549402107;11/10/2026;0.525686907;5/10/2027;0.501971711;11/10/2027;0.478256512"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.04875; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2016, + DateUtil.MAY, + 18 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2028, + DateUtil.MAY, + 10 + ); + + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 5, 10).julian(), + DateUtil.CreateFromYMD (2017, 11, 10).julian(), + DateUtil.CreateFromYMD (2018, 5, 10).julian(), + DateUtil.CreateFromYMD (2018, 11, 10).julian(), + DateUtil.CreateFromYMD (2019, 5, 10).julian(), + DateUtil.CreateFromYMD (2019, 11, 10).julian(), + DateUtil.CreateFromYMD (2020, 5, 10).julian(), + DateUtil.CreateFromYMD (2020, 11, 10).julian(), + DateUtil.CreateFromYMD (2021, 5, 10).julian(), + DateUtil.CreateFromYMD (2021, 11, 10).julian(), + DateUtil.CreateFromYMD (2022, 5, 10).julian(), + DateUtil.CreateFromYMD (2022, 11, 10).julian(), + DateUtil.CreateFromYMD (2023, 5, 10).julian(), + DateUtil.CreateFromYMD (2023, 11, 10).julian(), + DateUtil.CreateFromYMD (2024, 5, 10).julian(), + DateUtil.CreateFromYMD (2024, 11, 10).julian(), + DateUtil.CreateFromYMD (2025, 5, 10).julian(), + DateUtil.CreateFromYMD (2025, 11, 10).julian(), + DateUtil.CreateFromYMD (2026, 5, 10).julian(), + DateUtil.CreateFromYMD (2026, 11, 10).julian(), + DateUtil.CreateFromYMD (2027, 5, 10).julian(), + DateUtil.CreateFromYMD (2027, 11, 10).julian(), + }, + new double[] { + 0.976275687, + 0.952560487, + 0.928845291, + 0.905130091, + 0.881414892, + 0.857699692, + 0.833984496, + 0.810269296, + 0.786554097, + 0.762838897, + 0.739123697, + 0.715408501, + 0.691693301, + 0.667978102, + 0.644262902, + 0.620547702, + 0.596832506, + 0.573117307, + 0.549402107, + 0.525686907, + 0.501971711, + 0.478256512, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Saharanpur.java b/src/main/java/org/drip/sample/bondsink/Saharanpur.java index 0d46f53fe9be..3393bf970fba 100644 --- a/src/main/java/org/drip/sample/bondsink/Saharanpur.java +++ b/src/main/java/org/drip/sample/bondsink/Saharanpur.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Saharanpur demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Saharanpur. + * Saharanpur generates the Full Suite of Replication Metrics for the Sinker Bond Saharanpur. * * @author Lakshmi Krishnamurthy */ public class Saharanpur { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,473 +114,227 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2012, 12, 20); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2027, 12, 20); - double dblCoupon = 0.055; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 4; + String strName = "Saharanpur"; double dblCleanPrice = 1.058939; - int iFreq = 4; - String strCUSIP = "Saharanpur"; - String strDayCount = "30/360"; - String strDateFactor = "12/20/2012;1;3/20/2013;0.989165479;6/20/2013;0.978181983;9/20/2013;0.967047464;12/20/2013;0.955759846;3/20/2014;0.944317023;6/20/2014;0.932716861;9/20/2014;0.920957196;12/20/2014;0.909035837;3/20/2015;0.896950558;6/20/2015;0.884699107;9/20/2015;0.872279199;12/20/2015;0.859688517;3/20/2016;0.846924713;6/20/2016;0.833985407;9/20/2016;0.820868185;12/20/2016;0.807570601;3/20/2017;0.794090176;6/20/2017;0.780424395;9/20/2017;0.766570709;12/20/2017;0.752526535;3/20/2018;0.738289254;6/20/2018;0.72385621;9/20/2018;0.709224712;12/20/2018;0.694392031;3/20/2019;0.6793554;6/20/2019;0.664112016;9/20/2019;0.648659035;12/20/2019;0.632993575;3/20/2020;0.617112716;6/20/2020;0.601013495;9/20/2020;0.584692909;12/20/2020;0.568147916;3/20/2021;0.551375428;6/20/2021;0.534372319;9/20/2021;0.517135418;12/20/2021;0.499661509;3/20/2022;0.481947333;6/20/2022;0.463989588;9/20/2022;0.445784924;12/20/2022;0.427329945;3/20/2023;0.408621211;6/20/2023;0.389655232;9/20/2023;0.37042847;12/20/2023;0.35093734;3/20/2024;0.331178208;6/20/2024;0.311147387;9/20/2024;0.290841142;12/20/2024;0.270255687;3/20/2025;0.249387182;6/20/2025;0.228231734;9/20/2025;0.206785399;12/20/2025;0.185044178;3/20/2026;0.163004014;6/20/2026;0.140660798;9/20/2026;0.118010363;12/20/2026;0.095048484;3/20/2027;0.07177088;6/20/2027;0.048173208;9/20/2027;0.024251069"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.055; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, /* Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() - ), */ - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2012, + DateUtil.DECEMBER, + 20 + ); + + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2027, + DateUtil.DECEMBER, + 20 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 3, 20).julian(), + DateUtil.CreateFromYMD (2017, 6, 20).julian(), + DateUtil.CreateFromYMD (2017, 9, 20).julian(), + DateUtil.CreateFromYMD (2017, 12, 20).julian(), + DateUtil.CreateFromYMD (2018, 3, 20).julian(), + DateUtil.CreateFromYMD (2018, 6, 20).julian(), + DateUtil.CreateFromYMD (2018, 9, 20).julian(), + DateUtil.CreateFromYMD (2018, 12, 20).julian(), + DateUtil.CreateFromYMD (2019, 3, 20).julian(), + DateUtil.CreateFromYMD (2019, 6, 20).julian(), + DateUtil.CreateFromYMD (2019, 9, 20).julian(), + DateUtil.CreateFromYMD (2019, 12, 20).julian(), + DateUtil.CreateFromYMD (2020, 3, 20).julian(), + DateUtil.CreateFromYMD (2020, 6, 20).julian(), + DateUtil.CreateFromYMD (2020, 9, 20).julian(), + DateUtil.CreateFromYMD (2020, 12, 20).julian(), + DateUtil.CreateFromYMD (2021, 3, 20).julian(), + DateUtil.CreateFromYMD (2021, 6, 20).julian(), + DateUtil.CreateFromYMD (2021, 9, 20).julian(), + DateUtil.CreateFromYMD (2021, 12, 20).julian(), + DateUtil.CreateFromYMD (2022, 3, 20).julian(), + DateUtil.CreateFromYMD (2022, 6, 20).julian(), + DateUtil.CreateFromYMD (2022, 9, 20).julian(), + DateUtil.CreateFromYMD (2022, 12, 20).julian(), + DateUtil.CreateFromYMD (2023, 3, 20).julian(), + DateUtil.CreateFromYMD (2023, 6, 20).julian(), + DateUtil.CreateFromYMD (2023, 9, 20).julian(), + DateUtil.CreateFromYMD (2023, 12, 20).julian(), + DateUtil.CreateFromYMD (2024, 3, 20).julian(), + DateUtil.CreateFromYMD (2024, 6, 20).julian(), + DateUtil.CreateFromYMD (2024, 9, 20).julian(), + DateUtil.CreateFromYMD (2024, 12, 20).julian(), + DateUtil.CreateFromYMD (2025, 3, 20).julian(), + DateUtil.CreateFromYMD (2025, 6, 20).julian(), + DateUtil.CreateFromYMD (2025, 9, 20).julian(), + DateUtil.CreateFromYMD (2025, 12, 20).julian(), + DateUtil.CreateFromYMD (2026, 3, 20).julian(), + DateUtil.CreateFromYMD (2026, 6, 20).julian(), + DateUtil.CreateFromYMD (2026, 9, 20).julian(), + DateUtil.CreateFromYMD (2026, 12, 20).julian(), + DateUtil.CreateFromYMD (2027, 3, 20).julian(), + DateUtil.CreateFromYMD (2027, 6, 20).julian(), + DateUtil.CreateFromYMD (2027, 9, 20).julian(), + }, + new double[] { + 0.794090176, + 0.780424395, + 0.766570709, + 0.752526535, + 0.738289254, + 0.723856210, + 0.709224712, + 0.694392031, + 0.679355400, + 0.664112016, + 0.648659035, + 0.632993575, + 0.617112716, + 0.601013495, + 0.584692909, + 0.568147916, + 0.551375428, + 0.534372319, + 0.517135418, + 0.499661509, + 0.481947333, + 0.463989588, + 0.445784924, + 0.427329945, + 0.408621211, + 0.389655232, + 0.370428470, + 0.350937340, + 0.331178208, + 0.311147387, + 0.290841142, + 0.270255687, + 0.249387182, + 0.228231734, + 0.206785399, + 0.185044178, + 0.163004014, + 0.140660798, + 0.118010363, + 0.095048484, + 0.071770880, + 0.048173208, + 0.024251069, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Salem.java b/src/main/java/org/drip/sample/bondsink/Salem.java index a10c0f821c72..be04a28b64e0 100644 --- a/src/main/java/org/drip/sample/bondsink/Salem.java +++ b/src/main/java/org/drip/sample/bondsink/Salem.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,37 +55,46 @@ */ /** - * Salem demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for Salem. + * Salem generates the Full Suite of Replication Metrics for the Sinker Bond Salem. * * @author Lakshmi Krishnamurthy */ public class Salem { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -111,473 +114,177 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2014, 8, 11); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2026, 9, 3); - double dblCoupon = 0.0375; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 2; + String strName = "Salem"; double dblCleanPrice = 1.01114; - int iFreq = 2; - String strCUSIP = "Salem"; - String strDayCount = "30/360"; - String strDateFactor = "8/11/2014;1;3/3/2016;0.970903241;9/3/2016;0.942322722;3/3/2017;0.913786792;9/3/2017;0.885297621;3/3/2018;0.857293406;9/3/2018;0.829340734;3/3/2019;0.801442245;9/3/2019;0.77360076;3/3/2020;0.7458193;9/3/2020;0.718101103;3/3/2021;0.690449645;9/3/2021;0.66286866;3/3/2022;0.635362168;9/3/2022;0.607934498;3/3/2023;0.580590323;9/3/2023;0.553334692;3/3/2024;0.526173071;9/3/2024;0.499111382;3/3/2025;0.472156058;9/3/2025;0.445314095;3/3/2026;0.418593118"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.0375; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, /* Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() - ), */ - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2014, + DateUtil.AUGUST, + 11 + ); + + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2026, + DateUtil.SEPTEMBER, + 3 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 9, 3).julian(), + DateUtil.CreateFromYMD (2018, 3, 3).julian(), + DateUtil.CreateFromYMD (2018, 9, 3).julian(), + DateUtil.CreateFromYMD (2019, 3, 3).julian(), + DateUtil.CreateFromYMD (2019, 9, 3).julian(), + DateUtil.CreateFromYMD (2020, 3, 3).julian(), + DateUtil.CreateFromYMD (2020, 9, 3).julian(), + DateUtil.CreateFromYMD (2021, 3, 3).julian(), + DateUtil.CreateFromYMD (2021, 9, 3).julian(), + DateUtil.CreateFromYMD (2022, 3, 3).julian(), + DateUtil.CreateFromYMD (2022, 9, 3).julian(), + DateUtil.CreateFromYMD (2023, 3, 3).julian(), + DateUtil.CreateFromYMD (2023, 9, 3).julian(), + DateUtil.CreateFromYMD (2024, 3, 3).julian(), + DateUtil.CreateFromYMD (2024, 9, 3).julian(), + DateUtil.CreateFromYMD (2025, 3, 3).julian(), + DateUtil.CreateFromYMD (2025, 9, 3).julian(), + DateUtil.CreateFromYMD (2026, 3, 3).julian(), + }, + new double[] { + 0.885297621, + 0.857293406, + 0.829340734, + 0.801442245, + 0.773600760, + 0.745819300, + 0.718101103, + 0.690449645, + 0.662868660, + 0.635362168, + 0.607934498, + 0.580590323, + 0.553334692, + 0.526173071, + 0.499111382, + 0.472156058, + 0.445314095, + 0.418593118, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/bondsink/Warangal.java b/src/main/java/org/drip/sample/bondsink/Warangal.java index b5fcb9c6c5aa..5897bc605661 100644 --- a/src/main/java/org/drip/sample/bondsink/Warangal.java +++ b/src/main/java/org/drip/sample/bondsink/Warangal.java @@ -2,17 +2,11 @@ package org.drip.sample.bondsink; import org.drip.analytics.date.*; -import org.drip.param.creator.MarketParamsBuilder; -import org.drip.param.market.CurveSurfaceQuoteContainer; -import org.drip.param.valuation.*; import org.drip.product.creator.BondBuilder; import org.drip.product.credit.BondComponent; -import org.drip.product.definition.Component; -import org.drip.quant.common.*; +import org.drip.quant.common.Array2D; import org.drip.service.env.EnvManager; -import org.drip.service.template.*; -import org.drip.state.discount.MergedDiscountForwardCurve; -import org.drip.state.govvie.GovvieCurve; +import org.drip.service.scenario.*; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -61,38 +55,46 @@ */ /** - * Warangal demonstrates Sink Fixed Coupon Multi-flavor Pricing and Relative Value Measure Generation for - * Warangal. + * Warangal generates the Full Suite of Replication Metrics for the Sinker Bond Warangal. * * @author Lakshmi Krishnamurthy */ public class Warangal { - private static final MergedDiscountForwardCurve FundingCurve ( - final JulianDate dtSpot, - final String strCurrency, - final double dblBump) + public static final void main ( + final String[] astArgs) throws Exception { - String[] astrDepositMaturityTenor = new String[] { + EnvManager.InitEnv ( + "", + true + ); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.MARCH, + 10 + ); + + String[] astrDepositTenor = new String[] { "2D" }; double[] adblDepositQuote = new double[] { - 0.0111956 + dblBump // 2D + 0.0130411 // 2D }; double[] adblFuturesQuote = new double[] { - 0.011375 + dblBump, // 98.8625 - 0.013350 + dblBump, // 98.6650 - 0.014800 + dblBump, // 98.5200 - 0.016450 + dblBump, // 98.3550 - 0.017850 + dblBump, // 98.2150 - 0.019300 + dblBump // 98.0700 + 0.01345, // 98.655 + 0.01470, // 98.530 + 0.01575, // 98.425 + 0.01660, // 98.340 + 0.01745, // 98.255 + 0.01845 // 98.155 }; - String[] astrFixFloatMaturityTenor = new String[] { + String[] astrFixFloatTenor = new String[] { "02Y", "03Y", "04Y", @@ -112,470 +114,183 @@ private static final MergedDiscountForwardCurve FundingCurve ( "50Y" }; - double[] adblFixFloatQuote = new double[] { - 0.017029 + dblBump, // 2Y - 0.019354 + dblBump, // 3Y - 0.021044 + dblBump, // 4Y - 0.022291 + dblBump, // 5Y - 0.023240 + dblBump, // 6Y - 0.024025 + dblBump, // 7Y - 0.024683 + dblBump, // 8Y - 0.025243 + dblBump, // 9Y - 0.025720 + dblBump, // 10Y - 0.026130 + dblBump, // 11Y - 0.026495 + dblBump, // 12Y - 0.027230 + dblBump, // 15Y - 0.027855 + dblBump, // 20Y - 0.028025 + dblBump, // 25Y - 0.028028 + dblBump, // 30Y - 0.027902 + dblBump, // 40Y - 0.027655 + dblBump // 50Y + String[] astrGovvieTenor = new String[] { + "1Y", + "2Y", + "3Y", + "5Y", + "7Y", + "10Y", + "20Y", + "30Y" }; - MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve ( - dtSpot, - strCurrency, - astrDepositMaturityTenor, - adblDepositQuote, - "ForwardRate", - adblFuturesQuote, - "ForwardRate", - astrFixFloatMaturityTenor, - adblFixFloatQuote, - "SwapRate" - ); - - Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit ( - dtSpot, - strCurrency, - astrDepositMaturityTenor - ); - - Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack ( - dtSpot, - adblFuturesQuote.length, - strCurrency - ); - - Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard ( - dtSpot, - strCurrency, - "ALL", - astrFixFloatMaturityTenor, - "MAIN", - 0. - ); - - ValuationParams valParams = new ValuationParams ( - dtSpot, - dtSpot, - strCurrency - ); - - CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create ( - dcFunding, - null, - null, - null, - null, - null, - null - ); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| DEPOSIT INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aDepositComp.length; ++i) - System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aDepositComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println ("\t| FUTURES INPUT vs. CALC ||"); - - System.out.println ("\t|-------------------------------------||"); - - for (int i = 0; i < aFuturesComp.length; ++i) - System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFuturesComp[i].measureValue ( - valParams, - null, - csqc, - null, - "ForwardRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|-------------------------------------||"); - - System.out.println(); - - System.out.println ("\t|------------------------------------------------|| "); - - System.out.println ("\t| FIX-FLOAT INPUTS vs CALIB ||"); - - System.out.println ("\t|------------------------------------------------|| "); - - for (int i = 0; i < aFixFloatComp.length; ++i) - System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "CalibSwapRate" - ), 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" + - FormatUtil.FormatDouble (aFixFloatComp[i].measureValue ( - valParams, - null, - csqc, - null, - "FairPremium" - ), 1, 6, 1.) + " ||" - ); - - System.out.println ("\t|------------------------------------------------||"); - - System.out.println(); - - return dcFunding; - } - - private static final GovvieCurve GovvieCurve ( - final JulianDate dtSpot, - final String strCode, - final double[] adblCoupon, - final double[] adblYield) - throws Exception - { - JulianDate[] adtEffective = new JulianDate[] { - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot, - dtSpot + double[] adblFixFloatQuote = new double[] { + 0.016410, // 2Y + 0.017863, // 3Y + 0.019030, // 4Y + 0.020035, // 5Y + 0.020902, // 6Y + 0.021660, // 7Y + 0.022307, // 8Y + 0.022879, // 9Y + 0.023363, // 10Y + 0.023820, // 11Y + 0.024172, // 12Y + 0.024934, // 15Y + 0.025581, // 20Y + 0.025906, // 25Y + 0.025973, // 30Y + 0.025838, // 40Y + 0.025560 // 50Y }; - JulianDate[] adtMaturity = new JulianDate[] { - dtSpot.addTenor ("1Y"), - dtSpot.addTenor ("2Y"), - dtSpot.addTenor ("3Y"), - dtSpot.addTenor ("5Y"), - dtSpot.addTenor ("7Y"), - dtSpot.addTenor ("10Y"), - dtSpot.addTenor ("20Y"), - dtSpot.addTenor ("30Y") + double[] adblGovvieYield = new double[] { + 0.01219, // 1Y + 0.01391, // 2Y + 0.01590, // 3Y + 0.01937, // 5Y + 0.02200, // 7Y + 0.02378, // 10Y + 0.02677, // 20Y + 0.02927 // 30Y }; - GovvieCurve gc = LatentMarketStateBuilder.GovvieCurve ( - strCode, - dtSpot, - adtEffective, - adtMaturity, - adblCoupon, - adblYield, - "Yield", - LatentMarketStateBuilder.SHAPE_PRESERVING - ); - - BondComponent[] aComp = TreasuryBuilder.FromCode ( - strCode, - adtEffective, - adtMaturity, - adblCoupon - ); - - ValuationParams valParams = ValuationParams.Spot (dtSpot.julian()); - - CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer(); - - csqc.setGovvieState (gc); - - System.out.println(); - - System.out.println ("\t|-------------------------------------------||"); - - System.out.println ("\t| TREASURY INPUT vs CALIB YIELD ||"); - - System.out.println ("\t|-------------------------------------------||"); - - for (int i = 0; i < aComp.length; ++i) - System.out.println ("\t| " + aComp[i].name() + " | " + - FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " + - FormatUtil.FormatDouble (aComp[i].yieldFromPrice ( - valParams, - null, - null, - aComp[i].maturityDate().julian(), - 1., - aComp[i].priceFromYield ( - valParams, - null, - null, - gc.yield (aComp[i].maturityDate().julian()) - ) - ), 1, 3, 100.) + "% ||" - ); - - System.out.println ("\t|-------------------------------------------||"); - - return gc; - } - - private static final void RVMeasures ( - final BondComponent bondBullet, - final BondComponent bondSinker, - final JulianDate dtValue, - final CurveSurfaceQuoteContainer csqc, - final double dblCleanPrice) - throws Exception - { - JulianDate dtSettle = dtValue.addBusDays ( - 3, - bondBullet.currency() - ); - - ValuationParams valParams = new ValuationParams ( - dtValue, - dtSettle, - bondBullet.currency() - ); - - System.out.println(); - - System.out.println ("\t|--------------------------------||"); - - System.out.println ("\t| Trade Date : " + dtValue + " ||"); - - System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||"); - - System.out.println ("\t|--------------------------------||"); - - System.out.println(); - - double dblYTM = Double.NaN; - double dblYTW = Double.NaN; - double dblOASTW = Double.NaN; - double dblWALTM = Double.NaN; - double dblWALTW = Double.NaN; - double dblZSpreadTW = Double.NaN; - double dblModifiedDurationTW = Double.NaN; - - WorkoutInfo wi = bondBullet.exerciseYieldFromPrice ( - valParams, - csqc, - null, - dblCleanPrice - ); - - try { - dblYTW = wi.yield(); - - dblYTM = bondBullet.yieldFromPrice ( - valParams, - csqc, - null, - bondBullet.maturityDate().julian(), - 1., - dblCleanPrice - ); - - dblWALTW = bondSinker.weightedAverageLife ( - valParams, - csqc, - wi.date(), - wi.factor() - ); - - dblWALTM = bondSinker.weightedAverageLife ( - valParams, - csqc, - bondSinker.maturityDate().julian(), - 1. - ); - - dblZSpreadTW = bondBullet.zSpreadFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblOASTW = bondBullet.oasFromYield ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - wi.yield() - ); - - dblModifiedDurationTW = bondSinker.modifiedDurationFromPrice ( - valParams, - csqc, - null, - wi.date(), - wi.factor(), - dblCleanPrice - ); - } catch (Exception e) { - // e.printStackTrace(); - } - - System.out.println ("\t Bond Name => " + bondSinker.name()); - - System.out.println ("\t Effective Date => " + bondSinker.effectiveDate()); - - System.out.println ("\t Maturity Date => " + bondSinker.maturityDate()); - - System.out.println ("\t Exercise Date => " + new JulianDate (wi.date())); - - System.out.println ("\t Price => " + FormatUtil.FormatDouble (dblCleanPrice, 1, 5, 100.)); - - System.out.println ("\t Bond Accrued => " + FormatUtil.FormatDouble (bondBullet.accrued (dtValue.julian(), csqc), 1, 4, 100.)); - - System.out.println ("\t Bond YTW => " + FormatUtil.FormatDouble (dblYTW, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond YTM => " + FormatUtil.FormatDouble (dblYTM, 1, 3, 100.) + "%"); - - System.out.println ("\t Bond WAL TW => " + FormatUtil.FormatDouble (dblWALTW, 1, 3, 1.)); - - System.out.println ("\t Bond WAL TM => " + FormatUtil.FormatDouble (dblWALTM, 1, 3, 1.)); - - System.out.println ("\t Bond Modified Duration TW => " + FormatUtil.FormatDouble (dblModifiedDurationTW, 1, 4, 10000.)); - - System.out.println ("\t Bond Z Spread TW => " + FormatUtil.FormatDouble (dblZSpreadTW, 1, 1, 10000.)); - - System.out.println ("\t Bond OAS TW => " + FormatUtil.FormatDouble (dblOASTW, 1, 1, 10000.)); - } - - public static final void main ( - final String[] astrArgs) - throws Exception - { - EnvManager.InitEnv ( - "", - true - ); - - JulianDate dtSpot = DateUtil.CreateFromYMD ( - 2017, - DateUtil.MARCH, - 10 - ); - - String strCurrency = "USD"; - String strTreasuryCode = "UST"; - - double[] adblTreasuryCoupon = new double[] { - 0.0100, - 0.0100, - 0.0125, - 0.0150, - 0.0200, - 0.0225, - 0.0250, - 0.0300 + String[] astrCreditTenor = new String[] { + "06M", + "01Y", + "02Y", + "03Y", + "04Y", + "05Y", + "07Y", + "10Y" }; - double[] adblTreasuryYield = new double[] { - 0.0083, // 1Y - 0.0122, // 2Y - 0.0149, // 3Y - 0.0193, // 5Y - 0.0227, // 7Y - 0.0248, // 10Y - 0.0280, // 20Y - 0.0308 // 30Y + double[] adblCreditQuote = new double[] { + 60., // 6M + 68., // 1Y + 88., // 2Y + 102., // 3Y + 121., // 4Y + 138., // 5Y + 168., // 7Y + 188. // 10Y }; - JulianDate dtEffective = DateUtil.CreateFromYMD (2004, 5, 4); - JulianDate dtMaturity = DateUtil.CreateFromYMD (2024, 3, 30); - double dblCoupon = 0.06119; + double dblFX = 1.; + int iSettleLag = 3; + int iCouponFreq = 4; + String strName = "Warangal"; double dblCleanPrice = 1.102304; - int iFreq = 4; - String strCUSIP = "Warangal"; - String strDayCount = "30/360"; - String strDateFactor = "1/19/2016;1;7/15/2016;0.996959469;1/15/2017;0.974197066;7/15/2017;0.951275164;1/15/2018;0.928098079;7/15/2018;0.904352596;1/15/2019;0.880606358;7/15/2019;0.856859495;1/15/2020;0.833111873;7/15/2020;0.809363354;1/15/2021;0.785614111;7/15/2021;0.761863915;1/15/2022;0.738112689;7/15/2022;0.71436057;1/15/2023;0.69060727;7/15/2023;0.666852848;1/15/2024;0.643097228;7/15/2024;0.619340247;1/15/2025;0.595581909;7/15/2025;0.571822018;1/15/2026;0.548083781;7/15/2026;0.52436507;1/15/2027;0.500644216;7/15/2027;0.478957989"; + double dblIssuePrice = 1.0; + String strCurrency = "USD"; + double dblSpreadBump = 20.; + double dblCouponRate = 0.06119; + double dblIssueAmount = 1.0e00; + String strTreasuryCode = "UST"; + String strCouponDayCount = "30/360"; + double dblSpreadDurationMultiplier = 5.; - BondComponent bondBullet = BondBuilder.CreateSimpleFixed ( - strCUSIP, - strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, - dtEffective, - dtMaturity, - null, - null + JulianDate dtEffective = DateUtil.CreateFromYMD ( + 2004, + DateUtil.MAY, + 4 ); - BondComponent bondSinker = BondBuilder.CreateSimpleFixed ( - strCUSIP, + JulianDate dtMaturity = DateUtil.CreateFromYMD ( + 2024, + DateUtil.MARCH, + 30 + ); + + BondComponent bond = BondBuilder.CreateSimpleFixed ( + strName, strCurrency, - "", - dblCoupon, - iFreq, - strDayCount, + strName, + dblCouponRate, + iCouponFreq, + strCouponDayCount, dtEffective, dtMaturity, - Array2D.FromDateFactorVertex ( - strDateFactor, - dtMaturity.julian() + Array2D.FromArray ( + new int[] { + DateUtil.CreateFromYMD (2017, 7, 15).julian(), + DateUtil.CreateFromYMD (2018, 1, 15).julian(), + DateUtil.CreateFromYMD (2018, 7, 15).julian(), + DateUtil.CreateFromYMD (2019, 1, 15).julian(), + DateUtil.CreateFromYMD (2019, 7, 15).julian(), + DateUtil.CreateFromYMD (2020, 1, 15).julian(), + DateUtil.CreateFromYMD (2020, 7, 15).julian(), + DateUtil.CreateFromYMD (2021, 1, 15).julian(), + DateUtil.CreateFromYMD (2021, 7, 15).julian(), + DateUtil.CreateFromYMD (2022, 1, 15).julian(), + DateUtil.CreateFromYMD (2022, 7, 15).julian(), + DateUtil.CreateFromYMD (2023, 1, 15).julian(), + DateUtil.CreateFromYMD (2023, 7, 15).julian(), + DateUtil.CreateFromYMD (2024, 1, 15).julian(), + DateUtil.CreateFromYMD (2024, 7, 15).julian(), + DateUtil.CreateFromYMD (2025, 1, 15).julian(), + DateUtil.CreateFromYMD (2025, 7, 15).julian(), + DateUtil.CreateFromYMD (2026, 1, 15).julian(), + DateUtil.CreateFromYMD (2026, 7, 15).julian(), + DateUtil.CreateFromYMD (2027, 1, 15).julian(), + DateUtil.CreateFromYMD (2027, 7, 15).julian(), + }, + new double[] { + 0.951275164, + 0.928098079, + 0.904352596, + 0.880606358, + 0.856859495, + 0.833111873, + 0.809363354, + 0.785614111, + 0.761863915, + 0.738112689, + 0.714360570, + 0.690607270, + 0.666852848, + 0.643097228, + 0.619340247, + 0.595581909, + 0.571822018, + 0.548083781, + 0.524365070, + 0.500644216, + 0.478957989, + } ), null ); - RVMeasures ( - bondBullet, - bondSinker, + BondReplicator abr = BondReplicator.CorporateSenior ( + dblCleanPrice, + dblIssuePrice, + dblIssueAmount, dtSpot, - MarketParamsBuilder.Create ( - FundingCurve ( - dtSpot, - strCurrency, - 0. - ), - GovvieCurve ( - dtSpot, - strTreasuryCode, - adblTreasuryCoupon, - adblTreasuryYield - ), - null, - null, - null, - null, - null - ), - dblCleanPrice + astrDepositTenor, + adblDepositQuote, + adblFuturesQuote, + astrFixFloatTenor, + adblFixFloatQuote, + dblSpreadBump, + dblSpreadDurationMultiplier, + strTreasuryCode, + astrGovvieTenor, + adblGovvieYield, + astrCreditTenor, + adblCreditQuote, + dblFX, + Double.NaN, + iSettleLag, + bond ); + BondReplicationRun abrr = abr.generateRun(); + + System.out.println (abrr.display()); + EnvManager.TerminateEnv(); } } diff --git a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAAttribution.java b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAAttribution.java index 70856c698fc7..a8e8f7f83a61 100644 --- a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAAttribution.java +++ b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAAttribution.java @@ -407,7 +407,7 @@ public static final void main ( iSpotDate, aiVertexDate, tc, - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, diff --git a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAExplain.java b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAExplain.java index e585150210a0..1a48c1f03aba 100644 --- a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAExplain.java +++ b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAExplain.java @@ -408,7 +408,7 @@ public static final void main ( iSpotDate, aiVertexDate, tc, - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, diff --git a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAGreeks.java b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAGreeks.java index 1bd35e5a78a2..25fcfa4e6481 100644 --- a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAGreeks.java +++ b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAGreeks.java @@ -406,7 +406,7 @@ public static final void main ( iSpotDate, aiVertexDate, tc, - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, diff --git a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAReplicationPortfolio.java b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAReplicationPortfolio.java index e72456529ee4..947cb8b72a6a 100644 --- a/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAReplicationPortfolio.java +++ b/src/main/java/org/drip/sample/burgard2011/CorrelatedNumeraireXVAReplicationPortfolio.java @@ -406,7 +406,7 @@ public static final void main ( iSpotDate, aiVertexDate, tc, - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, diff --git a/src/main/java/org/drip/sample/burgard2011/XVAExplain.java b/src/main/java/org/drip/sample/burgard2011/XVAExplain.java index d2172bc57dae..ec84cb401888 100644 --- a/src/main/java/org/drip/sample/burgard2011/XVAExplain.java +++ b/src/main/java/org/drip/sample/burgard2011/XVAExplain.java @@ -408,7 +408,7 @@ public static void main ( iSpotDate, aiVertexDate, tc, - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, diff --git a/src/main/java/org/drip/sample/burgard2011/XVAGreeks.java b/src/main/java/org/drip/sample/burgard2011/XVAGreeks.java index 19433f2e9e79..a4b057876005 100644 --- a/src/main/java/org/drip/sample/burgard2011/XVAGreeks.java +++ b/src/main/java/org/drip/sample/burgard2011/XVAGreeks.java @@ -397,7 +397,7 @@ public static void main ( iSpotDate, aiVertexDate, tc, - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, diff --git a/src/main/java/org/drip/sample/burgard2011/XVAMarketGeneration.java b/src/main/java/org/drip/sample/burgard2011/XVAMarketGeneration.java index 63b268d1e9c0..024cef5ee2a7 100644 --- a/src/main/java/org/drip/sample/burgard2011/XVAMarketGeneration.java +++ b/src/main/java/org/drip/sample/burgard2011/XVAMarketGeneration.java @@ -272,7 +272,7 @@ public static final void main ( tBankSubordinateFunding, tCounterPartyFunding ), - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, diff --git a/src/main/java/org/drip/sample/burgard2011/XVAReplicationPortfolio.java b/src/main/java/org/drip/sample/burgard2011/XVAReplicationPortfolio.java index 51405cb9802d..2bd7a4a46431 100644 --- a/src/main/java/org/drip/sample/burgard2011/XVAReplicationPortfolio.java +++ b/src/main/java/org/drip/sample/burgard2011/XVAReplicationPortfolio.java @@ -407,7 +407,7 @@ public static void main ( iSpotDate, aiVertexDate, tc, - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, diff --git a/src/main/java/org/drip/sample/burgard2012/EulerTrajectoryEvolutionScheme.java b/src/main/java/org/drip/sample/burgard2012/EulerTrajectoryEvolutionScheme.java index c5d4fbc01150..f8666641df4b 100644 --- a/src/main/java/org/drip/sample/burgard2012/EulerTrajectoryEvolutionScheme.java +++ b/src/main/java/org/drip/sample/burgard2012/EulerTrajectoryEvolutionScheme.java @@ -282,7 +282,7 @@ public static final void main ( iSpotDate, aiVertexDate, tc, - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, diff --git a/src/main/java/org/drip/sample/burgard2013/PerfectReplicationCollateralizedFunding.java b/src/main/java/org/drip/sample/burgard2013/PerfectReplicationCollateralizedFunding.java index 2f7b5daff645..4cfc7d58b675 100644 --- a/src/main/java/org/drip/sample/burgard2013/PerfectReplicationCollateralizedFunding.java +++ b/src/main/java/org/drip/sample/burgard2013/PerfectReplicationCollateralizedFunding.java @@ -14,7 +14,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/PerfectReplicationCollateralizedFundingStochastic.java b/src/main/java/org/drip/sample/burgard2013/PerfectReplicationCollateralizedFundingStochastic.java index ddeb72b4a641..23df820ef0d2 100644 --- a/src/main/java/org/drip/sample/burgard2013/PerfectReplicationCollateralizedFundingStochastic.java +++ b/src/main/java/org/drip/sample/burgard2013/PerfectReplicationCollateralizedFundingStochastic.java @@ -16,7 +16,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/PerfectReplicationZeroThresholdFunding.java b/src/main/java/org/drip/sample/burgard2013/PerfectReplicationZeroThresholdFunding.java index 9435ccd1b5e7..6d7180f48199 100644 --- a/src/main/java/org/drip/sample/burgard2013/PerfectReplicationZeroThresholdFunding.java +++ b/src/main/java/org/drip/sample/burgard2013/PerfectReplicationZeroThresholdFunding.java @@ -14,7 +14,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/PerfectReplicationZeroThresholdFundingStochastic.java b/src/main/java/org/drip/sample/burgard2013/PerfectReplicationZeroThresholdFundingStochastic.java index 0107e7d06999..af8017e4080a 100644 --- a/src/main/java/org/drip/sample/burgard2013/PerfectReplicationZeroThresholdFundingStochastic.java +++ b/src/main/java/org/drip/sample/burgard2013/PerfectReplicationZeroThresholdFundingStochastic.java @@ -16,7 +16,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/SemiReplicationCollateralizedFunding.java b/src/main/java/org/drip/sample/burgard2013/SemiReplicationCollateralizedFunding.java index ebeb303e5fc4..4495c0d2bca8 100644 --- a/src/main/java/org/drip/sample/burgard2013/SemiReplicationCollateralizedFunding.java +++ b/src/main/java/org/drip/sample/burgard2013/SemiReplicationCollateralizedFunding.java @@ -14,7 +14,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/SemiReplicationCollateralizedFundingStochastic.java b/src/main/java/org/drip/sample/burgard2013/SemiReplicationCollateralizedFundingStochastic.java index f17d05d07c8c..064e84e81c79 100644 --- a/src/main/java/org/drip/sample/burgard2013/SemiReplicationCollateralizedFundingStochastic.java +++ b/src/main/java/org/drip/sample/burgard2013/SemiReplicationCollateralizedFundingStochastic.java @@ -16,7 +16,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/SemiReplicationZeroThresholdFunding.java b/src/main/java/org/drip/sample/burgard2013/SemiReplicationZeroThresholdFunding.java index d082b09cd1f9..6a4ea47229c1 100644 --- a/src/main/java/org/drip/sample/burgard2013/SemiReplicationZeroThresholdFunding.java +++ b/src/main/java/org/drip/sample/burgard2013/SemiReplicationZeroThresholdFunding.java @@ -14,7 +14,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/SemiReplicationZeroThresholdFundingStochastic.java b/src/main/java/org/drip/sample/burgard2013/SemiReplicationZeroThresholdFundingStochastic.java index b2e21cbb3fe0..b162dd57812a 100644 --- a/src/main/java/org/drip/sample/burgard2013/SemiReplicationZeroThresholdFundingStochastic.java +++ b/src/main/java/org/drip/sample/burgard2013/SemiReplicationZeroThresholdFundingStochastic.java @@ -16,7 +16,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/SetOffCollateralizedFunding.java b/src/main/java/org/drip/sample/burgard2013/SetOffCollateralizedFunding.java index 1cd678236883..84de405a3cf6 100644 --- a/src/main/java/org/drip/sample/burgard2013/SetOffCollateralizedFunding.java +++ b/src/main/java/org/drip/sample/burgard2013/SetOffCollateralizedFunding.java @@ -14,7 +14,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/SetOffCollateralizedFundingStochastic.java b/src/main/java/org/drip/sample/burgard2013/SetOffCollateralizedFundingStochastic.java index a85465804da3..3f627d38d633 100644 --- a/src/main/java/org/drip/sample/burgard2013/SetOffCollateralizedFundingStochastic.java +++ b/src/main/java/org/drip/sample/burgard2013/SetOffCollateralizedFundingStochastic.java @@ -16,7 +16,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/SetOffZeroThresholdFunding.java b/src/main/java/org/drip/sample/burgard2013/SetOffZeroThresholdFunding.java index 0687b814739e..60d8c76b4758 100644 --- a/src/main/java/org/drip/sample/burgard2013/SetOffZeroThresholdFunding.java +++ b/src/main/java/org/drip/sample/burgard2013/SetOffZeroThresholdFunding.java @@ -14,7 +14,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/burgard2013/SetOffZeroThresholdFundingStochastic.java b/src/main/java/org/drip/sample/burgard2013/SetOffZeroThresholdFundingStochastic.java index c7f4a5927fc2..794ca851122c 100644 --- a/src/main/java/org/drip/sample/burgard2013/SetOffZeroThresholdFundingStochastic.java +++ b/src/main/java/org/drip/sample/burgard2013/SetOffZeroThresholdFundingStochastic.java @@ -16,7 +16,7 @@ import org.drip.xva.cpty.*; import org.drip.xva.definition.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/intexfeed/BrokenDateLIBOREUR.java b/src/main/java/org/drip/sample/intexfeed/BrokenDateLIBOREUR.java new file mode 100644 index 000000000000..3fe390d44ee3 --- /dev/null +++ b/src/main/java/org/drip/sample/intexfeed/BrokenDateLIBOREUR.java @@ -0,0 +1,188 @@ + +package org.drip.sample.intexfeed; + +import org.drip.analytics.date.*; +import org.drip.analytics.daycount.Convention; +import org.drip.analytics.support.Helper; +import org.drip.market.otc.*; +import org.drip.quant.common.FormatUtil; +import org.drip.service.env.EnvManager; +import org.drip.service.template.LatentMarketStateBuilder; +import org.drip.state.discount.MergedDiscountForwardCurve; +import org.drip.state.identifier.ForwardLabel; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2018 Lakshmi Krishnamurthy + * Copyright (C) 2017 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. + */ + +/** + * BrokenDateLIBOREUR generates the EUR LIBOR Forward's over Monthly Increments with Maturity up to 60 Years + * for different Forward Tenors. + * + * @author Lakshmi Krishnamurthy + */ + +public class BrokenDateLIBOREUR { + + private static final MergedDiscountForwardCurve FundingCurve ( + final JulianDate dtSpot, + final String strCurrency) + throws Exception + { + String[] astrDepositMaturityTenor = new String[] { + "1W", + "2W", + "1M", + "2M", + "3M", + "6M", + "9M" + }; + + double[] adblDepositQuote = new double[] { + -0.00379, // 1W + -0.00372, // 2W + -0.00370, // 1M + -0.00341, // 2M + -0.00329, // 3M + -0.00271, // 6M + -0.00221 // 9M + }; + + String[] astrFixFloatMaturityTenor = new String[] { + "01Y", + }; + + double[] adblFixFloatQuote = new double[] { + -0.000204, // 1Y + }; + + return LatentMarketStateBuilder.SingleStretchSmoothFundingCurve ( + dtSpot, + strCurrency, + astrDepositMaturityTenor, + adblDepositQuote, + "ForwardRate", + null, // adblFuturesQuote, + null, // "ForwardRate", + astrFixFloatMaturityTenor, + adblFixFloatQuote, + "SwapRate" + ); + } + + public static final void main ( + final String[] astrArgs) + throws Exception + { + EnvManager.InitEnv (""); + + JulianDate dtSpot = DateUtil.CreateFromYMD ( + 2017, + DateUtil.OCTOBER, + 5 + ); + + int iNumMonth = 720; + String strCurrency = "USD"; + String[] astrForwardTenor = new String[] { + "1M", + "2M", + "3M", + "6M", + "12M" + }; + + FixedFloatSwapConvention ffsc = IBORFixedFloatContainer.ConventionFromJurisdiction (strCurrency); + + ForwardLabel forwardLabel = ffsc.floatStreamConvention().floaterIndex(); + + String strLIBORDayCount = forwardLabel.floaterIndex().dayCount(); + + int iLIBORFreq = Helper.TenorToFreq (forwardLabel.tenor()); + + MergedDiscountForwardCurve mdfc = FundingCurve ( + dtSpot, + strCurrency + ); + + System.out.println + ("SpotDate,ViewDate,ForwardTenor,ViewDiscountFactor,ViewForwardDiscountFactor, ForwardRate"); + + for (int i = 0; i < iNumMonth; ++i) { + JulianDate dtView = 0 == i ? dtSpot : dtSpot.addMonths (i); + + double dblDFView = mdfc.df (dtView); + + for (int j = 0; j < astrForwardTenor.length; ++j) { + JulianDate dtForward = dtView.addTenor (astrForwardTenor[j]); + + double dblDFForward = mdfc.df (dtForward); + + double dblForwardRate = Helper.DF2Yield ( + iLIBORFreq, + dblDFForward / dblDFView, + Convention.YearFraction ( + dtView.julian(), + dtForward.julian(), + strLIBORDayCount, + false, + null, + strCurrency + ) + ); + + System.out.println ( + dtSpot + "," + + dtView + "," + + astrForwardTenor[j] + "," + + FormatUtil.FormatDouble (dblDFView, 1, 8, 1.) + "," + + FormatUtil.FormatDouble (dblDFForward, 1, 8, 1.) + "," + + FormatUtil.FormatDouble (dblForwardRate, 1, 8, 100.) + "%" + ); + } + } + } +} diff --git a/src/main/java/org/drip/sample/intexfeed/BrokenDateLIBORForward.java b/src/main/java/org/drip/sample/intexfeed/BrokenDateLIBORUSD.java similarity index 98% rename from src/main/java/org/drip/sample/intexfeed/BrokenDateLIBORForward.java rename to src/main/java/org/drip/sample/intexfeed/BrokenDateLIBORUSD.java index 814c6d617236..a90ecba83b50 100644 --- a/src/main/java/org/drip/sample/intexfeed/BrokenDateLIBORForward.java +++ b/src/main/java/org/drip/sample/intexfeed/BrokenDateLIBORUSD.java @@ -58,13 +58,13 @@ */ /** - * BrokenDateLIBORForward generates the LIBOR Forward's over Monthly Increments with Maturity up to 60 Years + * BrokenDateLIBORUSD generates the USD LIBOR Forward's over Monthly Increments with Maturity up to 60 Years * for different Forward Tenors. * * @author Lakshmi Krishnamurthy */ -public class BrokenDateLIBORForward { +public class BrokenDateLIBORUSD { private static final MergedDiscountForwardCurve FundingCurve ( final JulianDate dtSpot, diff --git a/src/main/java/org/drip/sample/xva/CollateralizedCollateralGroup.java b/src/main/java/org/drip/sample/xva/CollateralizedCollateralGroup.java index cd59bb51371c..485437aa38db 100644 --- a/src/main/java/org/drip/sample/xva/CollateralizedCollateralGroup.java +++ b/src/main/java/org/drip/sample/xva/CollateralizedCollateralGroup.java @@ -11,7 +11,7 @@ import org.drip.service.env.EnvManager; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xva/CollateralizedCollateralGroupCorrelated.java b/src/main/java/org/drip/sample/xva/CollateralizedCollateralGroupCorrelated.java index 1dd45d0f7423..04b87676f5a7 100644 --- a/src/main/java/org/drip/sample/xva/CollateralizedCollateralGroupCorrelated.java +++ b/src/main/java/org/drip/sample/xva/CollateralizedCollateralGroupCorrelated.java @@ -12,7 +12,7 @@ import org.drip.service.env.EnvManager; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xva/PortfolioCollateralEstimate.java b/src/main/java/org/drip/sample/xva/PortfolioCollateralEstimate.java index b6cbc8b00e11..61fa1453b859 100644 --- a/src/main/java/org/drip/sample/xva/PortfolioCollateralEstimate.java +++ b/src/main/java/org/drip/sample/xva/PortfolioCollateralEstimate.java @@ -10,7 +10,7 @@ import org.drip.quant.common.FormatUtil; import org.drip.service.env.EnvManager; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; /* diff --git a/src/main/java/org/drip/sample/xva/ZeroThresholdCollateralGroup.java b/src/main/java/org/drip/sample/xva/ZeroThresholdCollateralGroup.java index 014a43e63e8b..6af8794cec24 100644 --- a/src/main/java/org/drip/sample/xva/ZeroThresholdCollateralGroup.java +++ b/src/main/java/org/drip/sample/xva/ZeroThresholdCollateralGroup.java @@ -11,7 +11,7 @@ import org.drip.service.env.EnvManager; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xva/ZeroThresholdCollateralGroupCorrelated.java b/src/main/java/org/drip/sample/xva/ZeroThresholdCollateralGroupCorrelated.java index b762a47fb085..b39d50fe89f2 100644 --- a/src/main/java/org/drip/sample/xva/ZeroThresholdCollateralGroupCorrelated.java +++ b/src/main/java/org/drip/sample/xva/ZeroThresholdCollateralGroupCorrelated.java @@ -12,7 +12,7 @@ import org.drip.service.env.EnvManager; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralNeutral.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralNeutral.java index 016b0f0a7550..485de335bfc8 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralNeutral.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralNeutral.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralNeutralStochastic.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralNeutralStochastic.java index 005089a36279..836d3c60bfa2 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralNeutralStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralNeutralStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralPayable.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralPayable.java index 7e5278f0a40f..75cae6ed9138 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralPayable.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralPayable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralPayableStochastic.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralPayableStochastic.java index 287f747c0771..054b5e789315 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralPayableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralPayableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralReceivable.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralReceivable.java index 05c44d6d1977..73409c90c9d4 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralReceivable.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralReceivable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralReceivableStochastic.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralReceivableStochastic.java index 3e0cd2e5f142..c45a03580ff5 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralReceivableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedCollateralReceivableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingNeutral.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingNeutral.java index 8f9c786ec5ab..4acf7726f3b1 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingNeutral.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingNeutral.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingNeutralStochastic.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingNeutralStochastic.java index c8111a4e56d5..1695e5a48a51 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingNeutralStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingNeutralStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingPayable.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingPayable.java index 741df6c8351a..4e974d811a08 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingPayable.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingPayable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingPayableStochastic.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingPayableStochastic.java index e2f904e8bb18..9a54d7040324 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingPayableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingPayableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingReceivable.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingReceivable.java index 793185bcd860..879f0e122362 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingReceivable.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingReceivable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingReceivableStochastic.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingReceivableStochastic.java index c9019a9c292d..e58a736833b7 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingReceivableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedFundingReceivableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingNeutral.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingNeutral.java index a790fe56f808..d11b587a16b4 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingNeutral.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingNeutral.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingNeutralStochastic.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingNeutralStochastic.java index 560f0ec90767..aef59351c325 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingNeutralStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingNeutralStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingPayable.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingPayable.java index 6918b793741f..cca8a24de057 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingPayable.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingPayable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingPayableStochastic.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingPayableStochastic.java index dccdee251c8c..ed978beda8c3 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingPayableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingPayableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingReceivable.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingReceivable.java index 9d4cb9917822..804964007a5c 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingReceivable.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingReceivable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingReceivableStochastic.java b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingReceivableStochastic.java index 5802efc868fa..19a48e58420a 100644 --- a/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingReceivableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/CollateralizedNettingReceivableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralNeutral.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralNeutral.java index ba7c27204473..17b720d20e56 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralNeutral.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralNeutral.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralNeutralStochastic.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralNeutralStochastic.java index 9979e166cbc6..22cff1a481e0 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralNeutralStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralNeutralStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralPayable.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralPayable.java index 191741870463..ec466b781901 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralPayable.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralPayable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralPayableStochastic.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralPayableStochastic.java index f0118cac3527..93f6911cbb54 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralPayableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralPayableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralReceivable.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralReceivable.java index 2f51ef5fad11..1952e07a4e1a 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralReceivable.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralReceivable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralReceivableStochastic.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralReceivableStochastic.java index eb59f496ed09..cd4f14b5f25c 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralReceivableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdCollateralReceivableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingNeutral.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingNeutral.java index f4a67f41d70f..eb2aaefd4a19 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingNeutral.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingNeutral.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingNeutralStochastic.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingNeutralStochastic.java index 33b4a2090c73..a76208a64c7b 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingNeutralStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingNeutralStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingPayable.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingPayable.java index 499660d36037..a9cbe6e7f38d 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingPayable.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingPayable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingPayableStochastic.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingPayableStochastic.java index f50558ede338..fad07c7d11c1 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingPayableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingPayableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingReceivable.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingReceivable.java index 4d1dc4162689..43a00f400628 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingReceivable.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingReceivable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingReceivableStochastic.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingReceivableStochastic.java index 23d54ef70220..a1617eff4ae5 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingReceivableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdFundingReceivableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingNeutral.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingNeutral.java index 0bc636d876c7..d41c863012c2 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingNeutral.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingNeutral.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingNeutralStochastic.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingNeutralStochastic.java index 93d936637921..a54d07b7281e 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingNeutralStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingNeutralStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingPayable.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingPayable.java index c49f67b2a57d..1b7a44de9053 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingPayable.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingPayable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingPayableStochastic.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingPayableStochastic.java index 80268d820bd0..fba56cfc95e6 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingPayableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingPayableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingReceivable.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingReceivable.java index dd016524213a..a4c3b70b7531 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingReceivable.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingReceivable.java @@ -13,7 +13,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingReceivableStochastic.java b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingReceivableStochastic.java index 0da98fb1425f..f0aea9e1933f 100644 --- a/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingReceivableStochastic.java +++ b/src/main/java/org/drip/sample/xvabasel/ZeroThresholdNettingReceivableStochastic.java @@ -15,7 +15,7 @@ import org.drip.xva.basel.*; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvadigest/CPGACollateralized.java b/src/main/java/org/drip/sample/xvadigest/CPGACollateralized.java index e9064496782e..3c3681d0df33 100644 --- a/src/main/java/org/drip/sample/xvadigest/CPGACollateralized.java +++ b/src/main/java/org/drip/sample/xvadigest/CPGACollateralized.java @@ -12,7 +12,7 @@ import org.drip.service.env.EnvManager; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvadigest/CPGACollateralizedCorrelated.java b/src/main/java/org/drip/sample/xvadigest/CPGACollateralizedCorrelated.java index e78911abe867..81cf656f2b2d 100644 --- a/src/main/java/org/drip/sample/xvadigest/CPGACollateralizedCorrelated.java +++ b/src/main/java/org/drip/sample/xvadigest/CPGACollateralizedCorrelated.java @@ -13,7 +13,7 @@ import org.drip.service.env.EnvManager; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvadigest/CPGAZeroThreshold.java b/src/main/java/org/drip/sample/xvadigest/CPGAZeroThreshold.java index 920205498ea4..58ee9b4e2d52 100644 --- a/src/main/java/org/drip/sample/xvadigest/CPGAZeroThreshold.java +++ b/src/main/java/org/drip/sample/xvadigest/CPGAZeroThreshold.java @@ -12,7 +12,7 @@ import org.drip.service.env.EnvManager; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvadigest/CPGAZeroThresholdCorrelated.java b/src/main/java/org/drip/sample/xvadigest/CPGAZeroThresholdCorrelated.java index 656d28c14b85..728786b8df28 100644 --- a/src/main/java/org/drip/sample/xvadigest/CPGAZeroThresholdCorrelated.java +++ b/src/main/java/org/drip/sample/xvadigest/CPGAZeroThresholdCorrelated.java @@ -13,7 +13,7 @@ import org.drip.service.env.EnvManager; import org.drip.xva.cpty.*; import org.drip.xva.hypothecation.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.strategy.*; import org.drip.xva.universe.*; diff --git a/src/main/java/org/drip/sample/xvafixfloat/AlbaneseAndersenBaselProxy.java b/src/main/java/org/drip/sample/xvafixfloat/AlbaneseAndersenBaselProxy.java index 56ce3ac205cc..1c5c30082334 100644 --- a/src/main/java/org/drip/sample/xvafixfloat/AlbaneseAndersenBaselProxy.java +++ b/src/main/java/org/drip/sample/xvafixfloat/AlbaneseAndersenBaselProxy.java @@ -15,7 +15,7 @@ import org.drip.xva.dynamics.*; import org.drip.xva.evolver.*; import org.drip.xva.holdings.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.universe.*; @@ -272,7 +272,7 @@ private static final MarketVertexGenerator ConstructMarketVertexGenerator ( bank, counterParty ), - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, @@ -467,11 +467,28 @@ public static final void main ( 0., CloseOutScheme.ISDA_92 ), - new NettingGroupSpecification ( + new CreditDebtGroupSpecification ( "NETGRPSPEC1", "NETGRPSPEC1", true, - true + true, + EntityHazardLabel.Standard ( + bank, + currency + ), + EntityHazardLabel.Standard ( + counterParty, + currency + ), + EntityRecoveryLabel.Senior ( + bank, + currency + ), + EntityRecoveryLabel.Senior ( + counterParty, + currency + ), + null ), new RollUpGroupSpecification ( "FUNDGRPSPEC1", diff --git a/src/main/java/org/drip/sample/xvafixfloat/GoldPlatedBaselProxy.java b/src/main/java/org/drip/sample/xvafixfloat/GoldPlatedBaselProxy.java index d3e56aa59699..c8f572d83721 100644 --- a/src/main/java/org/drip/sample/xvafixfloat/GoldPlatedBaselProxy.java +++ b/src/main/java/org/drip/sample/xvafixfloat/GoldPlatedBaselProxy.java @@ -15,7 +15,7 @@ import org.drip.xva.dynamics.*; import org.drip.xva.evolver.*; import org.drip.xva.holdings.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.universe.*; @@ -274,7 +274,7 @@ private static final MarketVertexGenerator ConstructMarketVertexGenerator ( bank, counterParty ), - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, @@ -480,11 +480,31 @@ public static final void main ( 0., CloseOutScheme.BILATERAL ), - new NettingGroupSpecification ( + new CreditDebtGroupSpecification ( "NETGRPSPEC1", "NETGRPSPEC1", true, - true + true, + EntityHazardLabel.Standard ( + bank, + currency + ), + EntityHazardLabel.Standard ( + counterParty, + currency + ), + EntityRecoveryLabel.Senior ( + bank, + currency + ), + EntityRecoveryLabel.Senior ( + counterParty, + currency + ), + EntityRecoveryLabel.Subordinate ( + bank, + currency + ) ), new RollUpGroupSpecification ( "FUNDGRPSPEC1", diff --git a/src/main/java/org/drip/sample/xvafixfloat/HedgeErrorBaselProxy.java b/src/main/java/org/drip/sample/xvafixfloat/HedgeErrorBaselProxy.java index 8269b5448930..7ad55dd5ff6f 100644 --- a/src/main/java/org/drip/sample/xvafixfloat/HedgeErrorBaselProxy.java +++ b/src/main/java/org/drip/sample/xvafixfloat/HedgeErrorBaselProxy.java @@ -15,7 +15,7 @@ import org.drip.xva.dynamics.*; import org.drip.xva.evolver.*; import org.drip.xva.holdings.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.universe.*; @@ -274,7 +274,7 @@ private static final MarketVertexGenerator ConstructMarketVertexGenerator ( bank, counterParty ), - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, @@ -480,11 +480,31 @@ public static final void main ( 0., CloseOutScheme.BILATERAL ), - new NettingGroupSpecification ( + new CreditDebtGroupSpecification ( "NETGRPSPEC1", "NETGRPSPEC1", true, - true + true, + EntityHazardLabel.Standard ( + bank, + currency + ), + EntityHazardLabel.Standard ( + counterParty, + currency + ), + EntityRecoveryLabel.Senior ( + bank, + currency + ), + EntityRecoveryLabel.Senior ( + counterParty, + currency + ), + EntityRecoveryLabel.Subordinate ( + bank, + currency + ) ), new RollUpGroupSpecification ( "FUNDGRPSPEC1", diff --git a/src/main/java/org/drip/sample/xvafixfloat/OneWayBaselProxy.java b/src/main/java/org/drip/sample/xvafixfloat/OneWayBaselProxy.java index 43aea8e1bddb..d436123b6cbd 100644 --- a/src/main/java/org/drip/sample/xvafixfloat/OneWayBaselProxy.java +++ b/src/main/java/org/drip/sample/xvafixfloat/OneWayBaselProxy.java @@ -15,7 +15,7 @@ import org.drip.xva.dynamics.*; import org.drip.xva.evolver.*; import org.drip.xva.holdings.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.universe.*; @@ -274,7 +274,7 @@ private static final MarketVertexGenerator ConstructMarketVertexGenerator ( bank, counterParty ), - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, @@ -480,11 +480,31 @@ public static final void main ( 0., CloseOutScheme.BILATERAL ), - new NettingGroupSpecification ( + new CreditDebtGroupSpecification ( "NETGRPSPEC1", "NETGRPSPEC1", true, - true + true, + EntityHazardLabel.Standard ( + bank, + currency + ), + EntityHazardLabel.Standard ( + counterParty, + currency + ), + EntityRecoveryLabel.Senior ( + bank, + currency + ), + EntityRecoveryLabel.Senior ( + counterParty, + currency + ), + EntityRecoveryLabel.Subordinate ( + bank, + currency + ) ), new RollUpGroupSpecification ( "FUNDGRPSPEC1", diff --git a/src/main/java/org/drip/sample/xvafixfloat/SemiReplicationBaselProxy.java b/src/main/java/org/drip/sample/xvafixfloat/SemiReplicationBaselProxy.java index cfcf89ca5dc9..45f8914446de 100644 --- a/src/main/java/org/drip/sample/xvafixfloat/SemiReplicationBaselProxy.java +++ b/src/main/java/org/drip/sample/xvafixfloat/SemiReplicationBaselProxy.java @@ -15,7 +15,7 @@ import org.drip.xva.dynamics.*; import org.drip.xva.evolver.*; import org.drip.xva.holdings.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.universe.*; @@ -274,7 +274,7 @@ private static final MarketVertexGenerator ConstructMarketVertexGenerator ( bank, counterParty ), - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, @@ -480,11 +480,31 @@ public static final void main ( 0., CloseOutScheme.BILATERAL ), - new NettingGroupSpecification ( + new CreditDebtGroupSpecification ( "NETGRPSPEC1", "NETGRPSPEC1", true, - true + true, + EntityHazardLabel.Standard ( + bank, + currency + ), + EntityHazardLabel.Standard ( + counterParty, + currency + ), + EntityRecoveryLabel.Senior ( + bank, + currency + ), + EntityRecoveryLabel.Senior ( + counterParty, + currency + ), + EntityRecoveryLabel.Subordinate ( + bank, + currency + ) ), new RollUpGroupSpecification ( "FUNDGRPSPEC1", diff --git a/src/main/java/org/drip/sample/xvafixfloat/SetOffBaselProxy.java b/src/main/java/org/drip/sample/xvafixfloat/SetOffBaselProxy.java index 5ef4481e4522..8d47bbf86824 100644 --- a/src/main/java/org/drip/sample/xvafixfloat/SetOffBaselProxy.java +++ b/src/main/java/org/drip/sample/xvafixfloat/SetOffBaselProxy.java @@ -15,7 +15,7 @@ import org.drip.xva.dynamics.*; import org.drip.xva.evolver.*; import org.drip.xva.holdings.*; -import org.drip.xva.set.*; +import org.drip.xva.proto.*; import org.drip.xva.settings.*; import org.drip.xva.universe.*; @@ -274,7 +274,7 @@ private static final MarketVertexGenerator ConstructMarketVertexGenerator ( bank, counterParty ), - new MarketDynamicsContainer ( + new EntityDynamicsContainer ( new TerminalLatentState ( EntityHazardLabel.Standard ( bank, @@ -480,11 +480,31 @@ public static final void main ( 0., CloseOutScheme.BILATERAL ), - new NettingGroupSpecification ( + new CreditDebtGroupSpecification ( "NETGRPSPEC1", "NETGRPSPEC1", true, - true + true, + EntityHazardLabel.Standard ( + bank, + currency + ), + EntityHazardLabel.Standard ( + counterParty, + currency + ), + EntityRecoveryLabel.Senior ( + bank, + currency + ), + EntityRecoveryLabel.Senior ( + counterParty, + currency + ), + EntityRecoveryLabel.Subordinate ( + bank, + currency + ) ), new RollUpGroupSpecification ( "FUNDGRPSPEC1", diff --git a/src/main/java/org/drip/service/env/BuildManager.java b/src/main/java/org/drip/service/env/BuildManager.java index 1bcf511c081b..e77fbdb3aac1 100644 --- a/src/main/java/org/drip/service/env/BuildManager.java +++ b/src/main/java/org/drip/service/env/BuildManager.java @@ -69,6 +69,11 @@ public static final boolean Init() try { s_aBuildRecord = new org.drip.service.env.BuildRecord[] { + new org.drip.service.env.BuildRecord ( + "3.34.0", + "1.8.0_112", + "Thu Feb 26 23:27:08 EST 2018" + ), new org.drip.service.env.BuildRecord ( "3.33.0", "1.8.0_112", diff --git a/src/main/java/org/drip/xva/dynamics/PathSimulator.java b/src/main/java/org/drip/xva/dynamics/PathSimulator.java index 62c9c73f3e99..4a533f239a5a 100644 --- a/src/main/java/org/drip/xva/dynamics/PathSimulator.java +++ b/src/main/java/org/drip/xva/dynamics/PathSimulator.java @@ -196,7 +196,7 @@ public static final PathSimulator UnitPositionGroupValue ( * * @param iCount Path Count * @param marketVertexGenerator Market Vertex Generator - * @param simulatorScheme Path Simulator Scheme + * @param adjustmentDigestScheme Adjustment Digest Scheme * @param positionGroupContainer Container of Position Groups * * @throws java.lang.Exception Thrown if the Inputs are Invalid diff --git a/src/main/java/org/drip/xva/evolver/MarketDynamicsContainer.java b/src/main/java/org/drip/xva/evolver/EntityDynamicsContainer.java similarity index 94% rename from src/main/java/org/drip/xva/evolver/MarketDynamicsContainer.java rename to src/main/java/org/drip/xva/evolver/EntityDynamicsContainer.java index 0b3a473c9b38..6f7932b958d5 100644 --- a/src/main/java/org/drip/xva/evolver/MarketDynamicsContainer.java +++ b/src/main/java/org/drip/xva/evolver/EntityDynamicsContainer.java @@ -47,8 +47,8 @@ */ /** - * MarketDynamicsContainer contains the Overnight Primary, the CSA Primary, Bank and the Counter Party Credit - * and Funding Latent State Evolvers. The References are:

+ * EntityDynamicsContainer contains the Bank and the Counter Party Hazard and Recovery Latent State + * Evolvers. The References are:

* * - Burgard, C., and M. Kjaer (2013): Funding Strategies, Funding Costs Risk 24 (12) * 82-87.

@@ -67,7 +67,7 @@ * @author Lakshmi Krishnamurthy */ -public class MarketDynamicsContainer extends org.drip.xva.evolver.DynamicsContainer +public class EntityDynamicsContainer extends org.drip.xva.evolver.DynamicsContainer { private org.drip.state.identifier.EntityHazardLabel _bankHazardLabel = null; private org.drip.state.identifier.EntityHazardLabel _counterPartyHazardLabel = null; @@ -76,7 +76,7 @@ public class MarketDynamicsContainer extends org.drip.xva.evolver.DynamicsContai private org.drip.state.identifier.EntityRecoveryLabel _bankSubordinateRecoveryLabel = null; /** - * MarketDynamicsContainer Constructor + * EntityDynamicsContainer Constructor * * @param bankHazardLatentState The Bank Hazard Rate Latent State * @param bankSeniorRecoveryLatentState The Bank Senior Recovery Rate Latent State @@ -87,7 +87,7 @@ public class MarketDynamicsContainer extends org.drip.xva.evolver.DynamicsContai * @throws java.lang.Exception Thrown if the Inputs are Invalid */ - public MarketDynamicsContainer ( + public EntityDynamicsContainer ( final org.drip.xva.evolver.TerminalLatentState bankHazardLatentState, final org.drip.xva.evolver.TerminalLatentState bankSeniorRecoveryLatentState, final org.drip.xva.evolver.TerminalLatentState bankSubordinateRecoveryLatentState, @@ -100,7 +100,7 @@ public MarketDynamicsContainer ( null == counterPartyHazardLatentState || null == counterPartyRecoveryLatentState) { - throw new java.lang.Exception ("MarketDynamicsContainer Constructor => Invalid Inputs"); + throw new java.lang.Exception ("EntityDynamicsContainer Constructor => Invalid Inputs"); } org.drip.state.identifier.LatentStateLabel bankHazardLabel = bankHazardLatentState.label(); @@ -123,7 +123,7 @@ public MarketDynamicsContainer ( !addTerminalLatentState (counterPartyHazardLatentState) || !addTerminalLatentState (counterPartyRecoveryLatentState)) { - throw new java.lang.Exception ("MarketDynamicsContainer Constructor => Invalid Inputs"); + throw new java.lang.Exception ("EntityDynamicsContainer Constructor => Invalid Inputs"); } _bankHazardLabel = (org.drip.state.identifier.EntityHazardLabel) bankHazardLabel; @@ -139,7 +139,7 @@ public MarketDynamicsContainer ( if (!(bankSubordinateRecoveryLabel instanceof org.drip.state.identifier.EntityRecoveryLabel) || !addTerminalLatentState (bankSubordinateRecoveryLatentState)) { - throw new java.lang.Exception ("MarketDynamicsContainer Constructor => Invalid Inputs"); + throw new java.lang.Exception ("EntityDynamicsContainer Constructor => Invalid Inputs"); } _bankSubordinateRecoveryLabel = (org.drip.state.identifier.EntityRecoveryLabel) diff --git a/src/main/java/org/drip/xva/evolver/LatentStateNodeContainer.java b/src/main/java/org/drip/xva/evolver/LatentStateNodeContainer.java index 6685c9371564..9fe18215ec95 100644 --- a/src/main/java/org/drip/xva/evolver/LatentStateNodeContainer.java +++ b/src/main/java/org/drip/xva/evolver/LatentStateNodeContainer.java @@ -376,7 +376,7 @@ public boolean exists ( * * @return The Labeled FX * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double fx ( @@ -438,7 +438,7 @@ public boolean exists ( * * @return The Labeled Repo * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double repo ( @@ -500,7 +500,7 @@ public boolean exists ( * * @return The Labeled Custom * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double custom ( @@ -562,7 +562,7 @@ public boolean exists ( * * @return The Labeled Govvie * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double govvie ( @@ -624,7 +624,7 @@ public boolean exists ( * * @return The Labeled Rating * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double rating ( @@ -686,7 +686,7 @@ public boolean exists ( * * @return The Labeled Forward * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double forward ( @@ -748,7 +748,7 @@ public boolean exists ( * * @return The Labeled Funding * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double funding ( @@ -810,7 +810,7 @@ public boolean exists ( * * @return The Labeled Pay Down * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double payDown ( @@ -872,7 +872,7 @@ public boolean exists ( * * @return The Labeled Overnight * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double overnight ( @@ -934,7 +934,7 @@ public boolean exists ( * * @return The Labeled Collateral * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double collateral ( @@ -996,7 +996,7 @@ public boolean exists ( * * @return The Labeled Volatility * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double volatility ( @@ -1015,7 +1015,7 @@ public double volatility ( * Add the Labeled OTC Fix Float * * @param otcFixFloatLabel The OTC Fix Float Label - * @param otcfixFloat The OTC Fix Float Value + * @param otcFixFloat The OTC Fix Float Value * * @return The Labeled OTC Fix Float successfully added */ @@ -1058,7 +1058,7 @@ public boolean exists ( * * @return The Labeled OTC Fix Float * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double otcFixFloat ( @@ -1121,7 +1121,7 @@ public boolean exists ( * * @return The Labeled Entity Credit * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double entityCredit ( @@ -1184,7 +1184,7 @@ public boolean exists ( * * @return The Labeled Entity Equity * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double entityEquity ( @@ -1228,7 +1228,7 @@ public boolean add ( /** * Check Presence of Labeled Entity Hazard * - * @param entityRecoveryLabel The Entity Hazard Label + * @param entityHazardLabel The Entity Hazard Label * * @return The Labeled Entity Hazard exists */ @@ -1247,7 +1247,7 @@ public boolean exists ( * * @return The Labeled Entity Hazard * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double entityHazard ( @@ -1291,7 +1291,7 @@ public boolean add ( /** * Check Presence of Labeled Entity Funding * - * @param entityRecoveryLabel The Entity Funding Label + * @param entityFundingLabel The Entity Funding Label * * @return The Labeled Entity Funding Exists */ @@ -1310,7 +1310,7 @@ public boolean exists ( * * @return The Labeled Entity Funding * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double entityFunding ( @@ -1373,7 +1373,7 @@ public boolean exists ( * * @return The Labeled Entity Recovery * - * @throws Thrown if Inputs are Invalid + * @throws java.lang.Exception Thrown if Inputs are Invalid */ public double entityRecovery ( diff --git a/src/main/java/org/drip/xva/holdings/PositionGroup.java b/src/main/java/org/drip/xva/holdings/PositionGroup.java index a3bc5022eb0e..4c17d260fca0 100644 --- a/src/main/java/org/drip/xva/holdings/PositionGroup.java +++ b/src/main/java/org/drip/xva/holdings/PositionGroup.java @@ -70,7 +70,7 @@ public class PositionGroup { private org.drip.xva.hypothecation.CollateralGroupPath _collateralGroupPath = null; private org.drip.xva.holdings.PositionGroupNumeraire _positionGroupNumeraire = null; - private org.drip.xva.set.PositionGroupSpecification _positionGroupSpecification = null; + private org.drip.xva.proto.PositionGroupSpecification _positionGroupSpecification = null; /** * PositionGroup Constructor @@ -82,7 +82,7 @@ public class PositionGroup */ public PositionGroup ( - final org.drip.xva.set.PositionGroupSpecification positionGroupSpecification, + final org.drip.xva.proto.PositionGroupSpecification positionGroupSpecification, final org.drip.xva.holdings.PositionGroupNumeraire positionGroupNumeraire) throws java.lang.Exception { @@ -99,7 +99,7 @@ public PositionGroup ( * @return The Position Group Specification */ - public org.drip.xva.set.PositionGroupSpecification positionGroupSpecification() + public org.drip.xva.proto.PositionGroupSpecification positionGroupSpecification() { return _positionGroupSpecification; } diff --git a/src/main/java/org/drip/xva/hypothecation/CollateralAmountEstimator.java b/src/main/java/org/drip/xva/hypothecation/CollateralAmountEstimator.java index 8b3d9bc77ef5..f7e808b083df 100644 --- a/src/main/java/org/drip/xva/hypothecation/CollateralAmountEstimator.java +++ b/src/main/java/org/drip/xva/hypothecation/CollateralAmountEstimator.java @@ -72,7 +72,7 @@ public class CollateralAmountEstimator { private double _currentBalance = java.lang.Double.NaN; private org.drip.measure.bridge.BrokenDateInterpolator _brokenDateInterpolator = null; - private org.drip.xva.set.CollateralGroupSpecification _collateralGroupSpecification = null; + private org.drip.xva.proto.CollateralGroupSpecification _collateralGroupSpecification = null; /** * CollateralAmountEstimator Constructor @@ -85,7 +85,7 @@ public class CollateralAmountEstimator */ public CollateralAmountEstimator ( - final org.drip.xva.set.CollateralGroupSpecification collateralGroupSpecification, + final org.drip.xva.proto.CollateralGroupSpecification collateralGroupSpecification, final org.drip.measure.bridge.BrokenDateInterpolator brokenDateInterpolator, final double currentBalance) throws java.lang.Exception @@ -105,7 +105,7 @@ public CollateralAmountEstimator ( * @return The Collateral Group Specification */ - public org.drip.xva.set.CollateralGroupSpecification collateralGroupSpecification() + public org.drip.xva.proto.CollateralGroupSpecification collateralGroupSpecification() { return _collateralGroupSpecification; } diff --git a/src/main/java/org/drip/xva/hypothecation/CollateralGroup.java b/src/main/java/org/drip/xva/hypothecation/CollateralGroup.java index d66878de40e3..fedfb5eb7700 100644 --- a/src/main/java/org/drip/xva/hypothecation/CollateralGroup.java +++ b/src/main/java/org/drip/xva/hypothecation/CollateralGroup.java @@ -70,7 +70,7 @@ public class CollateralGroup { private double[][] _positionGroupArrayVertex = null; private org.drip.xva.universe.MarketVertex[] _marketVertexArray = null; - private org.drip.xva.set.CollateralGroupSpecification _collateralGroupSpecification = null; + private org.drip.xva.proto.CollateralGroupSpecification _collateralGroupSpecification = null; private org.drip.measure.bridge.BrokenDateInterpolator brokenDateInterpolator ( final int positionGroupIndex, @@ -323,7 +323,7 @@ private org.drip.xva.hypothecation.CollateralGroupVertex collateralGroupVertex ( */ public CollateralGroup ( - final org.drip.xva.set.CollateralGroupSpecification collateralGroupSpecification, + final org.drip.xva.proto.CollateralGroupSpecification collateralGroupSpecification, final org.drip.xva.universe.MarketVertex[] marketVertexArray, final double[][] positionGroupArrayVertex) throws java.lang.Exception @@ -369,7 +369,7 @@ public CollateralGroup ( * @return The Collateral Group Specification */ - public org.drip.xva.set.CollateralGroupSpecification collateralGroupSpecification() + public org.drip.xva.proto.CollateralGroupSpecification collateralGroupSpecification() { return _collateralGroupSpecification; } diff --git a/src/main/java/org/drip/xva/set/CollateralGroupSpecification.java b/src/main/java/org/drip/xva/proto/CollateralGroupSpecification.java similarity index 98% rename from src/main/java/org/drip/xva/set/CollateralGroupSpecification.java rename to src/main/java/org/drip/xva/proto/CollateralGroupSpecification.java index 580d65110b7c..c606ab623cb0 100644 --- a/src/main/java/org/drip/xva/set/CollateralGroupSpecification.java +++ b/src/main/java/org/drip/xva/proto/CollateralGroupSpecification.java @@ -1,5 +1,5 @@ -package org.drip.xva.set; +package org.drip.xva.proto; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -67,7 +67,7 @@ * @author Lakshmi Krishnamurthy */ -public class CollateralGroupSpecification extends org.drip.xva.set.RollUpGroupSpecification +public class CollateralGroupSpecification extends org.drip.xva.proto.RollUpGroupSpecification { private int _closeOutScheme = -1; private int _brokenDateScheme = -1; diff --git a/src/main/java/org/drip/xva/proto/CreditDebtGroupSpecification.java b/src/main/java/org/drip/xva/proto/CreditDebtGroupSpecification.java new file mode 100644 index 000000000000..e2906397615e --- /dev/null +++ b/src/main/java/org/drip/xva/proto/CreditDebtGroupSpecification.java @@ -0,0 +1,247 @@ + +package org.drip.xva.proto; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2018 Lakshmi Krishnamurthy + * Copyright (C) 2017 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. + */ + +/** + * CreditDebtGroupSpecification contains the Specification of a Credit/Debt Netting Group. 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. + * + * - Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk, Risk 20 (2) 86-90. + * + * - Li, B., and Y. Tang (2007): Quantitative Analysis, Derivatives Modeling, and Trading Strategies in the + * Presence of Counter-party Credit Risk for the Fixed Income Market, World Scientific Publishing, + * Singapore. + * + * - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk + * 21 (2) 97-102. + * + * @author Lakshmi Krishnamurthy + */ + +public class CreditDebtGroupSpecification extends org.drip.xva.proto.RollUpGroupSpecification +{ + private boolean _contractual = true; + private boolean _enforceable = true; + private org.drip.state.identifier.EntityHazardLabel _bankHazardLabel = null; + private org.drip.state.identifier.EntityHazardLabel _counterPartyHazardLabel = null; + private org.drip.state.identifier.EntityRecoveryLabel _bankSeniorRecoveryLabel = null; + private org.drip.state.identifier.EntityRecoveryLabel _counterPartyRecoveryLabel = null; + private org.drip.state.identifier.EntityRecoveryLabel _bankSubordinateRecoveryLabel = null; + + /** + * Generate a Standard Instance of CreditDebtGroupSpecification + * + * @param id The Collateral Group ID + * @param name The Collateral Group Name + * @param bankHazardLabel The Bank Hazard Rate Latent State Label + * @param counterPartyHazardLabel The Counter Party Hazard Rate Latent State Label + * @param bankSeniorRecoveryLabel The Bank Senior Recovery Rate Latent State Label + * @param counterPartyRecoveryLabel The Counter Party Recovery Rate Latent State Label + * @param bankSubordinateRecoveryLabel The Bank Subordinate Recovery Rate Latent State Label + * + * @return Standard Instance of NettingGroupSpecification + */ + + public static final CreditDebtGroupSpecification Standard ( + final java.lang.String id, + final java.lang.String name, + final org.drip.state.identifier.EntityHazardLabel bankHazardLabel, + final org.drip.state.identifier.EntityHazardLabel counterPartyHazardLabel, + final org.drip.state.identifier.EntityRecoveryLabel bankSeniorRecoveryLabel, + final org.drip.state.identifier.EntityRecoveryLabel counterPartyRecoveryLabel, + final org.drip.state.identifier.EntityRecoveryLabel bankSubordinateRecoveryLabel) + { + try { + return new CreditDebtGroupSpecification ( + id, + name, + true, + true, + bankHazardLabel, + counterPartyHazardLabel, + bankSeniorRecoveryLabel, + counterPartyRecoveryLabel, + bankSubordinateRecoveryLabel + ); + } + catch (java.lang.Exception e) + { + e.printStackTrace(); + } + + return null; + } + + /** + * CreditDebtGroupSpecification Constructor + * + * @param id The Collateral Group ID + * @param name The Collateral Group Name + * @param contractual TRUE - The Netting is Contractual + * @param enforceable TRUE - The Netting is Enforceable + * @param bankHazardLabel The Bank Hazard Rate Latent State Label + * @param counterPartyHazardLabel The Counter Party Hazard Rate Latent State Label + * @param bankSeniorRecoveryLabel The Bank Senior Recovery Rate Latent State Label + * @param counterPartyRecoveryLabel The Counter Party Recovery Rate Latent State Label + * @param bankSubordinateRecoveryLabel The Bank Subordinate Recovery Rate Latent State Label + * + * @throws java.lang.Exception Thrown if the Inputs are Invalid + */ + + public CreditDebtGroupSpecification ( + final java.lang.String id, + final java.lang.String name, + final boolean contractual, + final boolean enforceable, + final org.drip.state.identifier.EntityHazardLabel bankHazardLabel, + final org.drip.state.identifier.EntityHazardLabel counterPartyHazardLabel, + final org.drip.state.identifier.EntityRecoveryLabel bankSeniorRecoveryLabel, + final org.drip.state.identifier.EntityRecoveryLabel counterPartyRecoveryLabel, + final org.drip.state.identifier.EntityRecoveryLabel bankSubordinateRecoveryLabel) + throws java.lang.Exception + { + super ( + id, + name + ); + + if (null == (_bankHazardLabel = bankHazardLabel) || + null == (_counterPartyHazardLabel = counterPartyHazardLabel) || + null == (_bankSeniorRecoveryLabel = bankSeniorRecoveryLabel) || + null == (_counterPartyRecoveryLabel = counterPartyRecoveryLabel)) + { + throw new java.lang.Exception ("CreditDebtGroupSpecification Constructor"); + } + + _contractual = contractual; + _enforceable = enforceable; + _bankSubordinateRecoveryLabel = bankSubordinateRecoveryLabel; + } + + /** + * Indicate if the Netting allowed is Contractual + * + * @return TRUE - The Netting allowed is Contractual + */ + + public boolean contractual() + { + return _contractual; + } + + /** + * Indicate if the Netting is Enforceable + * + * @return TRUE - The Netting is Enforceable + */ + + public boolean enforceable() + { + return _enforceable; + } + + /** + * Retrieve the Bank Hazard Label + * + * @return The Bank Hazard Label + */ + + public org.drip.state.identifier.EntityHazardLabel bankHazardLabel() + { + return _bankHazardLabel; + } + + /** + * Retrieve the Counter Party Hazard Label + * + * @return The Counter Party Hazard Label + */ + + public org.drip.state.identifier.EntityHazardLabel counterPartyHazardLabel() + { + return _counterPartyHazardLabel; + } + + /** + * Retrieve the Bank Senior Recovery Label + * + * @return The Bank Senior Recovery Label + */ + + public org.drip.state.identifier.EntityRecoveryLabel bankSeniorRecoveryLabel() + { + return _bankSeniorRecoveryLabel; + } + + /** + * Retrieve the Bank Subordinate Recovery Label + * + * @return The Bank Subordinate Recovery Label + */ + + public org.drip.state.identifier.EntityRecoveryLabel bankSubordinateRecoveryLabel() + { + return _bankSubordinateRecoveryLabel; + } + + /** + * Retrieve the Counter Party Recovery Label + * + * @return The Counter Party Recovery Label + */ + + public org.drip.state.identifier.EntityRecoveryLabel counterPartyRecoveryLabel() + { + return _counterPartyRecoveryLabel; + } +} diff --git a/src/main/java/org/drip/xva/set/PositionGroupSpecification.java b/src/main/java/org/drip/xva/proto/PositionGroupSpecification.java similarity index 83% rename from src/main/java/org/drip/xva/set/PositionGroupSpecification.java rename to src/main/java/org/drip/xva/proto/PositionGroupSpecification.java index bca4447341cf..b67b48758637 100644 --- a/src/main/java/org/drip/xva/set/PositionGroupSpecification.java +++ b/src/main/java/org/drip/xva/proto/PositionGroupSpecification.java @@ -1,5 +1,5 @@ -package org.drip.xva.set; +package org.drip.xva.proto; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -66,11 +66,11 @@ * @author Lakshmi Krishnamurthy */ -public class PositionGroupSpecification extends org.drip.xva.set.RollUpGroupSpecification +public class PositionGroupSpecification extends org.drip.xva.proto.RollUpGroupSpecification { - private org.drip.xva.set.RollUpGroupSpecification _fundingGroupSpecification = null; - private org.drip.xva.set.NettingGroupSpecification _creditDebtGroupSpecification = null; - private org.drip.xva.set.CollateralGroupSpecification _collateralGroupSpecification = null; + private org.drip.xva.proto.RollUpGroupSpecification _fundingGroupSpecification = null; + private org.drip.xva.proto.CreditDebtGroupSpecification _creditDebtGroupSpecification = null; + private org.drip.xva.proto.CollateralGroupSpecification _collateralGroupSpecification = null; /** * PositionGroupSpecification Constructor @@ -87,9 +87,9 @@ public class PositionGroupSpecification extends org.drip.xva.set.RollUpGroupSpec public PositionGroupSpecification ( final java.lang.String id, final java.lang.String name, - final org.drip.xva.set.CollateralGroupSpecification collateralGroupSpecification, - final org.drip.xva.set.NettingGroupSpecification creditDebtGroupSpecification, - final org.drip.xva.set.RollUpGroupSpecification fundingGroupSpecification) + final org.drip.xva.proto.CollateralGroupSpecification collateralGroupSpecification, + final org.drip.xva.proto.CreditDebtGroupSpecification creditDebtGroupSpecification, + final org.drip.xva.proto.RollUpGroupSpecification fundingGroupSpecification) throws java.lang.Exception { super ( @@ -111,7 +111,7 @@ public PositionGroupSpecification ( * @return The Position's Collateral Group Specification */ - public org.drip.xva.set.CollateralGroupSpecification collateralGroupSpecification() + public org.drip.xva.proto.CollateralGroupSpecification collateralGroupSpecification() { return _collateralGroupSpecification; } @@ -122,7 +122,7 @@ public org.drip.xva.set.CollateralGroupSpecification collateralGroupSpecificatio * @return The Position's Credit Debt Group Specification */ - public org.drip.xva.set.NettingGroupSpecification creditDebtGroupSpecification() + public org.drip.xva.proto.CreditDebtGroupSpecification creditDebtGroupSpecification() { return _creditDebtGroupSpecification; } @@ -133,7 +133,7 @@ public org.drip.xva.set.NettingGroupSpecification creditDebtGroupSpecification() * @return The Position's Funding Group Specification */ - public org.drip.xva.set.RollUpGroupSpecification fundingGroupSpecification() + public org.drip.xva.proto.RollUpGroupSpecification fundingGroupSpecification() { return _fundingGroupSpecification; } diff --git a/src/main/java/org/drip/xva/set/RollUpGroupSpecification.java b/src/main/java/org/drip/xva/proto/RollUpGroupSpecification.java similarity index 99% rename from src/main/java/org/drip/xva/set/RollUpGroupSpecification.java rename to src/main/java/org/drip/xva/proto/RollUpGroupSpecification.java index 280fde1354c5..be199da6791c 100644 --- a/src/main/java/org/drip/xva/set/RollUpGroupSpecification.java +++ b/src/main/java/org/drip/xva/proto/RollUpGroupSpecification.java @@ -1,5 +1,5 @@ -package org.drip.xva.set; +package org.drip.xva.proto; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- diff --git a/src/main/java/org/drip/xva/set/package-info.java b/src/main/java/org/drip/xva/proto/package-info.java similarity index 76% rename from src/main/java/org/drip/xva/set/package-info.java rename to src/main/java/org/drip/xva/proto/package-info.java index 6516c7d1302a..c8e0b474756b 100644 --- a/src/main/java/org/drip/xva/set/package-info.java +++ b/src/main/java/org/drip/xva/proto/package-info.java @@ -5,4 +5,4 @@ * @author Lakshmi Krishnamurthy */ -package org.drip.xva.set; +package org.drip.xva.proto; diff --git a/src/main/java/org/drip/xva/set/GroupSpecificationContainer.java b/src/main/java/org/drip/xva/set/GroupSpecificationContainer.java deleted file mode 100644 index 46002d1a4267..000000000000 --- a/src/main/java/org/drip/xva/set/GroupSpecificationContainer.java +++ /dev/null @@ -1,285 +0,0 @@ - -package org.drip.xva.set; - -/* - * -*- 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. - */ - -/** - * GroupSpecificationContainer holds the Named Group Specifications. 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. - * - * - Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk, Risk 20 (2) 86-90. - * - * - Li, B., and Y. Tang (2007): Quantitative Analysis, Derivatives Modeling, and Trading Strategies in the - * Presence of Counter-party Credit Risk for the Fixed Income Market, World Scientific Publishing, - * Singapore. - * - * - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk - * 21 (2) 97-102. - * - * @author Lakshmi Krishnamurthy - */ - -public class GroupSpecificationContainer -{ - private org.drip.analytics.support.CaseInsensitiveHashMap - _collateralGroupMap = null; - private org.drip.analytics.support.CaseInsensitiveHashMap - _nettingGroupMap = null; - private org.drip.analytics.support.CaseInsensitiveHashMap - _fundingGroupMap = null; - - /** - * GroupSpecificationContainer Constructor - */ - - public GroupSpecificationContainer() - { - _collateralGroupMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - _nettingGroupMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - _fundingGroupMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - } - - /** - * Retrieve the Collateral Group Map - * - * @return The Collateral Group Map - */ - - public org.drip.analytics.support.CaseInsensitiveHashMap - collateralGroupMap() - { - return _collateralGroupMap; - } - - /** - * Retrieve the Netting Group Map - * - * @return The Netting Group Map - */ - - public org.drip.analytics.support.CaseInsensitiveHashMap - nettingGroupMap() - { - return _nettingGroupMap; - } - - /** - * Retrieve the Funding Group Map - * - * @return The Funding Group Map - */ - - public org.drip.analytics.support.CaseInsensitiveHashMap - fundingGroupMap() - { - return _fundingGroupMap; - } - - /** - * Add the Collateral Group Specification - * - * @param collateralGroupSpecification Collateral Group Specification - * - * @return TRUE - The Collateral Group Specification successfully added - */ - - public boolean addCollateralGroupSpecification ( - final org.drip.xva.set.CollateralGroupSpecification collateralGroupSpecification) - { - if (null == collateralGroupSpecification) - { - return false; - } - - _collateralGroupMap.put ( - collateralGroupSpecification.id(), - collateralGroupSpecification - ); - - return true; - } - - /** - * Indicate if the Map contains the Collateral Group Specification - * - * @param id The Collateral Group ID - * - * @return TRUE - The Map contains the Collateral Group Specification - */ - - public boolean containsCollateralGroupSpecification ( - final java.lang.String id) - { - return null != id && !id.isEmpty() && _collateralGroupMap.containsKey (id); - } - - /** - * Retrieve the Collateral Group Specification corresponding to the ID - * - * @param id The Collateral Group ID - * - * @return The Collateral Group Specification - */ - - public org.drip.xva.set.CollateralGroupSpecification collateralGroupSpecification ( - final java.lang.String id) - { - return !containsCollateralGroupSpecification (id) ? null : _collateralGroupMap.get (id); - } - - /** - * Add the Netting Group Specification - * - * @param nettingGroupSpecification Netting Group Specification - * - * @return TRUE - The Netting Group Specification successfully added - */ - - public boolean addNettingGroupSpecification ( - final org.drip.xva.set.NettingGroupSpecification nettingGroupSpecification) - { - if (null == nettingGroupSpecification) - { - return false; - } - - _nettingGroupMap.put ( - nettingGroupSpecification.id(), - nettingGroupSpecification - ); - - return true; - } - - /** - * Indicate if the Map contains the Netting Group Specification - * - * @param id The Netting Group ID - * - * @return TRUE - The Map contains the Netting Group Specification - */ - - public boolean containsNettingGroupSpecification ( - final java.lang.String id) - { - return null != id && !id.isEmpty() && _nettingGroupMap.containsKey (id); - } - - /** - * Retrieve the Netting Group Specification corresponding to the ID - * - * @param id The Netting Group ID - * - * @return The Netting Group Specification - */ - - public org.drip.xva.set.NettingGroupSpecification nettingGroupSpecification ( - final java.lang.String id) - { - return !containsNettingGroupSpecification (id) ? null : _nettingGroupMap.get (id); - } - - /** - * Add the Funding Group Specification - * - * @param fundingGroupSpecification Funding Group Specification - * - * @return TRUE - The Funding Group Specification successfully added - */ - - public boolean addFundingGroupSpecification ( - final org.drip.xva.set.RollUpGroupSpecification fundingGroupSpecification) - { - if (null == fundingGroupSpecification) - { - return false; - } - - _fundingGroupMap.put ( - fundingGroupSpecification.id(), - fundingGroupSpecification - ); - - return true; - } - - /** - * Indicate if the Map contains the Funding Group Specification - * - * @param id The Funding Group ID - * - * @return TRUE - The Map contains the Funding Group Specification - */ - - public boolean containsFundingGroupSpecification ( - final java.lang.String id) - { - return null != id && !id.isEmpty() && _fundingGroupMap.containsKey (id); - } - - /** - * Retrieve the Funding Group Specification corresponding to the ID - * - * @param id The Funding Group ID - * - * @return The Funding Group Specification - */ - - public org.drip.xva.set.RollUpGroupSpecification fundingGroupSpecification ( - final java.lang.String id) - { - return !containsFundingGroupSpecification (id) ? null : _fundingGroupMap.get (id); - } -} diff --git a/src/main/java/org/drip/xva/set/NettingGroupSpecification.java b/src/main/java/org/drip/xva/set/NettingGroupSpecification.java deleted file mode 100644 index 1b0804919e6b..000000000000 --- a/src/main/java/org/drip/xva/set/NettingGroupSpecification.java +++ /dev/null @@ -1,152 +0,0 @@ - -package org.drip.xva.set; - -/* - * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - */ - -/*! - * Copyright (C) 2018 Lakshmi Krishnamurthy - * Copyright (C) 2017 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. - */ - -/** - * NettingGroupSpecification contains the Specification of a Netting Group. 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. - * - * - Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk, Risk 20 (2) 86-90. - * - * - Li, B., and Y. Tang (2007): Quantitative Analysis, Derivatives Modeling, and Trading Strategies in the - * Presence of Counter-party Credit Risk for the Fixed Income Market, World Scientific Publishing, - * Singapore. - * - * - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk - * 21 (2) 97-102. - * - * @author Lakshmi Krishnamurthy - */ - -public class NettingGroupSpecification extends org.drip.xva.set.RollUpGroupSpecification -{ - private boolean _contractual = true; - private boolean _enforceable = true; - - /** - * Generate a Standard Instance of NettingGroupSpecification - * - * @param id The Collateral Group ID - * @param name The Collateral Group Name - * - * @return Standard Instance of NettingGroupSpecification - */ - - public static final NettingGroupSpecification Standard ( - final java.lang.String id, - final java.lang.String name) - { - try { - return new NettingGroupSpecification ( - id, - name, - true, - true - ); - } - catch (java.lang.Exception e) - { - e.printStackTrace(); - } - - return null; - } - - /** - * NettingGroupSpecification Constructor - * - * @param id The Collateral Group ID - * @param name The Collateral Group Name - * @param contractual TRUE - The Netting is Contractual - * @param enforceable TRUE - The Netting is Enforceable - * - * @throws java.lang.Exception Thrown if the Inputs are Invalid - */ - - public NettingGroupSpecification ( - final java.lang.String id, - final java.lang.String name, - final boolean contractual, - final boolean enforceable) - throws java.lang.Exception - { - super ( - id, - name - ); - - _contractual = contractual; - _enforceable = enforceable; - } - - /** - * Indicate if the Netting allowed is Contractual - * - * @return TRUE - The Netting allowed is Contractual - */ - - public boolean contractual() - { - return _contractual; - } - - /** - * Indicate if the Netting is Enforceable - * - * @return TRUE - The Netting is Enforceable - */ - - public boolean enforceable() - { - return _enforceable; - } -} diff --git a/src/main/java/org/drip/xva/set/PositionGroupSpecificationContainer.java b/src/main/java/org/drip/xva/set/PositionGroupSpecificationContainer.java deleted file mode 100644 index 053212418016..000000000000 --- a/src/main/java/org/drip/xva/set/PositionGroupSpecificationContainer.java +++ /dev/null @@ -1,72 +0,0 @@ - -package org.drip.xva.set; - -/* - * -*- 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. - */ - -/** - * PositionGroupSpecificationContainer contains the Specifications of a Position Group. 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. - * - * - Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk, Risk 20 (2) 86-90. - * - * - Li, B., and Y. Tang (2007): Quantitative Analysis, Derivatives Modeling, and Trading Strategies in the - * Presence of Counter-party Credit Risk for the Fixed Income Market, World Scientific Publishing, - * Singapore. - * - * - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk - * 21 (2) 97-102. - * - * @author Lakshmi Krishnamurthy - */ - -public class PositionGroupSpecificationContainer -{ - -} diff --git a/src/main/java/org/drip/xva/universe/MarketVertexGenerator.java b/src/main/java/org/drip/xva/universe/MarketVertexGenerator.java index f86a60edcd62..0de8bf5cdedf 100644 --- a/src/main/java/org/drip/xva/universe/MarketVertexGenerator.java +++ b/src/main/java/org/drip/xva/universe/MarketVertexGenerator.java @@ -140,7 +140,7 @@ public class MarketVertexGenerator private int _spotDate = -1; private double[] _ycfWidth = null; private int[] _eventDateArray = null; - private org.drip.xva.evolver.MarketDynamicsContainer _entityLatentStateEvolver = null; + private org.drip.xva.evolver.EntityDynamicsContainer _entityLatentStateEvolver = null; private org.drip.xva.evolver.PrimarySecurityDynamicsContainer _tradeablesContainer = null; /** @@ -160,7 +160,7 @@ public static final MarketVertexGenerator PeriodHorizon ( final java.lang.String periodTenor, final int periodCount, final org.drip.xva.evolver.PrimarySecurityDynamicsContainer tradeablesContainer, - final org.drip.xva.evolver.MarketDynamicsContainer entityLatentStateEvolver) + final org.drip.xva.evolver.EntityDynamicsContainer entityLatentStateEvolver) { try { @@ -198,7 +198,7 @@ public MarketVertexGenerator ( final int spotDate, final int[] eventDateArray, final org.drip.xva.evolver.PrimarySecurityDynamicsContainer tradeablesContainer, - final org.drip.xva.evolver.MarketDynamicsContainer entityLatentStateEvolver) + final org.drip.xva.evolver.EntityDynamicsContainer entityLatentStateEvolver) throws java.lang.Exception { if (0 >= (_spotDate = spotDate) || @@ -245,7 +245,7 @@ public int spotDate() * @return The Entity Latent State Evolver */ - public org.drip.xva.evolver.MarketDynamicsContainer entityLatentStateEvolver() + public org.drip.xva.evolver.EntityDynamicsContainer entityLatentStateEvolver() { return _entityLatentStateEvolver; }