forked from jasonstrimpel/volatility-trading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Teste by HH.py
48 lines (40 loc) · 1.23 KB
/
Teste by HH.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#from volatility import volest
from volest.py 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
)