Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- State Discount Merged Forward Curve - Set Curve Construction Input (1, 2)
	- State Discount Merged Forward Curve - Rate Estimator (3)
	- State Discount Merged Forward Curve - Latent Quantification Metric (4)
	- State Discount Merged Forward Curve - Jack D Factor Manifest Measure #1 (5, 6)
	- State Discount Merged Forward Curve - Jack D Factor Manifest Measure #2 (7, 8)
	- State Discount Merged Forward Curve - Component Jack D Factor Manifest Measure #1 (9, 10, 11)
	- State Discount Merged Forward Curve - Component Jack D Factor Manifest Measure #2 (12)
	- State Discount Merged Forward Curve - Jack D Factor Manifest Measure #3 (13, 14, 15)
	- State Discount Merged Forward Curve - Jack D Factor Manifest Measure #4 (16, 17, 18)
	- State Discount Merged Forward Curve - Zero Rate Jacobian (19, 20, 21)
	- State Discount Merged Forward Curve - Canonical Truthness (22, 23, 24)
	- State Discount Explicit Boot Curve (25, 26)
	- State Discount Explicit Boot Curve - Constructor (27)
	- State Discount Explicit Boot Curve - Create Basis Rate Shifted (28)
	- State Discount Explicit Boot Curve - Construction Input Set (29)
	- State Discount Explicit Boot Curve - Manifest Measure (30, 31, 32)
	- State Curve Basis Spline #1 (33, 34)
	- State Curve Basis Spline - Span (35)
	- State Curve Basis Spline - Constructor (36, 37, 38)
	- State Curve Basis Spline #2 (39, 40, 41)
	- State Curve Basis Spline - Jack D Forward Manifest Measure (42)
	- State Curve Basis Spline Deterministic Volatility (43, 44)
	- State Curve Basis Spline Deterministic Volatility - Implied Span (45)
	- State Curve Basis Spline Deterministic Volatility - Constructor (46, 47, 48)
	- State Curve Basis Spline Deterministic Volatility - Implied (49, 50, 51)
	- State Curve Basis Spline Deterministic Volatility - Node (52, 53, 54)
	- State Curve Basis Spline Deterministic Volatility - Node Derivative (55, 56, 57)
	- State Curve Basis Spline Forward Rate (58, 59)
	- State Curve Basis Spline Forward Rate - Span (60)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:
  • Loading branch information
Lakshmik committed Dec 25, 2023
1 parent 4bdc951 commit 2fdc993
Show file tree
Hide file tree
Showing 6 changed files with 467 additions and 326 deletions.
39 changes: 39 additions & 0 deletions ReleaseNotes/02_28_2023.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Features:

- State Discount Merged Forward Curve - Set Curve Construction Input (1, 2)
- State Discount Merged Forward Curve - Rate Estimator (3)
- State Discount Merged Forward Curve - Latent Quantification Metric (4)
- State Discount Merged Forward Curve - Jack D Factor Manifest Measure #1 (5, 6)
- State Discount Merged Forward Curve - Jack D Factor Manifest Measure #2 (7, 8)
- State Discount Merged Forward Curve - Component Jack D Factor Manifest Measure #1 (9, 10, 11)
- State Discount Merged Forward Curve - Component Jack D Factor Manifest Measure #2 (12)
- State Discount Merged Forward Curve - Jack D Factor Manifest Measure #3 (13, 14, 15)
- State Discount Merged Forward Curve - Jack D Factor Manifest Measure #4 (16, 17, 18)
- State Discount Merged Forward Curve - Zero Rate Jacobian (19, 20, 21)
- State Discount Merged Forward Curve - Canonical Truthness (22, 23, 24)
- State Discount Explicit Boot Curve (25, 26)
- State Discount Explicit Boot Curve - Constructor (27)
- State Discount Explicit Boot Curve - Create Basis Rate Shifted (28)
- State Discount Explicit Boot Curve - Construction Input Set (29)
- State Discount Explicit Boot Curve - Manifest Measure (30, 31, 32)
- State Curve Basis Spline #1 (33, 34)
- State Curve Basis Spline - Span (35)
- State Curve Basis Spline - Constructor (36, 37, 38)
- State Curve Basis Spline #2 (39, 40, 41)
- State Curve Basis Spline - Jack D Forward Manifest Measure (42)
- State Curve Basis Spline Deterministic Volatility (43, 44)
- State Curve Basis Spline Deterministic Volatility - Implied Span (45)
- State Curve Basis Spline Deterministic Volatility - Constructor (46, 47, 48)
- State Curve Basis Spline Deterministic Volatility - Implied (49, 50, 51)
- State Curve Basis Spline Deterministic Volatility - Node (52, 53, 54)
- State Curve Basis Spline Deterministic Volatility - Node Derivative (55, 56, 57)
- State Curve Basis Spline Forward Rate (58, 59)
- State Curve Basis Spline Forward Rate - Span (60)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:
84 changes: 48 additions & 36 deletions src/main/java/org/drip/state/curve/BasisSplineBasisCurve.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@

package org.drip.state.curve;

import org.drip.numerical.differentiation.WengertJacobian;
import org.drip.spline.grid.Span;
import org.drip.state.basis.BasisCurve;
import org.drip.state.identifier.ForwardLabel;

/*
* -*- 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 @@ -83,72 +91,76 @@

/**
* <i>BasisSplineBasisCurve</i> manages the Basis Latent State, using the Basis as the State Response
* Representation. It exports the following functionality:
* Representation. It exports the following functionality:
*
* <br><br>
* <ul>
* <li>
* Calculate implied forward rate / implied forward rate Jacobian
* </li>
* <li><i>BasisSplineBasisCurve</i> Constructor</li>
* <li>Calculate implied forward rate / implied forward rate Jacobian</li>
* </ul>
*
* <br><br>
* <ul>
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
* <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/README.md">Latent State Inference and Creation Utilities</a></li>
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/curve/README.md">Basis Spline Based Latent States</a></li>
* </ul>
* <br><br>
* <br>
* <style>table, td, th {
* padding: 1px; border: 2px solid #008000; border-radius: 8px; background-color: #dfff00;
* text-align: center; color: #0000ff;
* }
* </style>
*
* <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/ProductCore.md">Product Core Module</a></td></tr>
* <tr><td><b>Library</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></td></tr>
* <tr><td><b>Project</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/README.md">Latent State Inference and Creation Utilities</a></td></tr>
* <tr><td><b>Package</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/curve/README.md">Basis Spline Based Latent States</a></td></tr>
* </table>
*
* @author Lakshmi Krishnamurthy
*/

public class BasisSplineBasisCurve extends org.drip.state.basis.BasisCurve {
private org.drip.spline.grid.Span _span = null;
public class BasisSplineBasisCurve extends BasisCurve
{
private Span _span = null;

/**
* BasisSplineBasisCurve constructor
*
* @param friReference The Reference Leg FRI
* @param friDerived The Derived Leg FRI
* @param bBasisOnReference TRUE - Is the Quoted Basis On the Reference Leg/Derived Leg
* @param referenceForwardLabel The Reference Leg Forward Label
* @param derivedForwardLabel The Derived Leg Forward Label
* @param basisOnReference TRUE - Is the Quoted Basis On the Reference Leg/Derived Leg
* @param span The Span over which the Basis Representation is valid
*
* @throws java.lang.Exception Thrown if the Inputs are Invalid
* @throws Exception Thrown if the Inputs are Invalid
*/

public BasisSplineBasisCurve (
final org.drip.state.identifier.ForwardLabel friReference,
final org.drip.state.identifier.ForwardLabel friDerived,
final boolean bBasisOnReference,
final org.drip.spline.grid.Span span)
throws java.lang.Exception
final ForwardLabel referenceForwardLabel,
final ForwardLabel derivedForwardLabel,
final boolean basisOnReference,
final Span span)
throws Exception
{
super ((int) span.left(), friReference, friDerived, bBasisOnReference);
super ((int) span.left(), referenceForwardLabel, derivedForwardLabel, basisOnReference);

_span = span;
}

@Override public double basis (
final int iDate)
throws java.lang.Exception
final int date)
throws Exception
{
double dblSpanLeft = _span.left();
double spanLeft = _span.left();

if (iDate <= dblSpanLeft) return _span.calcResponseValue (dblSpanLeft);
if (date <= spanLeft) return _span.calcResponseValue (spanLeft);

double dblSpanRight = _span.right();
double spanRight = _span.right();

if (iDate >= dblSpanRight) return _span.calcResponseValue (dblSpanRight);
if (date >= spanRight) return _span.calcResponseValue (spanRight);

return _span.calcResponseValue (iDate);
return _span.calcResponseValue (date);
}

@Override public org.drip.numerical.differentiation.WengertJacobian jackDForwardDManifestMeasure (
final java.lang.String strManifestMeasure,
final int iDate)
@Override public WengertJacobian jackDForwardDManifestMeasure (
final String manifestMeasure,
final int date)
{
return _span.jackDResponseDManifestMeasure (strManifestMeasure, iDate, 1);
return _span.jackDResponseDManifestMeasure (manifestMeasure, date, 1);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@

package org.drip.state.curve;

import org.drip.function.definition.R1ToR1;
import org.drip.numerical.common.NumberUtil;
import org.drip.spline.grid.Span;
import org.drip.state.identifier.CustomLabel;
import org.drip.state.volatility.VolatilityCurve;

/*
* -*- 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 @@ -85,96 +94,107 @@
* <i>BasisSplineDeterministicVolatility</i> extends the BasisSplineTermStructure for the specific case of
* the Implementation of the Deterministic Volatility Term Structure.
*
* <br><br>
* <ul>
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
* <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/README.md">Latent State Inference and Creation Utilities</a></li>
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/curve/README.md">Basis Spline Based Latent States</a></li>
* </ul>
* <br><br>
* <br>
* <style>table, td, th {
* padding: 1px; border: 2px solid #008000; border-radius: 8px; background-color: #dfff00;
* text-align: center; color: #0000ff;
* }
* </style>
*
* <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/ProductCore.md">Product Core Module</a></td></tr>
* <tr><td><b>Library</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></td></tr>
* <tr><td><b>Project</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/README.md">Latent State Inference and Creation Utilities</a></td></tr>
* <tr><td><b>Package</b></td> <td><a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/curve/README.md">Basis Spline Based Latent States</a></td></tr>
* </table>
*
* @author Lakshmi Krishnamurthy
*/

public class BasisSplineDeterministicVolatility extends org.drip.state.volatility.VolatilityCurve {
private org.drip.spline.grid.Span _spanImpliedVolatility = null;
public class BasisSplineDeterministicVolatility extends VolatilityCurve
{
private Span _impliedVolatilitySpan = null;

/**
* BasisSplineDeterministicVolatility Constructor
*
* @param iEpochDate The Epoch Date
* @param label Latent State Label
* @param strCurrency The Currency
* @param spanImpliedVolatility The Implied Volatility Span
* @param epochDate The Epoch Date
* @param customLabel Latent State Label
* @param currency The Currency
* @param impliedVolatilitySpan The Implied Volatility Span
*
* @throws java.lang.Exception Thrown if the Inputs are Invalid
* @throws Exception Thrown if the Inputs are Invalid
*/

public BasisSplineDeterministicVolatility (
final int iEpochDate,
final org.drip.state.identifier.CustomLabel label,
final java.lang.String strCurrency,
final org.drip.spline.grid.Span spanImpliedVolatility)
throws java.lang.Exception
final int epochDate,
final CustomLabel customLabel,
final String currency,
final Span impliedVolatilitySpan)
throws Exception
{
super (iEpochDate, label, strCurrency);
super (epochDate, customLabel, currency);

if (null == (_spanImpliedVolatility = spanImpliedVolatility))
throw new java.lang.Exception ("BasisSplineDeterministicVolatility ctr: Invalid Inputs");
if (null == (_impliedVolatilitySpan = impliedVolatilitySpan)) {
throw new Exception ("BasisSplineDeterministicVolatility ctr: Invalid Inputs");
}
}

@Override public double impliedVol (
final int iDate)
throws java.lang.Exception
final int date)
throws Exception
{
double dblSpanLeft = _spanImpliedVolatility.left();
double spanLeft = _impliedVolatilitySpan.left();

if (dblSpanLeft >= iDate) return _spanImpliedVolatility.calcResponseValue (dblSpanLeft);
if (spanLeft >= date) {
return _impliedVolatilitySpan.calcResponseValue (spanLeft);
}

double dblSpanRight = _spanImpliedVolatility.right();
double spanRight = _impliedVolatilitySpan.right();

if (dblSpanRight <= iDate) return _spanImpliedVolatility.calcResponseValue (dblSpanRight);
if (spanRight <= date) {
return _impliedVolatilitySpan.calcResponseValue (spanRight);
}

return _spanImpliedVolatility.calcResponseValue (iDate);
return _impliedVolatilitySpan.calcResponseValue (date);
}

@Override public double node (
final int iDate)
throws java.lang.Exception
final int date)
throws Exception
{
double dblImpliedVol = impliedVol (iDate);
double impliedVolatility = impliedVol (date);

return java.lang.Math.sqrt (dblImpliedVol * dblImpliedVol + 2. * dblImpliedVol * (iDate -
epoch().julian()) / 365.25 * _spanImpliedVolatility.calcResponseValueDerivative (iDate, 1));
return Math.sqrt (
impliedVolatility * impliedVolatility + 2. * impliedVolatility * (
date - epoch().julian()
) / 365.25 * _impliedVolatilitySpan.calcResponseValueDerivative (date, 1)
);
}

@Override public double vol (
final int iDate)
throws java.lang.Exception
final int date)
throws Exception
{
return node (iDate);
return node (date);
}

@Override public double nodeDerivative (
final int iDate,
final int iOrder)
throws java.lang.Exception
final int date,
final int order)
throws Exception
{
if (!org.drip.numerical.common.NumberUtil.IsValid (iDate))
throw new java.lang.Exception
("BasisSplineDeterministicVolatility::nodeDerivative => Invalid Inputs");
if (!NumberUtil.IsValid (date)) {
throw new Exception ("BasisSplineDeterministicVolatility::nodeDerivative => Invalid Inputs");
}

org.drip.function.definition.R1ToR1 au = new org.drip.function.definition.R1ToR1
(null) {
return new R1ToR1 (null) {
@Override public double evaluate (
double dblX)
throws java.lang.Exception
double x)
throws Exception
{
return node ((int) dblX);
return node ((int) x);
}
};

return au.derivative (iDate, iOrder);
}.derivative (date, order);
}
}
Loading

0 comments on commit 2fdc993

Please sign in to comment.