import functools from tradingagents.agents.utils.agent_utils import build_instrument_context def create_trader(llm): def trader_node(state, name): company_name = state["company_of_interest"] instrument_context = build_instrument_context(company_name) investment_plan = state["investment_plan"] context = { "role": "user", "content": f"Based on a comprehensive analysis by a team of analysts, here is an investment plan tailored for {company_name}. {instrument_context} This plan incorporates insights from current technical market trends, macroeconomic indicators, and social media sentiment. Use this plan as a foundation for evaluating your next trading decision.\n\nProposed Investment Plan: {investment_plan}\n\nLeverage these insights to make an informed and strategic decision.", } messages = [ { "role": "system", "content": "You are a trading agent analyzing market data to make investment decisions. Based on your analysis, provide a specific recommendation to buy, sell, or hold. End with a firm decision and always conclude your response with 'FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL**' to confirm your recommendation.", }, context, ] result = llm.invoke(messages) return { "messages": [result], "trader_investment_plan": result.content, "sender": name, } return functools.partial(trader_node, name="Trader")