Data Reference¶
OHLCV data providers, caching, and resampling utilities.
Market data contracts, adapters, and cache helpers.
BarsCache ¶
Simple parquet cache for Bars DataFrames.
__init__ ¶
__init__(
root: Path | str,
*,
ttl: timedelta | int | float | None = None,
offline: bool = False,
) -> None
Create a cache rooted at root.
write ¶
write(
engine: str,
symbol: str,
freq: str,
bars: DataFrame,
*,
now: Timestamp | datetime | str | None = None,
) -> CacheEntry
Write Bars data and sidecar metadata.
read ¶
read(
engine: str,
symbol: str,
freq: str,
*,
ttl: timedelta | int | float | None = None,
offline: bool | None = None,
now: Timestamp | datetime | str | None = None,
symbols: str | list[str] | None = None,
start: str | Timestamp | None = None,
end: str | Timestamp | None = None,
columns: list[str] | None = None,
) -> pd.DataFrame
Read cached Bars data and restore attrs.
fingerprint ¶
fingerprint(engine: str, symbol: str, freq: str) -> str
Return the cached fingerprint for one engine/symbol/frequency key.
exists ¶
exists(engine: str, symbol: str, freq: str) -> bool
Return whether both parquet data and metadata exist for a cache key.
is_fresh ¶
is_fresh(
engine: str,
symbol: str,
freq: str,
*,
ttl: timedelta | int | float | None = None,
now: Timestamp | datetime | str | None = None,
) -> bool
Return whether a cache entry exists and has not exceeded its TTL.
CacheEntry
dataclass
¶
Paths written for one cached Bars object.
CacheExpiredError ¶
Raised when a requested Bars cache entry is stale in online mode.
CacheMissError ¶
Raised when a requested Bars cache entry is missing.
Dataset ¶
A local file set queried by DuckDB with explicit UTC timestamps.
CSVs must include timestamp (with timezone), symbol and OHLCV columns. Parquet uses the same columns. Files are never rewritten or repaired.
read ¶
read(
*,
symbols: Any = None,
start: Any = None,
end: Any = None,
columns: Sequence[str] | None = None,
) -> pd.DataFrame
Read inclusive UTC boundaries and requested fields with SQL pushdown.
Full OHLCV is validated before projection. Filtering executes at source; no cache is silently reused after a file changes.
iter_batches ¶
iter_batches(
*,
batch_size: int = 65536,
symbols: Any = None,
start: Any = None,
end: Any = None,
columns: Sequence[str] | None = None,
)
Stream ordered validated frames; reject duplicates across batches.
Consume/close the iterator before another query on this connection.
profile ¶
profile(**query: Any) -> DataExplorer
Return the existing explorer over the explicitly selected data.
DuckDBBarsBackend ¶
Columnar Bars storage backed by DuckDB.
DuckDB is optional. Tests and custom integrations may inject a connection
object with execute/register/unregister methods to avoid importing the
package.
write ¶
write(bars: DataFrame, *, mode: str = 'append') -> None
Write contract-valid Bars rows into DuckDB.
read ¶
read(
*,
symbols: str
| list[str]
| tuple[str, ...]
| None = None,
start: str | Timestamp | None = None,
end: str | Timestamp | None = None,
columns: list[str] | tuple[str, ...] | None = None,
market: str | None = None,
freq: str | None = None,
) -> pd.DataFrame
Read Bars rows with optional symbol, date, and column filters.
read_cross_section ¶
read_cross_section(
timestamp: str | Timestamp,
*,
symbols: str
| list[str]
| tuple[str, ...]
| None = None,
columns: list[str] | tuple[str, ...] | None = None,
market: str | None = None,
freq: str | None = None,
) -> pd.DataFrame
Read one timestamp as a symbol-indexed cross section.
read_panel ¶
read_panel(
*,
symbols: str
| list[str]
| tuple[str, ...]
| None = None,
start: str | Timestamp | None = None,
end: str | Timestamp | None = None,
columns: list[str] | tuple[str, ...] | None = None,
market: str | None = None,
freq: str | None = None,
) -> pd.DataFrame
Read a timestamp/symbol indexed Bars panel.
DataExplorer ¶
Explore raw Bars-like market data before research or backtesting.
__init__ ¶
__init__(data: DataFrame) -> None
Create an explorer from a Bars contract frame or raw DataFrame.
describe ¶
describe() -> pd.DataFrame
Return numeric descriptive statistics including skew and kurtosis.
outliers ¶
outliers(
*, column: str = "close", zscore: float = 4.0
) -> pd.DataFrame
Return return outliers by absolute z-score.
correlation ¶
correlation(column: str = 'close') -> pd.DataFrame
Return multi-symbol return correlation.
report ¶
report(path: str | Path) -> Path
Render computed exploration tables through the shared Reporter.
DataProvider ¶
Protocol for OHLCV market data providers.
history_ohlc ¶
history_ohlc(
symbol: str | list[str] | tuple[str, ...],
*,
start: str | None = None,
end: str | None = None,
freq: Frequency = "1d",
) -> pd.DataFrame
Fetch historical OHLCV bars.
TdxProvider ¶
TDX-backed A-share OHLCV provider.
__init__ ¶
__init__(
*,
host: str | None = None,
port: int = 7709,
timeout: float = 5.0,
count: int = 800,
client_factory: Callable[[], object] | None = None,
) -> None
Create a provider with optional TDX client injection.
history_ohlc ¶
history_ohlc(
symbol: str | list[str] | tuple[str, ...],
*,
start: str | None = None,
end: str | None = None,
freq: Frequency = "1d",
) -> pd.DataFrame
Fetch A-share OHLCV data and return contract-valid Bars.
TradingViewProvider ¶
TradeLearn TradingView transport with legacy tvDatafeed client injection.
history_ohlc ¶
history_ohlc(
symbol: str | list[str] | tuple[str, ...],
*,
start: str | None = None,
end: str | None = None,
freq: Frequency = "1d",
exchange: str | None = None,
) -> pd.DataFrame
Fetch TradingView OHLCV data and return contract-valid Bars.
history_window ¶
history_window(
symbol,
resolution,
count=300,
to=None,
forward=False,
*,
adjustment="splits",
)
Fetch chart bars with a server-side cutoff or forward replay anchor.
resolve_symbol ¶
resolve_symbol(symbol, *, adjustment='splits')
Return TradingView chart symbol metadata.
TushareProvider ¶
Daily A-share prices, with weekly/monthly aggregation of adjusted daily data.
Requests cover at most 25 years and return at most 5,000 daily observations.
The latest observations are retained when the cap is reached; the result
then has possibly_truncated=True. Period bars include partial periods
and use the first observed session date.
Pre-adjustment uses the last factor on/before the fixed anchor (default:
requested end). Post-adjustment follows Tushare's absolute factor convention:
raw price * adj_factor. Volume and amount are never price-adjusted.
history_ohlc ¶
history_ohlc(
symbol,
start=None,
end=None,
freq="1d",
adjust="none",
anchor=None,
)
Fetch finite daily Bars and explicitly apply the requested anchored adjustment/aggregation.
open_dataset ¶
open_dataset(
paths: str | Path | Sequence[str | Path],
) -> Dataset
Open explicit local CSV/Parquet paths or glob patterns.