Code Monkey home page Code Monkey logo

volatility-trading's Introduction

volest

A complete set of volatility estimators based on Euan Sinclair's Volatility Trading.

http://www.amazon.com/gp/product/0470181990/tag=quantfinancea-20

The original version incorporated network data acquisition from Yahoo!Finance from pandas_datareader. Yahoo! changed their API and broke pandas_datareader.

The changes allow you to specify your own data so you're not tied into equity data from Yahoo! finance. If you're still using equity data, just download a CSV from finance.yahoo.com and use the data.yahoo_data_helper method to form the data properly.

Volatility estimators include:

  • Garman Klass
  • Hodges Tompkins
  • Parkinson
  • Rogers Satchell
  • Yang Zhang
  • Standard Deviation

Also includes

  • Skew
  • Kurtosis
  • Correlation

For each of the estimators, plot:

  • Probability cones
  • Rolling quantiles
  • Rolling extremes
  • Rolling descriptive statistics
  • Histogram
  • Comparison against arbirary comparable
  • Correlation against arbirary comparable
  • Regression against arbirary comparable

Create a term sheet with all the metrics printed to a PDF.

Page 1 - Volatility cones

Capture-1

Page 2 - Volatility rolling percentiles

Capture-2

Page 3 - Volatility rolling min and max

Capture-3

Page 4 - Volatility rolling mean, standard deviation and zscore

Capture-4

Page 5 - Volatility distribution

Capture-5

Page 6 - Volatility, benchmark volatility and ratio###

Capture-6

Page 7 - Volatility rolling correlation with benchmark

Capture-7

Page 3 - Volatility OLS results

Capture-8

Example usage:

from volatility import volest
import yfinance as yf

# data
symbol = 'JPM'
bench = 'SPY'
estimator = 'GarmanKlass'

# estimator windows
window = 30
windows = [30, 60, 90, 120]
quantiles = [0.25, 0.75]
bins = 100
normed = True

# use the yahoo helper to correctly format data from finance.yahoo.com
jpm_price_data = yf.Ticker(symbol).history(period="5y")
jpm_price_data.symbol = symbol
spx_price_data = yf.Ticker(bench).history(period="5y")
spx_price_data.symbol = bench

# initialize class
vol = volest.VolatilityEstimator(
    price_data=jpm_price_data,
    estimator=estimator,
    bench_data=spx_price_data
)

# call plt.show() on any of the below...
_, plt = vol.cones(windows=windows, quantiles=quantiles)
_, plt = vol.rolling_quantiles(window=window, quantiles=quantiles)
_, plt = vol.rolling_extremes(window=window)
_, plt = vol.rolling_descriptives(window=window)
_, plt = vol.histogram(window=window, bins=bins, normed=normed)

_, plt = vol.benchmark_compare(window=window)
_, plt = vol.benchmark_correlation(window=window)

# ... or create a pdf term sheet with all metrics in term-sheets/
vol.term_sheet(
    window,
    windows,
    quantiles,
    bins,
    normed
)

Hit me on twitter with comments, questions, issues @jasonstrimpel

volatility-trading's People

Contributors

jasonstrimpel avatar liubj2016 avatar occasionallydavid avatar snowhit3 avatar thisisamirmaleki avatar

Watchers

 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.