Skip to content

repair=True can rescale an entire price table by 100x and invert the Repaired? flags #2923

Closed

Description

@lenamonj

Every claim below is backed by an offline reproduction that runs without touching the network, so none of it needs to be taken on trust.

When _fix_unit_switch detects a genuine unit change in part of a table, the correction is applied to the whole table and the Repaired? flag array is inverted wholesale rather than being restricted to the affected block.

Reproduction, using a fixture frame shaped like pence-quoted LSE data with one genuine 100x block:

  • all 90 rows come back 100 times too large
  • the 20 genuinely broken rows are flagged Repaired? = False
  • 40 untouched rows are flagged Repaired? = True
  • a control run with that branch skipped returns 0 of 90 rows wrong

Three smaller defects fall out of the same audit:

  • history.py calls to_numpy() and then writes in place, raising ValueError: assignment destination is read-only on pandas 3.0.5. Your own fixture tests/data/SSNLF-1d-bad-div.csv triggers it.
  • the crude 100x fallback rescales OHLC but not Adj Close, and default auto_adjust then reapplies the factor.
  • a fund paying capital gains with no dividend on the same day hits a ZeroDivisionError.

I have a patch that fixes all four. Against your 42 committed golden fixtures it leaves 41 byte-identical and fixes the one that currently raises. Happy to open a PR if useful, or to leave the repro here if you would rather fix it your own way.

Activity

  1. github-actions commented on Jul 27, 2026

    @github-actions

    This issue appears to be a bug report but doesn't use our bug report template. Resubmit with our custom bug report form..

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions