Spaces:
Sleeping
Sleeping
Add the missing `try` syntax in tool `get_stock_price`
Browse files
app.py
CHANGED
|
@@ -19,8 +19,9 @@ def get_stock_price(stock_symbol: str)-> str:
|
|
| 19 |
Returns:
|
| 20 |
current stock price in dollars.
|
| 21 |
"""
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
return f"The current stock price of {symbol.upper()} is ${price:.2f}."
|
| 25 |
except Exception as e:
|
| 26 |
return f"Failed to retrieve stock price for {symbol}: {str(e)}"
|
|
|
|
| 19 |
Returns:
|
| 20 |
current stock price in dollars.
|
| 21 |
"""
|
| 22 |
+
try:
|
| 23 |
+
ticker = yf.Ticker(stock_symbol.upper())
|
| 24 |
+
price = ticker.info["regularMarketPrice"]
|
| 25 |
return f"The current stock price of {symbol.upper()} is ${price:.2f}."
|
| 26 |
except Exception as e:
|
| 27 |
return f"Failed to retrieve stock price for {symbol}: {str(e)}"
|