quantyi commited on
Commit
5ad6f67
·
verified ·
1 Parent(s): 185b0cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -21,16 +21,21 @@ def get_last_prices(ticker: str) -> str:
21
  Returns:
22
  str: The last available closing price as a string.
23
  """
24
- stock = yf.Ticker(ticker)
25
-
26
- # Retrieve intraday data for the current day at one-minute intervals
27
- df = stock.history(period="1d", interval="1m")
28
-
29
- if df.empty:
30
- raise ValueError("No data available for the specified ticker.")
 
 
 
 
 
31
 
32
- last_price = df['Close'].iloc[-1]
33
- return str(last_price)
34
 
35
  @tool
36
  def get_current_time_in_timezone(timezone: str) -> str:
 
21
  Returns:
22
  str: The last available closing price as a string.
23
  """
24
+ try:
25
+
26
+ stock = yf.Ticker(ticker)
27
+
28
+ # Retrieve intraday data for the current day at one-minute intervals
29
+ df = stock.history(period="1d", interval="1m")
30
+
31
+ if df.empty:
32
+ raise ValueError("No data available for the specified ticker.")
33
+
34
+ last_price = df['Close'].iloc[-1]
35
+ return f"The currente price is {str(last_price)}"
36
 
37
+ except Exception as e:
38
+ return f"Error fetching price: {str(e)}"
39
 
40
  @tool
41
  def get_current_time_in_timezone(timezone: str) -> str: