diff --git a/ReleaseNotes/05_15_2024.txt b/ReleaseNotes/05_15_2024.txt new file mode 100644 index 00000000000..c63989d3568 --- /dev/null +++ b/ReleaseNotes/05_15_2024.txt @@ -0,0 +1,53 @@ + +Features: + +Bug Fixes/Re-organization: + +Samples: + + - Service JSON Bond Processor - Secular Metrics #1 (1, 2, 3) + - Service JSON Bond Processor - Secular Metrics #2 (4, 5, 6) + - Service JSON Bond Processor - Secular Metrics #3 (7, 8, 9) + - Service JSON Bond Processor - Secular Metrics #4 (10, 11) + - Service JSON Bond Processor - Curve Metrics #1 (12, 13, 14) + - Service JSON Bond Processor - Curve Metrics #2 (15, 16, 17) + - Service JSON Bond Processor - Curve Metrics #3 (18, 19, 20) + - Service JSON Bond Processor - Curve Metrics #4 (21, 22, 23) + - Service JSON Bond Processor - Curve Metrics #5 (24, 25, 26) + - Service JSON Bond Processor - Curve Metrics #6 (27, 28, 29) + - Service JSON Bond Processor - Curve Metrics #7 (30, 31, 32) + - Service JSON Bond Processor - Curve Metrics #8 (33, 34, 35) + - Service JSON Bond Processor - Curve Metrics #9 (36, 37, 38) + - Service JSON Bond Processor - Curve Metrics #10 (39, 40, 41) + - Service JSON Bond Processor - Curve Metrics #11 (42, 43, 44) + - Service JSON Bond Processor - Curve Metrics #12 (45, 46, 47) + - Service JSON Bond Processor - Curve Metrics #13 (48, 49, 50) + - Service JSON Bond Processor - Curve Metrics #14 (51, 52, 53) + - Service JSON Bond Processor - Cash Flows #1 (54, 55) + - Service JSON Bond Processor - Cash Flows #2 (56, 57) + - Service JSON Bond Processor - Cash Flows #3 (58, 59, 60) + - Service JSON Bond Processor - Cash Flows #4 (61, 62, 63) + - Service JSON Bond Processor - Cash Flows #5 (64, 65, 66) + - Service JSON Bond Processor - Cash Flows #6 (67, 68, 69) + - Service JSON Bond Processor - Cash Flows #7 (70, 71, 72) + - Service JSON Bond Processor - Cash Flows #8 (73, 74, 75) + - Service JSON Bond Processor - Cash Flows #9 (76, 77, 78) + - Service JSON Bond Processor (79, 80, 81) + - Service JSON Credit Default Swap Processor #1 (82, 83, 84) + - Service JSON Credit Default Swap Processor - Curve Metrics #1 (85, 86, 87) + - Service JSON Credit Default Swap Processor - Curve Metrics #2 (88, 89, 90) + - Service JSON Credit Default Swap Processor - Curve Metrics #3 (91, 92, 93) + - Service JSON Credit Default Swap Processor - Curve Metrics #4 (94, 95, 96) + - Service JSON Credit Default Swap Processor - Curve Metrics #5 (97, 98, 99) + - Service JSON Credit Default Swap Processor - Curve Metrics #6 (100, 101, 102) + - Service JSON Credit Default Swap Processor - Curve Metrics #7 (103, 104, 105) + - Service JSON Credit Default Swap Processor - Curve Metrics #8 (106, 107, 108) + - Service JSON Credit Default Swap Processor - Curve Metrics #9 (109, 110, 111) + - Service JSON Credit Default Swap Processor - Curve Metrics #10 (112, 113, 114) + - Service JSON Credit Default Swap Processor - Curve Metrics #11 (115, 116) + - Service JSON Credit Default Swap Processor - Curve Metrics #12 (117, 118) + - Service JSON Credit Default Swap Processor #2 (119) + - Service JSON Date Processor (120) + + +IdeaDRIP: diff --git a/src/main/java/org/drip/service/json/BondProcessor.java b/src/main/java/org/drip/service/json/BondProcessor.java index 74d162182b4..79dbd67a3e8 100644 --- a/src/main/java/org/drip/service/json/BondProcessor.java +++ b/src/main/java/org/drip/service/json/BondProcessor.java @@ -1,6 +1,11 @@ package org.drip.service.json; +import java.util.List; + +import org.drip.analytics.cashflow.CompositePeriod; +import org.drip.analytics.date.JulianDate; +import org.drip.analytics.support.Helper; import org.drip.param.market.CurveSurfaceQuoteContainer; import org.drip.param.valuation.ValuationParams; import org.drip.product.creator.BondBuilder; @@ -8,6 +13,7 @@ import org.drip.service.jsonparser.Converter; import org.drip.service.representation.JSONArray; import org.drip.service.representation.JSONObject; +import org.drip.state.credit.CreditCurve; import org.drip.state.discount.MergedDiscountForwardCurve; /* @@ -95,7 +101,9 @@ * following Functionality: * * * *
@@ -270,54 +278,58 @@ public class BondProcessor @SuppressWarnings ("unchecked") static final JSONObject CurveMetrics ( final JSONObject jsonParameter) { - MergedDiscountForwardCurve fundingDiscountCurve = - LatentStateProcessor.FundingCurve (jsonParameter); + MergedDiscountForwardCurve fundingDiscountCurve = LatentStateProcessor.FundingCurve (jsonParameter); - if (null == fundingDiscountCurve) return null; + if (null == fundingDiscountCurve) { + return null; + } - CurveSurfaceQuoteContainer curveSurfaceQuoteContainer = new - CurveSurfaceQuoteContainer(); + CurveSurfaceQuoteContainer curveSurfaceQuoteContainer = new CurveSurfaceQuoteContainer(); - if (!curveSurfaceQuoteContainer.setFundingState (fundingDiscountCurve) || !curveSurfaceQuoteContainer.setGovvieState - (LatentStateProcessor.TreasuryCurve (jsonParameter))) + if (!curveSurfaceQuoteContainer.setFundingState (fundingDiscountCurve) || + !curveSurfaceQuoteContainer.setGovvieState (LatentStateProcessor.TreasuryCurve (jsonParameter))) + { return null; + } double cleanPrice = Double.NaN; BondComponent bondComponent = null; - int iSpotDate = fundingDiscountCurve.epoch().julian(); + int spotDate = fundingDiscountCurve.epoch().julian(); - ValuationParams valuationParams = ValuationParams.Spot (iSpotDate); + ValuationParams valuationParams = ValuationParams.Spot (spotDate); - org.drip.analytics.date.JulianDate dtMaturity = Converter.DateEntry - (jsonParameter, "BondMaturityDate"); + JulianDate maturityDate = Converter.DateEntry (jsonParameter, "BondMaturityDate"); try { - if (null == (bondComponent = BondBuilder.CreateSimpleFixed - (Converter.StringEntry (jsonParameter, "BondName"), - fundingDiscountCurve.currency(), "", Converter.DoubleEntry (jsonParameter, - "BondCoupon"), Converter.IntegerEntry (jsonParameter, - "BondFrequency"), Converter.StringEntry (jsonParameter, - "BondDayCount"), Converter.DateEntry (jsonParameter, - "BondEffectiveDate"), dtMaturity, null, null))) + if (null == ( + bondComponent = BondBuilder.CreateSimpleFixed ( + Converter.StringEntry (jsonParameter, "BondName"), + fundingDiscountCurve.currency(), + "", + Converter.DoubleEntry (jsonParameter, "BondCoupon"), + Converter.IntegerEntry (jsonParameter, "BondFrequency"), + Converter.StringEntry (jsonParameter, "BondDayCount"), + Converter.DateEntry (jsonParameter, "BondEffectiveDate"), + maturityDate, + null, + null + ) + )) + { return null; + } - - if (jsonParameter.containsKey ("BondCleanPrice")) - cleanPrice = Converter.DoubleEntry ( - jsonParameter, - "BondCleanPrice" - ); - else if (jsonParameter.containsKey("BondYield")) + if (jsonParameter.containsKey ("BondCleanPrice")) { + cleanPrice = Converter.DoubleEntry (jsonParameter, "BondCleanPrice"); + } else if (jsonParameter.containsKey ("BondYield")) { cleanPrice = bondComponent.priceFromYield ( valuationParams, curveSurfaceQuoteContainer, null, - Converter.DoubleEntry ( - jsonParameter, - "BondYield" - ) + Converter.DoubleEntry (jsonParameter, "BondYield") ); + } } catch (Exception e) { e.printStackTrace(); @@ -330,48 +342,84 @@ else if (jsonParameter.containsKey("BondYield")) jsonResponse.put ("BondEffectiveDate", bondComponent.effectiveDate().toString()); - jsonResponse.put ("BondMaturityDate", dtMaturity.toString()); + jsonResponse.put ("BondMaturityDate", maturityDate.toString()); jsonResponse.put ("BondFirstCouponDate", bondComponent.firstCouponDate().toString()); jsonResponse.put ("BondCleanPrice", cleanPrice); try { - jsonResponse.put ("BondASW", bondComponent.aswFromPrice (valuationParams, curveSurfaceQuoteContainer, null, cleanPrice)); + jsonResponse.put ( + "BondASW", + bondComponent.aswFromPrice (valuationParams, curveSurfaceQuoteContainer, null, cleanPrice) + ); } catch (Exception e) { e.printStackTrace(); } try { - jsonResponse.put ("BondGSpread", bondComponent.gSpreadFromPrice (valuationParams, curveSurfaceQuoteContainer, null, cleanPrice)); + jsonResponse.put ( + "BondGSpread", + bondComponent.gSpreadFromPrice ( + valuationParams, + curveSurfaceQuoteContainer, + null, + cleanPrice + ) + ); } catch (Exception e) { e.printStackTrace(); } try { - jsonResponse.put ("BondISpread", bondComponent.iSpreadFromPrice (valuationParams, curveSurfaceQuoteContainer, null, cleanPrice)); + jsonResponse.put ( + "BondISpread", + bondComponent.iSpreadFromPrice ( + valuationParams, + curveSurfaceQuoteContainer, + null, + cleanPrice + ) + ); } catch (Exception e) { e.printStackTrace(); } try { - jsonResponse.put ("BondOAS", bondComponent.oasFromPrice (valuationParams, curveSurfaceQuoteContainer, null, cleanPrice)); + jsonResponse.put ( + "BondOAS", + bondComponent.oasFromPrice (valuationParams, curveSurfaceQuoteContainer, null, cleanPrice) + ); } catch (Exception e) { e.printStackTrace(); } try { - jsonResponse.put ("BondTreasurySpread", bondComponent.tsySpreadFromPrice (valuationParams, curveSurfaceQuoteContainer, null, - cleanPrice)); + jsonResponse.put ( + "BondTreasurySpread", + bondComponent.tsySpreadFromPrice ( + valuationParams, + curveSurfaceQuoteContainer, + null, + cleanPrice + ) + ); } catch (Exception e) { e.printStackTrace(); } - jsonResponse.put ("BondTreasuryBenchmark", org.drip.analytics.support.Helper.BaseTsyBmk - (iSpotDate, dtMaturity.julian())); + jsonResponse.put ("BondTreasuryBenchmark", Helper.BaseTsyBmk (spotDate, maturityDate.julian())); try { - jsonResponse.put ("BondZSpread", bondComponent.zSpreadFromPrice (valuationParams, curveSurfaceQuoteContainer, null, cleanPrice)); + jsonResponse.put ( + "BondZSpread", + bondComponent.zSpreadFromPrice ( + valuationParams, + curveSurfaceQuoteContainer, + null, + cleanPrice + ) + ); } catch (Exception e) { e.printStackTrace(); } @@ -390,39 +438,47 @@ else if (jsonParameter.containsKey("BondYield")) @SuppressWarnings ("unchecked") static final JSONObject CashFlows ( final JSONObject jsonParameter) { - MergedDiscountForwardCurve fundingDiscountCurve = - LatentStateProcessor.FundingCurve (jsonParameter); + MergedDiscountForwardCurve fundingDiscountCurve = LatentStateProcessor.FundingCurve (jsonParameter); - if (null == fundingDiscountCurve) return null; + if (null == fundingDiscountCurve) { + return null; + } - CurveSurfaceQuoteContainer curveSurfaceQuoteContainer = new - CurveSurfaceQuoteContainer(); + CurveSurfaceQuoteContainer curveSurfaceQuoteContainer = new CurveSurfaceQuoteContainer(); - if (!curveSurfaceQuoteContainer.setFundingState (fundingDiscountCurve)) return null; + if (!curveSurfaceQuoteContainer.setFundingState (fundingDiscountCurve)) { + return null; + } - org.drip.state.credit.CreditCurve cc = LatentStateProcessor.CreditCurve - (jsonParameter, fundingDiscountCurve); + CreditCurve creditCurve = LatentStateProcessor.CreditCurve (jsonParameter, fundingDiscountCurve); - curveSurfaceQuoteContainer.setCreditState (cc); + curveSurfaceQuoteContainer.setCreditState (creditCurve); - double dblValueNotional = 1.; + double valueNotional = 1.; BondComponent bondComponent = null; - org.drip.analytics.date.JulianDate dtMaturity = Converter.DateEntry - (jsonParameter, "BondMaturityDate"); + JulianDate maturityDate = Converter.DateEntry (jsonParameter, "BondMaturityDate"); try { - if (null == (bondComponent = BondBuilder.CreateSimpleFixed - (Converter.StringEntry (jsonParameter, "BondName"), - fundingDiscountCurve.currency(), "", Converter.DoubleEntry (jsonParameter, - "BondCoupon"), Converter.IntegerEntry (jsonParameter, - "BondFrequency"), Converter.StringEntry (jsonParameter, - "BondDayCount"), Converter.DateEntry (jsonParameter, - "BondEffectiveDate"), dtMaturity, null, null))) + if (null == ( + bondComponent = BondBuilder.CreateSimpleFixed ( + Converter.StringEntry (jsonParameter, "BondName"), + fundingDiscountCurve.currency(), + "", + Converter.DoubleEntry (jsonParameter, "BondCoupon"), + Converter.IntegerEntry (jsonParameter, "BondFrequency"), + Converter.StringEntry (jsonParameter, "BondDayCount"), + Converter.DateEntry (jsonParameter, "BondEffectiveDate"), + maturityDate, + null, + null + ) + )) + { return null; + } - dblValueNotional = Converter.DoubleEntry (jsonParameter, - "BondValueNotional"); + valueNotional = Converter.DoubleEntry (jsonParameter, "BondValueNotional"); } catch (Exception e) { e.printStackTrace(); @@ -433,46 +489,50 @@ else if (jsonParameter.containsKey("BondYield")) jsonResponse.put ("BondName", bondComponent.name()); - java.util.List lsCP = bondComponent.couponPeriods(); + List compositePeriodList = bondComponent.couponPeriods(); - if (null == lsCP || 0 == lsCP.size()) return null; + if (null == compositePeriodList || 0 == compositePeriodList.size()) { + return null; + } JSONArray jsonCashFlowArray = new JSONArray(); - for (org.drip.analytics.cashflow.CompositePeriod cp : lsCP) { - if (null == cp) return null; + for (CompositePeriod compositePeriod : compositePeriodList) { + if (null == compositePeriod) { + return null; + } JSONObject jsonCashFlow = new JSONObject(); - jsonCashFlow.put ("StartDate", new org.drip.analytics.date.JulianDate - (cp.startDate()).toString()); + jsonCashFlow.put ("StartDate", new JulianDate (compositePeriod.startDate()).toString()); - jsonCashFlow.put ("EndDate", new org.drip.analytics.date.JulianDate (cp.endDate()).toString()); + jsonCashFlow.put ("EndDate", new JulianDate (compositePeriod.endDate()).toString()); - jsonCashFlow.put ("PayDate", new org.drip.analytics.date.JulianDate (cp.payDate()).toString()); + jsonCashFlow.put ("PayDate", new JulianDate (compositePeriod.payDate()).toString()); try { - double dblCouponRate = cp.periods().get (0).baseRate (curveSurfaceQuoteContainer); + double couponRate = compositePeriod.periods().get (0).baseRate (curveSurfaceQuoteContainer); - jsonCashFlow.put ("FixingDate", new org.drip.analytics.date.JulianDate - (cp.fxFixingDate()).toString()); + jsonCashFlow.put ("FixingDate", new JulianDate (compositePeriod.fxFixingDate()).toString()); - jsonCashFlow.put ("CouponDCF", cp.couponDCF()); + jsonCashFlow.put ("CouponDCF", compositePeriod.couponDCF()); - jsonCashFlow.put ("CouponRate", dblCouponRate); + jsonCashFlow.put ("CouponRate", couponRate); - if (null != cc) jsonCashFlow.put ("SurvivalFactor", cc.survival (cp.payDate())); + if (null != creditCurve) { + jsonCashFlow.put ("SurvivalFactor", creditCurve.survival (compositePeriod.payDate())); + } - jsonCashFlow.put ("PayDiscountFactor", cp.df (curveSurfaceQuoteContainer)); + jsonCashFlow.put ("PayDiscountFactor", compositePeriod.df (curveSurfaceQuoteContainer)); - jsonCashFlow.put ("CouponAmount", dblCouponRate * dblValueNotional); + jsonCashFlow.put ("CouponAmount", couponRate * valueNotional); } catch (Exception e) { e.printStackTrace(); return null; } - jsonCashFlow.put ("BaseNotional", cp.baseNotional() * dblValueNotional); + jsonCashFlow.put ("BaseNotional", compositePeriod.baseNotional() * valueNotional); jsonCashFlowArray.add (jsonCashFlow); } diff --git a/src/main/java/org/drip/service/json/CreditDefaultSwapProcessor.java b/src/main/java/org/drip/service/json/CreditDefaultSwapProcessor.java index af7a78d20e0..51c877174a0 100644 --- a/src/main/java/org/drip/service/json/CreditDefaultSwapProcessor.java +++ b/src/main/java/org/drip/service/json/CreditDefaultSwapProcessor.java @@ -1,11 +1,30 @@ package org.drip.service.json; +import java.util.Map; + +import org.drip.analytics.cashflow.CompositePeriod; +import org.drip.analytics.cashflow.LossQuadratureMetrics; +import org.drip.analytics.date.JulianDate; +import org.drip.param.market.CurveSurfaceQuoteContainer; +import org.drip.param.valuation.ValuationParams; +import org.drip.product.definition.CreditDefaultSwap; +import org.drip.service.jsonparser.Converter; +import org.drip.service.representation.JSONArray; +import org.drip.service.representation.JSONObject; +import org.drip.service.template.OTCInstrumentBuilder; +import org.drip.state.credit.CreditCurve; +import org.drip.state.discount.MergedDiscountForwardCurve; +import org.drip.state.identifier.EntityCDSLabel; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -81,21 +100,26 @@ /** * CreditDefaultSwapProcessor Sets Up and Executes a JSON Based In/Out Credit Default Swap Valuation - * Processor. - * - *

+ * Processor. It provides the following Functionality: + * * - *

+ * + *
+ * + * + * + * + * + *
Module Computational Core Module
Library Computation Support
Project Environment, Product/Definition Containers, and Scenario/State Manipulation APIs
Package JSON Based Valuation Request Service
+ *
* * @author Lakshmi Krishnamurthy */ -public class CreditDefaultSwapProcessor { +public class CreditDefaultSwapProcessor +{ /** * JSON Based in/out Credit Default Swap Curve Metrics Thunker @@ -105,119 +129,142 @@ public class CreditDefaultSwapProcessor { * @return JSON Credit Default Swap Curve Metrics Response */ - @SuppressWarnings ("unchecked") static final org.drip.service.representation.JSONObject CurveMetrics ( - final org.drip.service.representation.JSONObject jsonParameter) + @SuppressWarnings ("unchecked") static final JSONObject CurveMetrics ( + final JSONObject jsonParameter) { - org.drip.state.discount.MergedDiscountForwardCurve dcFunding = - org.drip.service.json.LatentStateProcessor.FundingCurve (jsonParameter); + MergedDiscountForwardCurve fundingDiscountCurve = LatentStateProcessor.FundingCurve (jsonParameter); - org.drip.state.credit.CreditCurve ccSurvivalRecovery = - org.drip.service.json.LatentStateProcessor.CreditCurve (jsonParameter, dcFunding); + CreditCurve survivalRecoveryCreditCurve = LatentStateProcessor.CreditCurve ( + jsonParameter, + fundingDiscountCurve + ); - if (null == ccSurvivalRecovery) return null; + if (null == survivalRecoveryCreditCurve) { + return null; + } - org.drip.param.market.CurveSurfaceQuoteContainer csqc = new - org.drip.param.market.CurveSurfaceQuoteContainer(); + CurveSurfaceQuoteContainer curveSurfaceQuoteContainer = new CurveSurfaceQuoteContainer(); - if (!csqc.setFundingState (dcFunding) || !csqc.setCreditState (ccSurvivalRecovery)) return null; + if (!curveSurfaceQuoteContainer.setFundingState (fundingDiscountCurve) || + !curveSurfaceQuoteContainer.setCreditState (survivalRecoveryCreditCurve)) + { + return null; + } - org.drip.analytics.date.JulianDate dtSpot = dcFunding.epoch(); + JulianDate spotDate = fundingDiscountCurve.epoch(); - org.drip.product.definition.CreditDefaultSwap cds = null; + CreditDefaultSwap cds = null; try { - cds = org.drip.service.template.OTCInstrumentBuilder.CDS (dtSpot, - org.drip.service.jsonparser.Converter.StringEntry (jsonParameter, "CDSMaturity"), - org.drip.service.jsonparser.Converter.DoubleEntry (jsonParameter, "CDSCoupon"), - dcFunding.currency(), ((org.drip.state.identifier.EntityCDSLabel) - (ccSurvivalRecovery.label())).referenceEntity()); - } catch (java.lang.Exception e) { + cds = OTCInstrumentBuilder.CDS ( + spotDate, + Converter.StringEntry (jsonParameter, "CDSMaturity"), + Converter.DoubleEntry (jsonParameter, "CDSCoupon"), + fundingDiscountCurve.currency(), + ((EntityCDSLabel) (survivalRecoveryCreditCurve.label())).referenceEntity() + ); + } catch (Exception e) { e.printStackTrace(); return null; } - if (null == cds) return null; + if (null == cds) { + return null; + } - java.util.Map mapResult = cds.value - (org.drip.param.valuation.ValuationParams.Spot (dtSpot.julian()), null, csqc, null); + Map cdsMetricMap = cds.value ( + ValuationParams.Spot (spotDate.julian()), + null, + curveSurfaceQuoteContainer, + null + ); - if (null == mapResult) return null; + if (null == cdsMetricMap) { + return null; + } - org.drip.service.representation.JSONObject jsonResponse = new org.drip.service.representation.JSONObject(); + JSONObject jsonResponse = new JSONObject(); - for (java.util.Map.Entry me : mapResult.entrySet()) - jsonResponse.put (me.getKey(), me.getValue()); + for (Map.Entry cdsMetricMapEntry : cdsMetricMap.entrySet()) { + jsonResponse.put (cdsMetricMapEntry.getKey(), cdsMetricMapEntry.getValue()); + } - org.drip.service.representation.JSONArray jsonCouponFlowArray = new org.drip.service.representation.JSONArray(); + JSONArray jsonCouponFlowArray = new JSONArray(); - for (org.drip.analytics.cashflow.CompositePeriod cp : cds.couponPeriods()) { - org.drip.service.representation.JSONObject jsonCouponFlow = new org.drip.service.representation.JSONObject(); + for (CompositePeriod compositePeriod : cds.couponPeriods()) { + JSONObject jsonCouponFlow = new JSONObject(); try { - jsonCouponFlow.put ("StartDate", new org.drip.analytics.date.JulianDate - (cp.startDate()).toString()); + jsonCouponFlow.put ("StartDate", new JulianDate (compositePeriod.startDate()).toString()); - jsonCouponFlow.put ("EndDate", new org.drip.analytics.date.JulianDate - (cp.endDate()).toString()); + jsonCouponFlow.put ("EndDate", new JulianDate (compositePeriod.endDate()).toString()); - jsonCouponFlow.put ("PayDate", new org.drip.analytics.date.JulianDate - (cp.payDate()).toString()); + jsonCouponFlow.put ("PayDate", new JulianDate (compositePeriod.payDate()).toString()); - jsonCouponFlow.put ("CouponDCF", cp.couponDCF()); + jsonCouponFlow.put ("CouponDCF", compositePeriod.couponDCF()); - jsonCouponFlow.put ("PayDiscountFactor", cp.df (csqc)); + jsonCouponFlow.put ("PayDiscountFactor", compositePeriod.df (curveSurfaceQuoteContainer)); - jsonCouponFlow.put ("SurvivalProbability", cp.survival (csqc)); - } catch (java.lang.Exception e) { + jsonCouponFlow.put ( + "SurvivalProbability", + compositePeriod.survival (curveSurfaceQuoteContainer) + ); + } catch (Exception e) { e.printStackTrace(); return null; } - jsonCouponFlow.put ("BaseNotional", cp.baseNotional()); + jsonCouponFlow.put ("BaseNotional", compositePeriod.baseNotional()); - jsonCouponFlow.put ("Tenor", cp.tenor()); + jsonCouponFlow.put ("Tenor", compositePeriod.tenor()); - jsonCouponFlow.put ("FundingLabel", cp.fundingLabel().fullyQualifiedName()); + jsonCouponFlow.put ("FundingLabel", compositePeriod.fundingLabel().fullyQualifiedName()); - jsonCouponFlow.put ("CreditLabel", cp.creditLabel().fullyQualifiedName()); + jsonCouponFlow.put ("CreditLabel", compositePeriod.creditLabel().fullyQualifiedName()); - jsonCouponFlow.put ("ReferenceRate", cp.couponMetrics (dtSpot.julian(), csqc).rate()); + jsonCouponFlow.put ( + "ReferenceRate", + compositePeriod.couponMetrics (spotDate.julian(), curveSurfaceQuoteContainer).rate() + ); jsonCouponFlowArray.add (jsonCouponFlow); } jsonResponse.put ("CouponFlow", jsonCouponFlowArray); - org.drip.service.representation.JSONArray jsonLossFlowArray = new org.drip.service.representation.JSONArray(); + JSONArray jsonLossFlowArray = new JSONArray(); - for (org.drip.analytics.cashflow.LossQuadratureMetrics lqm : cds.lossFlow (dtSpot, csqc)) { - org.drip.service.representation.JSONObject jsonLossFlow = new org.drip.service.representation.JSONObject(); + for (LossQuadratureMetrics lossQuadratureMetrics : + cds.lossFlow (spotDate, curveSurfaceQuoteContainer)) + { + JSONObject jsonLossFlow = new JSONObject(); try { - jsonLossFlow.put ("StartDate", new org.drip.analytics.date.JulianDate - (lqm.startDate()).toString()); + jsonLossFlow.put ( + "StartDate", + new JulianDate (lossQuadratureMetrics.startDate()).toString() + ); - jsonLossFlow.put ("EndDate", new org.drip.analytics.date.JulianDate - (lqm.endDate()).toString()); - } catch (java.lang.Exception e) { + jsonLossFlow.put ("EndDate", new JulianDate (lossQuadratureMetrics.endDate()).toString()); + } catch (Exception e) { e.printStackTrace(); return null; } - jsonLossFlow.put ("StartSurvival", lqm.startSurvival()); + jsonLossFlow.put ("StartSurvival", lossQuadratureMetrics.startSurvival()); - jsonLossFlow.put ("EndSurvival", lqm.endSurvival()); + jsonLossFlow.put ("EndSurvival", lossQuadratureMetrics.endSurvival()); - jsonLossFlow.put ("EffectiveNotional", lqm.effectiveNotional()); + jsonLossFlow.put ("EffectiveNotional", lossQuadratureMetrics.effectiveNotional()); - jsonLossFlow.put ("EffectiveRecovery", lqm.effectiveRecovery()); + jsonLossFlow.put ("EffectiveRecovery", lossQuadratureMetrics.effectiveRecovery()); - jsonLossFlow.put ("EffectiveAccrual", lqm.accrualDCF()); + jsonLossFlow.put ("EffectiveAccrual", lossQuadratureMetrics.accrualDCF()); - jsonLossFlow.put ("EffectiveDF", lqm.effectiveDF()); + jsonLossFlow.put ("EffectiveDF", lossQuadratureMetrics.effectiveDF()); jsonLossFlowArray.add (jsonLossFlow); } diff --git a/src/main/java/org/drip/service/json/DateProcessor.java b/src/main/java/org/drip/service/json/DateProcessor.java index 638eb01031f..554974822cf 100644 --- a/src/main/java/org/drip/service/json/DateProcessor.java +++ b/src/main/java/org/drip/service/json/DateProcessor.java @@ -6,6 +6,9 @@ */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -80,16 +83,21 @@ */ /** - * DateProcessor Sets Up and Executes a JSON Based In/Out Date Related Service. - * - *

+ * DateProcessor Sets Up and Executes a JSON Based In/Out Date Related Service. It provides the + * following Functionality: + * * - *

+ * + *
+ * + * + * + * + * + *
Module Computational Core Module
Library Computation Support
Project Environment, Product/Definition Containers, and Scenario/State Manipulation APIs
Package JSON Based Valuation Request Service
+ *
* * @author Lakshmi Krishnamurthy */