Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the start_date feature #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions RoughInvestmentReturns.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
from __future__ import division

import math, numpy
from datetime import date

def get_months(start_date, end_date):
'''
Gets the monthes between two dates
'''
start_month, start_year = start_date.split(":")
end_month, end_year = end_date.split(":")
return (int(end_year)-int(start_year))*12 + (int(end_month)-int(start_month))

invested = int(input("Invested: "))
current = int(input("Current: "))
months = int(input("Months: "))
months = input("Enter either Number of Months or A Start Date (MM:YYYY): ")

if ":" in months:
# Create an object of the datetime module
today = date.today()
# Set the format to be MM:YYYY
date = today.strftime("%m:%Y")
months = get_months(start_date= months, end_date= date)
Comment on lines +22 to +23
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not hide the datetime.date

Suggested change
date = today.strftime("%m:%Y")
months = get_months(start_date= months, end_date= date)
today_date = today.strftime("%m:%Y")
months = get_months(start_date= months, end_date= today_date)

else:
months = int(months)


values = []

for i in range(months):
values.append(-(invested/months))
values.append(-(invested/months))

values.append(current)

Expand Down