haive.tools.tools.toolkits.financialdatasets_toolkit¶
Financial Datasets Toolkit Module.
This module provides a toolkit for accessing comprehensive financial data through the Financial Datasets API. It offers tools for retrieving financial statements, market data, and other financial information for approximately 16,000+ tickers spanning over 30 years of historical data.
The toolkit provides access to: - Income statements - Balance sheets - Cash flow statements - Company financial metrics - Historical financial data
- Required Environment Variables:
FINANCIAL_DATASETS_API_KEY: Your Financial Datasets API key from financialdatasets.ai
OPENAI_API_KEY: An OpenAI API key for agent functionality
Examples
>>> from haive.tools.toolkits.financialdatasets_toolkit import get_financial_datasets_tools
>>> tools = get_financial_datasets_tools()
>>> # Use tools with an agent framework
>>> from langchain.agents import AgentExecutor, create_tool_calling_agent
>>> from langchain_openai import ChatOpenAI
>>> from langchain_core.prompts import ChatPromptTemplate
>>> model = ChatOpenAI(model="gpt-4o")
>>> prompt = ChatPromptTemplate.from_messages([
... ("system", system_prompt),
... ("human", "{input}"),
... ("placeholder", "{agent_scratchpad}"),
... ])
>>> agent = create_tool_calling_agent(model, tools, prompt)
>>> agent_executor = AgentExecutor(agent=agent, tools=tools)
>>> agent_executor.invoke({"input": "What was AAPL's revenue in 2023?"})
Classes¶
Configuration for Financial Datasets API access. |
Functions¶
|
Create a list of Financial Datasets tools. |
Module Contents¶
- class haive.tools.tools.toolkits.financialdatasets_toolkit.FinancialDatasetsConfig(/, **data)¶
Bases:
pydantic.BaseModelConfiguration for Financial Datasets API access.
This model manages the API keys and client configuration for accessing the Financial Datasets API.
- Parameters:
data (Any)
- api_key¶
Financial Datasets API key. If not provided, will use the FINANCIAL_DATASETS_API_KEY environment variable.
- Type:
Optional[str]
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- get_client()¶
Initialize and return a Financial Datasets API client.
- Returns:
An initialized Financial Datasets API wrapper.
- Return type:
FinancialDatasetsAPIWrapper
- Raises:
ValueError – If no API key is available (neither provided nor in environment).
- haive.tools.tools.toolkits.financialdatasets_toolkit.get_financial_datasets_tools(config=None)¶
Create a list of Financial Datasets tools.
This function creates a set of tools for accessing various financial data endpoints from the Financial Datasets API, including income statements, balance sheets, and cash flow statements.
- Parameters:
config (Optional[FinancialDatasetsConfig]) – Configuration with API key and settings. If not provided, will create a default config using environment variables.
- Returns:
A list of tools for interacting with Financial Datasets API.
- Return type:
List[Tool]
- Raises:
ValueError – If the API client cannot be initialized due to missing credentials.