quantyi commited on
Commit
5a4b19c
·
verified ·
1 Parent(s): ddd9027

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
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: #it's import to specify the return type
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
- df = stock.history(period ="1d", interval = "1m")
 
20
 
21
  if df.empty:
22
- raise ValueError(f'Nessun dato disponibile per il ticker')
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