Data (wraquant.data)¶
Data fetching, cleaning, validation, transformation, and caching. Supports yfinance, FRED, and NASDAQ Data Link as data sources, with comprehensive cleaning pipelines for handling missing values, outliers, corporate actions, and calendar alignment.
Quick Example¶
from wraquant.data import fetch_prices
# Fetch daily OHLCV from yfinance
prices = fetch_prices(["AAPL", "MSFT", "GOOGL"], start="2020-01-01")
print(prices.head())
# Data is automatically cleaned: forward-filled, split-adjusted,
# with trading calendar alignment.
See also
Getting Started – First analysis with fetched data
Statistics (wraquant.stats) – Statistical analysis on fetched data
API Reference¶
Data fetching, cleaning, validation, transforms, and caching for financial data.
Provides a unified API for fetching prices, macroeconomic data, and other financial time series from multiple sources (Yahoo Finance, FRED, NASDAQ Data Link, CSV files), plus cleaning, validation, and transformation utilities. This module is the primary entry point for getting data into wraquant and preparing it for downstream analysis.
Key sub-modules:
Fetching (
loaders) –fetch_pricesretrieves OHLCV data,fetch_macroretrieves macroeconomic indicators, andfetch_ohlcvreturns full OHLCV bars. A pluggableProviderRegistryallows custom data sources.Cleaning (
cleaning,cleaning_advanced) – Handle missing values (fill_missing), outliers (detect_outliers,remove_outliers,winsorize), duplicates, split/dividend adjustments, OHLCV resampling, fuzzy merges, and date parsing.Validation (
validation,validation_advanced) – Check data quality withvalidate_ohlcv,validate_returns,check_completeness,check_staleness, anddata_quality_report. Schema-based validation via pandera is available throughpandera_validate.Transforms (
transforms) – Convert between prices and returns (to_returns,to_prices), compute excess returns, normalize prices, and calculate rolling/expanding z-scores.
Example
>>> from wraquant.data import fetch_prices, validate_ohlcv, to_returns
>>> prices = fetch_prices("AAPL", start="2020-01-01")
>>> report = validate_ohlcv(prices)
>>> returns = to_returns(prices["close"])
Use wraquant.data for all data ingestion and preparation. For file-
and database-based I/O (Parquet, HDF5, SQL, cloud storage), use
wraquant.io instead. The data module feeds cleaned data into
wraquant.stats, wraquant.ts, wraquant.backtest, and all
other analytical modules.
- class DataProvider[source]¶
Bases:
ABCAbstract base class for all data providers.
Subclasses must implement
fetch_pricesand declare theirname.- abstractmethod fetch_prices(symbol, start=None, end=None, **kwargs)[source]¶
Fetch closing prices for a symbol.
- Parameters:
- Return type:
- Returns:
Price series with DatetimeIndex.
- fetch_ohlcv(symbol, start=None, end=None, **kwargs)[source]¶
Fetch OHLCV data for a symbol.
- Parameters:
- Return type:
- Returns:
DataFrame with open, high, low, close, volume columns.
- class ProviderRegistry[source]¶
Bases:
objectRegistry for data providers.
Allows registering, retrieving, and listing data providers by name.
- register(provider, *, default=False)[source]¶
Register a data provider.
- Parameters:
provider (
DataProvider) – DataProvider instance to register.default (
bool, default:False) – If True, make this the default provider.
- Return type:
- get(name=None)[source]¶
Get a provider by name, or the default.
- fetch_prices(symbol, start=None, end=None, source=None, **kwargs)[source]¶
Fetch closing prices for a symbol.
Retrieves a daily close price series from the specified data provider. The default provider is determined by the registry (typically Yahoo Finance for equities).
- Parameters:
symbol (
str) – Ticker symbol (e.g.,'AAPL','EURUSD=X','BTC-USD').start (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – Start date (string, datetime, or pandas Timestamp).Nonefetches from the earliest available date.end (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – End date.Nonefetches up to today.source (
str|None, default:None) – Provider name (e.g.,'yahoo','fred').Noneuses the default provider.**kwargs (
Any) – Additional keyword arguments forwarded to the provider’sfetch_pricesmethod.
- Returns:
Price series with a DatetimeIndex.
- Return type:
- Raises:
DataFetchError – If the provider fails to fetch the data.
Example
>>> prices = fetch_prices("AAPL", start="2020-01-01")
See also
fetch_ohlcv: Fetch full OHLCV data. fetch_macro: Fetch macroeconomic series from FRED.
- fetch_ohlcv(symbol, start=None, end=None, source=None, **kwargs)[source]¶
Fetch OHLCV (Open, High, Low, Close, Volume) data for a symbol.
Returns a DataFrame with standard column names suitable for backtesting, technical analysis, and charting.
- Parameters:
symbol (
str) – Ticker symbol (e.g.,'AAPL').start (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – Start date.Nonefetches from the earliest available date.end (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – End date.Nonefetches up to today.source (
str|None, default:None) – Provider name.Noneuses the default provider.**kwargs (
Any) – Additional keyword arguments forwarded to the provider.
- Returns:
- DataFrame with columns
open,high, low,close,volumeand a DatetimeIndex.
- DataFrame with columns
- Return type:
- Raises:
DataFetchError – If the provider fails to fetch the data.
Example
>>> df = fetch_ohlcv("AAPL", start="2020-01-01")
See also
fetch_prices: Fetch close prices only (lighter weight). fetch_macro: Fetch macroeconomic series.
- fetch_macro(series_id, start=None, end=None, source='fred', **kwargs)[source]¶
Fetch macroeconomic data series.
Retrieves economic indicators from FRED (Federal Reserve Economic Data) or other macro data providers. Common series include GDP, unemployment rate (UNRATE), federal funds rate (DFF), CPI, and Treasury yields.
- Parameters:
series_id (
str) – Series identifier (e.g.,'GDP','UNRATE','DFF','T10Y2Y').start (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – Start date.Nonefetches the full history.end (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – End date.Nonefetches up to the latest available release.source (
str, default:'fred') – Provider name (default'fred').**kwargs (
Any) – Additional keyword arguments forwarded to the provider.
- Returns:
Macro data series with a DatetimeIndex.
- Return type:
- Raises:
DataFetchError – If the provider fails to fetch the data.
Example
>>> gdp = fetch_macro("GDP", source="fred")
See also
fetch_prices: Fetch asset prices. fetch_ohlcv: Fetch OHLCV bar data.
- list_providers()[source]¶
List all available data providers.
Returns the names of all registered providers (e.g.,
'yahoo','fred','nasdaq','csv'). The list depends on which optional dependencies are installed.Example
>>> providers = list_providers() >>> "yahoo" in providers True
- align_series(*series, method='inner')[source]¶
Align multiple series to a common index.
- Parameters:
- Returns:
Aligned series sharing the same index.
- Return type:
- detect_outliers(data, method='zscore', threshold=3.0)[source]¶
Flag rows that contain outlier values.
- fill_missing(data, method='ffill', limit=None)[source]¶
Fill or remove missing values.
- Parameters:
data (
DataFrame|Series) – Input data possibly containing NaN values.method (
Literal['ffill','bfill','interpolate','drop'], default:'ffill') – Strategy for handling missing values.limit (
int|None, default:None) – Maximum number of consecutive NaN values to fill. Only used with'ffill','bfill', and'interpolate'.
- Returns:
Data with missing values handled.
- Return type:
- handle_splits_dividends(prices, splits=None, dividends=None)[source]¶
Adjust a price series for stock splits and dividends.
- Parameters:
- Returns:
Adjusted price series.
- Return type:
- remove_outliers(data, method='zscore', threshold=3.0)[source]¶
Remove rows containing outlier values from the data.
- Parameters:
data (
DataFrame|Series) – Input data with a DatetimeIndex.method (
Literal['zscore','iqr','mad'], default:'zscore') – Outlier detection method.threshold (
float, default:3.0) – Sensitivity threshold. For z-score and MAD this is the number of standard deviations; for IQR it is the multiplier applied to the interquartile range.
- Returns:
Data with outlier rows removed.
- Return type:
- resample_ohlcv(ohlcv, freq='W')[source]¶
Resample OHLCV data to a lower frequency.
The aggregation follows standard financial conventions:
open – first value in the period
high – maximum value in the period
low – minimum value in the period
close – last value in the period
volume – sum over the period
- percentile_rank(data, window=252)[source]¶
Compute a rolling percentile rank.
For each date the value is ranked within the preceding window observations and expressed as a percentile (0–1).
- rank_transform(data)[source]¶
Apply a cross-sectional rank transform.
Values are replaced with their rank divided by the count of non-NaN values, producing output in the range
(0, 1].
- to_prices(returns, initial_price=100.0, method='simple')[source]¶
Convert a return series back to prices.
- Parameters:
- Returns:
Reconstructed price series beginning at initial_price.
- Return type:
- to_returns(prices, method='simple')[source]¶
Convert a price series to returns.
- Parameters:
- Returns:
Return series. The first row will be
NaN.- Return type:
- check_completeness(data, expected_freq='B')[source]¶
Report on data completeness relative to an expected frequency.
- Parameters:
- Returns:
Dictionary containing:
expected_count – number of expected periods
actual_count – number of actual observations
missing_count – number of missing periods
missing_dates – list of missing dates
completeness_pct – percentage of expected dates present
- Return type:
- check_staleness(data, max_unchanged=5)[source]¶
Detect stale (stuck/unchanged) values in a time series.
- Parameters:
- Returns:
Dictionary containing:
stale_periods – list of
(start, end, length)tuples for each run of identical values exceeding max_unchanged.total_stale_rows – total number of rows within stale periods.
- Return type:
- data_quality_report(data, freq='B')[source]¶
Generate a comprehensive data quality report.
Combines completeness, staleness, and value-range checks into a single report dictionary.
- Parameters:
- Returns:
Dictionary containing:
completeness – output of
check_completeness()staleness – output of
check_staleness()missing_values – NaN counts per column
duplicated_dates – number of duplicate index entries
date_range –
(first_date, last_date)shape –
(rows, cols)dtypes – column data types
- Return type:
- validate_ohlcv(df)[source]¶
Validate OHLCV data for common issues.
Checks performed:
high_lt_low – rows where high < low
close_outside_range – rows where close is outside [low, high]
negative_volume – rows with negative volume
missing_values – count of NaN values per column
gaps – missing business days in the index
- validate_returns(returns, max_abs=0.5)[source]¶
Validate a return series for suspicious values.
- Parameters:
- Returns:
Dictionary containing:
suspicious – indices where |return| > max_abs
has_nan – whether any NaN values exist
nan_count – number of NaN values
min – minimum return value
max – maximum return value
- Return type:
- janitor_clean_names(df)[source]¶
Clean DataFrame column names using pyjanitor.
Converts column names to lowercase snake_case, strips whitespace, and replaces special characters with underscores.
- janitor_remove_empty(df)[source]¶
Remove empty rows and columns using pyjanitor.
Drops rows and columns that are entirely NaN or empty.
- fuzzy_merge(df1, df2, left_col, right_col, threshold=80.0)[source]¶
Merge two DataFrames using fuzzy string matching via rapidfuzz.
For each value in left_col of df1, the best match above threshold in right_col of df2 is found. Matched rows are joined; unmatched rows from df1 are retained with NaN for df2 columns.
- Parameters:
- Returns:
Merged DataFrame with an additional
match_scorecolumn indicating the similarity score for each matched pair.- Return type:
- parse_dates_flexible(series)[source]¶
Parse mixed-format date strings using dateparser.
Handles a wide variety of date formats and natural language dates (e.g.
'yesterday','3 days ago').
- parse_prices(series)[source]¶
Parse price strings into numeric amounts and currencies.
Uses the
price-parserlibrary to extract amounts and currency codes from strings like'$1,234.56'or'EUR 99.99'.
- fix_text(series)[source]¶
Fix text encoding issues using ftfy and unidecode.
Repairs mojibake, normalises Unicode, and transliterates non-ASCII characters to their closest ASCII equivalents.
- pandera_validate(df, schema)[source]¶
Validate a DataFrame against a pandera schema.
Wraps
schema.validate()and returns the validated DataFrame (which may include coerced dtypes).
- create_ohlcv_schema(strict=False, coerce=True)[source]¶
Create a pandera schema for OHLCV financial data.
The schema enforces:
Columns
open,high,low,closeare positive floats.Column
volumeis a non-negative integer or float.high >= lowfor every row.closeis within[low, high]for every row.
- Parameters:
- Returns:
Schema suitable for passing to
pandera_validate().- Return type:
- create_returns_schema(max_abs_return=1.0, allow_nan=False, strict=False, coerce=True)[source]¶
Create a pandera schema for financial return data.
The schema enforces:
All return columns are float type.
Return values are within
[-max_abs_return, max_abs_return].
- Parameters:
max_abs_return (
float, default:1.0) – Maximum allowed absolute return value. Values outside[-max_abs_return, max_abs_return]fail validation.allow_nan (
bool, default:False) – Whether NaN values are allowed in return columns.strict (
bool, default:False) – If True, extra columns cause failure.coerce (
bool, default:True) – If True, attempt dtype coercion before validation.
- Returns:
Schema suitable for passing to
pandera_validate().- Return type:
Loaders¶
High-level data loading API.
Convenience functions that delegate to the provider registry.
- fetch_prices(symbol, start=None, end=None, source=None, **kwargs)[source]¶
Fetch closing prices for a symbol.
Retrieves a daily close price series from the specified data provider. The default provider is determined by the registry (typically Yahoo Finance for equities).
- Parameters:
symbol (
str) – Ticker symbol (e.g.,'AAPL','EURUSD=X','BTC-USD').start (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – Start date (string, datetime, or pandas Timestamp).Nonefetches from the earliest available date.end (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – End date.Nonefetches up to today.source (
str|None, default:None) – Provider name (e.g.,'yahoo','fred').Noneuses the default provider.**kwargs (
Any) – Additional keyword arguments forwarded to the provider’sfetch_pricesmethod.
- Returns:
Price series with a DatetimeIndex.
- Return type:
- Raises:
DataFetchError – If the provider fails to fetch the data.
Example
>>> prices = fetch_prices("AAPL", start="2020-01-01")
See also
fetch_ohlcv: Fetch full OHLCV data. fetch_macro: Fetch macroeconomic series from FRED.
- fetch_ohlcv(symbol, start=None, end=None, source=None, **kwargs)[source]¶
Fetch OHLCV (Open, High, Low, Close, Volume) data for a symbol.
Returns a DataFrame with standard column names suitable for backtesting, technical analysis, and charting.
- Parameters:
symbol (
str) – Ticker symbol (e.g.,'AAPL').start (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – Start date.Nonefetches from the earliest available date.end (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – End date.Nonefetches up to today.source (
str|None, default:None) – Provider name.Noneuses the default provider.**kwargs (
Any) – Additional keyword arguments forwarded to the provider.
- Returns:
- DataFrame with columns
open,high, low,close,volumeand a DatetimeIndex.
- DataFrame with columns
- Return type:
- Raises:
DataFetchError – If the provider fails to fetch the data.
Example
>>> df = fetch_ohlcv("AAPL", start="2020-01-01")
See also
fetch_prices: Fetch close prices only (lighter weight). fetch_macro: Fetch macroeconomic series.
- fetch_macro(series_id, start=None, end=None, source='fred', **kwargs)[source]¶
Fetch macroeconomic data series.
Retrieves economic indicators from FRED (Federal Reserve Economic Data) or other macro data providers. Common series include GDP, unemployment rate (UNRATE), federal funds rate (DFF), CPI, and Treasury yields.
- Parameters:
series_id (
str) – Series identifier (e.g.,'GDP','UNRATE','DFF','T10Y2Y').start (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – Start date.Nonefetches the full history.end (
Union[str,date,datetime,Timestamp,datetime64,None], default:None) – End date.Nonefetches up to the latest available release.source (
str, default:'fred') – Provider name (default'fred').**kwargs (
Any) – Additional keyword arguments forwarded to the provider.
- Returns:
Macro data series with a DatetimeIndex.
- Return type:
- Raises:
DataFetchError – If the provider fails to fetch the data.
Example
>>> gdp = fetch_macro("GDP", source="fred")
See also
fetch_prices: Fetch asset prices. fetch_ohlcv: Fetch OHLCV bar data.
Cleaning¶
Data cleaning utilities for financial time series.
- remove_outliers(data, method='zscore', threshold=3.0)[source]¶
Remove rows containing outlier values from the data.
- Parameters:
data (
DataFrame|Series) – Input data with a DatetimeIndex.method (
Literal['zscore','iqr','mad'], default:'zscore') – Outlier detection method.threshold (
float, default:3.0) – Sensitivity threshold. For z-score and MAD this is the number of standard deviations; for IQR it is the multiplier applied to the interquartile range.
- Returns:
Data with outlier rows removed.
- Return type:
- fill_missing(data, method='ffill', limit=None)[source]¶
Fill or remove missing values.
- Parameters:
data (
DataFrame|Series) – Input data possibly containing NaN values.method (
Literal['ffill','bfill','interpolate','drop'], default:'ffill') – Strategy for handling missing values.limit (
int|None, default:None) – Maximum number of consecutive NaN values to fill. Only used with'ffill','bfill', and'interpolate'.
- Returns:
Data with missing values handled.
- Return type:
- detect_outliers(data, method='zscore', threshold=3.0)[source]¶
Flag rows that contain outlier values.
- handle_splits_dividends(prices, splits=None, dividends=None)[source]¶
Adjust a price series for stock splits and dividends.
- Parameters:
- Returns:
Adjusted price series.
- Return type:
- align_series(*series, method='inner')[source]¶
Align multiple series to a common index.
- Parameters:
- Returns:
Aligned series sharing the same index.
- Return type:
- resample_ohlcv(ohlcv, freq='W')[source]¶
Resample OHLCV data to a lower frequency.
The aggregation follows standard financial conventions:
open – first value in the period
high – maximum value in the period
low – minimum value in the period
close – last value in the period
volume – sum over the period
Advanced Cleaning¶
Advanced data cleaning integrations using optional packages.
Provides wrappers around pyjanitor, rapidfuzz, dateparser, price-parser, country-converter, ftfy, and unidecode for column name cleaning, fuzzy merging, flexible date parsing, price parsing, country normalisation, and text encoding fixes.
- janitor_clean_names(df)[source]¶
Clean DataFrame column names using pyjanitor.
Converts column names to lowercase snake_case, strips whitespace, and replaces special characters with underscores.
- janitor_remove_empty(df)[source]¶
Remove empty rows and columns using pyjanitor.
Drops rows and columns that are entirely NaN or empty.
- fuzzy_merge(df1, df2, left_col, right_col, threshold=80.0)[source]¶
Merge two DataFrames using fuzzy string matching via rapidfuzz.
For each value in left_col of df1, the best match above threshold in right_col of df2 is found. Matched rows are joined; unmatched rows from df1 are retained with NaN for df2 columns.
- Parameters:
- Returns:
Merged DataFrame with an additional
match_scorecolumn indicating the similarity score for each matched pair.- Return type:
- parse_dates_flexible(series)[source]¶
Parse mixed-format date strings using dateparser.
Handles a wide variety of date formats and natural language dates (e.g.
'yesterday','3 days ago').
- parse_prices(series)[source]¶
Parse price strings into numeric amounts and currencies.
Uses the
price-parserlibrary to extract amounts and currency codes from strings like'$1,234.56'or'EUR 99.99'.
Validation¶
Data quality checks and validation for financial time series.
- validate_ohlcv(df)[source]¶
Validate OHLCV data for common issues.
Checks performed:
high_lt_low – rows where high < low
close_outside_range – rows where close is outside [low, high]
negative_volume – rows with negative volume
missing_values – count of NaN values per column
gaps – missing business days in the index
- validate_returns(returns, max_abs=0.5)[source]¶
Validate a return series for suspicious values.
- Parameters:
- Returns:
Dictionary containing:
suspicious – indices where |return| > max_abs
has_nan – whether any NaN values exist
nan_count – number of NaN values
min – minimum return value
max – maximum return value
- Return type:
- check_completeness(data, expected_freq='B')[source]¶
Report on data completeness relative to an expected frequency.
- Parameters:
- Returns:
Dictionary containing:
expected_count – number of expected periods
actual_count – number of actual observations
missing_count – number of missing periods
missing_dates – list of missing dates
completeness_pct – percentage of expected dates present
- Return type:
- check_staleness(data, max_unchanged=5)[source]¶
Detect stale (stuck/unchanged) values in a time series.
- Parameters:
- Returns:
Dictionary containing:
stale_periods – list of
(start, end, length)tuples for each run of identical values exceeding max_unchanged.total_stale_rows – total number of rows within stale periods.
- Return type:
- data_quality_report(data, freq='B')[source]¶
Generate a comprehensive data quality report.
Combines completeness, staleness, and value-range checks into a single report dictionary.
- Parameters:
- Returns:
Dictionary containing:
completeness – output of
check_completeness()staleness – output of
check_staleness()missing_values – NaN counts per column
duplicated_dates – number of duplicate index entries
date_range –
(first_date, last_date)shape –
(rows, cols)dtypes – column data types
- Return type:
Advanced Validation¶
Advanced data validation using pandera.
Provides pandera schema validation for DataFrames and pre-built schemas for common financial data formats (OHLCV, returns).
- pandera_validate(df, schema)[source]¶
Validate a DataFrame against a pandera schema.
Wraps
schema.validate()and returns the validated DataFrame (which may include coerced dtypes).
- create_ohlcv_schema(strict=False, coerce=True)[source]¶
Create a pandera schema for OHLCV financial data.
The schema enforces:
Columns
open,high,low,closeare positive floats.Column
volumeis a non-negative integer or float.high >= lowfor every row.closeis within[low, high]for every row.
- Parameters:
- Returns:
Schema suitable for passing to
pandera_validate().- Return type:
- create_returns_schema(max_abs_return=1.0, allow_nan=False, strict=False, coerce=True)[source]¶
Create a pandera schema for financial return data.
The schema enforces:
All return columns are float type.
Return values are within
[-max_abs_return, max_abs_return].
- Parameters:
max_abs_return (
float, default:1.0) – Maximum allowed absolute return value. Values outside[-max_abs_return, max_abs_return]fail validation.allow_nan (
bool, default:False) – Whether NaN values are allowed in return columns.strict (
bool, default:False) – If True, extra columns cause failure.coerce (
bool, default:True) – If True, attempt dtype coercion before validation.
- Returns:
Schema suitable for passing to
pandera_validate().- Return type:
Transforms¶
Data transformations for financial time series.
- to_returns(prices, method='simple')[source]¶
Convert a price series to returns.
- Parameters:
- Returns:
Return series. The first row will be
NaN.- Return type:
- to_prices(returns, initial_price=100.0, method='simple')[source]¶
Convert a return series back to prices.
- Parameters:
- Returns:
Reconstructed price series beginning at initial_price.
- Return type:
- rank_transform(data)[source]¶
Apply a cross-sectional rank transform.
Values are replaced with their rank divided by the count of non-NaN values, producing output in the range
(0, 1].
- percentile_rank(data, window=252)[source]¶
Compute a rolling percentile rank.
For each date the value is ranked within the preceding window observations and expressed as a percentile (0–1).
Calendar¶
Trading calendar utilities.
Wraps exchange-calendars and pandas-market-calendars for trading day schedules, market hours, and holiday detection.
- get_trading_calendar(exchange='XNYS')[source]¶
Get a trading calendar for an exchange.
- Parameters:
exchange (
str, default:'XNYS') – Exchange MIC code (default: NYSE = ‘XNYS’).- Return type:
- Returns:
exchange_calendars.ExchangeCalendar instance.
Example
>>> cal = get_trading_calendar("XNYS")
Cache¶
Caching infrastructure for data fetches.
Provides both in-memory TTL cache and optional disk caching via diskcache.
- class MemoryCache[source]¶
Bases:
objectSimple in-memory cache with TTL.
Base¶
Abstract base classes and provider registry for data sources.
- class DataProvider[source]¶
Bases:
ABCAbstract base class for all data providers.
Subclasses must implement
fetch_pricesand declare theirname.- abstractmethod fetch_prices(symbol, start=None, end=None, **kwargs)[source]¶
Fetch closing prices for a symbol.
- Parameters:
- Return type:
- Returns:
Price series with DatetimeIndex.
- fetch_ohlcv(symbol, start=None, end=None, **kwargs)[source]¶
Fetch OHLCV data for a symbol.
- Parameters:
- Return type:
- Returns:
DataFrame with open, high, low, close, volume columns.
- class ProviderRegistry[source]¶
Bases:
objectRegistry for data providers.
Allows registering, retrieving, and listing data providers by name.
- register(provider, *, default=False)[source]¶
Register a data provider.
- Parameters:
provider (
DataProvider) – DataProvider instance to register.default (
bool, default:False) – If True, make this the default provider.
- Return type:
- get(name=None)[source]¶
Get a provider by name, or the default.
Utilities¶
Data utility functions — date parsing, symbol cleaning, etc.
- infer_frequency(index)[source]¶
Attempt to infer the frequency of a DatetimeIndex.
- Parameters:
index (
DatetimeIndex) – DatetimeIndex to analyze.- Return type:
- Returns:
Frequency string or None if cannot be determined.