agentleFS
shakeebshaanshakeebshaan/claude-code-quant-skills/skills/data-scrub/SKILL.md

data-scrub

Skill2 starsChanged 7 months agoMITView on GitHub

Audit a market-data CSV for missing bars, timezone drift, weekend handling, stale ticks, duplicate timestamps, and survivorship. Use before running any backtest on new data.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No gaps greater than 1 bar (for 24/7 crypto) or expected gaps (market hours for equities)

    line 26
  2. Distinctive:

    If not, warn user before using for backtests.

    line 53

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Data Scrub Skill

Garbage in → backtest lies. Before ANY strategy runs on new data, audit it.

Ask for

  • File path
  • Expected timeframe (1m, 5m, 1h, 1d)
  • Expected timezone (UTC recommended)
  • Expected date range
  • Symbol(s) covered

Run these checks — each must PASS

1. Schema

  • Required columns: timestamp, open, high, low, close, volume
  • Dtypes correct? (timestamp = datetime64, OHLCV = float)

2. Timestamp integrity

  • Monotonic increasing, no duplicates
  • No gaps greater than 1 bar (for 24/7 crypto) or expected gaps (market hours for equities)
  • Timezone explicit and consistent — never naive
  • No daylight-saving jumps

3. Bar integrity

  • low <= open <= high for every bar
  • low <= close <= high for every bar
  • low <= high (sanity)
  • volume >= 0

4. Missing data

  • Count NaN in each column
  • Flag any bar where volume = 0 AND OHLC all equal → likely a stale / synthetic bar
  • Flag bars where high == low with non-zero volume → suspicious

5. Outliers

  • Return series: count bars with |return| > 20% (flag for review)
  • Volume spikes > 20x 30-bar rolling median → real or data error?

6. Symbol-level (if multi-symbol)

  • Symbol universe consistent across time, or point-in-time?
  • Delistings handled?
  • Ticker changes / splits adjusted?

7. Corporate actions (equities)

  • Dividend-adjusted?
  • Split-adjusted?
  • If not, warn user before using for backtests.

Code template

import pandas as pd

def scrub(df: pd.DataFrame, timeframe: str = "1h") -> dict:
    issues = {}
    expected_delta = pd.Timedelta(timeframe)

    issues["dupes"]       = df.index.duplicated().sum()
    issues["monotonic"]   = df.index.is_monotonic_increasing
    issues["gaps"]        = ((df.index.to_series().diff() > expected_delta).sum())
    issues["ohlc_break"]  = ((df["low"] > df["open"]) |
                             (df["low"] > df["close"]) |
                             (df["high"] < df["open"]) |
                             (df["high"] < df["close"]) |
                             (df["low"] > df["high"])).sum()
    issues["neg_volume"]  = (df["volume"] < 0).sum()
    issues["nan_rows"]    = df.isna().any(axis=1).sum()
    issues["stale_bars"]  = ((df["volume"] == 0) &
                             (df["open"] == df["close"])).sum()
    return issues

Output format

Single markdown table with Check / Result / Severity / Fix.

Severity:

  • BLOCK — do not backtest until fixed
  • WARN — acknowledge and document
  • OK — passed

End with a one-sentence verdict: ready for backtest / fixes required.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.