Skip to content

Commit 53781f7

Browse files
author
vikabi
committed
addition of time period feature
1 parent 5c14a30 commit 53781f7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

MachineLearning Projects/Stock-Analysis/StockAnalysis.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@ def get_ticker_list():
2121
except ValueError:
2222
print("Please input a valid integer only.")
2323

24+
# Function to get the time period for analysis
25+
def get_time_period():
26+
try:
27+
start_date = input("Enter the start date (YYYY-MM-DD): ")
28+
end_date = input("Enter the end date (YYYY-MM-DD): ")
29+
return start_date, end_date
30+
except ValueError:
31+
print("Invalid date format. Please use the format YYYY-MM-DD.")
32+
2433
# Main function
2534
def main():
2635
tickerlist = get_ticker_list()
2736

28-
end_date = datetime.today().strftime('%Y-%m-%d')
29-
start_date = (datetime.today() - timedelta(days=365)).strftime('%Y-%m-%d')
37+
start_date, end_date = get_time_period() # Get time period for analysis
3038

3139
data = pd.DataFrame()
3240

0 commit comments

Comments
 (0)