Coverage for src / jquantstats / _utils / _protocol.py: 100%
3 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-07 15:52 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-07 15:52 +0000
1"""Protocols describing the minimal interfaces required by the _utils subpackage."""
3from __future__ import annotations
5from typing import Protocol, runtime_checkable
7import polars as pl
10@runtime_checkable
11class DataLike(Protocol): # pragma: no cover
12 """Structural interface required by `DataUtils`.
14 Any object satisfying this protocol can be passed as ``data`` without a
15 concrete dependency on `Data`.
16 """
18 returns: pl.DataFrame
19 index: pl.DataFrame
21 @property
22 def date_col(self) -> list[str]:
23 """Column names used as the date/time index."""
24 ...
27@runtime_checkable
28class PortfolioLike(Protocol): # pragma: no cover
29 """Structural interface required by `PortfolioUtils`.
31 Any object satisfying this protocol can be passed as ``portfolio`` without a
32 concrete dependency on `Portfolio`.
33 """
35 @property
36 def data(self) -> DataLike:
37 """Bridge to the Data analytics object for this portfolio."""
38 ...
40 @property
41 def assets(self) -> list[str]:
42 """Asset column names."""
43 ...