# ahgperrin/pycurve architecture

> Architecture diagram of the GitHub repository ahgperrin/pycurve, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahgperrin/pycurve
- Repository: https://github.com/ahgperrin/pycurve

## Overview

##### Project type and purpose
- PyCurve is a Python library (no frontend/backend) providing yield curve tools: core objects (Curve, Simulation), interpolation methods (linear, cubic), parametric yield‐curve models (Nelson‐Siegel, Svensson, Bjork‐Christensen and augmented), and stochastic short‐rate models (Vasicek, Hull–White).
- It is intended to be imported by user scripts to build, analyze, plot, and simulate yield curves.

##### File structure
- Top-level: setup.py, README.md, LICENSE, MANIFEST.in, example_screenshot/, and two directories:
- src/PyCurve/ – main package modules
- test/ – unit tests for each module
- src/PyCurve/ contains:
- curve.py, simulation.py – core objects
- linear.py, cubic.py – interpolation modules
- nelson_siegel.py, svensson_nelson_siegel.py – parametric NS models
- bjork_christensen.py, bjork_christensen_augmented.py – alternative parametric models
- actuarial_implementation.py – (likely implementation helpers)
- vasicek.py, hull_white.py – stochastic simulation models

##### README for additional insights
- Dependencies: numpy, scipy.interpolate, scipy.optimize, matplotlib for plotting.
- Examples show the typical flow: create a Curve → pass it to an interpolation or model class → call methods (d_rate, df_t, forward_rate, calibrate, simulate_paths) → use plotting helpers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User Layer"
        user["User Script"]:::external
    end

    subgraph "PyCurve Package"
        subgraph "Core Containers"
            curve["Curve"]:::core
            simulation["Simulation"]:::core
        end

        subgraph "Interpolation Modules"
            linear["LinearCurve"]:::interp
            cubic["CubicCurve"]:::interp
        end

        subgraph "Parametric Models"
            ns["NelsonSiegel"]:::param
            ns_aug["NelsonSiegelAugmented"]:::param
            bj["BjorkChristensen"]:::param
            bj_aug["BjorkChristensenAugmented"]:::param
            ai["ActuarialImplementation"]:::helper
        end

        subgraph "Stochastic Models"
            vas["Vasicek"]:::stoch
            hw["HullWhite"]:::stoch
        end
    end

    subgraph "External Libraries"
        numpy[(NumPy)]:::external
        sci_int[(SciPy.interpolate)]:::external
        sci_opt[(SciPy.optimize)]:::external
        mpl[(Matplotlib)]:::external
    end

    user -->|"imports"| curve
    curve --> simulation
    curve --> linear
    curve --> cubic
    curve --> ns
    curve --> ns_aug
    curve --> bj
    curve --> bj_aug
    curve --> vas
    curve --> hw

    linear -->|"uses"| sci_int
    cubic -->|"uses"| sci_int

    ns -->|"optimizes"| sci_opt
    ns_aug -->|"optimizes"| sci_opt
    bj -->|"optimizes"| sci_opt
    bj_aug -->|"optimizes"| sci_opt
    ai -->|"supports"| ns
    ai --> ns_aug
    ai --> bj
    ai --> bj_aug

    vas -->|"uses"| numpy
    vas --> simulation
    hw -->|"uses"| numpy
    hw --> simulation

    simulation -->|"plotting"| mpl

    click curve "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/curve.py"
    click simulation "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/simulation.py"
    click linear "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/linear.py"
    click cubic "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/cubic.py"
    click ns "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/nelson_siegel.py"
    click ns_aug "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/svensson_nelson_siegel.py"
    click bj "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/bjork_christensen.py"
    click bj_aug "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/bjork_christensen_augmented.py"
    click ai "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/actuarial_implementation.py"
    click vas "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/vasicek.py"
    click hw "https://github.com/ahgperrin/pycurve/blob/master/src/PyCurve/hull_white.py"

    classDef core fill:#D0E1FF,stroke:#0366d6
    classDef interp fill:#E0FFD0,stroke:#40A02B
    classDef param fill:#F0D0FF,stroke:#8E44AD
    classDef stoch fill:#FFE0B2,stroke:#D35400
    classDef helper fill:#EEEEEE,stroke:#7F8C8D
    classDef external fill:#F8F8F8,stroke:#444444,stroke-dasharray:2 2
```
