FinancialDatasetsTools 提供了一个全面的 API,用于从多个提供商检索和分析各种金融数据集,包括股价、财务报表、公司信息、SEC 备案文件和加密货币数据。

先决条件

该工具包需要一个 Financial Datasets API 密钥,可以通过在 financialdatasets.ai 注册账户获得。

pip install agno

将您的 API 密钥设置为环境变量:

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")

更多示例,请参阅 Financial Datasets Examples

工具包参数

ParameterTypeDefaultDescription
api_keyOptional[str]None可选的 API 密钥。如果未提供,则使用 FINANCIAL_DATASETS_API_KEY 环境变量
enable_financial_statementsboolTrue启用与财务报表相关的函数(损益表、资产负债表等)
enable_company_infoboolTrue启用公司信息相关函数
enable_market_databoolTrue启用市场数据相关函数(股价、收益、指标)
enable_ownership_databoolTrue启用所有权数据相关函数(内部交易、机构持股)
enable_newsboolTrue启用新闻相关函数
enable_sec_filingsboolTrue启用 SEC 备案文件相关函数
enable_cryptoboolTrue启用加密货币相关函数
enable_searchboolTrue启用搜索相关函数

工具包函数

FunctionDescription
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)获取按产品类别和地理区域划分的细分财务数据

速率限制和使用

Financial Datasets API 可能会根据您的订阅级别设置使用限制。请参阅其文档了解具体的速率限制信息。

开发者资源