backtest_lib.universe.vector_mapping.VectorMapping#

class backtest_lib.universe.vector_mapping.VectorMapping#

Bases: Mapping, ABC, Generic

Mapping with vectorized arithmetic semantics.

Backends may rely on matching key order to perform fast vector operations. When key order differs between two mappings, operations remain correct but typically require reindexing and incur a performance cost.

abstractmethod abs() Self#

Return a mapping with absolute values.

abstractmethod floor() VectorMapping[K, int]#

Return a mapping with values floored to integers.

abstractmethod classmethod from_vectors(keys: Iterable[K_contra], values: Iterable[V_co]) Self#

Create a mapping from ordered key/value vectors.

abstractmethod sum() float#

Return the sum of all values.

abstractmethod truncate() VectorMapping[K, int]#

Return a mapping with values truncated to integers.