Merge #567 — analysis-only crypto asset mode

feat: add analysis-only crypto asset mode
This commit is contained in:
Yijia Xiao
2026-05-17 00:01:49 -07:00
committed by GitHub
13 changed files with 150 additions and 18 deletions

View File

@@ -12,7 +12,10 @@ def create_market_analyst(llm):
def market_analyst_node(state):
current_date = state["trade_date"]
instrument_context = build_instrument_context(state["company_of_interest"])
asset_type = state.get("asset_type", "stock")
instrument_context = build_instrument_context(
state["company_of_interest"], asset_type
)
tools = [
get_stock_data,

View File

@@ -11,7 +11,11 @@ from tradingagents.dataflows.config import get_config
def create_news_analyst(llm):
def news_analyst_node(state):
current_date = state["trade_date"]
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,
@@ -19,7 +23,7 @@ def create_news_analyst(llm):
]
system_message = (
"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()
)

View File

@@ -12,8 +12,15 @@ def create_bear_researcher(llm):
sentiment_report = state["sentiment_report"]
news_report = state["news_report"]
fundamentals_report = state["fundamentals_report"]
asset_type = state.get("asset_type", "stock")
target_label = "stock" if asset_type == "stock" else "asset"
fundamentals_label = (
"Company fundamentals report"
if asset_type == "stock"
else "Asset fundamentals report (may be unavailable for crypto)"
)
prompt = f"""You are a Bear Analyst making the case against investing in the stock. Your goal is to present a well-reasoned argument emphasizing risks, challenges, and negative indicators. Leverage the provided research and data to highlight potential downsides and counter bullish arguments effectively.
prompt = f"""You are a Bear Analyst making the case against investing in the {target_label}. Your goal is to present a well-reasoned argument emphasizing risks, challenges, and negative indicators. Leverage the provided research and data to highlight potential downsides and counter bullish arguments effectively.
Key points to focus on:
@@ -28,10 +35,10 @@ Resources available:
Market research report: {market_research_report}
Social media sentiment report: {sentiment_report}
Latest world affairs news: {news_report}
Company fundamentals report: {fundamentals_report}
{fundamentals_label}: {fundamentals_report}
Conversation history of the debate: {history}
Last bull argument: {current_response}
Use this information to deliver a compelling bear argument, refute the bull's claims, and engage in a dynamic debate that demonstrates the risks and weaknesses of investing in the stock.
Use this information to deliver a compelling bear argument, refute the bull's claims, and engage in a dynamic debate that demonstrates the risks and weaknesses of investing in the {target_label}.
""" + get_language_instruction()
response = llm.invoke(prompt)

View File

@@ -12,8 +12,15 @@ def create_bull_researcher(llm):
sentiment_report = state["sentiment_report"]
news_report = state["news_report"]
fundamentals_report = state["fundamentals_report"]
asset_type = state.get("asset_type", "stock")
target_label = "stock" if asset_type == "stock" else "asset"
fundamentals_label = (
"Company fundamentals report"
if asset_type == "stock"
else "Asset fundamentals report (may be unavailable for crypto)"
)
prompt = f"""You are a Bull Analyst advocating for investing in the stock. Your task is to build a strong, evidence-based case emphasizing growth potential, competitive advantages, and positive market indicators. Leverage the provided research and data to address concerns and counter bearish arguments effectively.
prompt = f"""You are a Bull Analyst advocating for investing in the {target_label}. Your task is to build a strong, evidence-based case emphasizing growth potential, competitive advantages, and positive market indicators. Leverage the provided research and data to address concerns and counter bearish arguments effectively.
Key points to focus on:
- Growth Potential: Highlight the company's market opportunities, revenue projections, and scalability.
@@ -26,7 +33,7 @@ Resources available:
Market research report: {market_research_report}
Social media sentiment report: {sentiment_report}
Latest world affairs news: {news_report}
Company fundamentals report: {fundamentals_report}
{fundamentals_label}: {fundamentals_report}
Conversation history of the debate: {history}
Last bear argument: {current_response}
Use this information to deliver a compelling bull argument, refute the bear's concerns, and engage in a dynamic debate that demonstrates the strengths of the bull position.

View File

@@ -22,7 +22,8 @@ def create_trader(llm):
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")
instrument_context = build_instrument_context(company_name, asset_type)
investment_plan = state["investment_plan"]
messages = [

View File

@@ -45,6 +45,7 @@ class RiskDebateState(TypedDict):
class AgentState(MessagesState):
company_of_interest: Annotated[str, "Company that we are interested in trading"]
asset_type: Annotated[str, "Asset type under analysis such as stock or crypto"]
trade_date: Annotated[str, "What date we are trading at"]
sender: Annotated[str, "Agent that sent this message"]

View File

@@ -36,12 +36,19 @@ def get_language_instruction() -> str:
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():

View File

@@ -16,12 +16,17 @@ class Propagator:
self.max_recur_limit = max_recur_limit
def create_initial_state(
self, company_name: str, trade_date: str, past_context: str = ""
self,
company_name: str,
trade_date: str,
asset_type: str = "stock",
past_context: str = "",
) -> Dict[str, Any]:
"""Create the initial state for the agent graph."""
return {
"messages": [("human", company_name)],
"company_of_interest": company_name,
"asset_type": asset_type,
"trade_date": str(trade_date),
"past_context": past_context,
"investment_debate_state": InvestDebateState(