Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
Bug Fixes/Re-organization:

	- Service Template OTC Instrument Builder - FRA Standard Deposit (1)
	- Service Template OTC Instrument Builder - Fix Float Standard #1 (2, 3)
	- Service Template OTC Instrument Builder - Fix Float Standard #2 (4, 5)
	- Service Template OTC Instrument Builder - Fix Float Component #1 (6, 7, 8)
	- Service Template OTC Instrument Builder - Fix Float Component #2 (9, 10, 11)
	- Service Template OTC Instrument Builder - Fix Float Component #3 (12, 13, 14)
	- Service Template OTC Instrument Builder - OIS Fix Float Component #1 (15, 16)
	- Service Template OTC Instrument Builder - OIS Fix Float Component #2 (17, 18)
	- Service Template OTC Instrument Builder - OIS Fix Float Futures #1 (19, 20)
	- Service Template OTC Instrument Builder - OIS Fix Float Futures #2 (21, 22)
	- Service Template OTC Instrument Builder - Float Float #1 (23, 24)
	- Service Template OTC Instrument Builder - Float Float #2 (25, 26, 27)
	- Service Template OTC Instrument Builder - Credit Default Swap #1 (28, 29, 30)
	- Service Template OTC Instrument Builder - Credit Default Swap #2 (31, 32, 33)
	- Service Template OTC Instrument Builder - FX Forward #1 (34, 35)
	- Service Template OTC Instrument Builder - FX Forward #2 (36, 37)
	- Service Template OTC Instrument Builder - FRA Standard Cap Floor #1 (38, 39, 40)
	- Service Template OTC Instrument Builder - FRA Standard Cap Floor #2 (41, 42, 43)
	- Service Template OTC Instrument Builder - Cap Floor #1 (44, 45)
	- Service Template OTC Instrument Builder - Cap Floor #2 (46, 47, 48)
	- Service Template OTC Instrument Builder - Stubs #1 (49, 50, 51)
	- Service Template OTC Instrument Builder - Stubs #2 (52, 53, 54)
	- Service Template OTC Instrument Builder - Stubs #3 (55, 56, 57)
	- Service Template OTC Instrument Builder - Stubs #4 (58, 59, 60)
	- Service Template OTC Instrument Builder - Stubs #5 (61, 62, 63)
	- Service Template OTC Instrument Builder - Stubs #6 (64, 65, 66)
	- Service Template OTC Instrument Builder - Stubs #7 (67, 68, 69)
	- Service Template OTC Instrument Builder - Stubs #8 (70, 71, 72)
	- Service Template Treasury Builder (73, 74, 75)
	- Service Template Treasury Builder - Component AGB (76, 77)
	- Service Template Treasury Builder - Component BTPS (78, 79)
	- Service Template Treasury Builder - Component CAN (80, 81)
	- Service Template Treasury Builder - Component DBR (82, 83)
	- Service Template Treasury Builder - Component FRTR (84, 85)
	- Service Template Treasury Builder - Component GGB (86, 87)
	- Service Template Treasury Builder - Component GILT (88, 89)
	- Service Template Treasury Builder - Component JGB (90, 91)
	- Service Template Treasury Builder - Component MBONO (92, 93)
	- Service Template Treasury Builder - Component SPGB (94, 95)
	- Service Template Treasury Builder - Component USD (96, 97)
	- Service Template Treasury Builder - Component From Code #1 (98, 99, 100)
	- Service Template Treasury Builder - Component From Code #2 (101, 102, 103)
	- Service Template Treasury Builder - Stub #1 (104, 105)
	- Service Template Treasury Builder - Stub #2 (106, 107, 108)
	- Service Template Treasury Builder - Stub #3 (109, 110, 111)
	- Service Template Treasury Builder - Stub #4 (112, 113, 114)
	- Service Template Treasury Builder - Stub #5 (115, 116)
	- Service State Credit Curve API (117, 118, 119)
	- Service State Credit Curve API - Daily Metrics (120)


Samples:

IdeaDRIP:
  • Loading branch information
Lakshmik committed Dec 16, 2024
1 parent 5e0b8b4 commit 84fa927
Show file tree
Hide file tree
Showing 4 changed files with 776 additions and 418 deletions.
59 changes: 59 additions & 0 deletions ReleaseNotes/04_16_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

Features:

Bug Fixes/Re-organization:

- Service Template OTC Instrument Builder - FRA Standard Deposit (1)
- Service Template OTC Instrument Builder - Fix Float Standard #1 (2, 3)
- Service Template OTC Instrument Builder - Fix Float Standard #2 (4, 5)
- Service Template OTC Instrument Builder - Fix Float Component #1 (6, 7, 8)
- Service Template OTC Instrument Builder - Fix Float Component #2 (9, 10, 11)
- Service Template OTC Instrument Builder - Fix Float Component #3 (12, 13, 14)
- Service Template OTC Instrument Builder - OIS Fix Float Component #1 (15, 16)
- Service Template OTC Instrument Builder - OIS Fix Float Component #2 (17, 18)
- Service Template OTC Instrument Builder - OIS Fix Float Futures #1 (19, 20)
- Service Template OTC Instrument Builder - OIS Fix Float Futures #2 (21, 22)
- Service Template OTC Instrument Builder - Float Float #1 (23, 24)
- Service Template OTC Instrument Builder - Float Float #2 (25, 26, 27)
- Service Template OTC Instrument Builder - Credit Default Swap #1 (28, 29, 30)
- Service Template OTC Instrument Builder - Credit Default Swap #2 (31, 32, 33)
- Service Template OTC Instrument Builder - FX Forward #1 (34, 35)
- Service Template OTC Instrument Builder - FX Forward #2 (36, 37)
- Service Template OTC Instrument Builder - FRA Standard Cap Floor #1 (38, 39, 40)
- Service Template OTC Instrument Builder - FRA Standard Cap Floor #2 (41, 42, 43)
- Service Template OTC Instrument Builder - Cap Floor #1 (44, 45)
- Service Template OTC Instrument Builder - Cap Floor #2 (46, 47, 48)
- Service Template OTC Instrument Builder - Stubs #1 (49, 50, 51)
- Service Template OTC Instrument Builder - Stubs #2 (52, 53, 54)
- Service Template OTC Instrument Builder - Stubs #3 (55, 56, 57)
- Service Template OTC Instrument Builder - Stubs #4 (58, 59, 60)
- Service Template OTC Instrument Builder - Stubs #5 (61, 62, 63)
- Service Template OTC Instrument Builder - Stubs #6 (64, 65, 66)
- Service Template OTC Instrument Builder - Stubs #7 (67, 68, 69)
- Service Template OTC Instrument Builder - Stubs #8 (70, 71, 72)
- Service Template Treasury Builder (73, 74, 75)
- Service Template Treasury Builder - Component AGB (76, 77)
- Service Template Treasury Builder - Component BTPS (78, 79)
- Service Template Treasury Builder - Component CAN (80, 81)
- Service Template Treasury Builder - Component DBR (82, 83)
- Service Template Treasury Builder - Component FRTR (84, 85)
- Service Template Treasury Builder - Component GGB (86, 87)
- Service Template Treasury Builder - Component GILT (88, 89)
- Service Template Treasury Builder - Component JGB (90, 91)
- Service Template Treasury Builder - Component MBONO (92, 93)
- Service Template Treasury Builder - Component SPGB (94, 95)
- Service Template Treasury Builder - Component USD (96, 97)
- Service Template Treasury Builder - Component From Code #1 (98, 99, 100)
- Service Template Treasury Builder - Component From Code #2 (101, 102, 103)
- Service Template Treasury Builder - Stub #1 (104, 105)
- Service Template Treasury Builder - Stub #2 (106, 107, 108)
- Service Template Treasury Builder - Stub #3 (109, 110, 111)
- Service Template Treasury Builder - Stub #4 (112, 113, 114)
- Service Template Treasury Builder - Stub #5 (115, 116)
- Service State Credit Curve API (117, 118, 119)
- Service State Credit Curve API - Daily Metrics (120)


Samples:

IdeaDRIP:
225 changes: 130 additions & 95 deletions src/main/java/org/drip/service/state/CreditCurveAPI.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@

package org.drip.service.state;

import org.drip.analytics.date.JulianDate;
import org.drip.historical.state.CreditCurveMetrics;
import org.drip.market.otc.CreditIndexConvention;
import org.drip.market.otc.CreditIndexConventionContainer;
import org.drip.product.definition.CreditDefaultSwap;
import org.drip.service.template.LatentMarketStateBuilder;
import org.drip.state.credit.CreditCurve;
import org.drip.state.discount.MergedDiscountForwardCurve;

/*
* -*- 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
Expand Down Expand Up @@ -80,88 +92,113 @@
*/

/**
* <i>CreditCurveAPI</i> computes the Metrics associated the Credit Curve State.
*
* <br><br>
* <i>CreditCurveAPI</i> computes the Metrics associated the Credit Curve State. It provides the following
* Functionality:
*
* <ul>
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationSupportLibrary.md">Computation Support</a></li>
* <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/service/README.md">Environment, Product/Definition Containers, and Scenario/State Manipulation APIs</a></li>
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/service/state/README.md">Curve Based State Metric Generator</a></li>
* <li>Construct an Instance of the Australian Treasury AUD AGB Bond</li>
* </ul>
* <br><br>
*
* <br>
* <table style="border:1px solid black;margin-left:auto;margin-right:auto;">
* <tr><td><b>Module </b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></td></tr>
* <tr><td><b>Library</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationSupportLibrary.md">Computation Support</a></td></tr>
* <tr><td><b>Project</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/service/README.md">Environment, Product/Definition Containers, and Scenario/State Manipulation APIs</a></td></tr>
* <tr><td><b>Package</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/service/state/README.md">Curve Based State Metric Generator</a></td></tr>
* </table>
* <br>
*
* @author Lakshmi Krishnamurthy
*/

public class CreditCurveAPI {
public class CreditCurveAPI
{

/**
* Generate the Horizon Metrics for the Specified Inputs
*
* @param dtSpot The Spot Date
* @param astrFundingFixingMaturityTenor Array of the Funding Fixing Curve Calibration Instrument Tenors
* @param adblFundingFixingQuote Array of the Funding Fixing Curve Calibration Instrument Quotes
* @param strFullCreditIndexName The Full Credit Index Name
* @param dblCreditIndexQuotedSpread The Credit Index Quoted Spread
* @param astrForTenor Array of the "For" Tenors
* @param spotDate The Spot Date
* @param fundingFixingMaturityTenorArray Array of the Funding Fixing Curve Calibration Instrument Tenors
* @param fundingFixingQuoteArray Array of the Funding Fixing Curve Calibration Instrument Quotes
* @param fullCreditIndexName The Full Credit Index Name
* @param creditIndexQuotedSpread The Credit Index Quoted Spread
* @param forTenorArray Array of the "For" Tenors
*
* @return Map of the Dated Credit Curve Metrics
*/

public static final org.drip.historical.state.CreditCurveMetrics DailyMetrics (
final org.drip.analytics.date.JulianDate dtSpot,
final java.lang.String[] astrFundingFixingMaturityTenor,
final double[] adblFundingFixingQuote,
final java.lang.String strFullCreditIndexName,
final double dblCreditIndexQuotedSpread,
final java.lang.String[] astrForTenor)
public static final CreditCurveMetrics DailyMetrics (
final JulianDate spotDate,
final String[] fundingFixingMaturityTenorArray,
final double[] fundingFixingQuoteArray,
final String fullCreditIndexName,
final double creditIndexQuotedSpread,
final String[] forTenorArray)
{
if (null == dtSpot || null == astrFundingFixingMaturityTenor || null == adblFundingFixingQuote ||
null == astrForTenor)
if (null == spotDate ||
null == fundingFixingMaturityTenorArray || 0 == fundingFixingMaturityTenorArray.length ||
null == fundingFixingQuoteArray ||
null == forTenorArray || 0 == forTenorArray.length ||
0 == fundingFixingMaturityTenorArray.length ||
fundingFixingMaturityTenorArray.length != fundingFixingQuoteArray.length)
{
return null;
}

int iNumForTenor = astrForTenor.length;
int iNumFundingFixingInstrument = astrFundingFixingMaturityTenor.length;
CreditIndexConvention creditIndexConvention = CreditIndexConventionContainer.ConventionFromFullName (
fullCreditIndexName
);

if (0 == iNumFundingFixingInstrument || iNumFundingFixingInstrument != adblFundingFixingQuote.length
|| 0 == iNumForTenor)
if (null == creditIndexConvention) {
return null;
}

org.drip.market.otc.CreditIndexConvention cic =
org.drip.market.otc.CreditIndexConventionContainer.ConventionFromFullName
(strFullCreditIndexName);

if (null == cic) return null;

org.drip.state.discount.MergedDiscountForwardCurve dcFundingFixing =
org.drip.service.template.LatentMarketStateBuilder.FundingCurve (dtSpot, cic.currency(), null,
null, "ForwardRate", null, "ForwardRate", astrFundingFixingMaturityTenor,
adblFundingFixingQuote, "SwapRate",
org.drip.service.template.LatentMarketStateBuilder.SHAPE_PRESERVING);

if (null == dcFundingFixing) return null;
MergedDiscountForwardCurve fundingFixingDiscountCurve = LatentMarketStateBuilder.FundingCurve (
spotDate,
creditIndexConvention.currency(),
null,
null,
"ForwardRate",
null,
"ForwardRate",
fundingFixingMaturityTenorArray,
fundingFixingQuoteArray,
"SwapRate",
LatentMarketStateBuilder.SHAPE_PRESERVING
);

if (null == fundingFixingDiscountCurve) {
return null;
}

org.drip.state.credit.CreditCurve cc = org.drip.service.template.LatentMarketStateBuilder.CreditCurve
(dtSpot, new org.drip.product.definition.CreditDefaultSwap[] {cic.indexCDS()}, new double[]
{dblCreditIndexQuotedSpread}, "FairPremium", dcFundingFixing);
CreditCurve creditCurve = LatentMarketStateBuilder.CreditCurve (
spotDate,
new CreditDefaultSwap[] {creditIndexConvention.indexCDS()},
new double[] {creditIndexQuotedSpread},
"FairPremium",
fundingFixingDiscountCurve
);

if (null == cc) return null;
if (null == creditCurve) {
return null;
}

try {
org.drip.historical.state.CreditCurveMetrics ccm = new
org.drip.historical.state.CreditCurveMetrics (dtSpot);
CreditCurveMetrics creditCurveMetrics = new CreditCurveMetrics (spotDate);

for (int j = 0; j < iNumForTenor; ++j) {
org.drip.analytics.date.JulianDate dtFor = dtSpot.addTenor (astrForTenor[j]);
for (int forTenorIndex = 0; forTenorIndex < forTenorArray.length; ++forTenorIndex) {
JulianDate forDate = spotDate.addTenor (forTenorArray[forTenorIndex]);

if (null == dtFor || !ccm.addSurvivalProbability (dtFor, cc.survival (dtFor)) ||
!ccm.addRecoveryRate (dtFor, cc.recovery (dtFor)))
if (null == forDate ||
!creditCurveMetrics.addSurvivalProbability (forDate, creditCurve.survival (forDate)) ||
!creditCurveMetrics.addRecoveryRate (forDate, creditCurve.recovery (forDate)))
{
continue;
}
}

return ccm;
} catch (java.lang.Exception e) {
return creditCurveMetrics;
} catch (Exception e) {
e.printStackTrace();
}

Expand All @@ -171,70 +208,68 @@ public static final org.drip.historical.state.CreditCurveMetrics DailyMetrics (
/**
* Generate the Horizon Metrics for the Specified Inputs
*
* @param adtSpot Array of Horizon Dates
* @param astrFundingFixingMaturityTenor Array of the Funding Fixing Curve Calibration Instrument Tenors
* @param aadblFundingFixingQuote Array of the Funding Fixing Curve Calibration Instrument Quotes
* @param astrFullCreditIndexName Array of the Full Credit Index Names
* @param adblCreditIndexQuotedSpread Array of the Credit Index Quoted Spreads
* @param astrForTenor Array of the "For" Tenors
* @param aspotDate Array of Horizon Dates
* @param fundingFixingMaturityTenorArray Array of the Funding Fixing Curve Calibration Instrument Tenors
* @param afundingFixingQuoteArray Array of the Funding Fixing Curve Calibration Instrument Quotes
* @param afullCreditIndexName Array of the Full Credit Index Names
* @param acreditIndexQuotedSpread Array of the Credit Index Quoted Spreads
* @param forTenorArray Array of the "For" Tenors
*
* @return Map of the Dated Credit Curve Metrics
*/

public static final java.util.TreeMap<org.drip.analytics.date.JulianDate,
org.drip.historical.state.CreditCurveMetrics> HorizonMetrics (
final org.drip.analytics.date.JulianDate[] adtSpot,
final java.lang.String[] astrFundingFixingMaturityTenor,
final double[][] aadblFundingFixingQuote,
final java.lang.String[] astrFullCreditIndexName,
final double[] adblCreditIndexQuotedSpread,
final java.lang.String[] astrForTenor)
public static final java.util.TreeMap<JulianDate, CreditCurveMetrics> HorizonMetrics (
final JulianDate[] aspotDate,
final String[] fundingFixingMaturityTenorArray,
final double[][] afundingFixingQuoteArray,
final String[] afullCreditIndexName,
final double[] acreditIndexQuotedSpread,
final String[] forTenorArray)
{
if (null == adtSpot || null == astrFundingFixingMaturityTenor || null == aadblFundingFixingQuote ||
null == astrFullCreditIndexName || null == adblCreditIndexQuotedSpread || null == astrForTenor)
if (null == aspotDate || null == fundingFixingMaturityTenorArray || null == afundingFixingQuoteArray ||
null == afullCreditIndexName || null == acreditIndexQuotedSpread || null == forTenorArray)
return null;

int iNumSpot = adtSpot.length;
int iNumForTenor = astrForTenor.length;
int iNumFundingFixingInstrument = astrFundingFixingMaturityTenor.length;
int iNumSpot = aspotDate.length;
int iNumForTenor = forTenorArray.length;
int iNumFundingFixingInstrument = fundingFixingMaturityTenorArray.length;

if (0 == iNumSpot || iNumSpot != aadblFundingFixingQuote.length || iNumSpot !=
astrFullCreditIndexName.length || iNumSpot != adblCreditIndexQuotedSpread.length || 0 ==
if (0 == iNumSpot || iNumSpot != afundingFixingQuoteArray.length || iNumSpot !=
afullCreditIndexName.length || iNumSpot != acreditIndexQuotedSpread.length || 0 ==
iNumFundingFixingInstrument || 0 == iNumForTenor)
return null;

java.util.TreeMap<org.drip.analytics.date.JulianDate, org.drip.historical.state.CreditCurveMetrics>
mapCCM = new java.util.TreeMap<org.drip.analytics.date.JulianDate,
org.drip.historical.state.CreditCurveMetrics>();
java.util.TreeMap<JulianDate, CreditCurveMetrics>
mapCCM = new java.util.TreeMap<JulianDate,
CreditCurveMetrics>();

for (int i = 0; i < iNumSpot; ++i) {
org.drip.market.otc.CreditIndexConvention cic =
org.drip.market.otc.CreditIndexConventionContainer.ConventionFromFullName
(astrFullCreditIndexName[i]);
CreditIndexConvention creditIndexConvention =
CreditIndexConventionContainer.ConventionFromFullName (afullCreditIndexName[i]);

if (null == cic) continue;
if (null == creditIndexConvention) continue;

org.drip.state.discount.MergedDiscountForwardCurve dcFundingFixing =
org.drip.service.template.LatentMarketStateBuilder.FundingCurve (adtSpot[i], cic.currency(),
null, null, "ForwardRate", null, "ForwardRate", astrFundingFixingMaturityTenor,
aadblFundingFixingQuote[i], "SwapRate",
org.drip.service.template.LatentMarketStateBuilder.SHAPE_PRESERVING);
MergedDiscountForwardCurve dcFundingFixing =
LatentMarketStateBuilder.FundingCurve (aspotDate[i], creditIndexConvention.currency(),
null, null, "ForwardRate", null, "ForwardRate", fundingFixingMaturityTenorArray,
afundingFixingQuoteArray[i], "SwapRate",
LatentMarketStateBuilder.SHAPE_PRESERVING);

if (null == dcFundingFixing) continue;

org.drip.state.credit.CreditCurve cc =
org.drip.service.template.LatentMarketStateBuilder.CreditCurve (adtSpot[i], new
org.drip.product.definition.CreditDefaultSwap[] {cic.indexCDS()}, new double[]
{adblCreditIndexQuotedSpread[i]}, "FairPremium", dcFundingFixing);
CreditCurve cc =
LatentMarketStateBuilder.CreditCurve (aspotDate[i], new
CreditDefaultSwap[] {creditIndexConvention.indexCDS()}, new double[]
{acreditIndexQuotedSpread[i]}, "FairPremium", dcFundingFixing);

if (null == cc) continue;

try {
org.drip.historical.state.CreditCurveMetrics ccm = new
org.drip.historical.state.CreditCurveMetrics (adtSpot[i]);
CreditCurveMetrics ccm = new
CreditCurveMetrics (aspotDate[i]);

for (int j = 0; j < iNumForTenor; ++j) {
org.drip.analytics.date.JulianDate dtFor = adtSpot[i].addTenor (astrForTenor[j]);
JulianDate dtFor = aspotDate[i].addTenor (forTenorArray[j]);

if (null == dtFor) continue;

Expand All @@ -243,8 +278,8 @@ org.drip.historical.state.CreditCurveMetrics> HorizonMetrics (
continue;
}

mapCCM.put (adtSpot[i], ccm);
} catch (java.lang.Exception e) {
mapCCM.put (aspotDate[i], ccm);
} catch (Exception e) {
e.printStackTrace();

continue;
Expand Down
Loading

0 comments on commit 84fa927

Please sign in to comment.