# Market-Wide Candlestick Pattern Scanner

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

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

## Signature

```ts
scanMarket(data)
```

dispatch a frozen registry across injected detector candidates and emit only causal occurrence records with explicit rejection reasons.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ as_of: string; minimum_geometry_score: number; registry: { pattern_id: string; name: string; direction: string; window: number; detector: string; version: string; enabled: boolean; priority: number }[]; candidates: { instrument_id: string; interval: string; price_basis: string; session: string; pattern_id: string; pattern_name: string; direction: string; start_index: number; end_index: number; start_time: string; end_time: string; detected_at: string; available_at: string; bar_closed: boolean; detector_version: string; geometry_score: number; reason_codes: string[] }[] }` | yes | Topic input record; the required fields are fixed by this topic data-contract. |

## Returns

`{ state, as_of, candidate_count, occurrence_count, skipped_count, occurrences, skipped }`

One `ready` scan record containing deterministically ordered causal occurrences and reason-coded skipped candidates, with counts for both.

## 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
{
  "as_of": "2026-01-05T10:06:00Z",
  "minimum_geometry_score": 0.8,
  "registry": [
    {
      "pattern_id": "D06-F03-A01",
      "name": "Bullish Engulfing",
      "direction": "bullish",
      "window": 2,
      "detector": "bullish_engulfing",
      "version": "v1",
      "enabled": true,
      "priority": 2
    }
  ],
  "candidates": [
    {
      "instrument_id": "SYNTH:AAA",
      "interval": "5m",
      "price_basis": "raw-trades",
      "session": "synthetic-utc",
      "pattern_id": "D06-F03-A01",
      "pattern_name": "Bullish Engulfing",
      "direction": "bullish",
      "start_index": 10,
      "end_index": 11,
      "start_time": "2026-01-05T10:00:00Z",
      "end_time": "2026-01-05T10:05:00Z",
      "detected_at": "2026-01-05T10:05:01Z",
      "available_at": "2026-01-05T10:05:01Z",
      "bar_closed": true
    },
    {
      "instrument_id": "SYNTH:LIVE",
      "interval": "5m",
      "price_basis": "raw-trades",
      "session": "synthetic-utc",
      "pattern_id": "D06-F03-A01",
      "pattern_name": "Bullish Engulfing",
      "direction": "bullish",
      "start_index": 10,
      "end_index": 11,
      "start_time": "2026-01-05T10:00:00Z",
      "end_time": "2026-01-05T10:05:00Z",
      "detected_at": "2026-01-05T10:05:01Z",
      "available_at": "2026-01-05T10:05:01Z",
      "bar_closed": false
    },
    {
      "instrument_id": "SYNTH:WEAK",
      "interval": "5m",
      "price_basis": "raw-trades",
      "session": "synthetic-utc",
      "pattern_id": "D06-F03-A01",
      "pattern_name": "Bullish Engulfing",
      "direction": "bullish",
      "start_index": 10,
      "end_index": 11,
      "start_time": "2026-01-05T10:00:00Z",
      "end_time": "2026-01-05T10:05:00Z",
      "detected_at": "2026-01-05T10:05:01Z",
      "available_at": "2026-01-05T10:05:01Z",
      "bar_closed": true
    }
  ]
}
```

### Call

```ts
scanMarket(data)
```

### Returns

object with 4 fields: state, candidate_count, occurrence_count, skipped_count

```json
{
  "state": "ready",
  "candidate_count": 3,
  "occurrence_count": 1,
  "skipped_count": 2
}
```

## 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/market-wide-candlestick-pattern-scanner/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/price-action-and-candlesticks/candlestick-scanning-and-context/market-wide-candlestick-pattern-scanner/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
