项目作者: jasonstrimpel

项目描述 :
A complete set of volatility estimators based on Euan Sinclair's Volatility Trading
高级语言: Python
项目地址: git://github.com/jasonstrimpel/volatility-trading.git
创建时间: 2014-06-14T21:04:23Z
项目社区:https://github.com/jasonstrimpel/volatility-trading

开源协议:GNU General Public License v3.0

下载


volest

Learn how to apply this code to your own options trading

Getting Started With Python for Quant Finance is the cohort-based course and community that will take you from complete beginner to up and running with Python for quant finance in 30 days.

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

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:

  1. from volatility import volest
  2. import yfinance as yf
  3. # data
  4. symbol = 'JPM'
  5. bench = 'SPY'
  6. estimator = 'GarmanKlass'
  7. # estimator windows
  8. window = 30
  9. windows = [30, 60, 90, 120]
  10. quantiles = [0.25, 0.75]
  11. bins = 100
  12. normed = True
  13. # use the yahoo helper to correctly format data from finance.yahoo.com
  14. jpm_price_data = yf.Ticker(symbol).history(period="5y")
  15. jpm_price_data.symbol = symbol
  16. spx_price_data = yf.Ticker(bench).history(period="5y")
  17. spx_price_data.symbol = bench
  18. # initialize class
  19. vol = volest.VolatilityEstimator(
  20. price_data=jpm_price_data,
  21. estimator=estimator,
  22. bench_data=spx_price_data
  23. )
  24. # call plt.show() on any of the below...
  25. _, plt = vol.cones(windows=windows, quantiles=quantiles)
  26. _, plt = vol.rolling_quantiles(window=window, quantiles=quantiles)
  27. _, plt = vol.rolling_extremes(window=window)
  28. _, plt = vol.rolling_descriptives(window=window)
  29. _, plt = vol.histogram(window=window, bins=bins, normed=normed)
  30. _, plt = vol.benchmark_compare(window=window)
  31. _, plt = vol.benchmark_correlation(window=window)
  32. # ... or create a pdf term sheet with all metrics in term-sheets/
  33. vol.term_sheet(
  34. window,
  35. windows,
  36. quantiles,
  37. bins,
  38. normed
  39. )

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