Skip to content

Commit 63ba858

Browse files
author
vikabi
committed
updated code
1 parent ad07c6a commit 63ba858

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

MachineLearning Projects/Stock-Analysis/StockAnalysis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime, timedelta
44
import matplotlib.pyplot as plt
55

6+
# Function to get a list of tickers for analysis
67
def get_ticker_list():
78
while True:
89
try:
@@ -20,6 +21,7 @@ def get_ticker_list():
2021
except ValueError:
2122
print("Please input a valid integer only.")
2223

24+
# Main function
2325
def main():
2426
tickerlist = get_ticker_list()
2527

@@ -28,6 +30,7 @@ def main():
2830

2931
data = pd.DataFrame()
3032

33+
# Loop through each ticker to fetch data
3134
for ticker in tickerlist:
3235
try:
3336
y = yf.Ticker(ticker)
@@ -40,6 +43,7 @@ def main():
4043
print("An error occurred while fetching data for", ticker, ":", str(e))
4144

4245
if not data.empty:
46+
# Plotting the data
4347
data.plot(title="Stock Price Analysis")
4448
plt.xlabel("Date")
4549
plt.ylabel("Price")
@@ -49,5 +53,6 @@ def main():
4953
else:
5054
print("No data available for analysis.")
5155

56+
# Entry point of the program
5257
if __name__ == "__main__":
5358
main()

0 commit comments

Comments
 (0)