mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-27 06:56:39 +03:00
refactor: move the decision log to tradingagents/decision_log.py
- it is the run's persistent record, used by the graph, backtest and CLI, not an agent utility; agents/utils is gone
This commit is contained in:
@@ -10,8 +10,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
|
||||||
from tradingagents.backtest import iter_grid, run_backtest, summarize
|
from tradingagents.backtest import iter_grid, run_backtest, summarize
|
||||||
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
|
|
||||||
DECISION = "Rating: Buy\n\nbuy it"
|
DECISION = "Rating: Buy\n\nbuy it"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import pytest
|
|||||||
|
|
||||||
from tradingagents.agents.managers.portfolio_manager import create_portfolio_manager
|
from tradingagents.agents.managers.portfolio_manager import create_portfolio_manager
|
||||||
from tradingagents.agents.schemas import PortfolioDecision, PortfolioRating
|
from tradingagents.agents.schemas import PortfolioDecision, PortfolioRating
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
from tradingagents.graph.propagation import Propagator
|
from tradingagents.graph.propagation import Propagator
|
||||||
from tradingagents.graph.reflection import Reflector
|
from tradingagents.graph.reflection import Reflector
|
||||||
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
||||||
@@ -886,12 +886,12 @@ class TestLegacyRemoval:
|
|||||||
|
|
||||||
def test_financial_situation_memory_removed(self):
|
def test_financial_situation_memory_removed(self):
|
||||||
"""FinancialSituationMemory must not be importable from the memory module."""
|
"""FinancialSituationMemory must not be importable from the memory module."""
|
||||||
import tradingagents.agents.utils.memory as m
|
import tradingagents.decision_log as m
|
||||||
assert not hasattr(m, "FinancialSituationMemory")
|
assert not hasattr(m, "FinancialSituationMemory")
|
||||||
|
|
||||||
def test_bm25_not_imported(self):
|
def test_bm25_not_imported(self):
|
||||||
"""rank_bm25 must not be present in the memory module namespace."""
|
"""rank_bm25 must not be present in the memory module namespace."""
|
||||||
import tradingagents.agents.utils.memory as m
|
import tradingagents.decision_log as m
|
||||||
assert not hasattr(m, "BM25Okapi")
|
assert not hasattr(m, "BM25Okapi")
|
||||||
|
|
||||||
def test_reflect_and_remember_removed(self):
|
def test_reflect_and_remember_removed(self):
|
||||||
@@ -957,7 +957,7 @@ class TestLegacyRemoval:
|
|||||||
def test_a_failed_reflection_leaves_the_entry_pending_and_lets_the_run_start(tmp_path, monkeypatch):
|
def test_a_failed_reflection_leaves_the_entry_pending_and_lets_the_run_start(tmp_path, monkeypatch):
|
||||||
"""Settling past decisions happens on the way into a new run, and reflection
|
"""Settling past decisions happens on the way into a new run, and reflection
|
||||||
calls an LLM. A transient failure there must not stop the new analysis."""
|
calls an LLM. A transient failure there must not stop the new analysis."""
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
||||||
|
|
||||||
graph = object.__new__(TradingAgentsGraph)
|
graph = object.__new__(TradingAgentsGraph)
|
||||||
@@ -990,7 +990,7 @@ def test_a_failed_reflection_leaves_the_entry_pending_and_lets_the_run_start(tmp
|
|||||||
def test_the_holding_window_is_configurable(tmp_path, monkeypatch):
|
def test_the_holding_window_is_configurable(tmp_path, monkeypatch):
|
||||||
"""A decision written for months should not be graded at a week without the
|
"""A decision written for months should not be graded at a week without the
|
||||||
operator choosing that window."""
|
operator choosing that window."""
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
||||||
|
|
||||||
graph = object.__new__(TradingAgentsGraph)
|
graph = object.__new__(TradingAgentsGraph)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
|
|
||||||
|
|
||||||
def _log(tmp_path):
|
def _log(tmp_path):
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ def test_load_reads_a_valid_file(tmp_path):
|
|||||||
# --- threading through the graph --------------------------------------------
|
# --- threading through the graph --------------------------------------------
|
||||||
|
|
||||||
def _bare_graph(tmp_path):
|
def _bare_graph(tmp_path):
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
from tradingagents.graph.propagation import Propagator
|
from tradingagents.graph.propagation import Propagator
|
||||||
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ def test_the_scale_quoted_in_a_prompt_does_not_become_the_rating():
|
|||||||
|
|
||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
def test_the_memory_log_records_review_rather_than_a_tradeable_hold(tmp_path):
|
def test_the_memory_log_records_review_rather_than_a_tradeable_hold(tmp_path):
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
|
|
||||||
log = TradingMemoryLog({"memory_log_path": str(tmp_path / "m.md")})
|
log = TradingMemoryLog({"memory_log_path": str(tmp_path / "m.md")})
|
||||||
log.store_decision("NVDA", "2026-01-05", REFUSAL)
|
log.store_decision("NVDA", "2026-01-05", REFUSAL)
|
||||||
@@ -75,7 +75,7 @@ def test_the_memory_log_records_review_rather_than_a_tradeable_hold(tmp_path):
|
|||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
def test_the_signal_and_the_log_agree_on_the_same_decision(tmp_path):
|
def test_the_signal_and_the_log_agree_on_the_same_decision(tmp_path):
|
||||||
from tradingagents.agents.rating import parse_rating
|
from tradingagents.agents.rating import parse_rating
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
|
|
||||||
log = TradingMemoryLog({"memory_log_path": str(tmp_path / "m.md")})
|
log = TradingMemoryLog({"memory_log_path": str(tmp_path / "m.md")})
|
||||||
for text in (INVERTED, REFUSAL, "**Rating**: Buy\n\nAccumulate."):
|
for text in (INVERTED, REFUSAL, "**Rating**: Buy\n\nAccumulate."):
|
||||||
@@ -89,8 +89,8 @@ def test_the_signal_and_the_log_agree_on_the_same_decision(tmp_path):
|
|||||||
@pytest.mark.unit
|
@pytest.mark.unit
|
||||||
def test_an_unscored_decision_is_left_out_of_the_backtest_figures(tmp_path):
|
def test_an_unscored_decision_is_left_out_of_the_backtest_figures(tmp_path):
|
||||||
"""REVIEW has no direction, so it cannot count for or against the system."""
|
"""REVIEW has no direction, so it cannot count for or against the system."""
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
|
||||||
from tradingagents.backtest import summarize
|
from tradingagents.backtest import summarize
|
||||||
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
|
|
||||||
log = TradingMemoryLog({"memory_log_path": str(tmp_path / "m.md")})
|
log = TradingMemoryLog({"memory_log_path": str(tmp_path / "m.md")})
|
||||||
log.store_decision("NVDA", "2026-01-05", "**Rating**: Buy\n\nx")
|
log.store_decision("NVDA", "2026-01-05", "**Rating**: Buy\n\nx")
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ from datetime import datetime, timedelta
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from tradingagents.agents.rating import RATING_REVIEW
|
from tradingagents.agents.rating import RATING_REVIEW
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
|
||||||
from tradingagents.dataflows.date_window import get_current_date
|
from tradingagents.dataflows.date_window import get_current_date
|
||||||
from tradingagents.dataflows.symbols import safe_ticker_component
|
from tradingagents.dataflows.symbols import safe_ticker_component
|
||||||
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ from typing import Any
|
|||||||
|
|
||||||
from tradingagents.agents.context import build_instrument_context, resolve_instrument_identity
|
from tradingagents.agents.context import build_instrument_context, resolve_instrument_identity
|
||||||
from tradingagents.agents.rating import parse_rating
|
from tradingagents.agents.rating import parse_rating
|
||||||
from tradingagents.agents.utils.memory import TradingMemoryLog
|
|
||||||
from tradingagents.dataflows.config import run_config, set_config
|
from tradingagents.dataflows.config import run_config, set_config
|
||||||
from tradingagents.dataflows.date_window import get_current_date
|
from tradingagents.dataflows.date_window import get_current_date
|
||||||
from tradingagents.dataflows.symbols import safe_ticker_component
|
from tradingagents.dataflows.symbols import safe_ticker_component
|
||||||
from tradingagents.dataflows.vendors.yahoo.market import get_closes
|
from tradingagents.dataflows.vendors.yahoo.market import get_closes
|
||||||
|
from tradingagents.decision_log import TradingMemoryLog
|
||||||
from tradingagents.default_config import DEFAULT_CONFIG
|
from tradingagents.default_config import DEFAULT_CONFIG
|
||||||
from tradingagents.llm_clients import create_llm_client
|
from tradingagents.llm_clients import create_llm_client
|
||||||
from tradingagents.reporting import write_report_tree
|
from tradingagents.reporting import write_report_tree
|
||||||
|
|||||||
Reference in New Issue
Block a user