-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrun.py
45 lines (32 loc) · 932 Bytes
/
run.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
import sys
import os
from dotenv import load_dotenv
load_dotenv()
# This is some code I reuse for any scripting projects I have.
# It's probably too complex for a project with only one command but it works...
def vix_controller(args):
from vix.vix import Vix
key = os.environ.get("TDAMER_KEY")
ticker = args[0]
vixvol = Vix(
td_api_key=key,
debug=False,
caching_enabled=True
)
vix = vixvol.calculate(ticker)
print('VIX: ' + str(vix))
def main():
sys.argv.pop(0)
args = [arg.strip() for arg in sys.argv]
if (':' in args[0]):
command = args.pop(0)
program = command.split(':')[0] + "_controller"
subroutine = command.split(':')[1]
globals()[program](subroutine, args)
return
else:
program = args.pop(0) + "_controller"
globals()[program](args)
return
if __name__ == '__main__':
main()