fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Unified Candlestick Pattern Registry

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#

buildRegistry(data)

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

Parameters#

NameTypeNotes
data{ patterns: { pattern_id: string; name: string; direction: string; window: number; detector: string; version: string; enabled: boolean; priority: number }[] }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#

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

Input#

data
{
  "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#

buildRegistry(data)

Returns#

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

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

Diagrams#

Unified Candlestick Pattern Registry — decision

Calculation flow#

Decision flow
flowchart LR
    A["Validated point-in-time input"] --> B["Validate each specification"]
    B --> C["Reject duplicate ID or name"]
    C --> D{"Boundary satisfied?"}
    D -->|"Yes"| E["Reason-coded ready output"]
    D -->|"No"| F["Explicit rejected or unavailable state"]

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#

The rest of the Candlestick Scanning and Context family#