fix(assets): merge ticker renames and re-key price_bars to the current symbol #88

Merged
gertjan merged 1 commit from fix/symbol-rename-rekey into main 2026-07-15 19:45:47 +00:00
Owner

Renamed tickers left their entire price history stranded under the old
symbol: refresh_symbol_changes skipped every rename whose new symbol
already existed in Mongo (the daily list sync creates it first, so that
was nearly all of them), nothing ever re-keyed price_bars, and the batch
EOD ingest kept accepting FMP rows under the old label. Discovered via
Fiserv (FI/FISV); a production sweep found 75+ affected renames since
Nov 2025 (e.g. KFS→KWY: 6250 bars under KFS, 37 under KWY).

  • refresh_symbol_changes: the existing-new-doc path now merges instead
    of skipping — mark old doc inactive, record previous_symbols on the
    new doc, re-key price_bars old→new. Plain renames re-key too. Changes
    are processed newest-first so a reverted rename (FISV→FI→FISV) is not
    re-applied; renames outside our universe no longer create stub assets.
    New lookback_days/dry_run params for historical backfill via CLI.
  • TimeseriesRepository.rekey_symbol: single-transaction UPDATE+DELETE;
    rows already present under the new symbol win. Idempotent.
  • update_batch_eod: remap FMP rows still labelled with a pre-rename
    ticker via get_ticker_alias_map, but never when the raw symbol is
    itself an active asset (recycled tickers can't be hijacked).
  • add_previous_symbol is now idempotent (daily re-runs, 7-day window);
    update_symbol's asset_type filter is optional (renames aren't
    stock-only — most affected assets were ETFs).
  • symbol_changes_refresh now runs daily (was weekly Monday with the same
    7-day lookback, which silently dropped renames whenever a run misfired)
    with watchdog staleness tightened 196h→26h.
  • CLI: assets refresh-symbol-changes --days/--dry-run; new assets
    rekey-symbol OLD NEW for one-off migrations.

Verified with a read-only dry run against production: 244 merge/rename
actions planned over a 260-day backfill, including FI→FISV.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

Renamed tickers left their entire price history stranded under the old symbol: refresh_symbol_changes skipped every rename whose new symbol already existed in Mongo (the daily list sync creates it first, so that was nearly all of them), nothing ever re-keyed price_bars, and the batch EOD ingest kept accepting FMP rows under the old label. Discovered via Fiserv (FI/FISV); a production sweep found 75+ affected renames since Nov 2025 (e.g. KFS→KWY: 6250 bars under KFS, 37 under KWY). - refresh_symbol_changes: the existing-new-doc path now merges instead of skipping — mark old doc inactive, record previous_symbols on the new doc, re-key price_bars old→new. Plain renames re-key too. Changes are processed newest-first so a reverted rename (FISV→FI→FISV) is not re-applied; renames outside our universe no longer create stub assets. New lookback_days/dry_run params for historical backfill via CLI. - TimeseriesRepository.rekey_symbol: single-transaction UPDATE+DELETE; rows already present under the new symbol win. Idempotent. - update_batch_eod: remap FMP rows still labelled with a pre-rename ticker via get_ticker_alias_map, but never when the raw symbol is itself an active asset (recycled tickers can't be hijacked). - add_previous_symbol is now idempotent (daily re-runs, 7-day window); update_symbol's asset_type filter is optional (renames aren't stock-only — most affected assets were ETFs). - symbol_changes_refresh now runs daily (was weekly Monday with the same 7-day lookback, which silently dropped renames whenever a run misfired) with watchdog staleness tightened 196h→26h. - CLI: assets refresh-symbol-changes --days/--dry-run; new assets rekey-symbol OLD NEW for one-off migrations. Verified with a read-only dry run against production: 244 merge/rename actions planned over a 260-day backfill, including FI→FISV. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fix(assets): merge ticker renames and re-key price_bars to the current symbol
All checks were successful
Deploy / check (pull_request) Successful in 3m27s
Deploy / deploy (pull_request) Has been skipped
76349129f6
Renamed tickers left their entire price history stranded under the old
symbol: refresh_symbol_changes skipped every rename whose new symbol
already existed in Mongo (the daily list sync creates it first, so that
was nearly all of them), nothing ever re-keyed price_bars, and the batch
EOD ingest kept accepting FMP rows under the old label. Discovered via
Fiserv (FI/FISV); a production sweep found 75+ affected renames since
Nov 2025 (e.g. KFS→KWY: 6250 bars under KFS, 37 under KWY).

- refresh_symbol_changes: the existing-new-doc path now merges instead
  of skipping — mark old doc inactive, record previous_symbols on the
  new doc, re-key price_bars old→new. Plain renames re-key too. Changes
  are processed newest-first so a reverted rename (FISV→FI→FISV) is not
  re-applied; renames outside our universe no longer create stub assets.
  New lookback_days/dry_run params for historical backfill via CLI.
- TimeseriesRepository.rekey_symbol: single-transaction UPDATE+DELETE;
  rows already present under the new symbol win. Idempotent.
- update_batch_eod: remap FMP rows still labelled with a pre-rename
  ticker via get_ticker_alias_map, but never when the raw symbol is
  itself an active asset (recycled tickers can't be hijacked).
- add_previous_symbol is now idempotent (daily re-runs, 7-day window);
  update_symbol's asset_type filter is optional (renames aren't
  stock-only — most affected assets were ETFs).
- symbol_changes_refresh now runs daily (was weekly Monday with the same
  7-day lookback, which silently dropped renames whenever a run misfired)
  with watchdog staleness tightened 196h→26h.
- CLI: assets refresh-symbol-changes --days/--dry-run; new assets
  rekey-symbol OLD NEW for one-off migrations.

Verified with a read-only dry run against production: 244 merge/rename
actions planned over a 260-day backfill, including FI→FISV.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gertjan deleted branch fix/symbol-rename-rekey 2026-07-15 19:45:47 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gertjan/bodega!88
No description provided.