Skip to content

Loader

finml_core.data.loader

MarketDataLoader(source='yfinance')

Automated Data Ingestor and Standardizer.

This class acts as the primary gateway for raw market data. Its core mission is to abstract the complexity of external APIs, transforming heterogeneous data sources into the internal standardized Long-Format MultiIndex required by the entire library ecosystem.

The engine ensures that regardless of the provider, the final output strictly adheres to a [Date, Ticker] MultiIndex structure with standardized OCHLV columns.

The constructor initializes the loader by selecting a specific data provider registry. This setup determines the internal mapping logic that will be applied during the standardization process.

Parameters:

Name Type Description Default
source str

Provider name from the PROVIDERS registry.

'yfinance'

get_financial_data(tickers, etf, start, end=None)

Fetches and standardizes financial data from the configured source.

This method acts as a high-level factory. It ensures that regardless of the source's original API format, the output is consistently aligned and ready for the DatasetGenerator or any other standalone class within the library (e.g., FeatureGenerator, TripleBarrierLabeling).

Parameters:

Name Type Description Default
tickers List[str]

List of asset symbols to fetch.

required
etf str

Reference ETF (e.g., '^GSPC') used to define the market calendar and align trading days.

required
start str

Start date/time. Supports various resolutions (e.g., YYYY-MM-DD or YYYY-MM-DD HH:MM:SS) depending on the providers capability.

required
end str

End date/time. Supports the same resolutions as start. Defaults to today.

None

Returns:

Type Description
DataFrame

A standardized MultiIndex DataFrame (Date, Ticker) containing adjusted OHLCV data, ready for quantitative analysis.

Raises:

Type Description
KeyError

If the source provided during initialization is not yet implemented in the data fetching logic.