Skip to content

Improve Curve support: IO, interpolation and tests #4

Description

@asancdec

Improve Curve support: IO, interpolation, and tests

Motivation

core::Curve<T> is currently useful for simple curve construction and exact-maturity discount-factor access, but it is still incomplete as a market-data component.

Several workflows need curves to be loaded from files, interpolated between pillars, validated more thoroughly, and reported consistently. Curve support should become closer in quality to the volatility surface infrastructure.

Goal

Make core::Curve<T> a more complete market-data object with explicit interpolation, extrapolation, IO support, and test coverage.

Scope

Add interpolation for discount factors between known maturities.

Initial interpolation modes:

  • linear discount-factor interpolation
  • log-linear discount-factor interpolation
  • linear zero-rate interpolation

Additional interpolation schemes to consider:

  • cubic spline interpolation
  • monotone cubic interpolation
  • tension spline interpolation
  • piecewise-constant interpolation where useful

The first implementation does not need to support every interpolation scheme immediately, but the design should allow additional interpolation policies to be added cleanly.

Add explicit extrapolation behavior:

  • reject out-of-range maturities
  • flat-zero extrapolation
  • flat-forward extrapolation

Add IO support for curve data:

  • CSV reader for maturity/discount-factor pairs
  • CSV reader for maturity/rate pairs
  • JSON reader for curve fixtures/configuration

Add basic report/print helpers for curves.

Add tests for:

  • valid curve construction
  • validation failures
  • exact pillar lookup
  • interpolation behavior
  • extrapolation behavior
  • CSV parsing
  • JSON parsing
  • malformed curve files

Proposed API shape

Use enums to make interpolation and extrapolation explicit:

enum class CurveInterpolation
{
    LinearDiscountFactor,
    LogLinearDiscountFactor,
    LinearZeroRate,
    CubicSpline,
    MonotoneCubic,
    TensionSpline,
    PiecewiseConstant
};

enum class CurveExtrapolation
{
    Reject,
    FlatZero,
    FlatForward
};

Possible constructor/config shape:

Curve(
    maturities,
    discountFactors,
    interpolation,
    extrapolation
);

Required public operations:

interpolateDF(T maturity);
interpolateDF(std::span<const T> maturities);

Non-goals

  • Do not implement full curve bootstrapping in this issue.
  • Do not replace the existing flat-rate constructor.
  • Do not add full multi-curve market-state support yet.
  • Do not add curve bumping/shocking utilities yet.
  • Do not require every interpolation scheme in the first PR.
  • Do not change Heston/SVI pricing behavior except where improved curve interpolation is directly needed.

Follow-up work

Possible follow-up issues:

  • zero-curve and forward-curve wrappers
  • bootstrapping from market instruments
  • curve bumping and scenario shocks
  • multi-curve market state support
  • performance tests for vectorized curve interpolation
  • additional interpolation policies if not implemented initially

Acceptance criteria

  • Curve<T> supports interpolation between pillars.
  • Out-of-range behavior is explicit and tested.
  • At least one simple interpolation mode is implemented first.
  • The API is extensible to cubic spline, monotone cubic, tension spline, and other schemes.
  • Curves can be loaded from CSV and JSON fixtures.
  • Existing curve and market-state tests continue to pass.
  • New unit tests cover valid and malformed curve inputs.
  • Current assumptions and limitations are documented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions