mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-22 12:45:35 +03:00
- both manager prompts and both rating fields listed "materially conflicting" as a Hold condition, and every bull/bear and risk debate is conflicting, so a modest directional edge collapsed to Hold - state one rule at all four sites: conflict alone is not a reason to Hold, commit to the stronger side sized by how decisively it wins, and Hold only when the evidence is still balanced after weighing or too thin for a call - a modest bull edge now resolves to Overweight; a genuinely balanced debate still resolves to Hold #1321
71 lines
2.8 KiB
Python
71 lines
2.8 KiB
Python
"""Research Manager: turns the bull/bear debate into a structured investment plan for the trader."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from tradingagents.agents.schemas import ResearchPlan, render_research_plan
|
|
from tradingagents.agents.utils.agent_utils import (
|
|
get_instrument_context_from_state,
|
|
get_language_instruction,
|
|
)
|
|
from tradingagents.agents.utils.structured import (
|
|
NO_EXTERNAL_TOOLS,
|
|
bind_structured,
|
|
invoke_structured_or_freetext,
|
|
)
|
|
|
|
|
|
def create_research_manager(llm):
|
|
structured_llm = bind_structured(llm, ResearchPlan, "Research Manager")
|
|
|
|
def research_manager_node(state) -> dict:
|
|
instrument_context = get_instrument_context_from_state(state)
|
|
history = state["investment_debate_state"].get("history", "")
|
|
|
|
investment_debate_state = state["investment_debate_state"]
|
|
|
|
prompt = f"""As the Research Manager and debate facilitator, your role is to critically evaluate this round of debate and deliver a clear, actionable investment plan for the trader.
|
|
|
|
{instrument_context}
|
|
|
|
---
|
|
|
|
**Rating Scale** (use exactly one):
|
|
- **Buy**: Strong conviction in the bull thesis; recommend taking or growing the position
|
|
- **Overweight**: Constructive view; recommend gradually increasing exposure
|
|
- **Hold**: Balanced view; recommend maintaining the current position
|
|
- **Underweight**: Cautious view; recommend trimming exposure
|
|
- **Sell**: Strong conviction in the bear thesis; recommend exiting or avoiding the position
|
|
|
|
The debate always contains conflicting arguments; deciding which side is stronger is the job, so conflict alone is not a reason to Hold. Commit to the side with the stronger case, sized by how decisively it wins. Choose Hold only when the evidence is still balanced after that weighing, or too thin to support a call; do not manufacture a direction to appear decisive. Weigh the bull and bear cases on their merits, independent of which side spoke first or last.
|
|
|
|
---
|
|
|
|
**Debate History:**
|
|
{history}
|
|
|
|
{NO_EXTERNAL_TOOLS}""" + get_language_instruction()
|
|
|
|
investment_plan = invoke_structured_or_freetext(
|
|
structured_llm,
|
|
llm,
|
|
prompt,
|
|
render_research_plan,
|
|
"Research Manager",
|
|
)
|
|
|
|
new_investment_debate_state = {
|
|
"judge_decision": investment_plan,
|
|
"history": investment_debate_state.get("history", ""),
|
|
"bear_history": investment_debate_state.get("bear_history", ""),
|
|
"bull_history": investment_debate_state.get("bull_history", ""),
|
|
"current_response": investment_plan,
|
|
"count": investment_debate_state["count"],
|
|
}
|
|
|
|
return {
|
|
"investment_debate_state": new_investment_debate_state,
|
|
"investment_plan": investment_plan,
|
|
}
|
|
|
|
return research_manager_node
|