# Missing-Bar Gap Classifier

`D01-F04-A01` · Market Data Engineering → Data Quality · archetype `row-classify` · difficulty 2/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/market-data-engineering/data-quality/missing-bar-gap-classifier/
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 { diagnoseGap } from "fintech-algorithms/market-data-engineering/data-quality/missing-bar-gap-classifier";
```

## Signature

```ts
diagnoseGap(row)
```

Decides why a bar is missing: the session was closed, the instrument was halted, the feed dropped, or a sequence number was skipped. A gap is only a data-quality incident in some of those cases, and treating them alike produces alert fatigue.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `row` | `{ case_id, scenario, timestamp, bar_state, session_status, halt_status, heartbeat_status, sequence_status }` | yes | One gap observation with every status the decision depends on, gathered from the layers that can each independently explain it. |

## Returns

`{ classification, decisive_layer, reason, evidence_ids, warnings }`

The classification plus which layer settled it, so the diagnosis can be audited rather than trusted.

## Errors

- When a required status field is absent — reported as a warning on the result rather than thrown

## Complexity

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

## Worked example

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

`row`:

```json
{
  "case_id": "C01",
  "scenario": "canonical",
  "timestamp": "2026-07-13T13:30:00Z",
  "bar_state": "present",
  "session_status": "open",
  "halt_status": "inactive",
  "heartbeat_status": "healthy",
  "sequence_status": "continuous",
  "activity_status": "trades",
  "activity_independent": true,
  "evidence_ids": ["BAR-001", "CAL-2026C"],
  "expected_classification": "present"
}
```

### Call

```ts
diagnoseGap(row)
```

### Returns

object with 5 fields: classification, decisive_layer, reason, evidence_ids, warnings

```json
{
  "classification": "present",
  "decisive_layer": "bar",
  "reason": "A validated bar is materialized.",
  "evidence_ids": ["BAR-001", "CAL-2026C"],
  "warnings": []
}
```

## Other exports

`classifyGap`, `classifyRows`. 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: **contract**.

The module loads, the entry point is callable and its declared signature matches the compiled code. The example below is real captured output, but no independently published figure asserts the numbers.

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-data-engineering/data-quality/missing-bar-gap-classifier/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-data-engineering/data-quality/missing-bar-gap-classifier/impl.ts
- Standalone repository: https://github.com/IslamBaraka90/Fintech-Missing-Bar-Gap-Classifier-algorithm
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-data-engineering/llms.txt
