# Advance/Decline Ratio

> Advancing Issues per Declining Issue

`D04-F01-A02` · Market Breadth and Internals → Advance/Decline Breadth · archetype `record-transform` · difficulty 1/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/market-breadth-and-internals/advance-decline-breadth/advance-decline-ratio/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## 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

```ts
calculateAdvanceDeclineRatio(snapshot)
```

Advances divided by declines. Scale-free where net advances is not, so readings stay comparable as the universe grows — the reason a raw A/D count from the 1960s cannot be compared with one from today.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `snapshot` | `BreadthSnapshot` | yes | One session's counts with their evidence state and full identity — venue, calendar, session and universe. |

## Returns

`{ evidence_state, ratio_state, advance_decline_ratio, direction, observed_partition_ratio, observed }`

The ratio plus a separate `evidence_state` and `ratio_state`, which distinguish a genuine reading from one the data could not support.

## Errors

- When declines is zero, making the ratio undefined — reported as a ratio_state rather than thrown

## Complexity

Time `O(1)`, space `O(1)`.

## Worked example

This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

### Input

`snapshot`:

```json
{
  "series_id": "SYNTH-ADR",
  "record_id": "ADR-R1",
  "session_date": "2026-01-05",
  "effective_at": "2026-01-05T21:00:00Z",
  "available_at": "2026-01-05T21:05:00Z",
  "venue_id": "SYNTH-X",
  "calendar_id": "SYNTH-CAL",
  "session_id": "regular",
  "universe_id": "SYNTH-100",
  "universe_revision": "U1",
  "listing_id_scheme": "synthetic-listing-id",
  "security_type_policy": "common-equity",
  "comparison_basis": "comparable-prior-close",
  "corporate_action_policy": "provider-adjusted"
}
```

Showing 14 of 27 fields.

### Call

```ts
calculateAdvanceDeclineRatio(snapshot)
```

### Returns

object with 13 fields: evidence_state, ratio_state, advance_decline_ratio, direction, observed_partition_ratio, selected_record_id, selected_revision, excluded_count, …

```json
{
  "evidence_state": "resolved",
  "ratio_state": "finite",
  "advance_decline_ratio": 2,
  "direction": "advances_dominant",
  "observed_partition_ratio": 2,
  "selected_record_id": "ADR-R1",
  "selected_revision": 1,
  "excluded_count": 0,
  "mover_count": 90,
  "classified_count": 100,
  "coverage_ratio": 1,
  "is_provisional": false,
  "reasons": []
}
```

## Other 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.

## Verification and provenance

Tier: **verified** (via input-expected).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/market-breadth-and-internals/advance-decline-breadth/advance-decline-ratio/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-breadth-and-internals/advance-decline-breadth/advance-decline-ratio/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-Advance-Decline-Ratio-Market-Breadth-algorithm
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-breadth-and-internals/llms.txt
