fintech-algorithms

Advance/Decline Ratio

Advancing Issues per Declining Issue

Install and import

bash
npm install fintech-algorithms
ts
import { calculateAdvanceDeclineRatio } from "fintech-algorithms/market-breadth-and-internals/advance-decline-breadth/advance-decline-ratio";

Signature

calculateAdvanceDeclineRatio(snapshot)

Worked example

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input

snapshot
{
  "series_id": "SYNTH:XNAS:ACTIVE-ISSUES:CLOSE",
  "record_id": "SYNTH-2026-01-05-R1",
  "session_date": "2026-01-05",
  "effective_at": "2026-01-05T21:00:00Z",
  "available_at": "2026-01-05T21:05:00Z",
  "venue_id": "SYNTH:XNAS",
  "calendar_id": "SYNTH:XNAS-CALENDAR",
  "session_id": "regular-close",
  "universe_id": "SYNTH:ACTIVE-COMMON-STOCK",
  "universe_revision": "2026-01-05-final",
  "listing_id_scheme": "synthetic-stable-listing-id-v1",
  "security_type_policy": "synthetic-common-stock-only",
  "comparison_basis": "official-close-to-corporate-action-adjusted-comparable-prior-close",
  "corporate_action_policy": "synthetic-adjusted-prior-close-v1"
}

Showing 14 of 27 fields.

Call

calculateAdvanceDeclineRatio(snapshot)

Returns

object with 19 fields: evidence_state, ratio_state, advance_decline_ratio, direction, observed_partition_ratio, observed_partition_direction, selected_record_id, selected_revision, …

{
  "evidence_state": "resolved",
  "ratio_state": "finite",
  "advance_decline_ratio": 2,
  "direction": "advances_dominant",
  "observed_partition_ratio": 2,
  "observed_partition_direction": "advances_dominant",
  "selected_record_id": "SYNTH-2026-01-05-R1",
  "selected_revision": 1,
  "advances": 60,
  "declines": 30,
  "unchanged": 10,
  "excluded_count": 0,
  "universe_size": 100,
  "mover_count": 90
}

Showing 14 of 19 fields.

Other exports

This module also exports evaluateAdvanceDeclineRatioAsOf. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams

Advance/Decline Ratio — ratio balance
Advance/Decline Ratio — same ratio different coverage

Calculation flow

Evidence and ratio state flow
flowchart TD
    Q["Declared as-of query"] --> F["Match identity, policy, and available time"]
    F --> N{"Eligible snapshot exists?"}
    N -->|"No"| U["unsupported; no metric"]
    N -->|"Yes"| C{"Revision chain unique, contiguous, linked?"}
    C -->|"No"| A["ambiguous; no metric"]
    C -->|"Yes"| P["Validate category partition and coverage"]
    P --> E{"Final with no exclusions?"}
    E -->|"No"| I["incomplete; observed diagnostic only"]
    E -->|"Yes"| R["resolved evidence"]
    R --> Z{"Universe or denominator edge?"}
    Z -->|"Empty universe"| Z1["empty_universe; null"]
    Z -->|"No movers"| Z2["no_movers; null"]
    Z -->|"No declines"| Z3["no_declines; null"]
    Z -->|"Declines positive"| O["finite A divided by D"]
Correction-aware snapshot lifecycle
sequenceDiagram
    participant M as Point-in-time security master
    participant P as Comparable closing prices
    participant C as Corporate-action policy
    participant B as Breadth publisher
    participant Q as As-of evaluator

    M->>B: Stable listing roster and universe revision
    P->>B: Current and comparable prior closes
    C->>B: Adjustment and exclusion decisions
    B->>Q: Revision 1 with effective_at and available_at
    Q-->>Q: Use revision 1 before any later correction is available
    B->>Q: Revision 2 supersedes revision 1
    Q-->>Q: Use revision 2 only after its available_at
    B-xQ: Conflicting or broken chain
    Q-->>Q: Return ambiguous rather than guess

How it works

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References

  • R01 - Advance/Decline Ratio glossary
  • R02 - Daily Market Files landing page
  • R03 - 2026 Daily Market Statistics CSV
  • R04 - Daily TAQ catalog
  • R05 - TAQ NYSE Closing Prices Client Specification
  • R06 - NYSE Reference Data
  • R07 - NYSE Corporate Actions
  • Evidence boundary