chore: remove old stock-specific agent and tool files
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2474f7ad58
commit
2d55fcc564
File diff suppressed because one or more lines are too long
|
|
@ -1,63 +0,0 @@
|
||||||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
|
||||||
import time
|
|
||||||
import json
|
|
||||||
from tradingagents.agents.utils.agent_utils import get_fundamentals, get_balance_sheet, get_cashflow, get_income_statement, get_insider_transactions
|
|
||||||
from tradingagents.dataflows.config import get_config
|
|
||||||
|
|
||||||
|
|
||||||
def create_fundamentals_analyst(llm):
|
|
||||||
def fundamentals_analyst_node(state):
|
|
||||||
current_date = state["trade_date"]
|
|
||||||
ticker = state["company_of_interest"]
|
|
||||||
company_name = state["company_of_interest"]
|
|
||||||
|
|
||||||
tools = [
|
|
||||||
get_fundamentals,
|
|
||||||
get_balance_sheet,
|
|
||||||
get_cashflow,
|
|
||||||
get_income_statement,
|
|
||||||
]
|
|
||||||
|
|
||||||
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, and company financial history 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."
|
|
||||||
+ " Use the available tools: `get_fundamentals` for comprehensive company analysis, `get_balance_sheet`, `get_cashflow`, and `get_income_statement` for specific financial statements.",
|
|
||||||
)
|
|
||||||
|
|
||||||
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}",
|
|
||||||
),
|
|
||||||
MessagesPlaceholder(variable_name="messages"),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
prompt = prompt.partial(system_message=system_message)
|
|
||||||
prompt = prompt.partial(tool_names=", ".join([tool.name for tool in tools]))
|
|
||||||
prompt = prompt.partial(current_date=current_date)
|
|
||||||
prompt = prompt.partial(ticker=ticker)
|
|
||||||
|
|
||||||
chain = prompt | llm.bind_tools(tools)
|
|
||||||
|
|
||||||
result = chain.invoke(state["messages"])
|
|
||||||
|
|
||||||
report = ""
|
|
||||||
|
|
||||||
if len(result.tool_calls) == 0:
|
|
||||||
report = result.content
|
|
||||||
|
|
||||||
return {
|
|
||||||
"messages": [result],
|
|
||||||
"fundamentals_report": report,
|
|
||||||
}
|
|
||||||
|
|
||||||
return fundamentals_analyst_node
|
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
|
||||||
import time
|
|
||||||
import json
|
|
||||||
from tradingagents.agents.utils.agent_utils import get_stock_data, get_indicators
|
|
||||||
from tradingagents.dataflows.config import get_config
|
|
||||||
|
|
||||||
|
|
||||||
def create_market_analyst(llm):
|
|
||||||
|
|
||||||
def market_analyst_node(state):
|
|
||||||
current_date = state["trade_date"]
|
|
||||||
ticker = state["company_of_interest"]
|
|
||||||
company_name = state["company_of_interest"]
|
|
||||||
|
|
||||||
tools = [
|
|
||||||
get_stock_data,
|
|
||||||
get_indicators,
|
|
||||||
]
|
|
||||||
|
|
||||||
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.
|
|
||||||
- close_200_sma: 200 SMA: A long-term trend benchmark. Usage: Confirm overall market trend and identify golden/death cross setups. Tips: It reacts slowly; best for strategic trend confirmation rather than frequent trading entries.
|
|
||||||
- close_10_ema: 10 EMA: A responsive short-term average. Usage: Capture quick shifts in momentum and potential entry points. Tips: Prone to noise in choppy markets; use alongside longer averages for filtering false signals.
|
|
||||||
|
|
||||||
MACD Related:
|
|
||||||
- macd: MACD: Computes momentum via differences of EMAs. Usage: Look for crossovers and divergence as signals of trend changes. Tips: Confirm with other indicators in low-volatility or sideways markets.
|
|
||||||
- macds: MACD Signal: An EMA smoothing of the MACD line. Usage: Use crossovers with the MACD line to trigger trades. Tips: Should be part of a broader strategy to avoid false positives.
|
|
||||||
- macdh: MACD Histogram: Shows the gap between the MACD line and its signal. Usage: Visualize momentum strength and spot divergence early. Tips: Can be volatile; complement with additional filters in fast-moving markets.
|
|
||||||
|
|
||||||
Momentum Indicators:
|
|
||||||
- rsi: RSI: Measures momentum to flag overbought/oversold conditions. Usage: Apply 70/30 thresholds and watch for divergence to signal reversals. Tips: In strong trends, RSI may remain extreme; always cross-check with trend analysis.
|
|
||||||
|
|
||||||
Volatility Indicators:
|
|
||||||
- boll: Bollinger Middle: A 20 SMA serving as the basis for Bollinger Bands. Usage: Acts as a dynamic benchmark for price movement. Tips: Combine with the upper and lower bands to effectively spot breakouts or reversals.
|
|
||||||
- boll_ub: Bollinger Upper Band: Typically 2 standard deviations above the middle line. Usage: Signals potential overbought conditions and breakout zones. Tips: Confirm signals with other tools; prices may ride the band in strong trends.
|
|
||||||
- boll_lb: Bollinger Lower Band: Typically 2 standard deviations below the middle line. Usage: Indicates potential oversold conditions. Tips: Use additional analysis to avoid false reversal signals.
|
|
||||||
- atr: ATR: Averages true range to measure volatility. Usage: Set stop-loss levels and adjust position sizes based on current market volatility. Tips: It's a reactive measure, so use it as part of a broader risk management strategy.
|
|
||||||
|
|
||||||
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_stock_data first to retrieve the CSV that is needed to generate indicators. Then use get_indicators with the specific indicator names. 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."""
|
|
||||||
)
|
|
||||||
|
|
||||||
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}",
|
|
||||||
),
|
|
||||||
MessagesPlaceholder(variable_name="messages"),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
prompt = prompt.partial(system_message=system_message)
|
|
||||||
prompt = prompt.partial(tool_names=", ".join([tool.name for tool in tools]))
|
|
||||||
prompt = prompt.partial(current_date=current_date)
|
|
||||||
prompt = prompt.partial(ticker=ticker)
|
|
||||||
|
|
||||||
chain = prompt | llm.bind_tools(tools)
|
|
||||||
|
|
||||||
result = chain.invoke(state["messages"])
|
|
||||||
|
|
||||||
report = ""
|
|
||||||
|
|
||||||
if len(result.tool_calls) == 0:
|
|
||||||
report = result.content
|
|
||||||
|
|
||||||
return {
|
|
||||||
"messages": [result],
|
|
||||||
"market_report": report,
|
|
||||||
}
|
|
||||||
|
|
||||||
return market_analyst_node
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
from langchain_core.messages import AIMessage
|
|
||||||
import time
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
def create_bear_researcher(llm, memory):
|
|
||||||
def bear_node(state) -> dict:
|
|
||||||
investment_debate_state = state["investment_debate_state"]
|
|
||||||
history = investment_debate_state.get("history", "")
|
|
||||||
bear_history = investment_debate_state.get("bear_history", "")
|
|
||||||
|
|
||||||
current_response = investment_debate_state.get("current_response", "")
|
|
||||||
market_research_report = state["market_report"]
|
|
||||||
sentiment_report = state["sentiment_report"]
|
|
||||||
news_report = state["news_report"]
|
|
||||||
fundamentals_report = state["fundamentals_report"]
|
|
||||||
|
|
||||||
curr_situation = f"{market_research_report}\n\n{sentiment_report}\n\n{news_report}\n\n{fundamentals_report}"
|
|
||||||
past_memories = memory.get_memories(curr_situation, n_matches=2)
|
|
||||||
|
|
||||||
past_memory_str = ""
|
|
||||||
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.
|
|
||||||
|
|
||||||
Key points to focus on:
|
|
||||||
|
|
||||||
- Risks and Challenges: Highlight factors like market saturation, financial instability, or macroeconomic threats that could hinder the stock's performance.
|
|
||||||
- Competitive Weaknesses: Emphasize vulnerabilities such as weaker market positioning, declining innovation, or threats from competitors.
|
|
||||||
- Negative Indicators: Use evidence from financial data, market trends, or recent adverse news to support your position.
|
|
||||||
- Bull Counterpoints: Critically analyze the bull argument with specific data and sound reasoning, exposing weaknesses or over-optimistic assumptions.
|
|
||||||
- Engagement: Present your argument in a conversational style, directly engaging with the bull analyst's points and debating effectively rather than simply listing facts.
|
|
||||||
|
|
||||||
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}
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = llm.invoke(prompt)
|
|
||||||
|
|
||||||
argument = f"Bear Analyst: {response.content}"
|
|
||||||
|
|
||||||
new_investment_debate_state = {
|
|
||||||
"history": history + "\n" + argument,
|
|
||||||
"bear_history": bear_history + "\n" + argument,
|
|
||||||
"bull_history": investment_debate_state.get("bull_history", ""),
|
|
||||||
"current_response": argument,
|
|
||||||
"count": investment_debate_state["count"] + 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
return {"investment_debate_state": new_investment_debate_state}
|
|
||||||
|
|
||||||
return bear_node
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
from langchain_core.messages import AIMessage
|
|
||||||
import time
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
def create_bull_researcher(llm, memory):
|
|
||||||
def bull_node(state) -> dict:
|
|
||||||
investment_debate_state = state["investment_debate_state"]
|
|
||||||
history = investment_debate_state.get("history", "")
|
|
||||||
bull_history = investment_debate_state.get("bull_history", "")
|
|
||||||
|
|
||||||
current_response = investment_debate_state.get("current_response", "")
|
|
||||||
market_research_report = state["market_report"]
|
|
||||||
sentiment_report = state["sentiment_report"]
|
|
||||||
news_report = state["news_report"]
|
|
||||||
fundamentals_report = state["fundamentals_report"]
|
|
||||||
|
|
||||||
curr_situation = f"{market_research_report}\n\n{sentiment_report}\n\n{news_report}\n\n{fundamentals_report}"
|
|
||||||
past_memories = memory.get_memories(curr_situation, n_matches=2)
|
|
||||||
|
|
||||||
past_memory_str = ""
|
|
||||||
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.
|
|
||||||
|
|
||||||
Key points to focus on:
|
|
||||||
- Growth Potential: Highlight the company's market opportunities, revenue projections, and scalability.
|
|
||||||
- Competitive Advantages: Emphasize factors like unique products, strong branding, or dominant market positioning.
|
|
||||||
- Positive Indicators: Use financial health, industry trends, and recent positive news as evidence.
|
|
||||||
- Bear Counterpoints: Critically analyze the bear argument with specific data and sound reasoning, addressing concerns thoroughly and showing why the bull perspective holds stronger merit.
|
|
||||||
- Engagement: Present your argument in a conversational style, engaging directly with the bear analyst's points and debating effectively rather than just listing data.
|
|
||||||
|
|
||||||
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}
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
response = llm.invoke(prompt)
|
|
||||||
|
|
||||||
argument = f"Bull Analyst: {response.content}"
|
|
||||||
|
|
||||||
new_investment_debate_state = {
|
|
||||||
"history": history + "\n" + argument,
|
|
||||||
"bull_history": bull_history + "\n" + argument,
|
|
||||||
"bear_history": investment_debate_state.get("bear_history", ""),
|
|
||||||
"current_response": argument,
|
|
||||||
"count": investment_debate_state["count"] + 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
return {"investment_debate_state": new_investment_debate_state}
|
|
||||||
|
|
||||||
return bull_node
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
from langchain_core.tools import tool
|
|
||||||
from typing import Annotated
|
|
||||||
from tradingagents.dataflows.interface import route_to_vendor
|
|
||||||
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def get_stock_data(
|
|
||||||
symbol: Annotated[str, "ticker symbol of the company"],
|
|
||||||
start_date: Annotated[str, "Start date in yyyy-mm-dd format"],
|
|
||||||
end_date: Annotated[str, "End date in yyyy-mm-dd format"],
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Retrieve stock price data (OHLCV) for a given ticker symbol.
|
|
||||||
Uses the configured core_stock_apis vendor.
|
|
||||||
Args:
|
|
||||||
symbol (str): Ticker symbol of the company, e.g. AAPL, TSM
|
|
||||||
start_date (str): Start date in yyyy-mm-dd format
|
|
||||||
end_date (str): End date in yyyy-mm-dd format
|
|
||||||
Returns:
|
|
||||||
str: A formatted dataframe containing the stock price data for the specified ticker symbol in the specified date range.
|
|
||||||
"""
|
|
||||||
return route_to_vendor("get_stock_data", symbol, start_date, end_date)
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
from langchain_core.tools import tool
|
|
||||||
from typing import Annotated
|
|
||||||
from tradingagents.dataflows.interface import route_to_vendor
|
|
||||||
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def get_fundamentals(
|
|
||||||
ticker: Annotated[str, "ticker symbol"],
|
|
||||||
curr_date: Annotated[str, "current date you are trading at, yyyy-mm-dd"],
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Retrieve comprehensive fundamental data for a given ticker symbol.
|
|
||||||
Uses the configured fundamental_data vendor.
|
|
||||||
Args:
|
|
||||||
ticker (str): Ticker symbol of the company
|
|
||||||
curr_date (str): Current date you are trading at, yyyy-mm-dd
|
|
||||||
Returns:
|
|
||||||
str: A formatted report containing comprehensive fundamental data
|
|
||||||
"""
|
|
||||||
return route_to_vendor("get_fundamentals", ticker, curr_date)
|
|
||||||
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def get_balance_sheet(
|
|
||||||
ticker: Annotated[str, "ticker symbol"],
|
|
||||||
freq: Annotated[str, "reporting frequency: annual/quarterly"] = "quarterly",
|
|
||||||
curr_date: Annotated[str, "current date you are trading at, yyyy-mm-dd"] = None,
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Retrieve balance sheet data for a given ticker symbol.
|
|
||||||
Uses the configured fundamental_data vendor.
|
|
||||||
Args:
|
|
||||||
ticker (str): Ticker symbol of the company
|
|
||||||
freq (str): Reporting frequency: annual/quarterly (default quarterly)
|
|
||||||
curr_date (str): Current date you are trading at, yyyy-mm-dd
|
|
||||||
Returns:
|
|
||||||
str: A formatted report containing balance sheet data
|
|
||||||
"""
|
|
||||||
return route_to_vendor("get_balance_sheet", ticker, freq, curr_date)
|
|
||||||
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def get_cashflow(
|
|
||||||
ticker: Annotated[str, "ticker symbol"],
|
|
||||||
freq: Annotated[str, "reporting frequency: annual/quarterly"] = "quarterly",
|
|
||||||
curr_date: Annotated[str, "current date you are trading at, yyyy-mm-dd"] = None,
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Retrieve cash flow statement data for a given ticker symbol.
|
|
||||||
Uses the configured fundamental_data vendor.
|
|
||||||
Args:
|
|
||||||
ticker (str): Ticker symbol of the company
|
|
||||||
freq (str): Reporting frequency: annual/quarterly (default quarterly)
|
|
||||||
curr_date (str): Current date you are trading at, yyyy-mm-dd
|
|
||||||
Returns:
|
|
||||||
str: A formatted report containing cash flow statement data
|
|
||||||
"""
|
|
||||||
return route_to_vendor("get_cashflow", ticker, freq, curr_date)
|
|
||||||
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def get_income_statement(
|
|
||||||
ticker: Annotated[str, "ticker symbol"],
|
|
||||||
freq: Annotated[str, "reporting frequency: annual/quarterly"] = "quarterly",
|
|
||||||
curr_date: Annotated[str, "current date you are trading at, yyyy-mm-dd"] = None,
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Retrieve income statement data for a given ticker symbol.
|
|
||||||
Uses the configured fundamental_data vendor.
|
|
||||||
Args:
|
|
||||||
ticker (str): Ticker symbol of the company
|
|
||||||
freq (str): Reporting frequency: annual/quarterly (default quarterly)
|
|
||||||
curr_date (str): Current date you are trading at, yyyy-mm-dd
|
|
||||||
Returns:
|
|
||||||
str: A formatted report containing income statement data
|
|
||||||
"""
|
|
||||||
return route_to_vendor("get_income_statement", ticker, freq, curr_date)
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
from langchain_core.tools import tool
|
|
||||||
from typing import Annotated
|
|
||||||
from tradingagents.dataflows.interface import route_to_vendor
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def get_news(
|
|
||||||
ticker: Annotated[str, "Ticker symbol"],
|
|
||||||
start_date: Annotated[str, "Start date in yyyy-mm-dd format"],
|
|
||||||
end_date: Annotated[str, "End date in yyyy-mm-dd format"],
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Retrieve news data for a given ticker symbol.
|
|
||||||
Uses the configured news_data vendor.
|
|
||||||
Args:
|
|
||||||
ticker (str): Ticker symbol
|
|
||||||
start_date (str): Start date in yyyy-mm-dd format
|
|
||||||
end_date (str): End date in yyyy-mm-dd format
|
|
||||||
Returns:
|
|
||||||
str: A formatted string containing news data
|
|
||||||
"""
|
|
||||||
return route_to_vendor("get_news", ticker, start_date, end_date)
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def get_global_news(
|
|
||||||
curr_date: Annotated[str, "Current date in yyyy-mm-dd format"],
|
|
||||||
look_back_days: Annotated[int, "Number of days to look back"] = 7,
|
|
||||||
limit: Annotated[int, "Maximum number of articles to return"] = 5,
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Retrieve global news data.
|
|
||||||
Uses the configured news_data vendor.
|
|
||||||
Args:
|
|
||||||
curr_date (str): Current date in yyyy-mm-dd format
|
|
||||||
look_back_days (int): Number of days to look back (default 7)
|
|
||||||
limit (int): Maximum number of articles to return (default 5)
|
|
||||||
Returns:
|
|
||||||
str: A formatted string containing global news data
|
|
||||||
"""
|
|
||||||
return route_to_vendor("get_global_news", curr_date, look_back_days, limit)
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def get_insider_transactions(
|
|
||||||
ticker: Annotated[str, "ticker symbol"],
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Retrieve insider transaction information about a company.
|
|
||||||
Uses the configured news_data vendor.
|
|
||||||
Args:
|
|
||||||
ticker (str): Ticker symbol of the company
|
|
||||||
Returns:
|
|
||||||
str: A report of insider transaction data
|
|
||||||
"""
|
|
||||||
return route_to_vendor("get_insider_transactions", ticker)
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
from langchain_core.tools import tool
|
|
||||||
from typing import Annotated
|
|
||||||
from tradingagents.dataflows.interface import route_to_vendor
|
|
||||||
|
|
||||||
@tool
|
|
||||||
def get_indicators(
|
|
||||||
symbol: Annotated[str, "ticker symbol of the company"],
|
|
||||||
indicator: Annotated[str, "technical indicator to get the analysis and report of"],
|
|
||||||
curr_date: Annotated[str, "The current trading date you are trading on, YYYY-mm-dd"],
|
|
||||||
look_back_days: Annotated[int, "how many days to look back"] = 30,
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Retrieve a single technical indicator for a given ticker symbol.
|
|
||||||
Uses the configured technical_indicators vendor.
|
|
||||||
Args:
|
|
||||||
symbol (str): Ticker symbol of the company, e.g. AAPL, TSM
|
|
||||||
indicator (str): A single technical indicator name, e.g. 'rsi', 'macd'. Call this tool once per indicator.
|
|
||||||
curr_date (str): The current trading date you are trading on, YYYY-mm-dd
|
|
||||||
look_back_days (int): How many days to look back, default is 30
|
|
||||||
Returns:
|
|
||||||
str: A formatted dataframe containing the technical indicators for the specified ticker symbol and indicator.
|
|
||||||
"""
|
|
||||||
# LLMs sometimes pass multiple indicators as a comma-separated string;
|
|
||||||
# split and process each individually.
|
|
||||||
indicators = [i.strip() for i in indicator.split(",") if i.strip()]
|
|
||||||
if len(indicators) > 1:
|
|
||||||
results = []
|
|
||||||
for ind in indicators:
|
|
||||||
results.append(route_to_vendor("get_indicators", symbol, ind, curr_date, look_back_days))
|
|
||||||
return "\n\n".join(results)
|
|
||||||
return route_to_vendor("get_indicators", symbol, indicator.strip(), curr_date, look_back_days)
|
|
||||||
Loading…
Reference in New Issue