mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-27 06:56:39 +03:00
refactor: gather the memory log, settlement and reflection in tradingagents/memory
- memory/log.py holds TradingMemoryLog, still imported from tradingagents.memory - graph/settlement.py and graph/reflection.py move to memory/; Reflector leaves tradingagents.graph's exports
This commit is contained in:
@@ -148,7 +148,7 @@ def test_settling_reads_the_graphs_own_config(monkeypatch):
|
||||
graph = _graph(config)
|
||||
graph.memory_log = graph.reflector = None # the settlement below is a stand-in
|
||||
seen = []
|
||||
from tradingagents.graph import settlement
|
||||
from tradingagents.memory import settlement
|
||||
|
||||
monkeypatch.setattr(settlement, "settle_pending",
|
||||
lambda *a: seen.append(get_vendor("core_stock_apis", "get_stock_data")))
|
||||
|
||||
@@ -7,11 +7,10 @@ import pytest
|
||||
|
||||
from tradingagents.agents.managers.portfolio_manager import create_portfolio_manager
|
||||
from tradingagents.agents.schemas import PortfolioDecision, PortfolioRating
|
||||
from tradingagents.graph import settlement
|
||||
from tradingagents.graph.propagation import Propagator
|
||||
from tradingagents.graph.reflection import Reflector
|
||||
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
||||
from tradingagents.memory import TradingMemoryLog
|
||||
from tradingagents.memory import TradingMemoryLog, settlement
|
||||
from tradingagents.memory.reflection import Reflector
|
||||
|
||||
_SEP = TradingMemoryLog._SEPARATOR
|
||||
|
||||
@@ -1004,7 +1003,7 @@ def test_the_holding_window_is_configurable(tmp_path, monkeypatch):
|
||||
def test_the_reflection_states_the_window_it_judges():
|
||||
"""Judging a months-long thesis on a week's alpha, without saying so, turns
|
||||
a scope mismatch into a lesson that the call was wrong."""
|
||||
from tradingagents.graph.reflection import Reflector
|
||||
from tradingagents.memory.reflection import Reflector
|
||||
|
||||
prompt = Reflector(None)._system_prompt(holding_days=5)
|
||||
assert "5" in prompt and "trading day" in prompt
|
||||
|
||||
@@ -10,7 +10,7 @@ import pandas as pd
|
||||
import tradingagents.agents.context as au
|
||||
import tradingagents.dataflows.vendors.yahoo.market as yahoo_market
|
||||
import tradingagents.dataflows.vendors.yahoo.news as ynews
|
||||
from tradingagents.graph import settlement
|
||||
from tradingagents.memory import settlement
|
||||
|
||||
|
||||
def test_identity_lookup_normalizes_symbol(monkeypatch):
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from .conditional_logic import ConditionalLogic
|
||||
from .propagation import Propagator
|
||||
from .reflection import Reflector
|
||||
from .setup import GraphSetup
|
||||
from .trading_graph import TradingAgentsGraph
|
||||
|
||||
@@ -9,5 +8,4 @@ __all__ = [
|
||||
"ConditionalLogic",
|
||||
"GraphSetup",
|
||||
"Propagator",
|
||||
"Reflector",
|
||||
]
|
||||
|
||||
@@ -13,14 +13,13 @@ from tradingagents.dataflows.date_window import get_current_date
|
||||
from tradingagents.dataflows.symbols import safe_ticker_component
|
||||
from tradingagents.default_config import DEFAULT_CONFIG
|
||||
from tradingagents.llm_clients import build_llm_kwargs, create_llm_client
|
||||
from tradingagents.memory import TradingMemoryLog
|
||||
from tradingagents.memory import TradingMemoryLog, settlement
|
||||
from tradingagents.memory.reflection import Reflector
|
||||
from tradingagents.reporting import write_report_tree
|
||||
|
||||
from . import settlement
|
||||
from .checkpointer import checkpoint_step, clear_checkpoint, get_checkpointer, thread_id
|
||||
from .conditional_logic import ConditionalLogic
|
||||
from .propagation import Propagator
|
||||
from .reflection import Reflector
|
||||
from .setup import GraphSetup
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
"""The memory log: each decision recorded as made, settled against the market, and reflected on.
|
||||
|
||||
``log`` keeps the entries, ``settlement`` measures a decision's return once its
|
||||
holding window has traded, and ``reflection`` turns that outcome into a lesson
|
||||
the next run of the same ticker reads.
|
||||
"""
|
||||
|
||||
from tradingagents.memory.log import TradingMemoryLog
|
||||
|
||||
__all__ = ["TradingMemoryLog"]
|
||||
Reference in New Issue
Block a user