numeraire.core.data#

Concrete DataView implementations and the PIT / horizon machinery.

This module ships TimeSeriesView, covering the market-timing / aggregate-predictor case (VoC, 1/A): a returns block (date x asset) with cardinality 1..N and one or more time-series features blocks (date x feature). It implements the numeraire.core.protocols.DataView protocol and adds the explicit-horizon pairing the OOS engine relies on:

features_asof(t) (info known <= t) <-> target_asof(t, h) (realized over (t, t+h])

The pairing is engine-owned so a method never indexes returns itself — this makes the SOF-style one-period contemporaneous leak structurally impossible.

Multi-block / availability. Each feature source enters as its own FeatureBlock with its own calendar and an availability lag (in the block’s own periods): a row dated tau is usable at decision time t only after lag periods have elapsed. lag=0 = period-end-known (prices, Goyal-Welch predictors); lag>=1 = a publication-lagged macro source that ships no vintage panel (the conservative no-vintage fallback, e.g. FRED used at lag=1). Blocks are aligned to the returns (decision) calendar independently and concatenated, so heterogeneous sources — different lags, different calendars — coexist as macro inputs. Block-level vintage (a real (tau, v) panel resolved by asof over release dates) crystallizes next, as a third FeatureBlock flavour; the view shape here is built to take it without further reshaping.

Backward compatibility: TimeSeriesView(returns, features=df) wraps df as a single lag=0 block sharing the returns calendar — identical to the original single-block behaviour.

Cross-section. CrossSectionView is the sibling for the cross-sectional family (Fama-MacBeth / IPCA / characteristic sorts): a ragged panel of many assets whose predictors vary by (date, asset) rather than being shared across assets. It shares the DataView protocol (window + calendar) but exposes a cross-section-shaped features_asof / target_asof / aligned — see its own docstring. The naming follows the field’s own dichotomy (Fama 2015, “Cross-Section Versus Time-Series Tests”): time-series tests (GRS) vs cross-sectional tests (FM).

TimeSeriesView

A point-in-time view: a returns (decision) calendar + one or more aligned feature blocks.

CrossSectionView

A cross-sectional (panel) view: many assets with per-asset characteristics, ragged over time.

FeatureBlock

One time-series feature block: a (date x feature) frame + an availability lag.

VintagedBlock

A vintaged (point-in-time) block: a (ref_date x vintage) panel resolved by asof.

CharBlock

A per-asset [t, i] characteristic source with its own PIT, joined into a panel view.

PanelTensor

A dense (T x N x K) materialization of a ragged panel — the eject for tensor/NN methods.

Block

A tagged feature block the view aligns to the decision calendar and concatenates.