Skip to content

PIT Vintage Resolvers

alphaforge.pit.resolvers

Vintage resolvers for point-in-time data projection.

A :class:VintageResolver translates a :class:~alphaforge.pit.views.VintageView declaration into concrete asof_date resolution logic. The resolver sits between the caller (e.g. a backtest loop) and the PIT adapter: the caller asks "what should I fetch for this (series, obs_date, asof_date) triple?", and the resolver returns the effective asof_date to pass to the adapter.

FrozenResolver

Resolves to the n-th release vintage for each (series, obs_date).

Stateful: carries an immutable pre-computed revision map built at construction time. After construction, :meth:resolve is a dict lookup with no adapter calls.

The revision map is built outside this class (typically by the backtest harness which has access to the PIT adapter) and passed in as a plain dict. This keeps the resolver free of adapter dependencies.

Parameters:

Name Type Description Default
revision_map dict[tuple[str, date], list[date]]

Mapping from (series_key, obs_date) to a sorted list of vintage dates on which that observation was revised.

required
n_releases int

Which release to freeze to (1-indexed). Defaults to 3.

3

LatestResolver

Collapses all vintages to the most recent available.

Stateless. Uses a far-future sentinel to exploit the adapter's existing "latest vintage ≤ asof" semantics.

RealtimeResolver

Identity projection — returns requested_asof unchanged.

Stateless. Zero overhead.

VintageResolver

Bases: Protocol

Resolves the effective asof_date for a fetch given a vintage view.

Implementations are stateless (:class:RealtimeResolver, :class:LatestResolver) or carry an immutable pre-computed revision map (:class:FrozenResolver).

view: VintageView property

The view this resolver implements.

resolve(series_key: str, obs_date: date, requested_asof: date, has_pit: bool) -> date

Return the effective asof_date the adapter should use.

Parameters:

Name Type Description Default
series_key str

Canonical series identifier.

required
obs_date date

Observation date being resolved.

required
requested_asof date

The walk-forward asof_date from the backtest.

required
has_pit bool

Whether this series has vintage history.

required

Returns:

Type Description
date

The asof_date to pass to adapter.fetch_asof().