Accessible here: defivolatilitysurface.streamlit.app
This repository contains an interactive Streamlit web application that calculates and visualizes implied volatility surfaces for cryptocurrency options. The application uses real-time on-chain data from Deribit for over 700 options and applies a Black-Scholes-based model to compute implied volatility with the Newton-Raphson method, leveraging Vega for iterative convergence. Users can adjust three parameters and view the implied volatility surface through a 3D Plotly plot, then connects to the GBT-4o-Mini model via API to analyze and generate optimal trading strategies based on the cacluted Implied volatility.
- Real-time Data: Retrieves data for 700+ cryptocurrency options using the Deribit API.
- Advanced Volatility Calculations: Implements a Black-Scholes model with Newton-Raphson and Vega for iterative convergence on highly volatile assets.
- Interactive 3D Visualization: Provides a customizable 3D surface plot for implied volatility across multiple parameters.
- Trading Strategies for BTC Option: Trading strategies generated from real-time data using OpenAI's GPT-4 Mini Model.
- 1. Data-Preprocessing.ipynb: Contains the data cleaning and preprocessing steps required for preparing the on-chain options data.
- 2. (BTC) - Exploratory Data Analysis.ipynb: Conducts exploratory data analysis for Bitcoin options, focusing on the Vega-based approach for implied volatility.
- 3. implied_volatility_surface.ipynb: This notebook calculates the implied volatility surface using a Black-Scholes-based model and visualizes it with Plotly.
- 4. vs.py: Queries data, calculates implied volatility, and visualizes the volatility surface, hosting the results interactively on Streamlit.
The Black-Scholes formula is used to price European-style options and forms the basis for implied volatility calculation. For a call option, the Black-Scholes price
where:
-
$S_0$ = current price of the underlying asset -
$X$ = strike price of the option -
$T$ = time to maturity of the option (in years) -
$r$ = risk-free interest rate -
$N(\cdot)$ = cumulative distribution function of the standard normal distribution
The terms
For put options, the formula changes slightly to:
Implied volatility (
where:
$f(\sigma) = C(\sigma) - C_{\text{obs}}$ -
$f'(\sigma)$ = Vega (partial derivative of the option price with respect to volatility)
Vega, used in iterative convergence, is given by:
where
Using Vega, we adjust volatility
- Calculation & Visualization: After running the app, use the interactive interface to input parameters and generate the implied volatility surface.