Skip to content

fix: adopt shared calendar contract in session-aware labeling #94

Closed

Description

@stefan-jansen

Calendar-aware labeling must preserve shared calendar selection and row-mode semantics

Affected source: main0e7865273cd462c507de02a9d3b64de7c6cbb099. Distinct from fixed-intraday feature ownership in closed issue76/PR90 and authoritative EquityCalendar helper issue91.

Public reproduction
from datetime import datetime
import polars as pl
from ml4t.engineer.config import LabelingConfig
from ml4t.engineer.labeling import calendar_aware_labels
data = pl.DataFrame({'timestamp': [datetime(2025,7,4,12), datetime(2025,7,7,12)], 'close': [100.,101.]})
calendar_aware_labels(data, LabelingConfig.triple_barrier(max_holding_period=1), calendar=None)

Observed: TypeError requiring callable calendar protocol methods. Omitting calendar also fails because it is mandatory. No shared FeedSpec path is accepted, and LabelingConfig cannot preserve a calendar declaration through JSON/YAML. Existing standalone numerical labeling kernels are separate from this calendar-aware wrapper.

Expected next-minor contract
Use canonical calendar and the shared Specs resolver: explicit argument > explicitly declared config selector > feed metadata > NYSE. Preserve omitted versus explicitnull through copied/serialized configs. calendar=None labels observation rows in input order without loading a provider or requiring timestamps; a named24/7 schedule remains calendar-aware. Keep legacy custom protocol calendars and explicit auto-gap mode as documented compatibility paths, never as proof of completeness. Consume existing FeedSpec column, timezone and timestamp declarations without a new wire format. Reject session-label intraday inputs and unsupported window units explicitly. Observation counts, validated expected bars, elapsed durations and session counts must remain distinct; expected-bar mode must validate the grid before labeling. Use declared timezone for naive input; do not guess holidays/frequency from data spacing.

Acceptance
Real public price->label and JSON/YAML->label workflows fail on the base and pass with the fix. Include row invariance across timestamp spacing/order, interleaved assets, absent timestamps, metadata null/name/omission precedence, exchange closures, declared naive timezone, invalid settings atomicity and expected-grid outage rejection. Run light focused checks locally and full hosted supported source/wheel/docs/package gates before ordinary merge. Preserve standalone legacy kernel behavior and document its boundary; do not claim full harmonization or authorize a release/deployment.

AI assistance: Codex reproduced the public failure, reviewed shared Specs contracts and prepared the focused consumer integration and executable evidence. Repository owner remains accountable for the source and results.

Activity

  1. stefan-jansen commented on Oct 17, 2026

    @stefan-jansen
    ContributorAuthor

    The shared resolver/config/row-mode consumer integration in PR95 is a focused implementation step. It now references this owning issue without closing it, so accepted remaining label-time work is not lost.

    Remaining implementation includes session-count labels and daily/session-label inputs. Count authoritative scheduled sessions, not observed distinct dates; distinguish the forward session endpoint from an elapsed duration or observed-row offset. Cover a valid NYSE holiday, an actual missing scheduled session, overnight venues, interleaved assets, timezone/DST boundaries and incomplete intraday grids through public labeling workflows. Preserve existing observation and elapsed numerical definitions; new session semantics must be explicit and tested, not silently substituted for existing kernels.

    Current PR95 explicitly rejects session-count windows/session-label instants. That is a truthful boundary, not completion of this newly confirmed requirement. Implement and qualify the remaining cases under this issue, reusing the shared Specs fields and real calendar adapter rather than an Engineer-only serialized time format.

    AI assistance: Codex reconciled the accepted remaining scope against the current PR and shared contract. This comment does not claim new tests or implementation have been executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions