66 lines
4.4 KiB
Python
66 lines
4.4 KiB
Python
import time
|
|
import json
|
|
|
|
|
|
def create_risky_debator(llm):
|
|
def risky_node(state) -> dict:
|
|
risk_debate_state = state["risk_debate_state"]
|
|
history = risk_debate_state.get("history", "")
|
|
risky_history = risk_debate_state.get("risky_history", "")
|
|
|
|
current_safe_response = risk_debate_state.get("current_safe_response", "")
|
|
current_neutral_response = risk_debate_state.get("current_neutral_response", "")
|
|
|
|
market_research_report = state["market_report"]
|
|
sentiment_report = state["sentiment_report"]
|
|
news_report = state["news_report"]
|
|
fundamentals_report = state["fundamentals_report"]
|
|
|
|
trader_decision = state["trader_investment_plan"]
|
|
|
|
user_position = state.get("user_position", "none")
|
|
cost_per_trade = state.get("cost_per_trade", 0.0)
|
|
|
|
prompt = f"""As the Risky Risk Analyst, your role is to actively champion high-reward, high-risk opportunities, emphasizing bold strategies and competitive advantages. Your recommendation will depend on the user's current position on the ticker and the trading cost per operation.
|
|
|
|
- The user has a current position of '{user_position}' and the cost per trade is {cost_per_trade}.
|
|
- If the user has an open long position, your recommendation can be to maintain the long position, close the long position, or close the long position and open a short position.
|
|
- If the user has an open short position, your recommendation can be to maintain the short position, close the short position, or close the short position and open a long position.
|
|
- If the user has no open position, your recommendation can be to do nothing, open a long position, or open a short position.
|
|
|
|
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}
|
|
|
|
Your task is to create a compelling case for the trader's decision by questioning and critiquing the conservative and neutral stances to demonstrate why your high-reward perspective offers the best path forward. Incorporate insights from the following sources into your arguments: Take into account that any transaction will incur a cost of {cost_per_trade}, so the potential profit of a transaction must be greater than this cost.
|
|
|
|
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."""
|
|
|
|
response = llm.invoke(prompt)
|
|
|
|
argument = f"Risky Analyst: {response.content}"
|
|
|
|
new_risk_debate_state = {
|
|
"history": history + "\n" + argument,
|
|
"risky_history": risky_history + "\n" + argument,
|
|
"safe_history": risk_debate_state.get("safe_history", ""),
|
|
"neutral_history": risk_debate_state.get("neutral_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", ""
|
|
),
|
|
"count": risk_debate_state["count"] + 1,
|
|
}
|
|
|
|
return {"risk_debate_state": new_risk_debate_state}
|
|
|
|
return risky_node
|