Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,20 +9,27 @@ from tools.final_answer import FinalAnswerTool
|
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
| 12 |
@tool
|
| 13 |
-
def get_last_prices(ticker:str)-> str:
|
| 14 |
-
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 15 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
"""
|
| 17 |
stock = yf.Ticker(ticker)
|
| 18 |
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
if df.empty:
|
| 22 |
-
raise ValueError(
|
| 23 |
|
| 24 |
last_price = df['Close'].iloc[-1]
|
| 25 |
-
|
| 26 |
return str(last_price)
|
| 27 |
|
| 28 |
@tool
|
|
|
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
+
|
| 13 |
@tool
|
| 14 |
+
def get_last_prices(ticker: str) -> str:
|
|
|
|
| 15 |
"""
|
| 16 |
+
Fetches the most recent closing price for the specified stock ticker from Yahoo Finance.
|
| 17 |
+
|
| 18 |
+
Args:
|
| 19 |
+
ticker (str): The stock symbol for which the last closing price is required (e.g., 'AAPL' for Apple).
|
| 20 |
+
|
| 21 |
+
Returns:
|
| 22 |
+
str: The most recent closing price of the stock 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
|