def standard_and_poors(work_days):
counter = 1
percentage_gain = 1
return_on_investment = 0
investment_per_day = 100
while counter <= work_days:
print (f"n ROI on day{counter} after investing {investment_per_day} is ${return_on_investment}")
return_on_investment += percentage_gain
percentage_gain *= 1.02739726027
#program accounts for fluctations in stock price per day
percentage_gain = 1.02739726027 * 0.5
counter += 1
return f"n ROI after investing {investment_per_day} after {counter} days is ${return_on_investment}"
days = int(input("How many days of ur life did you invest for? "))
The S&P 500 index fund returns an 11% average per year, which is + 0.02739726027 % per day. The average days worked over a lifetime is 90,000 hours, or 3715 days. My program aims to calculate the ROI after investing $100 for every day you work until you retire.
I am having difficulty accurately accounting for fluctuations in the stock price per day, as profit is of course not consistent on a day to day basis. I am not that good at math, so I’m unsure if there is a cool algorithm to randomly generate profit and loss increments into the ROI calculation .
I tried accounting for fluctuations by reducing the ROI by a half every other day , but that seems too linear. Thinking about it, I believe some sort of rand function would work, though I don’t know what would be the proper syntax for setting up the range.
Antonio Kerr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2