docs: drop comments that narrate the next line

- about seventy '# Create/Initialize/Add ...' lines across graph, cli and dataflows, and the file-path headers; comments that give a reason stay
This commit is contained in:
Yijia-Xiao
2026-09-24 05:00:36 +00:00
parent 4a30cb1c0a
commit 825e6321ae
16 changed files with 0 additions and 80 deletions
-1
View File
@@ -61,5 +61,4 @@ def get_config() -> dict:
return deepcopy(_config)
# Initialize with default config
initialize_config()
@@ -83,7 +83,6 @@ def get_indicator(
series_type = required_series_type
try:
# Get indicator data for the period
if indicator == "close_50_sma":
data = _make_api_request("SMA", {
"symbol": symbol,
@@ -146,12 +145,10 @@ def get_indicator(
symbol, symbol, f"Alpha Vantage does not serve the {indicator} indicator"
)
# Parse CSV data and extract values for the date range
lines = data.strip().split('\n')
if len(lines) < 2:
return f"Error: No data returned for {indicator}"
# Parse header and data
header = [col.strip() for col in lines[0].split(',')]
try:
date_col_idx = header.index('time')
@@ -185,10 +182,8 @@ def get_indicator(
if len(values) > value_col_idx:
try:
date_str = values[date_col_idx].strip()
# Parse the date
date_dt = datetime.strptime(date_str, "%Y-%m-%d")
# Check if date is in our range
if before <= date_dt <= curr_date_dt:
value = values[value_col_idx].strip()
result_data.append((date_dt, value))
@@ -23,7 +23,6 @@ def get_stock(
Returns:
CSV string containing the daily adjusted time series data filtered to the date range.
"""
# Parse dates to determine the range
start_dt = datetime.strptime(start_date, "%Y-%m-%d")
today = datetime.now()
-5
View File
@@ -180,7 +180,6 @@ def get_stock_stats_indicators_window(
date_values.append((date_str, indicator_value))
current_dt = current_dt - relativedelta(days=1)
# Build the result string
ind_string = ""
for date_str, value in date_values:
ind_string += f"{date_str}: {value}\n"
@@ -225,16 +224,13 @@ def _get_stock_stats_bulk(
df = wrap(data)
df["Date"] = df["Date"].dt.strftime("%Y-%m-%d")
# Calculate the indicator for all rows at once
df[indicator] # This triggers stockstats to calculate the indicator
# Create a dictionary mapping date strings to indicator values
result_dict = {}
for _, row in df.iterrows():
date_str = row["Date"]
indicator_value = row[indicator]
# Handle NaN/None values
if pd.isna(indicator_value):
result_dict[date_str] = "N/A"
else:
@@ -274,7 +270,6 @@ def get_stockstats_indicator(
def get_closes(symbol: str, start_date: str, end_date: str) -> pd.Series:
"""Daily closes from ``start_date`` up to, not including, ``end_date``."""
canonical = normalize_symbol(symbol)
-4
View File
@@ -15,7 +15,6 @@ from tradingagents.dataflows.vendors.yahoo.ohlcv import yf_retry
def _extract_article_data(article: dict) -> dict:
"""Extract article data from yfinance news format (handles nested 'content' structure)."""
# Handle nested content structure
if "content" in article:
content = article["content"]
title = content.get("title", "No title")
@@ -23,11 +22,9 @@ def _extract_article_data(article: dict) -> dict:
provider = content.get("provider", {})
publisher = provider.get("displayName", "Unknown")
# Get URL from canonicalUrl or clickThroughUrl
url_obj = content.get("canonicalUrl") or content.get("clickThroughUrl") or {}
link = url_obj.get("url", "")
# Get publish date
pub_date_str = content.get("pubDate", "")
pub_date = None
if pub_date_str:
@@ -87,7 +84,6 @@ def get_news_yfinance(
stock = yf.Ticker(canonical)
news = yf_retry(lambda: stock.get_news(count=article_limit)) or []
# Parse date range for filtering
start_dt = datetime.strptime(start_date, "%Y-%m-%d")
end_dt = datetime.strptime(end_date, "%Y-%m-%d")
-2
View File
@@ -154,7 +154,6 @@ class TradingMemoryLog:
and tag_line.startswith(pending_prefix)
and tag_line.endswith("| pending]")
):
# Parse rating from the existing pending tag
fields = [f.strip() for f in tag_line[1:-1].split("|")]
rating = fields[2]
new_tag = self._resolved_tag(
@@ -189,7 +188,6 @@ class TradingMemoryLog:
text = self._log_path.read_text(encoding="utf-8")
blocks = text.split(self._SEPARATOR)
# Build lookup keyed by (trade_date, ticker) for O(1) dispatch
update_map = {(u["trade_date"], u["ticker"]): u for u in updates}
new_blocks = []
-2
View File
@@ -1,5 +1,3 @@
# TradingAgents/graph/__init__.py
from .conditional_logic import ConditionalLogic
from .propagation import Propagator
from .reflection import Reflector
-2
View File
@@ -1,5 +1,3 @@
# TradingAgents/graph/conditional_logic.py
from tradingagents.agents.state import AgentState
-2
View File
@@ -1,5 +1,3 @@
# TradingAgents/graph/propagation.py
from typing import Any
from tradingagents.agents.state import InvestDebateState, RiskDebateState
-2
View File
@@ -1,5 +1,3 @@
# TradingAgents/graph/reflection.py
from typing import Any
-10
View File
@@ -1,5 +1,3 @@
# TradingAgents/graph/setup.py
from typing import Any
from langgraph.graph import END, START, StateGraph
@@ -84,29 +82,24 @@ class GraphSetup:
"fundamentals": lambda: create_fundamentals_analyst(self.quick_thinking_llm),
}
# Create researcher and manager nodes
bull_researcher_node = create_bull_researcher(self.quick_thinking_llm)
bear_researcher_node = create_bear_researcher(self.quick_thinking_llm)
research_manager_node = create_research_manager(self.deep_thinking_llm)
trader_node = create_trader(self.quick_thinking_llm)
# Create risk analysis nodes
aggressive_analyst = create_aggressive_debator(self.quick_thinking_llm)
neutral_analyst = create_neutral_debator(self.quick_thinking_llm)
conservative_analyst = create_conservative_debator(self.quick_thinking_llm)
portfolio_manager_node = create_portfolio_manager(self.deep_thinking_llm)
# Create workflow
workflow = StateGraph(AgentState)
# Add analyst nodes to the graph
for spec in plan.specs:
workflow.add_node(spec.agent_node, analyst_factories[spec.key]())
workflow.add_node(spec.clear_node, create_msg_delete())
if spec.tools:
workflow.add_node(spec.tool_node, ToolNode(list(spec.tools)))
# Add other nodes
workflow.add_node("Bull Researcher", bull_researcher_node)
workflow.add_node("Bear Researcher", bear_researcher_node)
workflow.add_node("Research Manager", research_manager_node)
@@ -116,11 +109,8 @@ class GraphSetup:
workflow.add_node("Conservative Analyst", conservative_analyst)
workflow.add_node("Portfolio Manager", portfolio_manager_node)
# Define edges
# Start with the first analyst
workflow.add_edge(START, plan.specs[0].agent_node)
# Connect analysts in sequence
for i, spec in enumerate(plan.specs):
if spec.tools:
workflow.add_conditional_edges(
-7
View File
@@ -1,5 +1,3 @@
# TradingAgents/graph/trading_graph.py
import json
import logging
import os
@@ -64,17 +62,13 @@ class TradingAgentsGraph:
self.config = config or DEFAULT_CONFIG
self.callbacks = callbacks or []
# Update the interface's config
set_config(self.config)
# Create necessary directories
os.makedirs(self.config["data_cache_dir"], exist_ok=True)
os.makedirs(self.config["results_dir"], exist_ok=True)
# Initialize LLMs with provider-specific thinking configuration
llm_kwargs = build_llm_kwargs(self.config)
# Add callbacks to kwargs if provided (passed to LLM constructor)
if self.callbacks:
llm_kwargs["callbacks"] = self.callbacks
@@ -96,7 +90,6 @@ class TradingAgentsGraph:
self.memory_log = TradingMemoryLog(self.config)
# Initialize components
self.conditional_logic = ConditionalLogic(
max_debate_rounds=self.config["max_debate_rounds"],
max_risk_discuss_rounds=self.config["max_risk_discuss_rounds"],