add get white paper, get market capitalization, get fundamental data of crypto
This commit is contained in:
parent
454d1b9d3c
commit
4ff4a6eb3c
|
|
@ -1,7 +1,7 @@
|
|||
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_sentiment, get_insider_transactions
|
||||
from tradingagents.agents.utils.agent_utils import get_fundamentals, get_whitepaper, get_market_cap
|
||||
from tradingagents.dataflows.config import get_config
|
||||
|
||||
|
||||
|
|
@ -13,15 +13,14 @@ def create_fundamentals_analyst(llm):
|
|||
|
||||
tools = [
|
||||
get_fundamentals,
|
||||
get_balance_sheet,
|
||||
get_cashflow,
|
||||
get_income_statement,
|
||||
get_whitepaper,
|
||||
get_market_cap
|
||||
]
|
||||
|
||||
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."
|
||||
"You are a researcher tasked with analyzing fundamental information over the past week about a crypto-currency coin. Please write a comprehensive report of the coin's fundamental information such as fundamental information, whitepaper, and global market capitalization to gain a full view of the coin'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.",
|
||||
+ " Use the available tools: `get_fundamentals` for comprehensive coin analysis, `get_whitepaper`, and `get_market_cap` for specific information.",
|
||||
)
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ from tradingagents.agents.utils.fundamental_data_tools import (
|
|||
get_fundamentals,
|
||||
get_balance_sheet,
|
||||
get_cashflow,
|
||||
get_income_statement
|
||||
get_income_statement,
|
||||
get_whitepaper,
|
||||
get_market_cap
|
||||
)
|
||||
from tradingagents.agents.utils.news_data_tools import (
|
||||
get_news,
|
||||
|
|
|
|||
|
|
@ -74,4 +74,28 @@ def get_income_statement(
|
|||
Returns:
|
||||
str: A formatted report containing income statement data
|
||||
"""
|
||||
return route_to_vendor("get_income_statement", ticker, freq, curr_date)
|
||||
return route_to_vendor("get_income_statement", ticker, freq, curr_date)
|
||||
|
||||
@tool
|
||||
def get_whitepaper(
|
||||
ticker: Annotated[str, "ticker symbol"],
|
||||
) -> str:
|
||||
"""
|
||||
Retrieve the whitepaper for a given ticker symbol.
|
||||
Uses the configured fundamental_data vendor.
|
||||
Args:
|
||||
ticker (str): Ticker symbol of the cryptocurrency
|
||||
Returns:
|
||||
str: A formatted string containing the whitepaper link or content
|
||||
"""
|
||||
return route_to_vendor("get_whitepaper", ticker)
|
||||
|
||||
@tool
|
||||
def get_market_cap() -> str:
|
||||
"""
|
||||
Retrieve the market capitalization percentages for cryptocurrencies.
|
||||
Uses the configured fundamental_data vendor.
|
||||
Returns:
|
||||
str: A formatted string containing market capitalization percentages
|
||||
"""
|
||||
return route_to_vendor("get_market_cap")
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import requests
|
||||
from .alpha_vantage_common import API_BASE_URL
|
||||
|
||||
def get_market_cap() -> str:
|
||||
"""
|
||||
Retrieve the market capitalization percentage data for various cryptocurrencies using CoinGecko.
|
||||
|
||||
Returns:
|
||||
str: Market capitalization percentage data for cryptocurrencies
|
||||
"""
|
||||
endpoint = f"https://api.coingecko.com/api/v3/global"
|
||||
response = requests.get(endpoint)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
market_cap_pct = data.get("data", {}).get("market_cap_percentage", {})
|
||||
# return json.dumps(result, indent=2)
|
||||
result = "# Market Capitalization Percentage Data\n\n"
|
||||
for coin, percentage in market_cap_pct.items():
|
||||
# Format each line as "Coin: XX.XX%"
|
||||
result += f"- {coin.upper()}: {percentage:.2f}%\n"
|
||||
return result
|
||||
|
|
@ -4,7 +4,7 @@ from typing import Annotated
|
|||
from .local import get_YFin_data, get_finnhub_news, get_finnhub_company_insider_sentiment, get_finnhub_company_insider_transactions, get_simfin_balance_sheet, get_simfin_cashflow, get_simfin_income_statements, get_reddit_global_news, get_reddit_company_news
|
||||
from .y_finance import get_YFin_data_online, get_stock_stats_indicators_window, get_balance_sheet as get_yfinance_balance_sheet, get_cashflow as get_yfinance_cashflow, get_income_statement as get_yfinance_income_statement, get_insider_transactions as get_yfinance_insider_transactions
|
||||
from .google import get_google_news
|
||||
from .openai import get_crypto_news_openai, get_global_news_openai, get_fundamentals_openai
|
||||
from .openai import get_crypto_news_openai, get_global_news_openai, get_fundamentals_openai, get_whitepaper_openai
|
||||
from .alpha_vantage import (
|
||||
get_stock as get_alpha_vantage_stock,
|
||||
get_indicator as get_alpha_vantage_indicator,
|
||||
|
|
@ -17,6 +17,7 @@ from .alpha_vantage import (
|
|||
)
|
||||
from .alpha_vantage_common import AlphaVantageRateLimitError
|
||||
from .telegram import get_crypto_news_telegram
|
||||
from .coin_gecko_fundamentals import get_market_cap as get_coin_gecko_market_cap
|
||||
|
||||
# Configuration and routing logic
|
||||
from .config import get_config
|
||||
|
|
@ -39,9 +40,11 @@ TOOLS_CATEGORIES = {
|
|||
"description": "Company fundamentals",
|
||||
"tools": [
|
||||
"get_fundamentals",
|
||||
"get_balance_sheet",
|
||||
"get_cashflow",
|
||||
"get_income_statement"
|
||||
# "get_balance_sheet",
|
||||
# "get_cashflow",
|
||||
# "get_income_statement",
|
||||
"get_whitepaper",
|
||||
"get_market_cap"
|
||||
]
|
||||
},
|
||||
"news_data": {
|
||||
|
|
@ -59,7 +62,10 @@ VENDOR_LIST = [
|
|||
"local",
|
||||
"yfinance",
|
||||
"openai",
|
||||
"google"
|
||||
"google",
|
||||
"telegram",
|
||||
"coin_gecko",
|
||||
"alpha_vantage",
|
||||
]
|
||||
|
||||
# Mapping of methods to their vendor-specific implementations
|
||||
|
|
@ -78,9 +84,15 @@ VENDOR_METHODS = {
|
|||
},
|
||||
# fundamental_data
|
||||
"get_fundamentals": {
|
||||
"alpha_vantage": get_alpha_vantage_fundamentals,
|
||||
# "alpha_vantage": get_alpha_vantage_fundamentals,
|
||||
"openai": get_fundamentals_openai,
|
||||
},
|
||||
"get_whitepaper": {
|
||||
"openai": get_whitepaper_openai,
|
||||
},
|
||||
"get_market_cap" : {
|
||||
"coin_gecko": get_coin_gecko_market_cap
|
||||
},
|
||||
"get_balance_sheet": {
|
||||
"alpha_vantage": get_alpha_vantage_balance_sheet,
|
||||
"yfinance": get_yfinance_balance_sheet,
|
||||
|
|
|
|||
|
|
@ -117,7 +117,42 @@ def get_fundamentals_openai(ticker, curr_date):
|
|||
"content": [
|
||||
{
|
||||
"type": "input_text",
|
||||
"text": f"Can you search Fundamental for discussions on {ticker} during of the month before {curr_date} to the month of {curr_date}. Make sure you only get the data posted during that period. List as a table, with PE/PS/Cash flow/ etc",
|
||||
# "text": f"Can you search Fundamental for discussions on {ticker} during of the month before {curr_date} to the month of {curr_date}. Make sure you only get the data posted during that period. List as a table, with PE/PS/Cash flow/ etc",
|
||||
"text": f"Can you search Fundamental data on {ticker} crypto-currency coin before {curr_date} to {curr_date}. Make sure you only get the data posted during that period. The data includes purpose, use case, technology, token utility, tokenomics, team & organization, development activity, ecosystem & adoption, and governance & community.",
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
text={"format": {"type": "text"}},
|
||||
reasoning={},
|
||||
tools=[
|
||||
{
|
||||
"type": "web_search_preview",
|
||||
"user_location": {"type": "approximate"},
|
||||
"search_context_size": "low",
|
||||
}
|
||||
],
|
||||
temperature=1,
|
||||
max_output_tokens=4096,
|
||||
top_p=1,
|
||||
store=True,
|
||||
)
|
||||
|
||||
return response.output[1].content[0].text
|
||||
|
||||
def get_whitepaper_openai(symbol):
|
||||
config = get_config()
|
||||
client = OpenAI(base_url=config["backend_url"])
|
||||
|
||||
response = client.responses.create(
|
||||
model=config["quick_think_llm"],
|
||||
input=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": [
|
||||
{
|
||||
"type": "input_text",
|
||||
"text": f"Give me the summary of {symbol} crypto coin white paper.",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ from tradingagents.agents.utils.agent_utils import (
|
|||
get_stock_data,
|
||||
get_indicators,
|
||||
get_fundamentals,
|
||||
get_whitepaper,
|
||||
get_market_cap,
|
||||
get_balance_sheet,
|
||||
get_cashflow,
|
||||
get_income_statement,
|
||||
|
|
@ -142,17 +144,19 @@ class TradingAgentsGraph:
|
|||
# News and insider information
|
||||
get_news,
|
||||
get_global_news,
|
||||
get_insider_sentiment,
|
||||
get_insider_transactions,
|
||||
# get_insider_sentiment,
|
||||
# get_insider_transactions,
|
||||
]
|
||||
),
|
||||
"fundamentals": ToolNode(
|
||||
[
|
||||
# Fundamental analysis tools
|
||||
get_fundamentals,
|
||||
get_balance_sheet,
|
||||
get_cashflow,
|
||||
get_income_statement,
|
||||
get_whitepaper,
|
||||
get_market_cap,
|
||||
# get_balance_sheet,
|
||||
# get_cashflow,
|
||||
# get_income_statement,
|
||||
]
|
||||
),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue