Dataflow: Robustified
route_to_vendor to treat empty/whitespace-only results as failures, ensuring the fallback chain continues to the next vendor. Analyst Nodes: Removed destructive logic that was overwriting real company names with ticker symbols in the anonymizer state. Fixed News Vendors: Resolved a TypeError in Google news results and removed the non-functional OpenAI news implementations. Report Generator: Fixed a NameError related to sys and restored path-parsing logic in
This commit is contained in:
parent
92a47f1994
commit
d0f229a444
|
|
@ -1,8 +1,17 @@
|
|||
import os
|
||||
import sys
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
# Add project root to sys.path to allow importing tradingagents
|
||||
current_dir = Path(__file__).parent
|
||||
sys.path.append(str(current_dir.parent))
|
||||
|
||||
try:
|
||||
from tradingagents.utils.anonymizer import TickerAnonymizer
|
||||
ANONYMIZER_AVAILABLE = True
|
||||
except ImportError:
|
||||
ANONYMIZER_AVAILABLE = False
|
||||
|
||||
TEMPLATE = """<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
|
@ -216,6 +225,13 @@ def generate_report(report_dir):
|
|||
date = "Unknown Date"
|
||||
ticker = "Unknown Ticker"
|
||||
|
||||
anonymizer = None
|
||||
if ANONYMIZER_AVAILABLE:
|
||||
anonymizer = TickerAnonymizer()
|
||||
real_ticker = anonymizer.deanonymize_ticker(ticker)
|
||||
if real_ticker:
|
||||
ticker = f"{real_ticker} ({ticker})"
|
||||
|
||||
reports = {}
|
||||
|
||||
# Read all markdown files
|
||||
|
|
@ -223,6 +239,11 @@ def generate_report(report_dir):
|
|||
try:
|
||||
with open(file, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Deanonymize content if possible
|
||||
if anonymizer:
|
||||
content = anonymizer.deanonymize_text(content)
|
||||
|
||||
reports[file.name] = content
|
||||
except Exception as e:
|
||||
print(f"Failed to read {file}: {e}")
|
||||
|
|
|
|||
|
|
@ -14,11 +14,6 @@ def create_fundamentals_analyst(llm):
|
|||
def fundamentals_analyst_node(state):
|
||||
current_date = state["trade_date"]
|
||||
real_ticker = state["company_of_interest"]
|
||||
company_name = state["company_of_interest"] # Acting as placeholder name
|
||||
|
||||
# BLINDFIRE PROTOCOL: Anonymize Ticker
|
||||
# We set name here too just in case fundamentals runs first or independently
|
||||
anonymizer.set_company_name(real_ticker, company_name)
|
||||
ticker = anonymizer.anonymize_ticker(real_ticker)
|
||||
|
||||
tools = [
|
||||
|
|
|
|||
|
|
@ -20,10 +20,7 @@ def create_market_analyst(llm):
|
|||
def market_analyst_node(state):
|
||||
current_date = state["trade_date"]
|
||||
real_ticker = state["company_of_interest"]
|
||||
company_name = state["company_of_interest"] # In this context acting as name too
|
||||
|
||||
# BLINDFIRE PROTOCOL: Anonymize Ticker
|
||||
anonymizer.set_company_name(real_ticker, company_name)
|
||||
ticker = anonymizer.anonymize_ticker(real_ticker)
|
||||
|
||||
# NOTE: We continue to use 'ticker' variable name but it now holds 'ASSET_XXX'
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@ def create_social_media_analyst(llm):
|
|||
def social_media_analyst_node(state):
|
||||
current_date = state["trade_date"]
|
||||
real_ticker = state["company_of_interest"]
|
||||
company_name = state["company_of_interest"]
|
||||
|
||||
# BLINDFIRE PROTOCOL: Anonymize Ticker
|
||||
anonymizer.set_company_name(real_ticker, company_name)
|
||||
ticker = anonymizer.anonymize_ticker(real_ticker)
|
||||
|
||||
tools = [
|
||||
|
|
|
|||
|
|
@ -181,6 +181,21 @@ class TradingAgentsGraph:
|
|||
self.reset_memory()
|
||||
|
||||
self.ticker = company_name
|
||||
|
||||
# 2. Register real company name for anonymization
|
||||
try:
|
||||
from tradingagents.utils.anonymizer import TickerAnonymizer
|
||||
import yfinance as yf
|
||||
anonymizer = TickerAnonymizer()
|
||||
ticker_obj = yf.Ticker(company_name)
|
||||
info = ticker_obj.info
|
||||
full_name = info.get("longName") or info.get("shortName")
|
||||
if full_name:
|
||||
# print(f"DEBUG: Registering company name for {company_name}: {full_name}")
|
||||
anonymizer.set_company_name(company_name, full_name)
|
||||
except Exception as e:
|
||||
# print(f"DEBUG: Failed to fetch company name for {company_name}: {e}")
|
||||
pass
|
||||
|
||||
# Initialize state
|
||||
init_agent_state = self.propagator.create_initial_state(
|
||||
|
|
|
|||
Loading…
Reference in New Issue