Skip to main content

VolSplinesLib

VolSplinesLib is a Python library for interpolating implied volatility surfaces using various volatility models. The library provides tools for fitting and interpolating models to market data, supporting popular methods like RFV, SLV, SABR, and SVI.

You can find the library on PyPI and on GitHub

Installation

You can install VolSplinesLib from PyPI:

pip install VolSplinesLib

Or, install directly from the GitHub repository:

pip install git+https://github.com/hedge0/VolSplinesLib.git

Usage

After installation, you can perform interpolations using the library. Here's a quick example:

import numpy as np
import matplotlib.pyplot as plt
from VolSplinesLib import perform_interpolation

# Sample data
x = np.array([100, 105, 110, 115, 120], dtype=np.float64)           # Strike prices
y_mid = np.array([0.2, 0.18, 0.16, 0.15, 0.14], dtype=np.float64)   # Mid implied volatilities
y_bid = np.array([0.19, 0.17, 0.15, 0.14, 0.13], dtype=np.float64)  # Bid IVs
y_ask = np.array([0.21, 0.19, 0.17, 0.16, 0.15], dtype=np.float64)  # Ask IVs

# Select the model you want to fit ('RFV', 'SLV', 'SABR', 'SVI')
selected_model = 'RFV'

# Perform interpolation
fine_x, interpolated_y = perform_interpolation(x, y_mid, y_bid, y_ask, selected_model)

# Optionally, plot the original data and the fitted model
plt.figure(figsize=(10, 6))
plt.scatter(x, y_mid, color='blue', label='Market Data')
plt.plot(fine_x, interpolated_y, color='red', label='Fitted {} Model'.format(selected_model))
plt.xlabel('Strike')
plt.ylabel('Implied Volatility')
plt.title('{} Model Fitting'.format(selected_model))
plt.legend()
plt.grid(True)
plt.show()

Available Models

  1. RFV (Rational Function Volatility)
  2. SLV (Stochastic Local Volatility)
  3. SABR (Stochastic Alpha Beta Rho)
  4. SVI (Stochastic Volatility Inspired)

Contributing

Contributions to VolSplinesLib are welcome! If you find a bug or have suggestions for improvements, please open an issue or submit a pull request. Make sure to follow these guidelines:

  1. Fork the repository and clone it locally.
  2. Create a new branch for your feature or fix.
  3. Add your changes and include tests for any new functionality.
  4. Run the test suite to ensure all tests pass.
  5. Submit a pull request describing your changes.

License

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

Contact

For any questions or feedback, feel free to reach out to the author via GitHub: hedge0.

Release files for VolSplinesLib 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for VolSplinesLib 0.1.3
File Size Uploaded
volsplineslib-0.1.3.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for VolSplinesLib 0.1.3
File Interpreter ABI Platform
VolSplinesLib-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / volsplineslib-0.1.3.tar.gz

Download URL volsplineslib-0.1.3.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bc796730d49856374bc4d66704647fb15e1934d106d85401b8f5e9cac93c57dc
BLAKE2b-256 checksum
How to use checksums
577695be7d1a0ed559af794b0e8b78521604109def82b26011c06e7bd71a82bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / VolSplinesLib-0.1.3-py3-none-any.whl

Download URL VolSplinesLib-0.1.3-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e838f8b295c3b131c5b3fd25c4d4f9997b8c23dff823d6decf821719d14f5356
BLAKE2b-256 checksum
How to use checksums
822b9d83824d5a0c0f08db1d140633dbe16bcbee3462d7f5f74c4e92487ea36b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page