Skip to content

Repository files navigation

Fixed-Income Numerics Research

This project provides a Python-based, first-principles demonstration of fixed-income numerics. It covers the entire workflow from raw data to risk analysis, including curve construction, pricing of vanilla interest rate products, and volatility modeling.

Project Structure

The project is organized into the following modules:

  • main.py: The main execution script that runs the entire workflow.
  • config.py: Configuration file for the project, including paths and conventions.
  • data_loader.py: Handles data ingestion from various sources with graceful fallbacks.
  • curve_construction.py: Implements the bootstrapping of the discount curve.
  • pricing.py: Contains functions for pricing bonds, swaps, and FRAs.
  • risk.py: Implements the calculation of DV01 and key-rate sensitivities.
  • volatility.py: Includes the Black-76 model for swaptions and a SABR model calibration.
  • hull_white.py: A lightweight implementation of the Hull-White short-rate model.
  • visualizations.py: Generates plots for risk and volatility analysis.

Installation

To run this project, you need to install the required packages. You can do this by running:

pip install numpy pandas matplotlib scipy pandas_datareader yfinance

Usage

To run the project, simply execute the main.py script:

python main.py

The script will perform the following steps:

  1. Load data from CSV files, FRED, Yahoo Finance, or generate synthetic data.
  2. Build the OIS discount curve.
  3. Price a fixed-coupon bond, an interest rate swap, and a forward rate agreement.
  4. Calculate DV01 and key-rate DV01 for the bond.
  5. Price a European swaption using the Black-76 model and calibrate a SABR model.
  6. Price a Bermudan swaption using the Hull-White model.
  7. Generate and save plots for the analysis.
  8. Export the results to CSV files in the output directory.

Data Schemas

The project can load data from the following CSV files located in the data directory:

ois_depos_swaps.csv

Column Description
tenor_str Tenor string (e.g., ON, 1W, 1M, 1Y)
instrument Instrument type (OIS, IRS, DEP, FRA)
quote_type Type of quote (rate or par)
quote_value The value of the quote

futures_fra.csv

Column Description
expiry_code Expiry code of the future (e.g., EDZ5)
type Type of instrument (FUT or FRA)
price_or_rate Price of the future or rate of the FRA

cds_par_spreads.csv

Column Description
tenor_str Tenor string (e.g., 6M, 1Y, 5Y)
spread_bps Par spread in basis points

capfloor_vols.csv

Column Description
expiry_yrs Expiry in years
strike Strike of the option
black_vol Black volatility

swaption_vols.csv

Column Description
expiry_yrs Expiry in years
tenor_yrs Tenor of the underlying swap in years
black_vol Black volatility

Output

The project generates the following files in the output directory:

  • discount_curve.csv: The bootstrapped discount curve.
  • keyrate_dv01.csv: The key-rate DV01 sensitivities.
  • keyrate_dv01.png: A bar chart of the key-rate DV01 sensitivities.
  • sabr_fit.png: A plot of the SABR model fit against market volatilities.
  • hw_convergence.png: A plot showing the convergence of the Hull-White model.

How to Extend

This project can be extended in several ways:

  • Multi-Curve Framework: Implement a proper multi-curve framework with separate discount and projection curves.
  • Calendars and Day Counts: Integrate a proper business day calendar and accurate day-count conventions.
  • Richer SABR Calibration: Calibrate the SABR model to the full volatility surface.
  • LSMC for Bermudans: Use a Least-Squares Monte Carlo (LSMC) approach for more accurate pricing of Bermudan options.

About

This project delivers a real-time fixed-income analytics system integrating FRED, BEA, and BLS data. It builds yield curves, prices bonds/derivatives, computes DV01 and key-rate risks, and applies Black-76, SABR, and Hull-White models. Analysis (Sep 20, 2025) shows an inverted curve, bond premium, and 5Y risk concentration.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages