Lookup icon
Loop icon
CompanyFacts icon
IonToJson icon
Query icon
IonToCsv icon
Fail icon
If icon
Log icon
SlackIncomingWebhook icon
Trigger icon

Monitor Financial Ratios from SEC XBRL Filings with DuckDB and Slack Alerts

Compute current ratio, debt-to-equity and margins from SEC XBRL filings in DuckDB and get Slack alerts on thresholds and sharp moves.

Categories
BusinessData

Compute four ratios for a watchlist from the XBRL numbers companies file with the SEC, and alert when one crosses a threshold or moves sharply. No API key or paid data feed.

How it works

  1. new_quarterly_report (EDGAR trigger) runs the flow when a watched company files a 10-Q or 10-K.
  2. each_company reads three years of us-gaap facts per ticker with xbrl.CompanyFacts.
  3. ratios (DuckDB) keeps one value per period (SEC's frame), derives fiscal Q4 of income items as the year minus its three quarters, and computes per quarter:
    • current ratio: current assets / current liabilities
    • debt-to-equity (interest-bearing debt / equity), flagged instead when equity is negative
    • gross and operating margin on total revenue Each input's fallback order of us-gaap concepts is commented in the SQL.
  4. freshness fails a triggered run on purpose while SEC's company facts lack the new report; the flow retry reruns it every 30 minutes (6 runs), so the new quarter gets checked, not the last.
  5. alerts checks the latest quarter against the thresholds, the balance-sheet ratios against the previous quarter and the margins against a year earlier, for the companies that filed.

What you get

  • Alerts at WARN in the logs and in Slack, and a ratio_table CSV of every quarter.
  • Banks get no current ratio or margins: they report none.

Who it's for

Credit, treasury and equity analysts, and finance teams watching suppliers or customers.

Why orchestrate this with Kestra

An event trigger and flow-level retries absorb SEC's publishing lag; the finance logic is one SQL query versioned with the flow.

Prerequisites

Kestra 2.0 with plugin-edgar 1.0.0 (auto-installed on save in a local OSS instance, otherwise kestra plugins install io.kestra.plugin:plugin-edgar:1.0.0).

Secrets

  • SLACK_WEBHOOK_URL (optional): without it the Slack step ends in a warning; alerts stay logged.

Quick start

  1. Namespaces > company.team > KV Store: key SEC_EDGAR_USER_AGENT, type STRING, value your name and email (Example Co admin@example.com). SEC rejects requests without one.
  2. Execute, then check the logs and ratio_table.
  3. Copy the watchlist into the trigger's tickers (a trigger can't read inputs) and enable it.

How to extend

  • Add a ratio: request its concepts in each_company and add a column in ratios.
  • Known limits: short-term debt under a company-specific concept is missed, so D/E can read low; the oldest year in the window may lack its derived Q4.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.