先决条件
该工具包需要一个 Financial Datasets API 密钥,可以通过在 financialdatasets.ai 注册账户获得。pip install agno
export FINANCIAL_DATASETS_API_KEY=your_api_key_here
示例
Financial Datasets 工具包的基本用法:from agno.agent import Agent
from agno.tools.financial_datasets import FinancialDatasetsTools
agent = Agent(
name="Financial Data Agent",
tools=[FinancialDatasetsTools()],
description="You are a financial data specialist that helps analyze financial information for stocks and cryptocurrencies.",
instructions=[
"When given a financial query:",
"1. Use appropriate Financial Datasets methods based on the query type",
"2. Format financial data clearly and highlight key metrics",
"3. For financial statements, compare important metrics with previous periods when relevant",
"4. Calculate growth rates and trends when appropriate",
"5. Handle errors gracefully and provide meaningful feedback",
],
markdown=True,
show_tool_calls=True,
)
# Get the most recent income statement for Apple
agent.print_response("Get the most recent income statement for AAPL and highlight key metrics")
工具包参数
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | Optional[str] | None | 可选的 API 密钥。如果未提供,则使用 FINANCIAL_DATASETS_API_KEY 环境变量 |
enable_financial_statements | bool | True | 启用与财务报表相关的函数(损益表、资产负债表等) |
enable_company_info | bool | True | 启用公司信息相关函数 |
enable_market_data | bool | True | 启用市场数据相关函数(股价、收益、指标) |
enable_ownership_data | bool | True | 启用所有权数据相关函数(内部交易、机构持股) |
enable_news | bool | True | 启用新闻相关函数 |
enable_sec_filings | bool | True | 启用 SEC 备案文件相关函数 |
enable_crypto | bool | True | 启用加密货币相关函数 |
enable_search | bool | True | 启用搜索相关函数 |
工具包函数
| Function | Description |
|---|---|
get_income_statements(ticker: str, period: str = "annual", limit: int = 10) | 获取公司损益表,可选择年度、季度或过去十二个月(ttm)期间 |
get_balance_sheets(ticker: str, period: str = "annual", limit: int = 10) | 获取公司资产负债表,可选择期间 |
get_cash_flow_statements(ticker: str, period: str = "annual", limit: int = 10) | 获取公司现金流量表 |
get_company_info(ticker: str) | 获取公司信息,包括业务描述、行业和细分行业 |
get_crypto_prices(symbol: str, interval: str = "1d", limit: int = 100) | 获取加密货币价格,可配置时间间隔 |
get_earnings(ticker: str, limit: int = 10) | 获取收益报告,包含每股收益(EPS)预估、实际值和收入数据 |
get_financial_metrics(ticker: str) | 获取公司的关键财务指标和比率 |
get_insider_trades(ticker: str, limit: int = 50) | 获取内部人士买卖活动数据 |
get_institutional_ownership(ticker: str) | 获取机构投资者及其持仓信息 |
get_news(ticker: Optional[str] = None, limit: int = 50) | 获取市场新闻,可选择按公司筛选 |
get_stock_prices(ticker: str, interval: str = "1d", limit: int = 100) | 获取历史股价,可配置时间间隔 |
search_tickers(query: str, limit: int = 10) | 根据查询字符串搜索股票代码 |
get_sec_filings(ticker: str, form_type: Optional[str] = None, limit: int = 50) | 获取 SEC 备案文件,可选择按文件类型过滤(10-K、10-Q 等) |
get_segmented_financials(ticker: str, period: str = "annual", limit: int = 10) | 获取按产品类别和地理区域划分的细分财务数据 |