Simple GUI with a drop-down menu to pick between etoro and commsec which adds $2 and $4 as a trading fee on each stock being
bought with the budget.
inputs of budget, stock price, and dividend
a final button to calculate with the results showing.
trading_platforms = [
‘etoro’,
‘commsec’
]
def show():
inFile = open(‘stocks.txt’, ‘r’)
for line in inFile:
print(line, end=””)
def menu():
print(f'{20 * “-“} MENU {20 * “-“}’)
for x in range(len(trading_platforms)):
print(f'[{x + 1}] {trading_platforms[x]}’)
print(46 * “-“)
def calculate(budget, stock_price, divident_stock, cost):
results = ((budget/stock_price+cost)*divident_stock)
print (results)
outfile =open(‘returns.txt’, ‘w’)
outfile.write(str(results))
outfile.close
def main():
menu()
while True:
try:
choice = int(
input(‘Enter a number [1 – 2] depending on your desired trading platform: ‘))
budget = int(input(‘what is your budget: $’))
stock_price = int(input(‘enter stock price: ‘))
divident_stock = float(input(‘enter divident: ‘))
except ValueError:
print(“Invalid Input, Please choose a number from the menu”)
else:
if choice < len(trading_platforms):
break
else:
print(f'{choice} is out of selection range, please try again.')
if choice == 1:
calculate(budget, stock_price, divident_stock, 4)
elif choice == 2:
calculate(budget, stock_price, divident_stock, 2)
else:
print('error, please try again')
main()