Implementation:AI4Finance Foundation FinRobot execute financial data step
| Knowledge Sources | |
|---|---|
| Domains | Finance, Data_Extraction, Pipeline_Step |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
Concrete shared pipeline step for running a data agent, fetching canonical FINANCIALS + PRICE, extracting a typed FinancialData snapshot, and building HistoricalMetrics + forward estimates, provided by the FinRobot shared helpers layer.
Description
The execute_financial_data_step function is the standard data-collection step shared by the equity_research, DCF, LBO, and comps pipelines. Centralised in _helpers.py so changes to extraction logic propagate everywhere.
The step:
- Runs the data agent for narrative
- Fetches FINANCIALS and PRICE via canonical fetch (provider failover, cache)
- Extracts FinancialData via extract_financial_data (with cross-validation warnings)
- Freezes the day-over-day session-change amount for traceable artifact leaves
- Fetches FORWARD_ESTIMATES (best-effort — a forward miss never fails the step)
- Builds HistoricalMetrics from multi-year data (consumed by DCF/LBO/technical steps)
Usage
- DCF_Valuation workflow (Step 1): Historical Data step.
- DDM_Valuation workflow (Step 1): Historical Data step.
- LBO_Analysis workflow (Step 1): Data Collection step.
- Comps_Analysis workflow (Step 1): Target Data step.
- Import this when you need a standard data-collection step in a pipeline. It writes to structured_context keys: historical_data / data_collection, historical_metrics, forward_estimates_raw, forward_financials.
Code Reference
Source Location
- Repository: FinRobot
- File: finrobot_desktop/finrobot/engine/pipelines/_helpers.py
Signature
async def execute_financial_data_step(
agent: Agent[Any, Any],
deps: FinRobotDeps,
prompt: str,
structured_context: dict[str, object],
ticker: str,
**_kwargs: object,
) -> StepOutput:
"""Standard data-collection step: run agent + fetch financials/price + extract.
Used by equity_research, dcf, lbo, comps pipelines. Centralised here so
changes to extraction logic propagate everywhere.
Also builds HistoricalMetrics from multi-year data and injects it into
structured_context (consumed by the DCF/LBO/technical steps).
"""
Import
from finrobot.engine.pipelines._helpers import execute_financial_data_step
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| agent | Agent | Yes | PydanticAI data agent for narrative |
| deps | FinRobotDeps | Yes | Settings, data_layer, artifact_store |
| prompt | str | Yes | Prompt for the agent |
| structured_context | dict | Yes | Mutable context dict |
| ticker | str | Yes Target company symbol |
Outputs
| Name | Type | Description |
|---|---|---|
| StepOutput | StepOutput | FinancialData in structured_data; writes historical_metrics, forward_estimates_raw, forward_financials, price_session to structured_context |
Usage Examples
Standard Data Collection Step
from finrobot.engine.pipelines._helpers import execute_financial_data_step
result = await execute_financial_data_step(
agent=data_agent,
deps=deps,
prompt="Collect financial data for analysis",
structured_context=ctx,
ticker="AAPL",
)
financial_data = result.structured_data # FinancialData
historical = ctx["historical_metrics"] # HistoricalMetrics