Skip to main content

A library for interpolating implied volatility surfaces

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

volsplineslib-0.1.3.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

VolSplinesLib-0.1.3-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file volsplineslib-0.1.3.tar.gz.

File metadata

  • Download URL: volsplineslib-0.1.3.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for volsplineslib-0.1.3.tar.gz
Algorithm Hash digest
SHA256 bc796730d49856374bc4d66704647fb15e1934d106d85401b8f5e9cac93c57dc
MD5 3cc2b309159f945f34fbe1227c758249
BLAKE2b-256 577695be7d1a0ed559af794b0e8b78521604109def82b26011c06e7bd71a82bc

See more details on using hashes here.

File details

Details for the file VolSplinesLib-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: VolSplinesLib-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for VolSplinesLib-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e838f8b295c3b131c5b3fd25c4d4f9997b8c23dff823d6decf821719d14f5356
MD5 ee349fe3be749e384ac3763f9057b90d
BLAKE2b-256 822b9d83824d5a0c0f08db1d140633dbe16bcbee3462d7f5f74c4e92487ea36b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page