# How this dataset is built One question decides everything below: **at what instant did this become public?** The two halves of the dataset answer it differently, and the difference is the reason they are worth keeping in one place. ## The shape of a run ``` TreasuryDirect auction query (one JSON, 120 fields, 1979 to next week) | | + one small result artifact per auction since March 2008 | read for 11:32 and nothing else v auction_calendar -- auction_announcements -- auction_results | home.treasury.gov daily rate feeds (five, one CSV per year each) | v nominal_yield_curve -- real_yield_curve -- bill_rates | | +------------------------+--> curve_features | v pit -> data/pit/us_treasury_events.delta | v quality gate -> manifest.json + quality_report.json -> Hugging Face ``` ## Two kinds of timestamp | | What the number describes | When it could be read | Precision | |---|---|---|---| | Auction result, from March 2008 | the auction | the minute stated in the artifact | `minute` | | Auction result, before that | the auction | end of the auction day | `date` | | Auction announcement | the coming auction | end of the announcement day | `date` | | Calendar entry | a future auction | end of the announcement day | `date` | | Yield curve, real curve, bills | 15:30 Eastern quotations | **18:00 Eastern** | `modeled_conservative` | ### The auction result states its own minute The Treasury publishes a small XML artifact for every auction since March 2008, and it contains two lines that settle the question: ```xml 13:00 13:02 ``` Two minutes after the close. That is the Treasury's own statement of when the result went out, and it is used exactly as written. Every field in the tables comes from the auction query; the artifact is fetched for its clock alone. Before March 2008 there is no artifact. Those results are dated to the end of the auction day, because the alternative — assuming the result was public at the close — would hand a backtest the number minutes before anyone had it, on every auction for twenty-nine years. ### The yield curve does not This is the single most important line in the dataset, so it is worth quoting the Treasury directly. Its methodology page says the inputs are > indicative, bid-side market price quotations (not actual transactions) for > the most recently auctioned securities obtained by the Federal Reserve Bank > of New York **at or near 3:30 PM** each trading day and, further down the same page, > Yield curve rates are **usually available** at Treasury's interest rate > website **by 6:00 PM Eastern Time** each trading day, but may be delayed due > to system problems or other issues. Those are two different instants. 3:30 p.m. is what the number measures; 6:00 p.m. is when anybody could read it. Dating a curve to 3:30 p.m. hands a backtest two and a half hours of the afternoon it did not have, every trading day since 1990. So every curve row carries both. `market_observation_at` is 15:30 Eastern, `knowledge_at` is 18:00 Eastern, `knowledge_time_precision` is `modeled_conservative`, and `availability_time_basis` is `treasury_usually_available_by_1800_et` so the rule is named rather than implied. A test asserts 18:00 on every row, and the gate fails the build if any row claims a precision the Treasury never published. Daylight saving is never computed. Every instant goes through `America/New_York` in the timezone database. ## Reading the auction query One JSON document, a hundred and twenty fields wide, every security auctioned since October 1979. Three things about it shape the code. **An absent field is absent.** The query writes a field it has no value for as an empty string, and the fields do not all start at the same time: the bidder categories — indirect, direct, primary dealer — begin in 2008, an investment rate applies to bills and not to bonds, and the competitive breakdown begins with the artifacts. Every one of those becomes null, never zero. A table of zeroes would read as "no indirect bidders took any of it", which is a claim nobody made. `metadata/field_coverage.parquet` records the first date each field is populated. **A CUSIP is not an identifier.** A reopening auctions the same CUSIP again, so an auction is keyed on the pair of CUSIP and auction date. **Announced is not auctioned.** An auction announced for next week already has a row, with its result fields empty. `totalAccepted` is what separates the two: it fills the calendar with `status = "scheduled"` and produces no result row. The derived shares — `indirect_accepted_pct` and the rest — are computed only from numbers in the same result, and are null wherever either side is absent. ### What is deliberately missing `wi_yield` and `auction_tail` are null on every row, and the gate fails the build if either is ever populated. The tail is the auction's high yield minus the when-issued market yield. No official point-in-time when-issued series exists. The daily par yield curve is not one: it is struck from indicative quotations at 3:30 p.m., hours after most auctions close, and subtracting it from the high yield produces a plausible number measuring something else. A field called `auction_tail` that does not contain an auction tail is worse than no field at all. ## Reading the rate feeds Five CSVs per year — nominal par yields, TIPS real yields, bill rates, the long-term composite and the long-term real average. Each is wide: a row per day, a column per maturity. That shape is wrong to store, because the set of columns changes underneath it. The 1-month bill appears in 2001, the 2-month in 2018, the 4-month in 2022 and the 1.5-month in 2025; the 30-year disappears from the curve between 15 February 2002 and 9 February 2006, four years in the middle of an otherwise unbroken series. A wide table records those as nulls that look like missing data; long form records them as what they are, which is a maturity that did not exist that day. So every cell becomes a row and a blank cell becomes nothing at all. Nothing is interpolated. Two header labels are not maturities and would be read as one: `LT COMPOSITE (>10 Yrs)` is an average of everything longer than ten years, not the ten-year rate, and filing it as `10Y` would put a second, different number under a name already taken. Those are mapped explicitly and kept as their own `curve_type`. Each feed is generated on request and takes the Treasury about seventeen seconds, so a cold backfill of thirty-seven years across five feeds runs six at a time. After that, a year that is over cannot change, and the run reuses the rows it already has: **185 requests become 5**, one per feed for the current year. That is not only a saving -- from a datacentre the feeds are slow enough that refetching all of them makes a scheduled run unreliable. ### The methodology changed, and the rates are not recomputed The par yield curve is the output of a procedure, and the procedure changed: the monotone convex method replaced the quasi-cubic hermite spline as of 6 December 2021, which the Treasury states on its methodology page. A rate from 2015 and a rate from 2022 are therefore not the same kind of number. Neither is recomputed under the other's method — the published values stand as published. `methodology_id` on every nominal curve row says which procedure produced it, and `metadata/yield_curve_methodology.parquet` says what each one was, with the Treasury's own description and the source URL. ## Derived features `curve_features` is arithmetic on two numbers that were public at the same instant, so it inherits that instant rather than an earlier one. Where a leg is missing — no 20-year point between 2002 and 2020, no real curve before 2003 — the feature is null rather than interpolated. `nominal_10y_minus_real_10y_bp` is a spread between two official curves published for the same day. It is **not** a market breakeven: both legs are par yields struck from indicative quotations, and neither is a traded inflation instrument. The column name says what it is. ## The gate `python -m recipe.cli verify` runs it, and `build` runs it too. A failure stops publication. Each check below has been made to fail in `tests/test_quality.py`: - a curve knowable before 18:00 Eastern on its own day; - a curve claiming a precision the Treasury never published; - a result knowable before its auction; - a calendar entry knowable before it was announced; - more accepted than tendered; - bidder categories that do not sum to the competitive award; - a security maturing on or before it is issued; - a populated `wi_yield` or `auction_tail`; - two yields for one maturity on one day; - a null yield, which should have been an absent row; - a curve dated in the future. A large daily move in a rate is a **warning**, never a correction. March 2020 had several and every one of them was real. Official rates are not smoothed here. Two other things are reported as warnings rather than errors, because both are facts about the source rather than parsing failures. One auction of 6 229 -- a 13-week bill from January 2009 -- has bidder categories that miss the competitive award by $10m on $26bn, which is the Treasury's own rounding. And twelve `pit` rows share an entity, a date and an instant, because in 1984-85 the Treasury sometimes auctioned two securities of the same odd term on the same day, and with no artifact to give them different minutes there is nothing to tell them apart but the CUSIP in `record_id`. ## Running it ```bash python -m recipe.cli build # fetch, parse, verify python -m recipe.cli build --rebuild # re-read everything; what a parser change needs python -m recipe.cli build --limit 50 # the newest fifty auctions, for development python -m recipe.cli verify # the gate and the manifest, over what is on disk python -m recipe.cli publish # mirror to Hugging Face, gate first ``` The document cache is not published, so a scheduled run starts from the tables in the dataset repository instead. A finished auction's result artifact cannot change, so a run that already holds the row does not ask TreasuryDirect for it again: the first build reads 6 229 artifacts in about thirty-five minutes, and every run after it reuses them and finishes in **four seconds**. What decides reuse for an auction is `raw_sha256`, not the precision of its instant. A row carrying a digest is one whose artifact was fetched and read, and that is settled whether or not the artifact turned out to state a release time -- **1 357 of them do not**, and reusing only the `minute` rows meant refetching every one of those on every run, forever, looking for a line that was never going to appear. A row with no digest is one whose artifact was never found, and that one is worth looking for again. For the rate feeds, **every** past year is settled, not only the ones that produced rows. The real curve begins in 2003 and the years before it return a file with nothing but a header; holding only the years with data meant fetching thirteen empty years on every run to be told again that they are empty. Five auctions of 11 114 state a noncompetitive closing time in the artifact that the query leaves empty, so those two fields are carried forward from the held announcement rather than rebuilt from the query. Without that the incremental build would quietly drop a field the dataset already had. Between them the reuse paths take a run that fetched 12 832 documents down to **seven requests** and about **two and a half seconds**, and the tables it produces are identical to the full build's in all eight configs. `--rebuild` ignores held rows entirely, which is what a parser change needs. ## Scheduling Two Hugging Face Jobs, managed from `recipe/hf_jobs.py`: | Job | Cron (UTC) | Why | |---|---|---| | `us-treasury-events-update` | `30 23 * * 1-5` | after the last auction close and after 18:00 Eastern | | `us-treasury-events-sweep` | `30 13 * * 1-5` | the morning's auction announcements, and a curve posted late | Each run restores the published repository, lints it, runs its tests, builds, verifies and only then publishes — in that order, before anything is fetched.