Check your price files for splits, gaps and bad prints before scripts use them
A script inspects the daily price files your tests read for missing days, duplicate dates, impossible prices and one-day jumps that look like an unadjusted split. Flagged files are fixed or left out before any backtest runs.
How it works
- Keep the price files your scripts use in one folder, with a short note for each source: where it came from, the download date, and whether prices are adjusted for splits and dividends.
- Before any backtest, sizing calculation or stats run, a check script reads each file and lists missing trading days against an exchange calendar, duplicate dates, zero or negative prices, highs below lows, closes outside the day's range and zero-volume days.
- It flags one-day moves larger than a threshold you set, and tests whether each one matches a common split ratio (2-for-1, 3-for-1, 1-for-10 and so on). A match is labelled "possible unadjusted split" for you to confirm against the company's own announcement or a second source.
- Where you have both adjusted and unadjusted closes, it compares them and flags files whose adjustment status disagrees with your note.
- The script writes a dated report and a pass or hold status for each file. Files on hold stay out of every run until you fix them or record why they're fine.
- The agent explains the report in plain English and never edits a price. You make any fixes and write the reason in the source note.
Copy-paste prompt
Write a Python script that checks my daily price files before my own tests use them. It gives no trading advice and never suggests trades or securities.
Inputs: the folder {{price_dir}} (one CSV per instrument with date, open, high, low, close, volume and adj_close if available), my source notes {{source_notes}}, an exchange trading calendar {{calendar_file}}, and the thresholds {{jump_threshold}} and {{split_ratios}}.
For each file, report:
1. Missing trading days and duplicate dates.
2. Rows with zero or negative prices, high below low or close outside the high-low range, and zero-volume days.
3. One-day close-to-close moves above {{jump_threshold}}, marking any that match one of {{split_ratios}} within 2% as "possible unadjusted split".
4. Whether the adj_close behaviour matches the adjustment status in my notes.
Give each file a status, pass or hold, write a dated report to {{report_path}} and change no data. Include three small test files with known problems so I can check the script catches them.Guardrails
- The script and the agent never edit price data. You make any fix and note the reason.
- Files on hold are left out of every test and calculation until cleared.
- A flagged jump is a question to check against a primary source, not something the model settles by guessing.
- Read-only on files; no broker access and no orders.
What can go wrong
A clean report doesn't mean clean data. Row-level checks catch the obvious breaks, but a dividend adjustment applied twice can pass every one of them, and a delisted company missing from the folder isn't a file problem at all. That's survivorship, which comes from how the list was built. Split matching also raises false alarms on genuine large moves such as earnings gaps, so the label says "possible" and the decision stays with you.
Why it helps
A backtest is only as good as the prices it reads, and the errors that matter most look like opportunity: an unadjusted split shows up as a huge one-day drop or jump that your rule happily trades. Agents make this worse, because a script written in minutes rarely checks its inputs, and a summary written by a model sounds equally confident on clean data and on broken data. A pass or hold status per file is a simple gate that every later step can respect.
How it fits with other entries
Run this before the quick rule backtest (aft-0018), the paper-vs-practice comparison (aft-0030) or any trial-logged testing (aft-0041). The prove-it-runs check (aft-0036) tests the script's logic on known cases; this entry tests the data the script is fed.
Where this comes from
A public post by Vinicio Donnarumma (@VinniDon) on X: data errors such as corrupted prints, restated histories and unadjusted splits turn up even in professional data, and he describes a strategy built on free data whose results came from an unadjusted split. The checklist, the split matching and the hold rule are ours.
Source and references
Based on a public post by Vinicio Donnarumma (@VinniDon) on X describing corrupted prints, restated histories and unadjusted splits in market data, including a strategy that only looked good because of an unadjusted split. The checklist, the hold status and the split matching are our adaptation.
Original: Vinicio Donnarumma on x
- Post on bad prints and unadjusted splits in backtest data · Vinicio Donnarumma (@VinniDon) on X (checked 19 Oct 2026)
- Stock Split: What It Means and How It Works · Investopedia (checked 19 Oct 2026)
- Adjusted Closing Price: How It Works, Types, Pros & Cons · Investopedia (checked 19 Oct 2026)
- Holidays and trading hours · New York Stock Exchange (checked 19 Oct 2026)
Spotted an error, or want your post removed? Email hello@agentsfortraders.com.
Educational content only. Not investment advice or a personal recommendation. No tickers, signals or trade alerts. Trading involves risk of loss.
Conteúdo exclusivamente educativo. Não constitui aconselhamento nem recomendação de investimento. Sem tickers, sinais ou alertas de negociação. Negociar envolve risco de perda.
Related use cases
Test a rule you wrote against history, without fooling yourself
Describe a rule in plain English and an agent writes and runs Python on daily data to see how it behaved historically, with costs, out-of-sample checks and warnings about look-ahead and survivorship bias.
Backtesting & rule researchMeasure the gap between a rule on paper and how you actually trade it
For one rule you already use, a script compares the trades an honest historical test says the rule would have taken with the trades your journal shows. You get counts and average R for missed, extra and timing differences, statistics only.
Agent ops: guardrails & costsMake your agent prove a new script works by running it, not describing it
When an agent builds or changes a tool you rely on, such as a sizing calculator or a journal stats script, finish by having it run your real command on hand-checked test cases and show the raw output against your expected numbers.
Backtesting & rule researchLog every rule variant you test and judge the best one against the count
Every time an agent tests a version of your rule, a script logs it. The report shows the best result next to how many variants were tried, so a lucky winner out of fifty isn't mistaken for an edge.
The Daily 3
Three agent workflows for swing traders, free, on US trading days.