-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
64 lines (56 loc) · 1.77 KB
/
main.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
# public imports
import json
# local imports
from visualization import visualize
from data_into_csv import data_into_csv
def selection():
"""Returns user selection and catches input errors.
"""
input_value = input("Select a number: ").strip()
if input_value == "break":
return "break"
# catch input errors
try:
input_value = int(input_value)
if (input_value > 0) and (input_value < 5):
return input_value
else:
print("You need to select a value from 1-3.")
return selection()
except:
print("You need to select a value from 1-3.")
return selection()
def main():
"""Prompts user and calls functions based on user input.
"""
while True:
# user prompt
print("\n\n\n\nType 'break' to exit the script.")
print("\n\nSelect what you want to do: \n\n")
print(json.dumps([ # Pretty print
"Visualize the Piotroski F-score of a stock: 1",
"Visualize the PEG-ratio of a stock: 2",
"Load stock perfomance-indicators into a CSV file: 3"
], indent=4))
print("\n")
# user selection
input_value = selection()
response = ""
print("\n")
if input_value == 1:
response = visualize(1) # visualize piotroski F-Score
elif input_value == 2:
response = visualize(2) # visualize PEG-Ratio
elif input_value == 3:
response = data_into_csv() # fill ticker-CSV with stock info and PI's
print(response)
elif input_value == "break":
print("\n")
break
if response == "break":
print("\n\n\n")
break
pass
# BOILERPLATE
if __name__ == "__main__":
main()