Spaces:
Sleeping
Sleeping
Update actor with yahooquery to search actions in yahoo finance
Browse files
app.py
CHANGED
@@ -8,13 +8,20 @@ from Gradio_UI import GradioUI
|
|
8 |
from yahooquery import search, Ticker
|
9 |
|
10 |
@tool
|
11 |
-
def busqueda_valor_accion(nombre_empresa:str)-> str:
|
12 |
-
"""
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
"""
|
19 |
resultado = search(nombre_empresa)
|
20 |
if "quotes" in resultado and resultado["quotes"]:
|
@@ -22,15 +29,16 @@ def busqueda_valor_accion(nombre_empresa:str)-> str:
|
|
22 |
ticker = primer_resultado["symbol"]
|
23 |
precio_accion = Ticker(ticker)
|
24 |
|
25 |
-
#
|
26 |
return f"""
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
"""
|
32 |
else:
|
33 |
-
return "No
|
|
|
34 |
|
35 |
@tool
|
36 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
8 |
from yahooquery import search, Ticker
|
9 |
|
10 |
@tool
|
11 |
+
def busqueda_valor_accion(nombre_empresa: str) -> str:
|
12 |
+
"""A tool that retrieves stock price information from Yahoo Finance.
|
13 |
+
The tool requires the **full name** of a company (e.g., "Amazon")
|
14 |
+
and returns key stock details, including:
|
15 |
+
|
16 |
+
- Company name
|
17 |
+
- Stock symbol (Ticker)
|
18 |
+
- Market/exchange
|
19 |
+
- Current stock price
|
20 |
+
|
21 |
+
**Note:** The input should be the company name (e.g., "Amazon"), **not** the stock symbol (e.g., "AMZN").
|
22 |
+
|
23 |
+
Args:
|
24 |
+
nombre_empresa (str): The full name of the company to look up.
|
25 |
"""
|
26 |
resultado = search(nombre_empresa)
|
27 |
if "quotes" in resultado and resultado["quotes"]:
|
|
|
29 |
ticker = primer_resultado["symbol"]
|
30 |
precio_accion = Ticker(ticker)
|
31 |
|
32 |
+
# Unify prints with line breaks
|
33 |
return f"""
|
34 |
+
Name: {primer_resultado['longname']}
|
35 |
+
Symbol (Ticker): {ticker}
|
36 |
+
Market: {primer_resultado['exchange']}
|
37 |
+
The stock price is: ${precio_accion.price[ticker]['regularMarketPrice']}
|
38 |
"""
|
39 |
else:
|
40 |
+
return "No results found. Please check the company name and try again."
|
41 |
+
|
42 |
|
43 |
@tool
|
44 |
def get_current_time_in_timezone(timezone: str) -> str:
|