# Unified Candlestick Pattern Registry

`D06-F05-A01` · Price Action and Candlesticks → Candlestick Scanning and Context · archetype `record-transform` · difficulty 2/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/price-action-and-candlesticks/candlestick-scanning-and-context/unified-candlestick-pattern-registry/
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 { buildRegistry } from "fintech-algorithms/price-action-and-candlesticks/candlestick-scanning-and-context/unified-candlestick-pattern-registry";
```

## Signature

```ts
buildRegistry(data)
```

construct a deterministic, versioned registry that rejects duplicate identities and ambiguous detector metadata.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ patterns: { pattern_id: string; name: string; direction: string; window: number; detector: string; version: string; enabled: boolean; priority: number }[] }` | yes | Topic input record; the required fields are fixed by this topic data-contract. |

## Returns

`{ state, registry_id, pattern_count, enabled_count, max_window, patterns }`

One `ready` registry record with stable catalog ordering, a versioned registry identity, aggregate counts, maximum detector window, and the validated pattern specifications.

## Complexity

Time `O(n log n) worst case; see README for topic-specific n`, space `O(n)`.

## Worked example

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

### Input

`data`:

```json
{
  "patterns": [
    {
      "pattern_id": "D06-F03-A01",
      "name": "Bullish Engulfing",
      "direction": "bullish",
      "window": 2,
      "detector": "bullish_engulfing",
      "version": "v1",
      "enabled": true,
      "priority": 2
    },
    {
      "pattern_id": "D06-F02-A01",
      "name": "Doji",
      "direction": "neutral",
      "window": 1,
      "detector": "doji",
      "version": "v1",
      "enabled": false,
      "priority": 1
    }
  ]
}
```

### Call

```ts
buildRegistry(data)
```

### Returns

object with 5 fields: state, pattern_count, enabled_count, max_window, registry_id

```json
{
  "state": "ready",
  "pattern_count": 2,
  "enabled_count": 1,
  "max_window": 2,
  "registry_id": "D06-F02-A01@v1;D06-F03-A01@v1"
}
```

## 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.12.0.
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/price-action-and-candlesticks/candlestick-scanning-and-context/unified-candlestick-pattern-registry/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/price-action-and-candlesticks/candlestick-scanning-and-context/unified-candlestick-pattern-registry/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/price-action-and-candlesticks/llms.txt
