-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtp_settings.py
72 lines (55 loc) · 3.34 KB
/
tp_settings.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
tp_settings.py
Last Modified: October 8, 2020
Description: This script handles the run-time settings for MySybil's tradier-options-plotter.
Modify them here and they will apply to bother run_sybil_plotter.py and closed_option_driver.py
"""
# TODO: add settings for volatility plots and other greeks.
# TODO: validate historyBinning
# TODO: validate timesalesBinning
# TODO: validate downloadBinning
# TODO: validate rfr
def get_settings():
settings_dict = {'API_KEY' : 'Bearer UNAGUmPNt1GPXWwWUxUGi4ekynpj',
# Communal API key, use to demo the scripts but please get your own for continued use.
# Sign up for free @ developer.tradier.com
'shouldPrintData' : True,
# True/False
# Do you want the data logged to the command line right before it is plotted?
'historyLimit' : 19,
# Integer from 1 to 40
# The crossover limit (in days) between intraday versus daily data.
'gridstyle' : '--',
#'--' or '-' or 'None'
# Grid-style for the plots.
'tight_layout' : False,
# True/False
# Minimize white-space surrounding the figure and bring the title inside the bounds of the plot.
'historyBinning' : '1D',
# '1D' or '7D' or '3D' or etc. Untested support for 1W / 1M / etc.
# The data binning for non-intraday plots.
'timesalesBinning' : '15min',
# '1min' or '5min' or '15min' or '60min'.
# The data binning for intraday plots.
'downloadBinning' : 15,
# '1' or '5' or '15' (minutes)
# The binning to download intraday data (not to plot, the data is resampled to your choosing later).
# Keep this at 1 (minute) unless you're downloading intraday data going back further than 20 days or stressing the API.
'rfr' : 0.002
# Float in the 0.001 to 0.05 range depending on treasury rates and interval time.
# The risk-free-rate for dealing with options in decimal.
}
# Validate the settings
if (settings_dict['historyLimit'] > 40):
print("WARNING: historyLimit larger than intraday data support from Tradier API. Reducing to 40 days.")
settings_dict['historyLimit'] = 40
if (settings_dict['historyLimit'] > 20 and settings_dict['downloadBinning'] < 5):
print("WARNING: Download binning interval too small for historyLimit. Increasing binning to 5min")
settings_dict['downloadBinning'] = 5
if not (type(settings_dict['shouldPrintData']) == bool):
print("WARNING: Invalid input for shouldPrintData. Required <type> boolean. Setting equal True.")
settings_dict['shouldPrintData'] = True
if not (type(settings_dict['tight_layout']) == bool):
print("WARNING: Invalid input for tight_layout. Required <type> boolean. Setting equal False.")
settings_dict['tight_layout'] = False
return settings_dict