Runbook: replay-split — replace unadjusted bars for a split symbol
When to run: A user reports wrong historical prices for a recently-split
ticker; or sequency.corporate_actions.replay_status = 'pending' for a split
you want to clear.
Prerequisites
- SSH access to compute server (for binary location + env).
ALPACA_API_KEY/ALPACA_API_SECRET(sourced from/opt/sequency/config/corporate-actions.envon compute).CH_URLpointing at data-server via vRack:http://10.0.0.2:8123.
Build
Dry-run first, always
- Factor: matches the known corporate action (10.0 for a 10:1 split).
- Price range: adjusted prices should be roughly pre-split-price / factor.
- Current row counts: non-zero in all five tables; the 1min count is the dominant source of truth.
Real run
phase=delete_rollups— 5m/15m/1h/daily ALTER DELETEs submitted.phase=delete_1min— base-table ALTER DELETE submitted.phase=wait_mutations— pollssystem.mutationsuntil drained.phase=insert_adjusted— bulk INSERTs via JSONEachRow; MVs auto-fire.phase=verify— post-replay counts logged.
replay_status='failed').
What if it fails partway?
- Mutation timeout — CH is probably busy. Wait; re-run the CLI; it’ll
skip any already-done mutations via the
is_donefilter and proceed to INSERT. - Alpaca error — check
curl -s -o /dev/null -w '%{http_code}' https://data.alpaca.markets/v2/stocks/BKNG/bars?...with your creds. Rerun the CLI once resolved. - INSERT partial success — re-run with
--force; it re-DELETES and re-INSERTs idempotently. - Interrupted mid-run (CTRL+C) — the CLI catches SIGINT and tries to mark
replay_status='failed'with a fresh 5-second context. If that succeeds, re-run normally (with--forceif you seereplay_status='failed'). If the CLI couldn’t reach CH during shutdown,replay_statuswill stay at whatever it was (likely'pending'); re-run without--force.
After a successful run
If pattern-detector was mid-cycle during replay, its next scheduled run picks up the adjusted data automatically. To force an immediate recompute for the symbol:What the CLI does NOT do
- Snapshot to S3 (re-fetching is cheap — Alpaca is the source of truth).
- Update the FalkorDB graph’s
Stock.split_replay_pendingflag (not needed for an operator-run sync replay; the graph stays consistent because PD reads from the same CH tables we just fixed). - Adjust options-chain strikes (separate issue).
- Handle multiple symbols per invocation (script a bash loop if needed).