Skip to content
Python

merge upstream main into crypto-analysis-mvp

CadeYu99ec63f966fe
diff --cc cli/main.py
index 6d2c25a13,33d110fb6..3fe3abedf
--- a/cli/main.py
+++ b/cli/main.py
@@@ -521,13 -520,22 +524,22 @@@ def get_user_selections()
)
analysis_date = get_analysis_date()
- # Step 3: Select analysts
+ # Step 3: Output language
console.print(
create_question_box(
- "Step 3: Analysts Team", "Select your LLM analyst agents for the analysis"
+ "Step 3: Output Language",
+ "Select the language for analyst reports and final decision"
+ )
+ )
+ output_language = ask_output_language()
+
+ # Step 4: Select analysts
+ console.print(
+ create_question_box(
+ "Step 4: Analysts Team", "Select your LLM analyst agents for the analysis"
)
)
- selected_analysts = select_analysts()
+ selected_analysts = select_analysts(asset_type)
console.print(
f"[green]Selected analysts:[/green] {', '.join(analyst.value for analyst in selected_analysts)}"
)
diff --cc cli/utils.py
index 6a02280cb,85c282edd..571f41dd7
--- a/cli/utils.py
+++ b/cli/utils.py
@@@ -3,7 -3,8 +3,8 @@@ from typing import List, Optional, Tupl
from rich.console import Console
-from cli.models import AnalystType
+from cli.models import AnalystType, AssetType
+ from tradingagents.llm_clients.model_catalog import get_model_options
console = Console()
diff --cc tradingagents/agents/analysts/market_analyst.py
index 2ebbb149c,fef8f7519..01020962e
--- a/tradingagents/agents/analysts/market_analyst.py
+++ b/tradingagents/agents/analysts/market_analyst.py
@@@ -9,9 -12,7 +12,10 @@@ def create_market_analyst(llm)
def market_analyst_node(state):
current_date = state["trade_date"]
- ticker = state["company_of_interest"]
- instrument_context = build_instrument_context(state["company_of_interest"])
+ asset_type = state.get("asset_type", "stock")
- asset_label = "stock" if asset_type == "stock" else "crypto asset"
++ instrument_context = build_instrument_context(
++ state["company_of_interest"], asset_type
++ )
tools = [
get_stock_data,
diff --cc tradingagents/agents/analysts/news_analyst.py
index f271d0d9f,e0fe93c5c..90917d168
--- a/tradingagents/agents/analysts/news_analyst.py
+++ b/tradingagents/agents/analysts/news_analyst.py
@@@ -8,9 -11,7 +11,11 @@@ from tradingagents.dataflows.config imp
def create_news_analyst(llm):
def news_analyst_node(state):
current_date = state["trade_date"]
- ticker = state["company_of_interest"]
- instrument_context = build_instrument_context(state["company_of_interest"])
+ asset_type = state.get("asset_type", "stock")
+ asset_label = "company" if asset_type == "stock" else "asset"
++ instrument_context = build_instrument_context(
++ state["company_of_interest"], asset_type
++ )
tools = [
get_news,
@@@ -18,8 -19,9 +23,9 @@@
]
system_message = (
- f"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Use the available tools: get_news(query, start_date, end_date) for {asset_label}-specific or targeted news searches, and get_global_news(curr_date, look_back_days, limit) for broader macroeconomic news. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions."
- "You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Use the available tools: get_news(query, start_date, end_date) for company-specific or targeted news searches, and get_global_news(curr_date, look_back_days, limit) for broader macroeconomic news. Provide specific, actionable insights with supporting evidence to help traders make informed decisions."
++ f"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Use the available tools: get_news(query, start_date, end_date) for {asset_label}-specific or targeted news searches, and get_global_news(curr_date, look_back_days, limit) for broader macroeconomic news. Provide specific, actionable insights with supporting evidence to help traders make informed decisions."
+ """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."""
+ + get_language_instruction()
)
prompt = ChatPromptTemplate.from_messages(
diff --cc tradingagents/agents/analysts/social_media_analyst.py
index 6552456dd,34a53c462..d47ce6442
--- a/tradingagents/agents/analysts/social_media_analyst.py
+++ b/tradingagents/agents/analysts/social_media_analyst.py
@@@ -8,17 -6,16 +6,20 @@@ from tradingagents.dataflows.config imp
def create_social_media_analyst(llm):
def social_media_analyst_node(state):
current_date = state["trade_date"]
- ticker = state["company_of_interest"]
- instrument_context = build_instrument_context(state["company_of_interest"])
+ asset_type = state.get("asset_type", "stock")
+ subject_label = "company" if asset_type == "stock" else "asset"
++ instrument_context = build_instrument_context(
++ state["company_of_interest"], asset_type
++ )
tools = [
get_news,
]
system_message = (
- f"You are a social media and targeted news researcher/analyst tasked with analyzing social media posts, recent {subject_label} news, and public sentiment for a specific {subject_label} over the past week. You will be given an asset identifier and your objective is to write a comprehensive long report detailing your analysis, insights, and implications for traders and investors after looking at social media, sentiment, and recent news related to that {subject_label}. Use the get_news(query, start_date, end_date) tool to search for {subject_label}-specific news and social media discussions. Try to look at all sources possible from social media to sentiment to news. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions."
- + """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read.""",
- "You are a social media and company specific news researcher/analyst tasked with analyzing social media posts, recent company news, and public sentiment for a specific company over the past week. You will be given a company's name your objective is to write a comprehensive long report detailing your analysis, insights, and implications for traders and investors on this company's current state after looking at social media and what people are saying about that company, analyzing sentiment data of what people feel each day about the company, and looking at recent company news. Use the get_news(query, start_date, end_date) tool to search for company-specific news and social media discussions. Try to look at all sources possible from social media to sentiment to news. Provide specific, actionable insights with supporting evidence to help traders make informed decisions."
++ f"You are a social media and targeted news researcher/analyst tasked with analyzing social media posts, recent {subject_label} news, and public sentiment for a specific {subject_label} over the past week. You will be given an asset identifier and your objective is to write a comprehensive long report detailing your analysis, insights, and implications for traders and investors after looking at social media, sentiment, and recent news related to that {subject_label}. Use the get_news(query, start_date, end_date) tool to search for {subject_label}-specific news and social media discussions. Try to look at all sources possible from social media to sentiment to news. Provide specific, actionable insights with supporting evidence to help traders make informed decisions."
+ + """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."""
+ + get_language_instruction()
)
prompt = ChatPromptTemplate.from_messages(
diff --cc tradingagents/agents/trader/trader.py
index a1a285331,07e9f262c..72a16dd6b
--- a/tradingagents/agents/trader/trader.py
+++ b/tradingagents/agents/trader/trader.py
@@@ -6,8 -6,7 +6,8 @@@ from tradingagents.agents.utils.agent_u
def create_trader(llm, memory):
def trader_node(state, name):
company_name = state["company_of_interest"]
- instrument_context = build_instrument_context(company_name)
+ asset_type = state.get("asset_type", "stock")
- target_label = "company" if asset_type == "stock" else "asset"
++ instrument_context = build_instrument_context(company_name, asset_type)
investment_plan = state["investment_plan"]
market_research_report = state["market_report"]
sentiment_report = state["sentiment_report"]
diff --cc tradingagents/agents/utils/agent_utils.py
index b329a3e97,4ba40a803..c0fb44205
--- a/tradingagents/agents/utils/agent_utils.py
+++ b/tradingagents/agents/utils/agent_utils.py
@@@ -19,6 -19,29 +19,36 @@@ from tradingagents.agents.utils.news_da
get_global_news
)
+
+ def get_language_instruction() -> str:
+ """Return a prompt instruction for the configured output language.
+
+ Returns empty string when English (default), so no extra tokens are used.
+ Only applied to user-facing agents (analysts, portfolio manager).
+ Internal debate agents stay in English for reasoning quality.
+ """
+ from tradingagents.dataflows.config import get_config
+ lang = get_config().get("output_language", "English")
+ if lang.strip().lower() == "english":
+ return ""
+ return f" Write your entire response in {lang}."
+
+
-def build_instrument_context(ticker: str) -> str:
++def build_instrument_context(ticker: str, asset_type: str = "stock") -> str:
+ """Describe the exact instrument so agents preserve exchange-qualified tickers."""
++ instrument_label = "asset" if asset_type == "crypto" else "instrument"
++ extra_hint = (
++ " Treat it as a crypto asset rather than a company, and do not assume company fundamentals are available."
++ if asset_type == "crypto"
++ else ""
++ )
+ return (
- f"The instrument to analyze is `{ticker}`. "
++ f"The {instrument_label} to analyze is `{ticker}`. "
+ "Use this exact ticker in every tool call, report, and recommendation, "
- "preserving any exchange suffix (e.g. `.TO`, `.L`, `.HK`, `.T`)."
++ "preserving any exchange suffix (e.g. `.TO`, `.L`, `.HK`, `.T`, `-USD`)."
++ + extra_hint
+ )
+
def create_msg_delete():
def delete_messages(state):
"""Clear messages and add placeholder for Anthropic compatibility"""