Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- State Curve Basis Spline Market Surface - y Anchor Term Structure (1, 2)
	- State Curve Basis Spline Repo #1 (3, 4)
	- State Curve Basis Spline Repo - Span (5)
	- State Curve Basis Spline Repo - Constructor (6, 7)
	- State Curve Basis Spline Repo #2 (8, 9, 10)
	- State Curve Basis Spline Term Structure (11, 12)
	- State Curve Basis Spline Term Structure - Constructor (13, 14, 15)
	- State Curve Basis Spline Term Structure - Span (16)
	- State Curve Basis Spline Term Structure - Node (17, 18, 19)
	- State Curve Basis Spline Term Structure - Node Derivative (20, 21, 22)
	- State Curve Derived Zero Rate #1 (23, 24)
	- State Curve Derived Zero Rate - NUM_DF_QUADRATURES (25)
	- State Curve Derived Zero Rate - Discount (26)
	- State Curve Derived Zero Rate - Multi-segment Sequence (27)
	- State Curve Derived Zero Rate - Multi-segment Sequence Discount Factor (28)
	- State Curve Derived Zero Rate - Entry From Discount (29, 30, 31)
	- State Curve Derived Zero Rate - Entry From Yield (32, 33, 34)
	- State Curve Derived Zero Rate - From Discount (35, 36, 37)
	- State Curve Derived Zero Rate - From Govvie (38, 39, 40)
	- State Curve Derived Zero Rate - From Base (41, 42, 43)
	- State Curve Derived Zero Rate - Constructor (44, 45, 46)
	- State Curve Derived Zero Rate - Discount Factor #1 (47, 48)
	- State Curve Derived Zero Rate #2 (49)
	- State Curve Derived Zero Rate - Manifest Measure (50)
	- State Curve Derived Zero Rate - Calibratable Component (51)
	- State Curve Derived Zero Rate - Latent Label (52)
	- State Curve Derived Zero Rate - Parallel Shift Manifest Measure (53)
	- State Curve Derived Zero Rate - Shift Manifest Measure (54)
	- State Curve Derived Zero Rate - Custom Tweak Manifest Measure (55)
	- State Curve Derived Zero Rate - Construction Input Set (56)
	- State Curve Derived Zero Rate - Parallel Shift Quantification Metric (57)
	- State Curve Derived Zero Rate - Custom Tweak Quantification Metric (58)
	- State Curve Derived Zero Rate - Discount Factor #2 (59, 60)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:
  • Loading branch information
Lakshmik committed Dec 25, 2023
1 parent 9ab283a commit e8a2471
Show file tree
Hide file tree
Showing 6 changed files with 596 additions and 350 deletions.
43 changes: 43 additions & 0 deletions ReleaseNotes/03_02_2023.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Features:

- State Curve Basis Spline Market Surface - y Anchor Term Structure (1, 2)
- State Curve Basis Spline Repo #1 (3, 4)
- State Curve Basis Spline Repo - Span (5)
- State Curve Basis Spline Repo - Constructor (6, 7)
- State Curve Basis Spline Repo #2 (8, 9, 10)
- State Curve Basis Spline Term Structure (11, 12)
- State Curve Basis Spline Term Structure - Constructor (13, 14, 15)
- State Curve Basis Spline Term Structure - Span (16)
- State Curve Basis Spline Term Structure - Node (17, 18, 19)
- State Curve Basis Spline Term Structure - Node Derivative (20, 21, 22)
- State Curve Derived Zero Rate #1 (23, 24)
- State Curve Derived Zero Rate - NUM_DF_QUADRATURES (25)
- State Curve Derived Zero Rate - Discount (26)
- State Curve Derived Zero Rate - Multi-segment Sequence (27)
- State Curve Derived Zero Rate - Multi-segment Sequence Discount Factor (28)
- State Curve Derived Zero Rate - Entry From Discount (29, 30, 31)
- State Curve Derived Zero Rate - Entry From Yield (32, 33, 34)
- State Curve Derived Zero Rate - From Discount (35, 36, 37)
- State Curve Derived Zero Rate - From Govvie (38, 39, 40)
- State Curve Derived Zero Rate - From Base (41, 42, 43)
- State Curve Derived Zero Rate - Constructor (44, 45, 46)
- State Curve Derived Zero Rate - Discount Factor #1 (47, 48)
- State Curve Derived Zero Rate #2 (49)
- State Curve Derived Zero Rate - Manifest Measure (50)
- State Curve Derived Zero Rate - Calibratable Component (51)
- State Curve Derived Zero Rate - Latent Label (52)
- State Curve Derived Zero Rate - Parallel Shift Manifest Measure (53)
- State Curve Derived Zero Rate - Shift Manifest Measure (54)
- State Curve Derived Zero Rate - Custom Tweak Manifest Measure (55)
- State Curve Derived Zero Rate - Construction Input Set (56)
- State Curve Derived Zero Rate - Parallel Shift Quantification Metric (57)
- State Curve Derived Zero Rate - Custom Tweak Quantification Metric (58)
- State Curve Derived Zero Rate - Discount Factor #2 (59, 60)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:
Binary file modified ScheduleSheet.xlsx
Binary file not shown.
17 changes: 10 additions & 7 deletions src/main/java/org/drip/state/curve/BasisSplineMarketSurface.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package org.drip.state.curve;

import org.drip.analytics.date.JulianDate;
import org.drip.analytics.definition.MarketSurface;
import org.drip.analytics.definition.NodeStructure;
import org.drip.spline.multidimensional.WireSurfaceStretch;
Expand Down Expand Up @@ -162,15 +163,17 @@ public BasisSplineMarketSurface (
return null;
}

@Override public org.drip.analytics.definition.NodeStructure yAnchorTermStructure (
final double dblMaturityDateAnchor)
@Override public NodeStructure yAnchorTermStructure (
final double maturityDateAnchor)
{
try {
return new BasisSplineTermStructure (epoch().julian(),
org.drip.state.identifier.CustomLabel.Standard (label() + "_" + new
org.drip.analytics.date.JulianDate ((int) dblMaturityDateAnchor)), currency(),
_wireSurfaceStretch.wireSpanYAnchor (dblMaturityDateAnchor));
} catch (java.lang.Exception e) {
return new BasisSplineTermStructure (
epoch().julian(),
CustomLabel.Standard (label() + "_" + new JulianDate ((int) maturityDateAnchor)),
currency(),
_wireSurfaceStretch.wireSpanYAnchor (maturityDateAnchor)
);
} catch (Exception e) {
e.printStackTrace();
}

Expand Down
64 changes: 38 additions & 26 deletions src/main/java/org/drip/state/curve/BasisSplineRepoCurve.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@

package org.drip.state.curve;

import org.drip.product.definition.Component;
import org.drip.spline.grid.Span;
import org.drip.state.repo.RepoCurve;

/*
* -*- 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 @@ -82,53 +89,58 @@

/**
* <i>BasisSplineRepoCurve</i> manages the Basis Latent State, using the Repo as the State Response
* Representation.
* Representation.
*
* <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 BasisSplineRepoCurve extends org.drip.state.repo.RepoCurve {
private org.drip.spline.grid.Span _span = null;
public class BasisSplineRepoCurve extends RepoCurve
{
private Span _span = null;

/**
* BasisSplineRepoCurve constructor
* <i>BasisSplineRepoCurve</i> constructor
*
* @param comp The Underlying Repo Component
* @param component The Underlying Repo Component
* @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 BasisSplineRepoCurve (
final org.drip.product.definition.Component comp,
final org.drip.spline.grid.Span span)
throws java.lang.Exception
final Component component,
final Span span)
throws Exception
{
super ((int) span.left(), comp);
super ((int) span.left(), component);

_span = span;
}

@Override public double repo (
final int iDate)
throws java.lang.Exception
final int date)
throws Exception
{
if (iDate < _span.left() || iDate >= component().maturityDate().julian())
throw new java.lang.Exception ("BasisSplineRepoCurve::repo => Invalid Input");

double dblSpanRight = _span.right();
if (date < _span.left() || date >= component().maturityDate().julian()) {
throw new Exception ("BasisSplineRepoCurve::repo => Invalid Input");
}

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

return _span.calcResponseValue (iDate);
return date >= spanRight ? _span.calcResponseValue (spanRight) : _span.calcResponseValue (date);
}
}
101 changes: 61 additions & 40 deletions src/main/java/org/drip/state/curve/BasisSplineTermStructure.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@

package org.drip.state.curve;

import org.drip.analytics.definition.NodeStructure;
import org.drip.numerical.common.NumberUtil;
import org.drip.spline.grid.Span;
import org.drip.state.identifier.CustomLabel;

/*
* -*- 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,79 +91,92 @@

/**
* <i>BasisSplineTermStructure</i> implements the TermStructure Interface - if holds the latent states Term
* Structure Parameters.
* Structure Parameters.
*
* <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 BasisSplineTermStructure extends org.drip.analytics.definition.NodeStructure {
private org.drip.spline.grid.Span _span = null;
public class BasisSplineTermStructure extends NodeStructure
{
private Span _span = null;

/**
* BasisSplineTermStructure Constructor
* <i>BasisSplineTermStructure</i> Constructor
*
* @param iEpochDate The Epoch Date
* @param label Term Structure Latent State Label
* @param strCurrency The Currency
* @param epochDate The Epoch Date
* @param customLabel Term Structure Latent State Label
* @param currency The Currency
* @param span The Latent State Span
*
* @throws java.lang.Exception Thrown if the Inputs are Invalid
*/

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

_span = span;
}

@Override public double node (
final int iPredictorOrdinate)
throws java.lang.Exception
final int predictorOrdinate)
throws Exception
{
double dblSpanLeft = _span.left();
double spanLeft = _span.left();

if (dblSpanLeft >= iPredictorOrdinate) return _span.calcResponseValue (dblSpanLeft);
if (spanLeft >= predictorOrdinate) {
return _span.calcResponseValue (spanLeft);
}

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

if (dblSpanRight <= iPredictorOrdinate) return _span.calcResponseValue (dblSpanRight);
if (spanRight <= predictorOrdinate) {
return _span.calcResponseValue (spanRight);
}

return _span.calcResponseValue (iPredictorOrdinate);
return _span.calcResponseValue (predictorOrdinate);
}

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

double dblSpanLeft = _span.left();
double spanLeft = _span.left();

if (dblSpanLeft >= iPredictorOrdinate)
return _span.calcResponseValueDerivative (dblSpanLeft, iOrder);
if (spanLeft >= predictorOrdinate) {
return _span.calcResponseValueDerivative (spanLeft, order);
}

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

if (dblSpanRight <= iPredictorOrdinate)
return _span.calcResponseValueDerivative (dblSpanRight, iOrder);
if (spanRight <= predictorOrdinate) {
return _span.calcResponseValueDerivative (spanRight, order);
}

return _span.calcResponseValueDerivative (iPredictorOrdinate, iOrder);
return _span.calcResponseValueDerivative (predictorOrdinate, order);
}
}
Loading

0 comments on commit e8a2471

Please sign in to comment.