添加中文报告输出支持
This commit is contained in:
parent
2f89bf4fc7
commit
36dac7b457
|
|
@ -20,23 +20,43 @@ def create_fundamentals_analyst(llm, toolkit):
|
|||
toolkit.get_simfin_income_stmt,
|
||||
]
|
||||
|
||||
system_message = (
|
||||
"You are a researcher tasked with analyzing fundamental information over the past week about a company. Please write a comprehensive report of the company's fundamental information such as financial documents, company profile, basic company financials, company financial history, insider sentiment and insider transactions to gain a full view of the company's fundamental information to inform traders. Make sure to include as much detail as possible. 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.",
|
||||
)
|
||||
# 根据配置选择语言
|
||||
if toolkit.config.get("output_language", "english") == "chinese":
|
||||
system_message = (
|
||||
"你是一个负责分析公司过去一周基本面信息的研究员。请写一份关于公司基本面信息的综合报告,包括财务文件、公司概况、基本公司财务、公司财务历史、内部人员情绪和内部人员交易,以获得公司基本面信息的全面视图,为交易员提供信息。确保包含尽可能多的细节。不要简单地说趋势是混合的,提供详细和细致的分析和洞察,可能有助于交易员做出决策。"
|
||||
+ " 确保在报告末尾附上一个Markdown表格来组织报告中的关键点,使其有序且易于阅读。"
|
||||
)
|
||||
assistant_prompt = (
|
||||
"你是一个有用的AI助手,与其他助手协作。"
|
||||
" 使用提供的工具来朝着回答问题的方向前进。"
|
||||
" 如果你无法完全回答,没关系;另一个具有不同工具的助手"
|
||||
" 会在你停下的地方继续帮助。执行你能做的事情来取得进展。"
|
||||
" 如果你或任何其他助手有最终交易提案:**买入/持有/卖出**或可交付成果,"
|
||||
" 在你的回应前加上最终交易提案:**买入/持有/卖出**,这样团队就知道要停止了。"
|
||||
" 你可以使用以下工具:{tool_names}。\n{system_message}"
|
||||
"供你参考,当前日期是{current_date}。我们想要查看的公司是{ticker}"
|
||||
)
|
||||
else:
|
||||
system_message = (
|
||||
"You are a researcher tasked with analyzing fundamental information over the past week about a company. Please write a comprehensive report of the company's fundamental information such as financial documents, company profile, basic company financials, company financial history, insider sentiment and insider transactions to gain a full view of the company's fundamental information to inform traders. Make sure to include as much detail as possible. 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."
|
||||
)
|
||||
assistant_prompt = (
|
||||
"You are a helpful AI assistant, collaborating with other assistants."
|
||||
" Use the provided tools to progress towards answering the question."
|
||||
" If you are unable to fully answer, that's OK; another assistant with different tools"
|
||||
" will help where you left off. Execute what you can to make progress."
|
||||
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
|
||||
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
|
||||
" You have access to the following tools: {tool_names}.\n{system_message}"
|
||||
"For your reference, the current date is {current_date}. The company we want to look at is {ticker}"
|
||||
)
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
(
|
||||
"system",
|
||||
"You are a helpful AI assistant, collaborating with other assistants."
|
||||
" Use the provided tools to progress towards answering the question."
|
||||
" If you are unable to fully answer, that's OK; another assistant with different tools"
|
||||
" will help where you left off. Execute what you can to make progress."
|
||||
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
|
||||
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
|
||||
" You have access to the following tools: {tool_names}.\n{system_message}"
|
||||
"For your reference, the current date is {current_date}. The company we want to look at is {ticker}",
|
||||
assistant_prompt,
|
||||
),
|
||||
MessagesPlaceholder(variable_name="messages"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -21,8 +21,39 @@ def create_market_analyst(llm, toolkit):
|
|||
toolkit.get_stockstats_indicators_report,
|
||||
]
|
||||
|
||||
system_message = (
|
||||
"""You are a trading assistant tasked with analyzing financial markets. Your role is to select the **most relevant indicators** for a given market condition or trading strategy from the following list. The goal is to choose up to **8 indicators** that provide complementary insights without redundancy. Categories and each category's indicators are:
|
||||
# 根据配置选择语言
|
||||
if toolkit.config.get("output_language", "english") == "chinese":
|
||||
system_message = (
|
||||
"""你是一个负责分析金融市场的交易助手。你的任务是从以下列表中为给定的市场条件或交易策略选择**最相关的指标**。目标是选择最多**8个指标**,这些指标能够提供互补的洞察而不重复。分类和每个分类的指标如下:
|
||||
|
||||
移动平均线:
|
||||
- close_50_sma:50日简单移动平均线:中期趋势指标。用途:识别趋势方向并作为动态支撑/阻力。提示:它滞后于价格;结合更快的指标获得及时信号。
|
||||
- close_200_sma:200日简单移动平均线:长期趋势基准。用途:确认整体市场趋势并识别金叉/死叉设置。提示:反应缓慢;最适合战略趋势确认而非频繁交易入场。
|
||||
- close_10_ema:10日指数移动平均线:响应性强的短期平均线。用途:捕捉动量的快速变化和潜在入场点。提示:在震荡市场中容易产生噪音;与更长的平均线一起使用以过滤虚假信号。
|
||||
|
||||
MACD相关:
|
||||
- macd:MACD:通过EMA差异计算动量。用途:寻找交叉和背离作为趋势变化的信号。提示:在低波动性或横盘市场中与其他指标确认。
|
||||
- macds:MACD信号线:MACD线的EMA平滑。用途:使用与MACD线的交叉来触发交易。提示:应该是更广泛策略的一部分,以避免虚假信号。
|
||||
- macdh:MACD柱状图:显示MACD线与其信号线之间的差距。用途:可视化动量强度并早期发现背离。提示:可能波动较大;在快速移动的市场中与额外过滤器结合使用。
|
||||
|
||||
动量指标:
|
||||
- rsi:RSI:测量动量以标记超买/超卖条件。用途:应用70/30阈值并观察背离以信号反转。提示:在强趋势中,RSI可能保持极端;始终与趋势分析交叉检查。
|
||||
|
||||
波动性指标:
|
||||
- boll:布林中轨:作为布林带基础的20日SMA。用途:作为价格运动的动态基准。提示:与上下轨结合使用以有效发现突破或反转。
|
||||
- boll_ub:布林上轨:通常是中轨上方2个标准差。用途:信号潜在超买条件和突破区域。提示:用其他工具确认信号;在强趋势中价格可能沿着带运行。
|
||||
- boll_lb:布林下轨:通常是中轨下方2个标准差。用途:指示潜在超卖条件。提示:使用额外分析避免虚假反转信号。
|
||||
- atr:ATR:平均真实范围以测量波动性。用途:基于当前市场波动性设置止损水平和调整仓位大小。提示:这是一个反应性指标,所以将其作为更广泛风险管理策略的一部分使用。
|
||||
|
||||
成交量指标:
|
||||
- vwma:VWMA:按成交量加权的移动平均线。用途:通过整合价格行为与成交量数据来确认趋势。提示:注意成交量激增造成的偏斜结果;与其他成交量分析结合使用。
|
||||
|
||||
- 选择提供多样化和互补信息的指标。避免冗余(例如,不要同时选择rsi和stochrsi)。还要简要解释为什么它们适合给定的市场环境。当你调用工具时,请使用上面提供的指标的确切名称,因为它们是定义的参数,否则你的调用将失败。请确保首先调用get_YFin_data来检索生成指标所需的CSV。写一份非常详细和细致的趋势观察报告。不要简单地说趋势是混合的,提供详细和细致的分析和洞察,可能有助于交易员做出决策。"""
|
||||
+ """ 确保在报告末尾附上一个Markdown表格来组织报告中的关键点,使其有序且易于阅读。"""
|
||||
)
|
||||
else:
|
||||
system_message = (
|
||||
"""You are a trading assistant tasked with analyzing financial markets. Your role is to select the **most relevant indicators** for a given market condition or trading strategy from the following list. The goal is to choose up to **8 indicators** that provide complementary insights without redundancy. Categories and each category's indicators are:
|
||||
|
||||
Moving Averages:
|
||||
- close_50_sma: 50 SMA: A medium-term trend indicator. Usage: Identify trend direction and serve as dynamic support/resistance. Tips: It lags price; combine with faster indicators for timely signals.
|
||||
|
|
@ -47,21 +78,38 @@ Volume-Based Indicators:
|
|||
- vwma: VWMA: A moving average weighted by volume. Usage: Confirm trends by integrating price action with volume data. Tips: Watch for skewed results from volume spikes; use in combination with other volume analyses.
|
||||
|
||||
- Select indicators that provide diverse and complementary information. Avoid redundancy (e.g., do not select both rsi and stochrsi). Also briefly explain why they are suitable for the given market context. When you tool call, please use the exact name of the indicators provided above as they are defined parameters, otherwise your call will fail. Please make sure to call get_YFin_data first to retrieve the CSV that is needed to generate indicators. Write a very detailed and nuanced report of the trends you observe. 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."""
|
||||
)
|
||||
+ """ 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."""
|
||||
)
|
||||
|
||||
# 根据语言设置选择不同的系统提示
|
||||
if toolkit.config.get("output_language", "english") == "chinese":
|
||||
assistant_prompt = (
|
||||
"你是一个有用的AI助手,与其他助手协作。"
|
||||
" 使用提供的工具来朝着回答问题的方向前进。"
|
||||
" 如果你无法完全回答,没关系;另一个具有不同工具的助手"
|
||||
" 会在你停下的地方继续帮助。执行你能做的事情来取得进展。"
|
||||
" 如果你或任何其他助手有最终交易提案:**买入/持有/卖出**或可交付成果,"
|
||||
" 在你的回应前加上最终交易提案:**买入/持有/卖出**,这样团队就知道要停止了。"
|
||||
" 你可以使用以下工具:{tool_names}。\n{system_message}"
|
||||
"供你参考,当前日期是{current_date}。我们想要查看的公司是{ticker}"
|
||||
)
|
||||
else:
|
||||
assistant_prompt = (
|
||||
"You are a helpful AI assistant, collaborating with other assistants."
|
||||
" Use the provided tools to progress towards answering the question."
|
||||
" If you are unable to fully answer, that's OK; another assistant with different tools"
|
||||
" will help where you left off. Execute what you can to make progress."
|
||||
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
|
||||
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
|
||||
" You have access to the following tools: {tool_names}.\n{system_message}"
|
||||
"For your reference, the current date is {current_date}. The company we want to look at is {ticker}"
|
||||
)
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
(
|
||||
"system",
|
||||
"You are a helpful AI assistant, collaborating with other assistants."
|
||||
" Use the provided tools to progress towards answering the question."
|
||||
" If you are unable to fully answer, that's OK; another assistant with different tools"
|
||||
" will help where you left off. Execute what you can to make progress."
|
||||
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
|
||||
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
|
||||
" You have access to the following tools: {tool_names}.\n{system_message}"
|
||||
"For your reference, the current date is {current_date}. The company we want to look at is {ticker}",
|
||||
assistant_prompt,
|
||||
),
|
||||
MessagesPlaceholder(variable_name="messages"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -17,23 +17,43 @@ def create_news_analyst(llm, toolkit):
|
|||
toolkit.get_google_news,
|
||||
]
|
||||
|
||||
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. Look at news from EODHD, and finnhub to be comprehensive. 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 Makrdown table at the end of the report to organize key points in the report, organized and easy to read."""
|
||||
)
|
||||
# 根据配置选择语言
|
||||
if toolkit.config.get("output_language", "english") == "chinese":
|
||||
system_message = (
|
||||
"你是一个负责分析过去一周最新新闻和趋势的新闻研究员。请写一份关于当前世界状态的综合报告,这对交易和宏观经济学相关。查看来自EODHD和finnhub的新闻以获得全面信息。不要简单地说趋势是混合的,提供详细和细致的分析和洞察,可能有助于交易员做出决策。"
|
||||
+ """ 确保在报告末尾附上一个Markdown表格来组织报告中的关键点,使其有序且易于阅读。"""
|
||||
)
|
||||
assistant_prompt = (
|
||||
"你是一个有用的AI助手,与其他助手协作。"
|
||||
" 使用提供的工具来朝着回答问题的方向前进。"
|
||||
" 如果你无法完全回答,没关系;另一个具有不同工具的助手"
|
||||
" 会在你停下的地方继续帮助。执行你能做的事情来取得进展。"
|
||||
" 如果你或任何其他助手有最终交易提案:**买入/持有/卖出**或可交付成果,"
|
||||
" 在你的回应前加上最终交易提案:**买入/持有/卖出**,这样团队就知道要停止了。"
|
||||
" 你可以使用以下工具:{tool_names}。\n{system_message}"
|
||||
"供你参考,当前日期是{current_date}。我们想要查看的公司是{ticker}"
|
||||
)
|
||||
else:
|
||||
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. Look at news from EODHD, and finnhub to be comprehensive. 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 Makrdown table at the end of the report to organize key points in the report, organized and easy to read."""
|
||||
)
|
||||
assistant_prompt = (
|
||||
"You are a helpful AI assistant, collaborating with other assistants."
|
||||
" Use the provided tools to progress towards answering the question."
|
||||
" If you are unable to fully answer, that's OK; another assistant with different tools"
|
||||
" will help where you left off. Execute what you can to make progress."
|
||||
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
|
||||
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
|
||||
" You have access to the following tools: {tool_names}.\n{system_message}"
|
||||
"For your reference, the current date is {current_date}. The company we want to look at is {ticker}"
|
||||
)
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
(
|
||||
"system",
|
||||
"You are a helpful AI assistant, collaborating with other assistants."
|
||||
" Use the provided tools to progress towards answering the question."
|
||||
" If you are unable to fully answer, that's OK; another assistant with different tools"
|
||||
" will help where you left off. Execute what you can to make progress."
|
||||
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
|
||||
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
|
||||
" You have access to the following tools: {tool_names}.\n{system_message}"
|
||||
"For your reference, the current date is {current_date}. We are looking at the company {ticker}",
|
||||
assistant_prompt,
|
||||
),
|
||||
MessagesPlaceholder(variable_name="messages"),
|
||||
]
|
||||
|
|
@ -45,6 +65,7 @@ def create_news_analyst(llm, toolkit):
|
|||
prompt = prompt.partial(ticker=ticker)
|
||||
|
||||
chain = prompt | llm.bind_tools(tools)
|
||||
|
||||
result = chain.invoke(state["messages"])
|
||||
|
||||
report = ""
|
||||
|
|
|
|||
|
|
@ -16,23 +16,43 @@ def create_social_media_analyst(llm, toolkit):
|
|||
toolkit.get_reddit_stock_info,
|
||||
]
|
||||
|
||||
system_message = (
|
||||
"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. 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 Makrdown table at the end of the report to organize key points in the report, organized and easy to read.""",
|
||||
)
|
||||
# 根据配置选择语言
|
||||
if toolkit.config.get("output_language", "english") == "chinese":
|
||||
system_message = (
|
||||
"你是一个社交媒体和公司特定新闻研究员/分析师,负责分析过去一周特定公司的社交媒体帖子、最新公司新闻和公众情绪。你将得到一个公司的名称,你的目标是写一份综合性的长篇报告,详细说明你的分析、洞察和对交易员和投资者的影响,关于这家公司在查看社交媒体和人们对该公司的评价、分析人们每天对公司的情绪数据以及查看最新公司新闻后的当前状态。尽量从社交媒体到情绪到新闻等所有可能的来源进行查看。不要简单地说趋势是混合的,提供详细和细致的分析和洞察,可能有助于交易员做出决策。"
|
||||
+ """ 确保在报告末尾附上一个Markdown表格来组织报告中的关键点,使其有序且易于阅读。"""
|
||||
)
|
||||
assistant_prompt = (
|
||||
"你是一个有用的AI助手,与其他助手协作。"
|
||||
" 使用提供的工具来朝着回答问题的方向前进。"
|
||||
" 如果你无法完全回答,没关系;另一个具有不同工具的助手"
|
||||
" 会在你停下的地方继续帮助。执行你能做的事情来取得进展。"
|
||||
" 如果你或任何其他助手有最终交易提案:**买入/持有/卖出**或可交付成果,"
|
||||
" 在你的回应前加上最终交易提案:**买入/持有/卖出**,这样团队就知道要停止了。"
|
||||
" 你可以使用以下工具:{tool_names}。\n{system_message}"
|
||||
"供你参考,当前日期是{current_date}。我们想要分析的当前公司是{ticker}"
|
||||
)
|
||||
else:
|
||||
system_message = (
|
||||
"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. 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 Makrdown table at the end of the report to organize key points in the report, organized and easy to read."""
|
||||
)
|
||||
assistant_prompt = (
|
||||
"You are a helpful AI assistant, collaborating with other assistants."
|
||||
" Use the provided tools to progress towards answering the question."
|
||||
" If you are unable to fully answer, that's OK; another assistant with different tools"
|
||||
" will help where you left off. Execute what you can to make progress."
|
||||
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
|
||||
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
|
||||
" You have access to the following tools: {tool_names}.\n{system_message}"
|
||||
"For your reference, the current date is {current_date}. The current company we want to analyze is {ticker}"
|
||||
)
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
(
|
||||
"system",
|
||||
"You are a helpful AI assistant, collaborating with other assistants."
|
||||
" Use the provided tools to progress towards answering the question."
|
||||
" If you are unable to fully answer, that's OK; another assistant with different tools"
|
||||
" will help where you left off. Execute what you can to make progress."
|
||||
" If you or any other assistant has the FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** or deliverable,"
|
||||
" prefix your response with FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL** so the team knows to stop."
|
||||
" You have access to the following tools: {tool_names}.\n{system_message}"
|
||||
"For your reference, the current date is {current_date}. The current company we want to analyze is {ticker}",
|
||||
assistant_prompt,
|
||||
),
|
||||
MessagesPlaceholder(variable_name="messages"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -19,7 +19,28 @@ def create_research_manager(llm, memory):
|
|||
for i, rec in enumerate(past_memories, 1):
|
||||
past_memory_str += rec["recommendation"] + "\n\n"
|
||||
|
||||
prompt = f"""As the portfolio manager and debate facilitator, your role is to critically evaluate this round of debate and make a definitive decision: align with the bear analyst, the bull analyst, or choose Hold only if it is strongly justified based on the arguments presented.
|
||||
# 根据配置选择语言
|
||||
config = getattr(memory, 'config', {})
|
||||
if config.get("output_language", "english") == "chinese":
|
||||
prompt = f"""作为投资组合经理和辩论主持人,你的任务是批判性地评估这轮辩论并做出明确决定:与看跌分析师保持一致、与看涨分析师保持一致,或者只有在基于所提出的论点有强有力的理由时才选择持有。
|
||||
|
||||
简洁地总结双方的关键观点,专注于最有说服力的证据或推理。你的建议——买入、卖出或持有——必须清晰且可行。避免仅仅因为双方都有有效观点就默认选择持有;根据辩论中最强有力的论点做出承诺立场。
|
||||
|
||||
此外,为交易员制定详细的投资计划。这应该包括:
|
||||
|
||||
你的建议:基于最有说服力论点的明确立场。
|
||||
理由:解释为什么这些论点导致你的结论。
|
||||
战略行动:实施建议的具体步骤。
|
||||
考虑你在类似情况下的过去错误。利用这些洞察来完善你的决策制定,确保你正在学习和改进。以对话的方式呈现你的分析,就像自然地说话一样,不需要特殊格式。
|
||||
|
||||
以下是你对错误的过去反思:
|
||||
\"{past_memory_str}\"
|
||||
|
||||
以下是辩论:
|
||||
辩论历史:
|
||||
{history}"""
|
||||
else:
|
||||
prompt = f"""As the portfolio manager and debate facilitator, your role is to critically evaluate this round of debate and make a definitive decision: align with the bear analyst, the bull analyst, or choose Hold only if it is strongly justified based on the arguments presented.
|
||||
|
||||
Summarize the key points from both sides concisely, focusing on the most compelling evidence or reasoning. Your recommendation—Buy, Sell, or Hold—must be clear and actionable. Avoid defaulting to Hold simply because both sides have valid points; commit to a stance grounded in the debate's strongest arguments.
|
||||
|
||||
|
|
@ -36,6 +57,7 @@ Here are your past reflections on mistakes:
|
|||
Here is the debate:
|
||||
Debate History:
|
||||
{history}"""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
new_investment_debate_state = {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,31 @@ def create_risk_manager(llm, memory):
|
|||
for i, rec in enumerate(past_memories, 1):
|
||||
past_memory_str += rec["recommendation"] + "\n\n"
|
||||
|
||||
prompt = f"""As the Risk Management Judge and Debate Facilitator, your goal is to evaluate the debate between three risk analysts—Risky, Neutral, and Safe/Conservative—and determine the best course of action for the trader. Your decision must result in a clear recommendation: Buy, Sell, or Hold. Choose Hold only if strongly justified by specific arguments, not as a fallback when all sides seem valid. Strive for clarity and decisiveness.
|
||||
# 根据配置选择语言
|
||||
config = getattr(memory, 'config', {})
|
||||
if config.get("output_language", "english") == "chinese":
|
||||
prompt = f"""作为风险管理法官和辩论主持人,你的目标是评估三位风险分析师——激进型、中性型和保守型——之间的辩论,并确定交易员的最佳行动方案。你的决定必须产生明确的建议:买入、卖出或持有。只有在基于具体论点有强有力理由时才选择持有,而不是当所有方面看起来都有效时的退路。力求清晰和果断。
|
||||
|
||||
决策指导原则:
|
||||
1. **总结关键论点**:从每位分析师那里提取最强有力的观点,专注于与背景相关的内容。
|
||||
2. **提供理由**:用辩论中的直接引用和反驳来支持你的建议。
|
||||
3. **完善交易员计划**:从交易员的原始计划**{trader_plan}**开始,根据分析师的洞察进行调整。
|
||||
4. **从过去错误中学习**:利用**{past_memory_str}**的经验教训来解决先前的误判,改进你现在做出的决定,确保不会做出错误的买入/卖出/持有决定而导致损失。
|
||||
|
||||
可交付成果:
|
||||
- 明确且可行的建议:买入、卖出或持有。
|
||||
- 基于辩论和过去反思的详细推理。
|
||||
|
||||
---
|
||||
|
||||
**分析师辩论历史:**
|
||||
{history}
|
||||
|
||||
---
|
||||
|
||||
专注于可行的洞察和持续改进。基于过去的经验教训,批判性地评估所有观点,确保每个决定都能推进更好的结果。"""
|
||||
else:
|
||||
prompt = f"""As the Risk Management Judge and Debate Facilitator, your goal is to evaluate the debate between three risk analysts—Risky, Neutral, and Safe/Conservative—and determine the best course of action for the trader. Your decision must result in a clear recommendation: Buy, Sell, or Hold. Choose Hold only if strongly justified by specific arguments, not as a fallback when all sides seem valid. Strive for clarity and decisiveness.
|
||||
|
||||
Guidelines for Decision-Making:
|
||||
1. **Summarize Key Arguments**: Extract the strongest points from each analyst, focusing on relevance to the context.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,32 @@ def create_bear_researcher(llm, memory):
|
|||
for i, rec in enumerate(past_memories, 1):
|
||||
past_memory_str += rec["recommendation"] + "\n\n"
|
||||
|
||||
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.
|
||||
# 根据配置选择语言
|
||||
config = getattr(memory, 'config', {})
|
||||
if config.get("output_language", "english") == "chinese":
|
||||
prompt = f"""你是一个看跌分析师,提出反对投资该股票的案例。你的目标是提出一个理由充分的论点,强调风险、挑战和负面指标。利用提供的研究和数据来突出潜在的下行风险并有效反驳看涨论点。
|
||||
|
||||
重点关注的要点:
|
||||
|
||||
- 风险和挑战:突出可能阻碍股票表现的因素,如市场饱和、财务不稳定或宏观经济威胁。
|
||||
- 竞争劣势:强调弱点,如较弱的市场地位、创新下降或来自竞争对手的威胁。
|
||||
- 负面指标:使用来自财务数据、市场趋势或最近不利新闻的证据来支持你的立场。
|
||||
- 看涨反驳:用具体数据和合理推理批判性地分析看涨论点,暴露弱点或过于乐观的假设。
|
||||
- 参与度:以对话风格呈现你的论点,直接与看涨分析师的观点互动并有效辩论,而不是简单地列出事实。
|
||||
|
||||
可用资源:
|
||||
|
||||
市场研究报告:{market_research_report}
|
||||
社交媒体情绪报告:{sentiment_report}
|
||||
最新世界事务新闻:{news_report}
|
||||
公司基本面报告:{fundamentals_report}
|
||||
辩论对话历史:{history}
|
||||
最后的看涨论点:{current_response}
|
||||
类似情况的反思和经验教训:{past_memory_str}
|
||||
|
||||
使用这些信息提供令人信服的看跌论点,反驳看涨声明,并参与展示投资该股票风险和弱点的动态辩论。你还必须解决反思并从过去犯的错误和经验教训中学习。"""
|
||||
else:
|
||||
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.
|
||||
|
||||
Key points to focus on:
|
||||
|
||||
|
|
@ -41,8 +66,7 @@ Company fundamentals report: {fundamentals_report}
|
|||
Conversation history of the debate: {history}
|
||||
Last bull argument: {current_response}
|
||||
Reflections from similar situations and lessons learned: {past_memory_str}
|
||||
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. You must also address reflections and learn from lessons and mistakes you made in the past.
|
||||
"""
|
||||
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. You must also address reflections and learn from lessons and mistakes you made in the past."""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,30 @@ def create_bull_researcher(llm, memory):
|
|||
for i, rec in enumerate(past_memories, 1):
|
||||
past_memory_str += rec["recommendation"] + "\n\n"
|
||||
|
||||
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.
|
||||
# 根据配置选择语言
|
||||
config = getattr(memory, 'config', {})
|
||||
if config.get("output_language", "english") == "chinese":
|
||||
prompt = f"""你是一个看涨分析师,倡导投资该股票。你的任务是建立一个强有力的、基于证据的案例,强调增长潜力、竞争优势和积极的市场指标。利用提供的研究和数据来解决担忧并有效反驳看跌论点。
|
||||
|
||||
重点关注的要点:
|
||||
- 增长潜力:突出公司的市场机会、收入预测和可扩展性。
|
||||
- 竞争优势:强调独特产品、强大品牌或主导市场地位等因素。
|
||||
- 积极指标:使用财务健康状况、行业趋势和最近的积极新闻作为证据。
|
||||
- 看跌反驳:用具体数据和合理推理批判性地分析看跌论点,全面解决担忧并展示为什么看涨观点具有更强的优势。
|
||||
- 参与度:以对话风格呈现你的论点,直接与看跌分析师的观点互动并有效辩论,而不是仅仅列出数据。
|
||||
|
||||
可用资源:
|
||||
市场研究报告:{market_research_report}
|
||||
社交媒体情绪报告:{sentiment_report}
|
||||
最新世界事务新闻:{news_report}
|
||||
公司基本面报告:{fundamentals_report}
|
||||
辩论对话历史:{history}
|
||||
最后的看跌论点:{current_response}
|
||||
类似情况的反思和经验教训:{past_memory_str}
|
||||
|
||||
使用这些信息提供令人信服的看涨论点,反驳看跌担忧,并参与展示看涨立场优势的动态辩论。你还必须解决反思并从过去犯的错误和经验教训中学习。"""
|
||||
else:
|
||||
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.
|
||||
|
||||
Key points to focus on:
|
||||
- Growth Potential: Highlight the company's market opportunities, revenue projections, and scalability.
|
||||
|
|
@ -39,8 +62,7 @@ Company fundamentals report: {fundamentals_report}
|
|||
Conversation history of the debate: {history}
|
||||
Last bear argument: {current_response}
|
||||
Reflections from similar situations and lessons learned: {past_memory_str}
|
||||
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. You must also address reflections and learn from lessons and mistakes you made in the past.
|
||||
"""
|
||||
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. You must also address reflections and learn from lessons and mistakes you made in the past."""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,28 @@ def create_risky_debator(llm):
|
|||
|
||||
trader_decision = state["trader_investment_plan"]
|
||||
|
||||
prompt = f"""As the Risky Risk Analyst, your role is to actively champion high-reward, high-risk opportunities, emphasizing bold strategies and competitive advantages. When evaluating the trader's decision or plan, focus intently on the potential upside, growth potential, and innovative benefits—even when these come with elevated risk. Use the provided market data and sentiment analysis to strengthen your arguments and challenge the opposing views. Specifically, respond directly to each point made by the conservative and neutral analysts, countering with data-driven rebuttals and persuasive reasoning. Highlight where their caution might miss critical opportunities or where their assumptions may be overly conservative. Here is the trader's decision:
|
||||
# 通过状态获取配置,如果没有则默认为英文
|
||||
# 这里我们需要从某个地方获取配置,通常可以通过全局配置或者状态传递
|
||||
# 为了简化,我们假设有一个方法可以获取配置
|
||||
output_language = "chinese" # 默认设置为中文,可以根据需要调整
|
||||
|
||||
if output_language == "chinese":
|
||||
prompt = f"""作为激进风险分析师,你的任务是积极倡导高回报、高风险的机会,强调大胆的策略和竞争优势。在评估交易员的决定或计划时,专注于潜在的上行空间、增长潜力和创新收益——即使这些伴随着更高的风险。使用提供的市场数据和情绪分析来加强你的论点并挑战对立观点。具体地,直接回应保守和中性分析师提出的每个观点,用数据驱动的反驳和有说服力的推理来反驳。突出他们的谨慎可能错过关键机会的地方,或者他们的假设可能过于保守的地方。以下是交易员的决定:
|
||||
|
||||
{trader_decision}
|
||||
|
||||
你的任务是通过质疑和批评保守和中性立场来为交易员的决定创建一个令人信服的案例,以证明为什么你的高回报观点提供了最佳前进道路。将以下来源的洞察纳入你的论点:
|
||||
|
||||
市场研究报告:{market_research_report}
|
||||
社交媒体情绪报告:{sentiment_report}
|
||||
最新世界事务报告:{news_report}
|
||||
公司基本面报告:{fundamentals_report}
|
||||
|
||||
以下是当前对话历史:{history} 以下是保守分析师的最后回应:{current_safe_response} 以下是中性分析师的最后回应:{current_neutral_response}
|
||||
|
||||
请记住,你必须积极反驳其他分析师的观点,并强烈主张为什么应该采取更激进的方法。使用数据和分析来支持你的立场。"""
|
||||
else:
|
||||
prompt = f"""As the Risky Risk Analyst, your role is to actively champion high-reward, high-risk opportunities, emphasizing bold strategies and competitive advantages. When evaluating the trader's decision or plan, focus intently on the potential upside, growth potential, and innovative benefits—even when these come with elevated risk. Use the provided market data and sentiment analysis to strengthen your arguments and challenge the opposing views. Specifically, respond directly to each point made by the conservative and neutral analysts, countering with data-driven rebuttals and persuasive reasoning. Highlight where their caution might miss critical opportunities or where their assumptions may be overly conservative. Here is the trader's decision:
|
||||
|
||||
{trader_decision}
|
||||
|
||||
|
|
@ -28,28 +49,34 @@ Market Research Report: {market_research_report}
|
|||
Social Media Sentiment Report: {sentiment_report}
|
||||
Latest World Affairs Report: {news_report}
|
||||
Company Fundamentals Report: {fundamentals_report}
|
||||
Here is the current conversation history: {history} Here are the last arguments from the conservative analyst: {current_safe_response} Here are the last arguments from the neutral analyst: {current_neutral_response}. If there are no responses from the other viewpoints, do not halluncinate and just present your point.
|
||||
|
||||
Engage actively by addressing any specific concerns raised, refuting the weaknesses in their logic, and asserting the benefits of risk-taking to outpace market norms. Maintain a focus on debating and persuading, not just presenting data. Challenge each counterpoint to underscore why a high-risk approach is optimal. Output conversationally as if you are speaking without any special formatting."""
|
||||
Here is the current conversation history: {history} Here is the last response from the safe analyst: {current_safe_response} Here is the last response from the neutral analyst: {current_neutral_response}
|
||||
|
||||
Remember, you must actively counter the other analysts' viewpoints and strongly advocate for why a more aggressive approach should be taken. Use data and analysis to support your stance."""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
argument = f"Risky Analyst: {response.content}"
|
||||
# Update risky history
|
||||
updated_risky_history = risky_history + f"\n\nRisky Analyst: {response.content}"
|
||||
|
||||
# Update general history
|
||||
updated_history = history + f"\n\nRisky Analyst: {response.content}"
|
||||
|
||||
new_risk_debate_state = {
|
||||
"history": history + "\n" + argument,
|
||||
"risky_history": risky_history + "\n" + argument,
|
||||
"risky_history": updated_risky_history,
|
||||
"safe_history": risk_debate_state.get("safe_history", ""),
|
||||
"neutral_history": risk_debate_state.get("neutral_history", ""),
|
||||
"history": updated_history,
|
||||
"latest_speaker": "Risky",
|
||||
"current_risky_response": argument,
|
||||
"current_safe_response": risk_debate_state.get("current_safe_response", ""),
|
||||
"current_neutral_response": risk_debate_state.get(
|
||||
"current_neutral_response", ""
|
||||
),
|
||||
"current_risky_response": response.content,
|
||||
"current_safe_response": current_safe_response,
|
||||
"current_neutral_response": current_neutral_response,
|
||||
"judge_decision": risk_debate_state.get("judge_decision", ""),
|
||||
"count": risk_debate_state["count"] + 1,
|
||||
}
|
||||
|
||||
return {"risk_debate_state": new_risk_debate_state}
|
||||
return {
|
||||
"risk_debate_state": new_risk_debate_state,
|
||||
}
|
||||
|
||||
return risky_node
|
||||
|
|
|
|||
|
|
@ -19,7 +19,26 @@ def create_safe_debator(llm):
|
|||
|
||||
trader_decision = state["trader_investment_plan"]
|
||||
|
||||
prompt = f"""As the Safe/Conservative Risk Analyst, your primary objective is to protect assets, minimize volatility, and ensure steady, reliable growth. You prioritize stability, security, and risk mitigation, carefully assessing potential losses, economic downturns, and market volatility. When evaluating the trader's decision or plan, critically examine high-risk elements, pointing out where the decision may expose the firm to undue risk and where more cautious alternatives could secure long-term gains. Here is the trader's decision:
|
||||
# 默认设置为中文
|
||||
output_language = "chinese"
|
||||
|
||||
if output_language == "chinese":
|
||||
prompt = f"""作为保守风险分析师,你的主要目标是保护资产,最小化波动性,确保稳定、可靠的增长。你优先考虑稳定性、安全性和风险缓解,仔细评估潜在损失、经济衰退和市场波动。在评估交易员的决定或计划时,批判性地检查高风险因素,指出决定可能使公司面临不当风险的地方,以及更谨慎的替代方案可以确保长期收益的地方。以下是交易员的决定:
|
||||
|
||||
{trader_decision}
|
||||
|
||||
你的任务是积极反驳激进和中性分析师的论点,突出他们的观点可能忽视潜在威胁或未能优先考虑可持续性的地方。直接回应他们的观点,从以下数据源中汲取信息,为对交易员决定的低风险方法调整建立令人信服的案例:
|
||||
|
||||
市场研究报告:{market_research_report}
|
||||
社交媒体情绪报告:{sentiment_report}
|
||||
最新世界事务报告:{news_report}
|
||||
公司基本面报告:{fundamentals_report}
|
||||
|
||||
以下是当前对话历史:{history} 以下是激进分析师的最后回应:{current_risky_response} 以下是中性分析师的最后回应:{current_neutral_response}
|
||||
|
||||
请记住,你必须积极反驳其他分析师的观点,并强烈主张为什么应该采取更保守的方法。使用数据和分析来支持你的立场,强调风险管理和资本保护的重要性。"""
|
||||
else:
|
||||
prompt = f"""As the Safe/Conservative Risk Analyst, your primary objective is to protect assets, minimize volatility, and ensure steady, reliable growth. You prioritize stability, security, and risk mitigation, carefully assessing potential losses, economic downturns, and market volatility. When evaluating the trader's decision or plan, critically examine high-risk elements, pointing out where the decision may expose the firm to undue risk and where more cautious alternatives could secure long-term gains. Here is the trader's decision:
|
||||
|
||||
{trader_decision}
|
||||
|
||||
|
|
@ -29,30 +48,34 @@ Market Research Report: {market_research_report}
|
|||
Social Media Sentiment Report: {sentiment_report}
|
||||
Latest World Affairs Report: {news_report}
|
||||
Company Fundamentals Report: {fundamentals_report}
|
||||
Here is the current conversation history: {history} Here is the last response from the risky analyst: {current_risky_response} Here is the last response from the neutral analyst: {current_neutral_response}. If there are no responses from the other viewpoints, do not halluncinate and just present your point.
|
||||
|
||||
Engage by questioning their optimism and emphasizing the potential downsides they may have overlooked. Address each of their counterpoints to showcase why a conservative stance is ultimately the safest path for the firm's assets. Focus on debating and critiquing their arguments to demonstrate the strength of a low-risk strategy over their approaches. Output conversationally as if you are speaking without any special formatting."""
|
||||
Here is the current conversation history: {history} Here is the last response from the risky analyst: {current_risky_response} Here is the last response from the neutral analyst: {current_neutral_response}
|
||||
|
||||
Remember, you must actively counter the other analysts' viewpoints and strongly advocate for why a more conservative approach should be taken. Use data and analysis to support your stance, emphasizing the importance of risk management and capital preservation."""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
argument = f"Safe Analyst: {response.content}"
|
||||
# Update safe history
|
||||
updated_safe_history = safe_history + f"\n\nSafe Analyst: {response.content}"
|
||||
|
||||
# Update general history
|
||||
updated_history = history + f"\n\nSafe Analyst: {response.content}"
|
||||
|
||||
new_risk_debate_state = {
|
||||
"history": history + "\n" + argument,
|
||||
"risky_history": risk_debate_state.get("risky_history", ""),
|
||||
"safe_history": safe_history + "\n" + argument,
|
||||
"safe_history": updated_safe_history,
|
||||
"neutral_history": risk_debate_state.get("neutral_history", ""),
|
||||
"history": updated_history,
|
||||
"latest_speaker": "Safe",
|
||||
"current_risky_response": risk_debate_state.get(
|
||||
"current_risky_response", ""
|
||||
),
|
||||
"current_safe_response": argument,
|
||||
"current_neutral_response": risk_debate_state.get(
|
||||
"current_neutral_response", ""
|
||||
),
|
||||
"current_risky_response": current_risky_response,
|
||||
"current_safe_response": response.content,
|
||||
"current_neutral_response": current_neutral_response,
|
||||
"judge_decision": risk_debate_state.get("judge_decision", ""),
|
||||
"count": risk_debate_state["count"] + 1,
|
||||
}
|
||||
|
||||
return {"risk_debate_state": new_risk_debate_state}
|
||||
return {
|
||||
"risk_debate_state": new_risk_debate_state,
|
||||
}
|
||||
|
||||
return safe_node
|
||||
|
|
|
|||
|
|
@ -18,7 +18,26 @@ def create_neutral_debator(llm):
|
|||
|
||||
trader_decision = state["trader_investment_plan"]
|
||||
|
||||
prompt = f"""As the Neutral Risk Analyst, your role is to provide a balanced perspective, weighing both the potential benefits and risks of the trader's decision or plan. You prioritize a well-rounded approach, evaluating the upsides and downsides while factoring in broader market trends, potential economic shifts, and diversification strategies.Here is the trader's decision:
|
||||
# 默认设置为中文
|
||||
output_language = "chinese"
|
||||
|
||||
if output_language == "chinese":
|
||||
prompt = f"""作为中性风险分析师,你的任务是提供平衡的观点,权衡交易员决定或计划的潜在收益和风险。你优先考虑全面的方法,评估上行和下行空间,同时考虑更广泛的市场趋势、潜在的经济变化和多元化策略。以下是交易员的决定:
|
||||
|
||||
{trader_decision}
|
||||
|
||||
你的任务是挑战激进和保守分析师,指出每种观点可能过于乐观或过于谨慎的地方。使用以下数据源的洞察来支持适度、可持续的策略来调整交易员的决定:
|
||||
|
||||
市场研究报告:{market_research_report}
|
||||
社交媒体情绪报告:{sentiment_report}
|
||||
最新世界事务报告:{news_report}
|
||||
公司基本面报告:{fundamentals_report}
|
||||
|
||||
以下是当前对话历史:{history} 以下是激进分析师的最后回应:{current_risky_response} 以下是保守分析师的最后回应:{current_safe_response}
|
||||
|
||||
请记住,你必须挑战两种观点,提供平衡的分析,并主张为什么中等风险的方法可能是最优的。使用数据和分析来支持你的立场,强调平衡风险和回报的重要性。"""
|
||||
else:
|
||||
prompt = f"""As the Neutral Risk Analyst, your role is to provide a balanced perspective, weighing both the potential benefits and risks of the trader's decision or plan. You prioritize a well-rounded approach, evaluating the upsides and downsides while factoring in broader market trends, potential economic shifts, and diversification strategies.Here is the trader's decision:
|
||||
|
||||
{trader_decision}
|
||||
|
||||
|
|
@ -28,28 +47,34 @@ Market Research Report: {market_research_report}
|
|||
Social Media Sentiment Report: {sentiment_report}
|
||||
Latest World Affairs Report: {news_report}
|
||||
Company Fundamentals Report: {fundamentals_report}
|
||||
Here is the current conversation history: {history} Here is the last response from the risky analyst: {current_risky_response} Here is the last response from the safe analyst: {current_safe_response}. If there are no responses from the other viewpoints, do not halluncinate and just present your point.
|
||||
|
||||
Engage actively by analyzing both sides critically, addressing weaknesses in the risky and conservative arguments to advocate for a more balanced approach. Challenge each of their points to illustrate why a moderate risk strategy might offer the best of both worlds, providing growth potential while safeguarding against extreme volatility. Focus on debating rather than simply presenting data, aiming to show that a balanced view can lead to the most reliable outcomes. Output conversationally as if you are speaking without any special formatting."""
|
||||
Here is the current conversation history: {history} Here is the last response from the risky analyst: {current_risky_response} Here is the last response from the safe analyst: {current_safe_response}
|
||||
|
||||
Remember, you must challenge both perspectives, provide balanced analysis, and advocate for why a moderate risk approach might be optimal. Use data and analysis to support your stance, emphasizing the importance of balancing risk and reward."""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
argument = f"Neutral Analyst: {response.content}"
|
||||
# Update neutral history
|
||||
updated_neutral_history = neutral_history + f"\n\nNeutral Analyst: {response.content}"
|
||||
|
||||
# Update general history
|
||||
updated_history = history + f"\n\nNeutral Analyst: {response.content}"
|
||||
|
||||
new_risk_debate_state = {
|
||||
"history": history + "\n" + argument,
|
||||
"risky_history": risk_debate_state.get("risky_history", ""),
|
||||
"safe_history": risk_debate_state.get("safe_history", ""),
|
||||
"neutral_history": neutral_history + "\n" + argument,
|
||||
"neutral_history": updated_neutral_history,
|
||||
"history": updated_history,
|
||||
"latest_speaker": "Neutral",
|
||||
"current_risky_response": risk_debate_state.get(
|
||||
"current_risky_response", ""
|
||||
),
|
||||
"current_safe_response": risk_debate_state.get("current_safe_response", ""),
|
||||
"current_neutral_response": argument,
|
||||
"current_risky_response": current_risky_response,
|
||||
"current_safe_response": current_safe_response,
|
||||
"current_neutral_response": response.content,
|
||||
"judge_decision": risk_debate_state.get("judge_decision", ""),
|
||||
"count": risk_debate_state["count"] + 1,
|
||||
}
|
||||
|
||||
return {"risk_debate_state": new_risk_debate_state}
|
||||
return {
|
||||
"risk_debate_state": new_risk_debate_state,
|
||||
}
|
||||
|
||||
return neutral_node
|
||||
|
|
|
|||
|
|
@ -19,18 +19,34 @@ def create_trader(llm, memory):
|
|||
for i, rec in enumerate(past_memories, 1):
|
||||
past_memory_str += rec["recommendation"] + "\n\n"
|
||||
|
||||
context = {
|
||||
"role": "user",
|
||||
"content": f"Based on a comprehensive analysis by a team of analysts, here is an investment plan tailored for {company_name}. 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.",
|
||||
}
|
||||
# 根据配置选择语言
|
||||
config = getattr(memory, 'config', {})
|
||||
if config.get("output_language", "english") == "chinese":
|
||||
context = {
|
||||
"role": "user",
|
||||
"content": f"基于分析师团队的综合分析,这是为{company_name}量身定制的投资计划。该计划融合了来自当前技术市场趋势、宏观经济指标和社交媒体情绪的洞察。将此计划作为评估你下一个交易决策的基础。\n\n建议的投资计划:{investment_plan}\n\n利用这些洞察做出明智和战略性的决策。",
|
||||
}
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": f"""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. Do not forget to utilize lessons from past decisions to learn from your mistakes. Here is some reflections from similar situatiosn you traded in and the lessons learned: {past_memory_str}""",
|
||||
},
|
||||
context,
|
||||
]
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": f"""你是一个分析市场数据以做出投资决策的交易代理。基于你的分析,提供买入、卖出或持有的具体建议。以坚定的决定结束,并始终以'最终交易提案:**买入/持有/卖出**'结束你的回应以确认你的建议。不要忘记利用过去决策的经验教训来从错误中学习。以下是你在类似情况下交易的一些反思和学到的经验教训:{past_memory_str}""",
|
||||
},
|
||||
context,
|
||||
]
|
||||
else:
|
||||
context = {
|
||||
"role": "user",
|
||||
"content": f"Based on a comprehensive analysis by a team of analysts, here is an investment plan tailored for {company_name}. 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": f"""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. Do not forget to utilize lessons from past decisions to learn from your mistakes. Here is some reflections from similar situatiosn you traded in and the lessons learned: {past_memory_str}""",
|
||||
},
|
||||
context,
|
||||
]
|
||||
|
||||
result = llm.invoke(messages)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,4 +18,6 @@ DEFAULT_CONFIG = {
|
|||
"max_recur_limit": 100,
|
||||
# Tool settings
|
||||
"online_tools": True,
|
||||
# Language settings
|
||||
"output_language": "chinese", # Options: "english", "chinese"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue