Coverage for src / jquantstats / _stats / _protocol.py: 100%
4 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-26 18:44 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-26 18:44 +0000
1"""Protocol describing the subset of Data that the _stats mixins require."""
3from __future__ import annotations
5from collections.abc import Iterator
6from typing import Protocol, runtime_checkable
8import polars as pl
11@runtime_checkable
12class DataLike(Protocol): # pragma: no cover
13 """Structural interface required by the Stats mixin classes.
15 Any object satisfying this protocol can be passed as ``data`` to the
16 mixin methods without a concrete dependency on :class:`~jquantstats._data.Data`.
17 """
19 returns: pl.DataFrame
20 index: pl.DataFrame
21 benchmark: pl.DataFrame | None
23 @property
24 def date_col(self) -> list[str]:
25 """Column names used as the date/time index."""
26 ...
28 @property
29 def assets(self) -> list[str]:
30 """Names of the asset return columns."""
31 ...
33 @property
34 def all(self) -> pl.DataFrame:
35 """Combined DataFrame of returns, index, and benchmark columns."""
36 ...
38 @property
39 def _periods_per_year(self) -> float:
40 """Estimated number of return periods per calendar year."""
41 ...
43 def items(self) -> Iterator[tuple[str, pl.Series]]:
44 """Iterate over (asset_name, returns_series) pairs."""
45 ...