|
| 1 | +# Worked examples |
| 2 | + |
| 3 | +The repository's [`examples/`](https://github.com/copyleftdev/anomalyx/tree/main/examples) |
| 4 | +directory holds small, runnable programs that use anomalyx on **real data**. They |
| 5 | +exist to demonstrate one thing the contract makes possible: an agent (or a |
| 6 | +30-line script) can *consume the `tq1` envelope directly* — parse the dense |
| 7 | +finding rows and the dict-pinned string table, then map each |
| 8 | +[handle](./envelope.md) back to a row, cell, or timestamp — rather than scraping |
| 9 | +human-readable text. |
| 10 | + |
| 11 | +They live outside the Cargo workspace and shell out to the installed `anomalyx` |
| 12 | +binary, so they have no effect on the build or the [quality gates](./gates.md). |
| 13 | +Each mirrors anomalyx's exit code (`0` clean, `1` anomalies, `2` error). |
| 14 | + |
| 15 | +## The examples |
| 16 | + |
| 17 | +| Example | Data | What it surfaces | |
| 18 | +|---|---|---| |
| 19 | +| `stock_anomalies.py` | Yahoo Finance daily history | anomalous trading days; distributional drift vs. another ticker | |
| 20 | +| `journal_anomalies.py` | `journalctl -o json` (systemd) | rare priorities, bursts, per-unit content spikes; drift between two windows | |
| 21 | +| `polymarket_anomalies.py` | Polymarket public APIs | information shocks (`point`/`mv`) and odds regime shifts (`coll.cusum`) | |
| 22 | +| `synergy_market.py` | Yahoo Finance + `agent-calc` | anomalyx *finds*; the exact-math kernel *proves* (tail probability, a t-test across the regime break, exact correlations) | |
| 23 | + |
| 24 | +Each maps the handle in every finding back to a calendar date / timestamp, |
| 25 | +so the output reads as *"this day, this column, this kind of deviation"*. |
| 26 | + |
| 27 | +## Contracts composing with contracts |
| 28 | + |
| 29 | +`synergy_market.py` is the clearest illustration of why a machine-readable |
| 30 | +contract matters. anomalyx is **descriptive and assumption-free** — it reports |
| 31 | +*which* days and regimes broke the pattern (`point.modz`, `mv.mahalanobis`, |
| 32 | +`coll.cusum`), never assuming a distribution. Its findings then flow, as typed |
| 33 | +JSON, straight into [`agent-calc`](https://github.com/copyleftdev/agent-calc) — |
| 34 | +a sibling contract-first CLI that does **exact** statistics: the return |
| 35 | +distribution's fat-tailed kurtosis, the worst day's tail probability under a |
| 36 | +fitted Gaussian (routinely *one-in-millions* — i.e. the naive risk model is what |
| 37 | +is broken), a two-sample *t*-test across the detected regime break (a real shift |
| 38 | +in the *mean*, or only the trajectory?), and exact correlations across a basket. |
| 39 | + |
| 40 | +Two executables, two contracts, no prose and no float drift in between — which is |
| 41 | +the whole thesis: *the executable is the contract.* |
| 42 | + |
| 43 | +See [`examples/README.md`](https://github.com/copyleftdev/anomalyx/blob/main/examples/README.md) |
| 44 | +for the exact commands and prerequisites. |
0 commit comments