Spaces:
Sleeping
Sleeping
Fix the variable name `stock_symbol`
Browse files
app.py
CHANGED
@@ -18,14 +18,15 @@ def get_stock_price(stock_symbol: str)-> str:
|
|
18 |
identify a publicly traded company's shares on a stock exchange, e.g., MSFT, AMZN.
|
19 |
|
20 |
Returns:
|
21 |
-
current stock price in dollars
|
|
|
22 |
"""
|
23 |
try:
|
24 |
ticker = yf.Ticker(stock_symbol.upper())
|
25 |
price = ticker.info["regularMarketPrice"]
|
26 |
-
return f"The current stock price of {
|
27 |
except Exception as e:
|
28 |
-
return f"Failed to retrieve stock price for {
|
29 |
|
30 |
@tool
|
31 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
18 |
identify a publicly traded company's shares on a stock exchange, e.g., MSFT, AMZN.
|
19 |
|
20 |
Returns:
|
21 |
+
one sentence which contains the current stock price in dollars if the Yahoo Finance API
|
22 |
+
call succeeds and one error message otherwise.
|
23 |
"""
|
24 |
try:
|
25 |
ticker = yf.Ticker(stock_symbol.upper())
|
26 |
price = ticker.info["regularMarketPrice"]
|
27 |
+
return f"The current stock price of {stock_symbol.upper()} is ${price:.2f}."
|
28 |
except Exception as e:
|
29 |
+
return f"Failed to retrieve stock price for {stock_symbol}: {str(e)}"
|
30 |
|
31 |
@tool
|
32 |
def get_current_time_in_timezone(timezone: str) -> str:
|