Clear the deferred full-repo lint backlog so the whole tree passes the strict ruff select (E,W,F,I,B,UP,C4,SIM). Mechanical fixes dominate: import sorting, pep585/604 annotations, dropped dead imports, and whitespace. The few semantic changes are behavior-preserving: declare __all__ on the agent_utils and alpha_vantage re-export hubs; expand 'from x import *' to explicit names; use immutable tuple defaults instead of mutable list defaults; contextlib.suppress for try/except/pass; and narrow an over-broad assertRaises.
36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
from typing import Annotated
|
|
|
|
from langchain_core.tools import tool
|
|
|
|
from tradingagents.dataflows.interface import route_to_vendor
|
|
|
|
|
|
@tool
|
|
def get_indicators(
|
|
symbol: Annotated[str, "ticker symbol of the company"],
|
|
indicator: Annotated[str, "technical indicator to get the analysis and report of"],
|
|
curr_date: Annotated[str, "The current trading date you are trading on, YYYY-mm-dd"],
|
|
look_back_days: Annotated[int, "how many days to look back"] = 30,
|
|
) -> str:
|
|
"""
|
|
Retrieve a single technical indicator for a given ticker symbol.
|
|
Uses the configured technical_indicators vendor.
|
|
Args:
|
|
symbol (str): Ticker symbol of the company, e.g. AAPL, TSM
|
|
indicator (str): A single technical indicator name, e.g. 'rsi', 'macd'. Call this tool once per indicator.
|
|
curr_date (str): The current trading date you are trading on, YYYY-mm-dd
|
|
look_back_days (int): How many days to look back, default is 30
|
|
Returns:
|
|
str: A formatted dataframe containing the technical indicators for the specified ticker symbol and indicator.
|
|
"""
|
|
# LLMs sometimes pass multiple indicators as a comma-separated string;
|
|
# split and process each individually.
|
|
indicators = [i.strip().lower() for i in indicator.split(",") if i.strip()]
|
|
results = []
|
|
for ind in indicators:
|
|
try:
|
|
results.append(route_to_vendor("get_indicators", symbol, ind, curr_date, look_back_days))
|
|
except ValueError as e:
|
|
results.append(str(e))
|
|
return "\n\n".join(results)
|