mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-27 15:02:39 +03:00
refactor(agents): organise the agents package by what each module holds
- tools.py: the analysts' data tools, previously seven modules under utils - context.py (was agent_utils, without its tool re-exports), state.py, rating.py and structured.py sit beside schemas.py - every role package has an __init__
This commit is contained in:
@@ -15,14 +15,7 @@ from langchain_core.messages import AIMessage
|
||||
from langgraph.graph import END, START, MessagesState, StateGraph
|
||||
from langgraph.prebuilt import ToolNode
|
||||
|
||||
from tradingagents.agents.utils import (
|
||||
core_stock_tools,
|
||||
fundamental_data_tools,
|
||||
macro_data_tools,
|
||||
market_data_validation_tools,
|
||||
news_data_tools,
|
||||
technical_indicators_tools,
|
||||
)
|
||||
from tradingagents.agents import tools
|
||||
from tradingagents.dataflows.date_window import as_of, as_of_window
|
||||
|
||||
TRADE_DATE = "2026-08-14"
|
||||
@@ -56,16 +49,16 @@ def test_as_of_window(start, end, expected):
|
||||
|
||||
|
||||
DATED_TOOLS = [
|
||||
core_stock_tools.get_stock_data,
|
||||
fundamental_data_tools.get_fundamentals,
|
||||
fundamental_data_tools.get_balance_sheet,
|
||||
fundamental_data_tools.get_cashflow,
|
||||
fundamental_data_tools.get_income_statement,
|
||||
news_data_tools.get_news,
|
||||
news_data_tools.get_global_news,
|
||||
technical_indicators_tools.get_indicators,
|
||||
macro_data_tools.get_macro_indicators,
|
||||
market_data_validation_tools.get_verified_market_snapshot,
|
||||
tools.get_stock_data,
|
||||
tools.get_fundamentals,
|
||||
tools.get_balance_sheet,
|
||||
tools.get_cashflow,
|
||||
tools.get_income_statement,
|
||||
tools.get_news,
|
||||
tools.get_global_news,
|
||||
tools.get_indicators,
|
||||
tools.get_macro_indicators,
|
||||
tools.get_verified_market_snapshot,
|
||||
]
|
||||
|
||||
|
||||
@@ -95,28 +88,28 @@ def _run(tool, args, module):
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_statement_tool_with_omitted_date_uses_the_run_date():
|
||||
args = _run(fundamental_data_tools.get_balance_sheet, {"ticker": "AAPL"}, fundamental_data_tools)
|
||||
args = _run(tools.get_balance_sheet, {"ticker": "AAPL"}, tools)
|
||||
assert args[-1] == TRADE_DATE # #1331: an omitted date no longer means unfiltered
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_future_curr_date_from_the_model_is_clamped():
|
||||
args = _run(fundamental_data_tools.get_fundamentals,
|
||||
{"ticker": "AAPL", "curr_date": "2026-09-14"}, fundamental_data_tools)
|
||||
args = _run(tools.get_fundamentals,
|
||||
{"ticker": "AAPL", "curr_date": "2026-09-14"}, tools)
|
||||
assert args == ("get_fundamentals", "AAPL", TRADE_DATE)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_future_window_from_the_model_is_clamped():
|
||||
args = _run(core_stock_tools.get_stock_data,
|
||||
{"symbol": "AAPL", "start_date": "2026-08-01", "end_date": "2026-09-14"}, core_stock_tools)
|
||||
args = _run(tools.get_stock_data,
|
||||
{"symbol": "AAPL", "start_date": "2026-08-01", "end_date": "2026-09-14"}, tools)
|
||||
assert args == ("get_stock_data", "AAPL", "2026-08-01", TRADE_DATE)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_direct_call_without_state_is_unchanged():
|
||||
with mock.patch.object(news_data_tools, "route_to_vendor", return_value="ok") as routed:
|
||||
news_data_tools.get_news.func("AAPL", "2026-09-01", "2026-09-08")
|
||||
with mock.patch.object(tools, "route_to_vendor", return_value="ok") as routed:
|
||||
tools.get_news.func("AAPL", "2026-09-01", "2026-09-08")
|
||||
assert routed.call_args.args == ("get_news", "AAPL", "2026-09-01", "2026-09-08")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user