Skip to content

Repair precise public price-return expressions #107

Closed

Description

@stefan-jansen

User workflow and ownership

Implement the accepted Engineer preparation/migration unit below. Preserve existing native defaults, dataframe contracts and independent use with supplied data. Data owns source adjustments/revision selection; Diagnostic owns the only Alphalens facade/cleaner and analytical workflows; Backtest owns simulation/accounting. Engineer produces native features, eligibility and outcomes, not competing engines.

Dependency: none. Start here. Recheck current main and owning records, execute the retained public
probe, and pin the actual failing source/environment before editing. Changes belong in
features/utils/arithmetic.py and reproduced downstream shared arithmetic only. Tests and
migration notes remain in the same numerical repair submission.

Preserve exact integer differences before division without signed/unsigned overflow, including
full-span differences. Cover simple/log/display percentage, lag, empty/single-row, invalid input,
zero denominators, Float32/64, null/NaN and grouped eager/lazy calls. Test declared Polars floor;
if a required type/API is unavailable, justify the narrow dependency-floor change and test it.
No early Float64 cast, whole-frame collect or Python row UDF should conceal lost ticks.

Proposed focused test file: tests/test_returns_precision.py. Verify with
uv run pytest tests/test_returns_precision.py -q, first failing on the selected producer base
for signed/unsigned tick loss and then passing on the repair. Ordinary controls must pass both.
Feed the actual output into a valid installed receiving return path; compounding is not another
Engineer engine. Inputs and row count remain unchanged and invalid declarations produce no output
write. Completion includes native artifact qualification, not just an adapter-specific workaround.

Premises

Input: price ticks

Question Answer Kind
record One exact typed price observation for one stable asset; return is decimal price change. definitional
absent-record An absent row supplies no price; an explicit null supplies an undefined quote, not a flat return. definitional
ordering-spacing Lag is ordered observations per asset; scheduled completeness is validated by the calling declared-grid workflow. definitional
entity-identity Explicit grouping keys separate histories, including interleaved input. definitional
known-at Primitive arithmetic does not assert causal availability; the caller's supplied prices and knowledge contract determine it. definitional
institution Exact integer arithmetic and declared simple/log definitions govern; no provider or inferred exchange rule. definitional

Claims

Id Claim How it could be false
precise-native-return Public eager/lazy integer returns retain each representable nonzero tick without overflow. Adjacent high integers collapse to zero or full-span subtraction wraps.
return-api-stable Ordinary/missing/domain/lag behavior and native shape remain compatible. An overflow repair drops rows, collects a lazy plan or changes float/null behavior.

Closes: price-ticks.record, price-ticks.absent-record, price-ticks.ordering-spacing, price-ticks.entity-identity, price-ticks.known-at, price-ticks.institution, precise-native-return, return-api-stable

Intake and completion

  • Reproduce public producer defects before repairs and retain exact failing/passing revisions.
  • Complete the methods, negative/error cases, runnable tests and migration route above.
  • Verify actual installed outputs and the applicable final-revision quality/platform gates.
  • Record producer/consumer dependencies separately from standalone qualification.

Plan reference: accepted Engineer preparation and Reloaded migration plan, unit 1 in milestone unreleased - Engineer preparation and Reloaded migration.

AI assistance: Codex prepared this intake projection from the accepted maintainer plan; implementation and independent test evidence are still required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions