Metadata-Version: 2.4
Name: curvemetric
Version: 1.5.0
Summary: Financial curve diagnostics and numerical validation
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/Phasetensor/CurveMetric
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Provides-Extra: quantlib
Requires-Dist: QuantLib>=1.32; extra == "quantlib"
Provides-Extra: tables
Requires-Dist: pandas>=2; extra == "tables"
Dynamic: license-file

# CurveMetric

Financial curve diagnostics and numerical validation for Python 3.11+. Compare two term structures on a common maturity grid and measure the effect on cash-flow present values. NumPy and SciPy power the core. QuantLib and pandas are optional.

## Install from source

    git clone https://github.com/Phasetensor/CurveMetric.git
    cd CurveMetric
    python -m pip install .

For QuantLib curve sampling or pandas tables, install with `python -m pip install '.[quantlib,tables]'`.

## Example

    from curvemetric import Curve, compare, present_value

    pillars = [1, 3, 5]
    rates = [0.02, 0.03, 0.04]
    a = Curve.from_zero_rates(pillars, rates)
    b = Curve.from_zero_rates(pillars, rates, "linear_zero")
    report = compare(a, b, [1, 2, 3, 4, 5])
    print(report["metrics"]["zero_bp"])
    print(present_value(b, [2, 5], [4, 104]) - present_value(a, [2, 5], [4, 104]))

Run `curvemetric examples/comparison.json report.html` for a standalone report. Choose a .csv suffix for pointwise data or .json for data and summary statistics.

[API and numerical conventions](docs/methods.md) · [Roadmap](ROADMAP.md) · [Benchmark results](benchmarks/results.csv) · [Apache 2.0](LICENSE)

## Reproduce validation

    python -m unittest discover -s tests -v
    PYTHONPATH=. python benchmarks/run.py > results.csv

The deterministic benchmark evaluates six interpolation choices, five analytical curve shapes and two pillar densities. The tests also check bootstrap residuals, closed-form DV01, parallel and key-rate shocks, multi-curve coupons, and file outputs.

## Research validation

Version 1.1 adds analytical instantaneous forwards, explicit curve conventions, tolerance-based PASS/FAIL/UNKNOWN verdicts, calibration Jacobians and full-price quote sensitivities. [Validation examples, figures and benchmark methodology](docs/validation.md). [Software citation](CITATION.cff).

The 1.1.0 CI run on Python 3.12 measured **89% combined statement and branch coverage** (344 statements, 27 missed, 110 branches, 22 partial). [Measured run](https://github.com/Phasetensor/CurveMetric/actions/runs/45994664908/job/140490942043).

## CurveMetric 1.5.0

[Advanced scientific methods, reproducible figures and results](docs/advanced.md) · [Module traceability and release gates](ROADMAP.md). The advanced APIs are available in curvemetric.numerics, curvemetric.model_validation, curvemetric.statistics and curvemetric.portfolio.
