market_analysis.datafetcher
Concurrent asset loading utilities.
This module defines the DataFetcher class, which creates Asset instances and downloads their data in parallel using threads.
Module Contents
Classes
Load and manage multiple Asset objects concurrently. |
API
- class market_analysis.datafetcher.DataFetcher(ticker_config: dict[str, dict[str, str]], max_workers: int = MAX_WORKERS)
Load and manage multiple Asset objects concurrently.
DataFetcher initializes Asset instances from a ticker configuration mapping and retrieves their historical data using a ThreadPoolExecutor.
Initialization
Initialize the DataFetcher.
Parameters
ticker_config : dict[str, dict[str, str]] Mapping of ticker symbols to configuration dictionaries. Each configuration must include a “label” key (e.g., {“^ATX”: {“label”: “ATX”}}). max_workers : int, optional Maximum number of threads used for concurrent downloads.
- load_assets() dict[str, market_analysis.asset.Asset]
Create Asset instances and fetch their data concurrently.
Assets are created in the order defined by
ticker_config. Only assets whose data was successfully fetched are included in the result.Returns
dict[str, Asset] Mapping of ticker symbols to Asset instances with successfully loaded data.