Schedule icon
Download icon
Get icon
If icon
Queries icon
Set icon
SlackIncomingWebhook icon
Log icon

Load US Treasury Average Interest Rates with DuckDB and Track Month-Over-Month Yield Movements

Ingest US Treasury interest rates monthly, diff against historical trends in DuckDB, export partitioned Parquet to internal storage and alert on rate spikes.

Categories
Data

The US Department of the Treasury publishes monthly average interest rates across all outstanding marketable securities (Treasury Bills, Notes, Bonds, and TIPS) and non-marketable debt obligations. Corporate treasury desks, quantitative risk analysts, and macro data engineers track these benchmark yields to model corporate borrowing costs, calculate discount curves, and assess macroeconomic interest rate exposure.

This flow automates the ingestion of the official Fiscal Data REST API, diffs the newest monthly yield curve against accepted historical values inside an embedded DuckDB engine, writes persistent columnar Parquet files into Kestra internal storage, maintains state across executions using Kestra KV store, and triggers targeted Slack alerts when benchmark rates shift beyond an operational basis point threshold.

How it works

  1. A monthly Schedule trigger is configured to execute on the 5th of each month (09:00 UTC), allowing sufficient buffer for the US Treasury to publish and finalize prior month figures.
  2. fetch_treasury_rates (io.kestra.plugin.core.http.Download) queries the US Treasury Fiscal Data API (api.fiscaldata.treasury.gov) for all average interest rate records matching the configured starting date, landing the JSON payload into Kestra internal storage.
  3. previous_rates (io.kestra.plugin.core.kv.Get, with errorOnMissing: false) retrieves the storage URI of the Parquet dataset produced during the previous run.
  4. bootstrap_history (io.kestra.plugin.core.flow.If) executes only on the initial run when no prior state exists in KV store, generating an empty baseline Parquet file with identical column schemas so downstream diff queries share a single deterministic execution path.
  5. diff_and_load (io.kestra.plugin.jdbc.duckdb.Queries, with fetchType: FETCH_ONE) ingests the JSON payload via read_json and unnest, filters out null entries, isolates the latest record for each security description and category, and executes a full join against the baseline Parquet dataset. It calculates basis point deltas (ROUND((current_rate - previous_rate) * 100, 2)), categorizes change types (NEW, CHANGED, UNCHANGED), and outputs three distinct artifacts:
    • latest_rates.parquet: The current snapshot of all active Treasury securities and their latest monthly yields.
    • rates_revision_log.parquet: A multi-period historical time-series Parquet dataset suitable for analytical warehouse loading.
    • rate_changes_summary.csv: A tabular summary of monthly movements sorted by absolute basis point variance.
  6. save_rates_kv (io.kestra.plugin.core.kv.Set) stores the internal storage URI of latest_rates.parquet under the key treasury_accepted_rates_uri.
  7. alert_on_material_rate_shift (io.kestra.plugin.core.flow.If) evaluates the summary metric material_shifts_count. If one or more securities shifted by more than material_shift_bps, it posts an alert payload to Slack via io.kestra.plugin.slack.notifications.SlackIncomingWebhook. With allowFailure: true, missing webhook credentials issue a graceful warning rather than aborting the pipeline. Otherwise, a standard Log task records peaceful metrics.
  8. summary_log records execution telemetry, and the root outputs expose both the Parquet datasets and the summary JSON to downstream flows.

What you get

  • A clean columnar Parquet file of the latest US Treasury security yields ready for direct querying with DuckDB, Trino, Polars, or Spark.
  • An append-only historical Parquet dataset capturing monthly yield adjustments across all federal debt categories.
  • An execution CSV detailing month-over-month rate variances and delta basis points.
  • Automated Slack alerting when sovereign interest rates experience abnormal volatility exceeding operational tolerances.
  • Zero external infrastructure dependencies: storage and state management operate entirely through Kestra internal storage and native KV store.

Who it's for

  • Corporate treasurers and CFO offices monitoring sovereign borrowing rates to optimize short-term cash placement.
  • Quantitative research and risk engineering teams ingesting official macroeconomic rate indices for discount curve construction.
  • Financial data platform engineers building resilient, stateful ELT pipelines from government open data portals.

Why orchestrate this with Kestra

  • Download and inputFiles handle REST API ingestion and file transport directly into DuckDB without custom Python wrappers or container images.
  • Native outputFiles and KV Store eliminate the overhead of external state databases, preserving dataset URIs across monthly runs.
  • Conditional execution (If) and error fault-tolerance (allowFailure) provide declarative alerting logic directly within workflow configuration.
  • Declarative parameters allow custom historical lookback windows and basis point alert sensitivities.

Prerequisites

  • Kestra 2.0 or later with the DuckDB JDBC plugin (io.kestra.plugin.jdbc.duckdb.Queries) and notifications plugin (io.kestra.plugin.slack.notifications.SlackIncomingWebhook).
  • Outbound HTTPS network access to api.fiscaldata.treasury.gov. The Fiscal Data API is open to the public and requires no API key.

Secrets

  • SLACK_WEBHOOK_URL: Optional Slack incoming webhook URI for receiving material rate shift alerts.

Quick start

  1. Import this blueprint into your Kestra instance and trigger an ad-hoc execution with default parameters. The first run acts as a baseline, ingesting historical yields and populating treasury_accepted_rates_uri in KV store.
  2. Inspect execution outputs to view latest_rates.parquet and the summary metrics.
  3. Trigger a second execution: all records will be classified as UNCHANGED, and alerting will be bypassed.
  4. Provide the SLACK_WEBHOOK_URL secret and enable the monthly Schedule trigger to receive automatic notifications whenever the Treasury Department publishes monthly rate updates.

How to extend

  • Add cloud storage export tasks (io.kestra.plugin.aws.s3.Upload, io.kestra.plugin.gcp.gcs.Upload) to mirror generated Parquet files directly into your enterprise data lake.
  • Chain an analytics query to compute yield curve spreads between short-term Treasury Bills and 10-Year or 30-Year Treasury Bonds.
  • Ingest additional Fiscal Data datasets such as the Daily Treasury Statement or Debt to the Penny by parameterizing the endpoint URI.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.