New indicator

From joemccann/radon · View interactive version

New indicator is an AI agent skill from the GitHub repository joemccann/radon. The canonical Radon pattern for shipping a new market indicator end to end (ingestion job, Turso storage, API route, regime chart tab, tests, systemd timer, CI, production verify). Derived from the BREADTH (21c13715, f067491e, 770d4674) and FINRA margin-debt (c5f4b877, b2f452fb, 189fcad8) builds. Re

How to use this skill

Skill file

New market indicator — the Radon pattern

An indicator is a vertical slice with seven parts. All seven ship together; the

reference implementations are the FINRA margin-debt tab (external HTTP source, daily

timer) and the NYSE breadth tab (IB + StockCharts, 5-min timer). Copy margin-debt for

scheduled external-source indicators; copy breadth for IB-fed intraday collectors.

0. File checklist

Create:

| File | Modeled on |

|---|---|

| scripts/clients/<source>_client.py (only if the source needs retry/conditional-GET logic) | scripts/clients/finra_client.py |

| scripts/fetch_<name>.py or scripts/<name>_scan.py | scripts/fetch_margin_debt.py / scripts/breadth_scan.py |

| scripts/db/migrations/00NN_<name>.sql (next free number, 4-digit, lex-ordered) | 0027_margin_debt_history.sql, 0029_rv_ratio.sql |

| scripts/tests/test_<name>.py | scripts/tests/test_margin_debt.py |

| web/app/api/<name>/route.ts | web/app/api/margin-debt/route.ts |

| web/lib/<name>.ts (pure helpers + types) | web/lib/marginDebt.ts |

| web/lib/use<Name>.ts | web/lib/useMarginDebt.ts |

| web/components/<Name>Panel.tsx | web/components/MarginDebtPanel.tsx |

| web/app/regime/<slug>/page.tsx (time-series regime only; name-ranking scanners use /scanner?mode=<slug>) | web/app/regime/margin/page.tsx / ScannerModeTabs |

| web/tests/<name>-api.test.ts | web/tests/margin-debt-api.test.ts |

| web/tests/<name>-panel.test.tsx | web/tests/margin-debt-panel.test.tsx |

| web/e2e/<name>-tab.spec.ts | web/e2e/margin-debt-tab.spec.ts |

| cloud/services/radon-<name>.service + .timer | radon-margin-debt.{service,timer}, radon-bpi.timer |

Modify (lockstep pins — miss one and a test fails, which is the point):

1. Ingestion job (`scripts/`)

1. writer.ensure_no_replica_for_writers()

2. writer.upsert_<name>_rows(series, recorded_at=scan_time) — only when rows changed

3. writer.upsert_scan_snapshot("<name>", scan_time, payload) — every cycle

4. writer.record_service_health("<name>", "ok", finished_at=scan_time) — every cycle, or error rows latch (feedback_service_health_heartbeat)

5. JSON fallback data/<name>.json (atomic write) — fallback only; Turso is the source of truth (Data Persistence rule: host-local files are ephemeral on the VPS)

2. Storage (Turso-first)

INSERT OR IGNORE INTO schema_migrations (version, applied_at) VALUES (NN, datetime('now'));

3. API route (`web/app/api/<name>/route.ts`)

4. Chart tab (`web/components/<Name>Panel.tsx`)

5. Tests (red/green TDD — write these first)

6. Scheduling and deploy

7. CI gates and shipping

CI (.github/workflows/ci.yml) gates every push to main, then auto-deploys on green:

  1. gitleaks secret scan
  2. bunx vitest run --config vitest.config.ts --coverage — full config, coverage ratchet lines 75 / functions 78 / branches 65 (web/app/api/** is inside coverage include — an untested route drops the ratchet)
  3. python -m pytest scripts/tests scripts/api/tests scripts/trade_blotter --cov=scripts --cov=api --cov-branch --cov-fail-under=64 + python -m pytest cloud/tests -q (validates your systemd units)
  4. Perimeter smoke (next build + curl auth asserts)
  5. Deploy to Hetzner (no manual approval; never push while a deploy is in flight — cancelled builds have corrupted production)

Playwright is not in CI — run it locally and attach the evidence.

Ship checklist: one focused commit (stage files explicitly, never git add -A), push once, gh run watch to green, then verify production: latest scan_snapshots/history rows in Turso, curl the prod API route (authenticated perimeter: anon 401/404 is the perimeter working, not an outage), and a browser screenshot of the live tab.

8. Gotchas that cost real debugging time

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.