Git Product home page Git Product logo

volvisualizer's Introduction

volvisualizer

Extract and visualize implied volatility from option chain data.

 

A tool to extract option data from Yahoo Finance and provide visualization and smoothing to gain understanding of the supply / demand balance of options of varying strikes and tenors.

 

Installation

Install from PyPI:

$ pip install volvisualizer

 

To install in new environment using anaconda:

$ conda create --name volvis

Activate new environment

$ activate volvis

Install Python

(volvis) $ conda install python==3.9

Install Spyder

(volvis) $ conda install spyder

Install package

(volvis) $ pip install volvisualizer

 

Setup

Import volatility module and initialise a Volatility object that will extract URLs and the option data for each tenor, here specifying S&P500 as the ticker, a start date of 18th August 2021, a delay of 0.5 seconds between each API call, select only monthly expiries and a dividend yield of 1.3%.

from volvisualizer.volatility import Volatility
imp = Volatility(ticker='^SPX', start_date='2021-8-18', wait=0.5, monthlies=True, q=0.013)

 

Line graph of individual option expiries.

imp.visualize(graphtype='line')

tsla_line

 

aapl_line

 

3D Scatter plot of each option implied volatility by strike and expiry.

imp.visualize(graphtype='scatter', voltype='ask')

aapl_scatter

 

3D Wireframe plot with scatter of each option implied volatility by strike and expiry.

imp.visualize(graphtype='surface', surfacetype='spline', scatter=True, smoothing=True)

gld_wire_scatter

 

3D Meshgrid plot of each option implied volatility by strike and expiry.

imp.visualize(graphtype='surface', surfacetype='mesh', smoothing=True)

spx_mesh

 

3D Interactive plot of each option implied volatility by strike and expiry that can be rotated and zoomed.

imp.visualize(graphtype='surface',surfacetype='interactive_spline', smoothing=True, notebook=False, colorscale='Blues', scatter=True, opacity=0.8)

spx_int_scatter

 

spx_int_scatter_270821

 

3D Interactive plot of each option implied volatility by strike and expiry using radial basis function interpolation.

imp.visualize(graphtype='surface', surfacetype='interactive_spline', rbffunc='cubic', colorscale='Jet', smoothing=True)

tsla_int_rbf

 

Extract Implied Volatility for a given maturity and strike

imp.vol(maturity='2021-09-30', strike=80)

37.61

 

Skew Summary Report

 

  • Downside TSLA skew out to 12 months
imp.skewreport(months=12, direction='down')

tsla_skew_270821_down

 

  • Upside GLD skew out to 9 months  
imp.skewreport(months=12, direction='up')

gld_skew_270821_up

 

  • Upside and Downside SPX skew out to 15 months
imp.skewreport(months=15, direction='full')

spx_skew_270821_full

 

Some simplifying assumptions have been made:

  • interest rates are constant; for greater accuracy a term structure should be employed.
  • the prices are taken to be valid at the snap time; if the last trade is some time ago and / or the market is volatile then this will be less accurate.

 

There are parameters to filter the data based on time since last trade, volume, open interest and select only the monthly options expiring on the 3rd Friday.

Some of the smoothing techniques are very sensitive to the quality (and quantity) of input data. Overfitting becomes a problem if there aren't enough data points and the more illiquid tickers often generate results that are not to be relied upon.

Additional work is required to calibrate to an arbitrage free surface.

volvisualizer's People

Contributors

gberesearch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.