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
- RFV (Rational Function Volatility)
- SLV (Stochastic Local Volatility)
- SABR (Stochastic Alpha Beta Rho)
- 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:
- Fork the repository and clone it locally.
- Create a new branch for your feature or fix.
- Add your changes and include tests for any new functionality.
- Run the test suite to ensure all tests pass.
- 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)
| File | Size | Uploaded | |
|---|---|---|---|
| volsplineslib-0.1.3.tar.gz | 6.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|