kollis commited on
Commit
e5063a1
·
1 Parent(s): 5e0acd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -16,10 +16,10 @@ class Stocks:
16
 
17
  def fetch_data(self):
18
  try:
19
- # Construct the ticker symbol based on the first letter
20
  ticker_symbol = self.symbol if self.symbol[0] == '%' else f"{self.symbol}.ns"
21
 
22
- # Fetch historical data based on the constructed ticker symbol
23
  data = yf.Ticker(ticker_symbol).history(period="10y", auto_adjust=True)
24
  return data
25
  except Exception as e:
@@ -30,11 +30,11 @@ class Stocks:
30
  if curDate in self.data.index:
31
  return curDate
32
  else:
33
- # Convert curDate to datetime and subtract one day
34
  curDate_dt = datetime.strptime(curDate, "%Y-%m-%d")
35
  newcDate_dt = curDate_dt - timedelta(days=1)
36
 
37
- # Convert newcDate to string and call the method again
38
  newcDate_str = newcDate_dt.strftime("%Y-%m-%d")
39
  return self.currentdateavailability(newcDate_str)
40
 
@@ -66,19 +66,19 @@ class Stocks:
66
  # curDate = self.currentdateavailability(curDate)
67
 
68
  # if curDate is not None:
69
- # # Calculate date 30 days ago
70
  # curDate_dt = datetime.strptime(curDate, "%Y-%m-%d")
71
  # days_ago_30 = curDate_dt - timedelta(days=30)
72
  # thirty_days_ago_date = days_ago_30.strftime("%Y-%m-%d")
73
 
74
- # # Ensure the availability of 30 days ago date
75
  # thirty_days_ago_date = self.currentdateavailability(thirty_days_ago_date)
76
 
77
- # # Get the index of curDate and 30 days ago date in the data
78
  # curDate_index = self.data.index.get_loc(curDate)
79
  # thirty_days_ago_index = self.data.index.get_loc(thirty_days_ago_date)
80
 
81
- # # Return close values from 30 days ago to curDate in an array
82
  # return self.data.iloc[thirty_days_ago_index:curDate_index + 1]['Close'].values
83
  # else:
84
  # return self.data.iloc[-30:]['Close'].values
 
16
 
17
  def fetch_data(self):
18
  try:
19
+
20
  ticker_symbol = self.symbol if self.symbol[0] == '%' else f"{self.symbol}.ns"
21
 
22
+
23
  data = yf.Ticker(ticker_symbol).history(period="10y", auto_adjust=True)
24
  return data
25
  except Exception as e:
 
30
  if curDate in self.data.index:
31
  return curDate
32
  else:
33
+
34
  curDate_dt = datetime.strptime(curDate, "%Y-%m-%d")
35
  newcDate_dt = curDate_dt - timedelta(days=1)
36
 
37
+
38
  newcDate_str = newcDate_dt.strftime("%Y-%m-%d")
39
  return self.currentdateavailability(newcDate_str)
40
 
 
66
  # curDate = self.currentdateavailability(curDate)
67
 
68
  # if curDate is not None:
69
+
70
  # curDate_dt = datetime.strptime(curDate, "%Y-%m-%d")
71
  # days_ago_30 = curDate_dt - timedelta(days=30)
72
  # thirty_days_ago_date = days_ago_30.strftime("%Y-%m-%d")
73
 
74
+
75
  # thirty_days_ago_date = self.currentdateavailability(thirty_days_ago_date)
76
 
77
+
78
  # curDate_index = self.data.index.get_loc(curDate)
79
  # thirty_days_ago_index = self.data.index.get_loc(thirty_days_ago_date)
80
 
81
+
82
  # return self.data.iloc[thirty_days_ago_index:curDate_index + 1]['Close'].values
83
  # else:
84
  # return self.data.iloc[-30:]['Close'].values