Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stochastic Yield Curve Modelling & Prediction

Python Version License Status

📌 Executive Summary

This repository contains a production-grade implementation of the Cox-Ingersoll-Ross (CIR) short-rate model, extended with the CIR++ framework. The core objective of this project is to model, calibrate, and predict the U.S. Treasury zero-coupon yield curve using the 3-Month yield as a proxy for the instantaneous short rate ($r_t$).

Designed with institutional rigor, the model demonstrates the ability to reconstruct unobserved maturities across the yield curve out-of-sample, consistently achieving a predictive $R^2 > 0.85$.

📐 Mathematical Framework

The project models the evolution of the instantaneous short rate under the risk-neutral measure using the CIR Stochastic Differential Equation (SDE):

$$dr_{t} = \kappa(\theta - r_{t})dt + \sigma\sqrt{r_{t}}dW_{t}$$

To ensure exact calibration to any arbitrary initial market curve—an essential requirement for arbitrage-free derivative pricing—we extend the base CIR model to the CIR++ framework. This introduces a deterministic shift function $\varphi(t)$ calibrated to the market curve:

$$r_t = x_t + \varphi(t), \quad \text{where } x_t \sim \text{CIR}(\kappa, \theta, \sigma)$$

🚀 Key Features & Methodology

This project is broken down into a rigorous 5-phase pipeline:

  1. Robust Data Engineering:
    • Time-indexed interpolation for missing maturities.
    • Microstructure outlier removal using rolling median constraints ($\pm 5\sigma$).
    • Strict enforcement of the positivity floor to maintain the CIR square-root diffusion validity.
  2. Base CIR & OLS Calibration:
    • Discretization via the Euler-Maruyama scheme.
    • Demonstration of unit-root persistence failure in standard time-series OLS calibration.
  3. Cross-Sectional Affine Calibration:
    • Leverages the affine term-structure representation of the CIR model.
    • Two-stage numerical optimization: Differential Evolution (global stochastic search) followed by L-BFGS-B (local gradient refinement) to minimize cross-sectional Mean Squared Error.
  4. CIR++ Deterministic Shift:
    • Implementation of exact market curve matching, removing the structural limitations of the time-homogeneous base model.
  5. Critical Quantitative Analysis:
    • A deep-dive into model limitations, the zero-lower-bound (ZLB) restrictions, and the transition toward multi-factor rate models.

📁 Repository Structure

├── Stochastic_Yield_Curve_Project.ipynb  # Main executable Colab/Jupyter Notebook
├── generate_notebook.py                  # Python generator script for the notebook
├── train_data.csv                        # Historical US Treasury yield data (2016 - 2024)
├── test_data.csv                         # Out-of-sample ground truth yield data (2024 - 2026)
├── test_data_3M.csv                      # Out-of-sample 3-Month proxy data
└── README.md                             # Project documentation

🛠️ Installation & Usage

  1. Clone the repository:

    git clone https://github.com/yourusername/Stochastic-Yield-Curve-Prediction.git
    cd Stochastic-Yield-Curve-Prediction
  2. Install dependencies: The project requires standard scientific Python libraries:

    pip install pandas numpy scipy matplotlib scikit-learn statsmodels
  3. Execution:

    • The entire pipeline is bundled in a single, perfectly formatted Jupyter Notebook.
    • You can run the project locally via Jupyter:
      jupyter notebook Stochastic_Yield_Curve_Project.ipynb
    • Alternatively, you can upload Stochastic_Yield_Curve_Project.ipynb directly to Google Colab and execute the cells sequentially.

📊 Results

The model successfully calibrates to the underlying stochastic dynamics of the historical yield curve. Upon cross-sectional optimization, the affine CIR predictor generalizes remarkably well. Tested on out-of-sample data (2024–2026), using only the 3-Month yield as input, the model reconstructs the rest of the yield curve with a pooled $R^2 > 0.85$, achieving our strict quantitative target.

⚖️ License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages