-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
66 lines (39 loc) · 1.39 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
65
import openpyxl
from sheet_management import *
# Excel workbook and sheets
workbook = openpyxl.load_workbook("AktienExcel.xlsx")
Status_sheet = workbook.get_sheet_by_name("Status")
Historie_sheet = workbook.get_sheet_by_name("Historie")
def main():
update_status()
update_prices()
print("Willkommen zu Deiner Aktienverwaltung.")
while True:
command = menu()
if command == 0:
break
handle_command(command)
save()
print("Auf Wiedersehen! Bis zum nächsten Mal.")
# USER INTERFACE
def menu():
command = -1
valid_commands = ["1", "2", "3", "0"]
while command not in valid_commands:
command = input("\nWas möchtest Du tun? \nAktien hinzufügen(1) "
"Aktien entfernen(2) Depot anzeigen(3) Beenden(0)\n")
return int(command)
def handle_command(command):
if command == 1 or command == 2:
update_stock_count_ui(command)
elif command == 3:
print_current_stocks()
def update_stock_count_ui(command):
operations = ["hinzufügen", "entfernen"]
symbol = input(f"Gib die Wertpapierkennung der Aktie an, die Du {operations[command - 1]} möchtest.\n").upper()
count = int(input(f"Wie viele {symbol}-Aktien möchtest Du {operations[command - 1]}?\n"))
if command == 2:
count = -count
add_stock(symbol, count)
if __name__ == "__main__":
main()