Principle:AI4Finance Foundation FinGPT Market Data Acquisition
| Knowledge Sources | |
|---|---|
| Domains | Finance, Data_Acquisition |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
The process of acquiring structured financial market data—prices, news, and fundamental metrics—from external data providers for use in model training and inference pipelines.
Description
Financial market data acquisition is the foundational step in any quantitative finance or financial LLM pipeline. It involves fetching historical price data (open, close, adjusted close), company news (headlines, summaries), and fundamental financials (quarterly metrics) from external APIs such as yfinance and Finnhub. The acquired data is structured into tabular formats with time-aligned weekly windows, enabling downstream prompt construction and model training.
The core challenge is integrating heterogeneous data sources with different rate limits, data formats, and coverage. This principle addresses the need for reliable, reproducible data pipelines that can handle multi-source aggregation, rate limiting, and temporal alignment.
Usage
Use this principle when building any financial model pipeline that requires historical market data:
- Training data preparation: Fetching historical prices, news, and fundamentals for LoRA fine-tuning datasets.
- Inference data fetching: Retrieving live market data for real-time predictions.
- Multi-market support: Resolving ticker symbols across different markets (US, India NSE/BSE).
This is always the first step in a financial LLM pipeline—the data quality directly determines model performance.
Theoretical Basis
Financial data acquisition rests on the efficient market hypothesis principle: market prices incorporate available information, and structured news/fundamentals data can provide signals for prediction. The temporal alignment of weekly windows ensures that the model sees information in the same chronological order it would have been available in practice, preventing look-ahead bias.
Key data structures:
- Weekly price windows: Start/End Date, Start/End Price, Weekly Returns, Bin Label
- News records: Date, Headline, Summary (JSON-encoded per week)
- Basic financials: Quarterly metrics aligned to the nearest reporting period
Pseudo-code for temporal alignment:
# Abstract: align news to weekly price windows
for each weekly_window:
news = fetch_news(symbol, window_start, window_end)
basics = fetch_fundamentals(symbol, nearest_report <= window_end)
return {price_data, news, basics}
Practical Guide
- Set API keys via environment variables (`FINNHUB_KEY`, `FINNHUB_API_KEY`, `OPENAI_KEY`).
- Respect rate limits: Finnhub has queries-per-minute limits; add `time.sleep(1)` between news calls.
- Use `with_basics=True` for richer prompts but expect slower data acquisition.
- For multi-market support, resolve symbols before fetching (e.g., Indian tickers need `.NS`/`.BO` suffixes for yfinance).
Related Pages
Implemented By
- Implementation:AI4Finance_Foundation_FinGPT_prepare_data_for_symbol
- Implementation:AI4Finance_Foundation_FinGPT_resolve_symbol
- Implementation:AI4Finance_Foundation_FinGPT_construct_prompt