Data API¶
asrquant.data ¶
Market-data normalization, validation, and hashing.
as_frame ¶
Return a float DataFrame with a unique, sorted DatetimeIndex.
Source code in src/asrquant/data.py
clean_prices ¶
clean_prices(prices: Series | DataFrame, policy: MissingDataPolicy | str = MissingDataPolicy.RAISE) -> pd.DataFrame
Validate positive prices and apply the selected missing-data policy.
Source code in src/asrquant/data.py
align_like ¶
align_like(values: Series | DataFrame, reference: DataFrame, fill_value: float = 0.0) -> pd.DataFrame
Align a Series/DataFrame to a price panel's index and columns.
Source code in src/asrquant/data.py
simple_returns ¶
Compute simple returns with no implicit forward fill.
log_returns ¶
data_fingerprint ¶
Create a stable SHA-256 fingerprint of values, index, and columns.
Source code in src/asrquant/data.py
load_prices ¶
load_prices(path: str | Path, date_column: str | None = None, *, columns: Sequence[str] | None = None, sheet_name: str | int = 0) -> pd.DataFrame
Load price/value panels from CSV, Parquet, Excel, JSON, or Feather.
The first column is used as the date column unless date_column is
supplied. Use columns to select price columns after parsing.
Source code in src/asrquant/data.py
load_sql ¶
load_sql(query: str, connection, date_column: str, columns: Sequence[str] | None = None) -> pd.DataFrame
Load a price/value panel from any pandas-compatible SQL connection.
Source code in src/asrquant/data.py
data_quality_report ¶
Summarize missingness, duplicates, monotonicity, and sampling gaps.
Source code in src/asrquant/data.py
resample_ohlcv ¶
Resample canonical OHLCV data with finance-consistent aggregations.
Source code in src/asrquant/data.py
validate_ohlcv ¶
Validate a canonical OHLCV table.
Source code in src/asrquant/data.py
validate ¶
Return non-mutating structural diagnostics for a time-series panel.
This canonical helper records data-quality issues instead of silently fixing
them. Use :func:clean_prices when an explicit cleaning policy is desired.
Source code in src/asrquant/data.py
from_provider ¶
from_provider(provider: str, symbols: str | Sequence[str] | None = None, *, field: str = 'Close', provider_kwargs: dict | None = None, **history_kwargs) -> pd.DataFrame
Load one or more series from an ASRQuant market-data provider.
Providers include yahoo, ecb, fred, alpha_vantage and
binance. For ECB yield curves use :func:ecb_yield_curve for a cleaner
maturity-based interface.
Source code in src/asrquant/data.py
yahoo ¶
yahoo(symbols: str | Sequence[str], *, start: str | None = None, end: str | None = None, period: str = 'max', interval: str = '1d', field: str = 'Close', auto_adjust: bool = True) -> pd.DataFrame
Download Yahoo Finance data through the optional yfinance backend.
Source code in src/asrquant/data.py
ecb_yield_curve ¶
ecb_yield_curve(maturities: Sequence[str] = ('3M', '6M', '1Y', '2Y', '3Y', '5Y', '7Y', '10Y', '15Y', '20Y', '30Y'), *, start: str | None = None, end: str | None = None, data_type: str = 'SR', last_n: int | None = None, provider_kwargs: dict | None = None) -> pd.DataFrame
Download aligned ECB euro-area AAA Svensson curve history.
The returned values are decimal annual rates. Network access is explicit and
the ECB provider metadata are retained in DataFrame.attrs.
Source code in src/asrquant/data.py
load ¶
load(source, date_column: str | None = None, *, columns: Sequence[str] | None = None, provider: str | None = None, symbols: str | Sequence[str] | None = None, field: str = 'Close', provider_kwargs: dict | None = None, format: str | None = None, sheet_name: str | int = 0, timeout: float = 30.0, **kwargs) -> pd.DataFrame
Canonical data loader for pandas objects, files, URLs, and providers.
Examples:
asr.data.load("prices.csv", date_column="Date")
asr.data.load("https://example.org/data.csv", date_column="DATE")
asr.data.load("yahoo", symbols=["SPY", "TLT"], start="2020-01-01")
asr.data.ecb_yield_curve(start="2024-01-01")