Candlestick Scanner Ranking and Deduplication
Install and import#
npm install fintech-algorithmsimport { rankAndDeduplicate } from "fintech-algorithms/price-action-and-candlesticks/candlestick-scanning-and-context/candlestick-scanner-ranking-and-deduplication";Signature#
rankAndDeduplicate(data)calculate a traceable composite rank, keep deterministic order, and deduplicate only within an explicit identity key and bar window.
Parameters#
| Name | Type | Notes |
|---|---|---|
data | { recency_half_life_bars: number; dedup_window_bars: number; occurrences: { occurrence_id: string; instrument_id: string; interval: string; pattern_id: string; direction: string; end_index: number; confidence: number; age_bars: number; liquidity_score: number; priority_score: number }[] } | Topic input record; the required fields are fixed by this topic data-contract. |
Returns#
{ state, ranked_count, suppressed_count, ranked, suppressed }
One ready ranking record containing stable ranks and component traces for kept occurrences plus reason-coded duplicates and both counts.
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#
{
"recency_half_life_bars": 5,
"dedup_window_bars": 2,
"occurrences": [
{
"occurrence_id": "A",
"instrument_id": "SYNTH:AAA",
"interval": "5m",
"pattern_id": "D06-F03-A01",
"direction": "bullish",
"end_index": 10,
"confidence": 90,
"age_bars": 1,
"liquidity_score": 0.8,
"priority_score": 0.8
},
{
"occurrence_id": "B",
"instrument_id": "SYNTH:AAA",
"interval": "5m",
"pattern_id": "D06-F03-A01",
"direction": "bullish",
"end_index": 11,
"confidence": 85,
"age_bars": 0,
"liquidity_score": 0.9,
"priority_score": 0.9
},
{
"occurrence_id": "C",
"instrument_id": "SYNTH:BBB",
"interval": "5m",
"pattern_id": "D06-F02-A06",
"direction": "bullish",
"end_index": 11,
"confidence": 70,
"age_bars": 2,
"liquidity_score": 1,
"priority_score": 0.5
}
]
}Call#
rankAndDeduplicate(data)Returns#
object with 3 fields: state, ranked_count, suppressed_count
{
"state": "ready",
"ranked_count": 2,
"suppressed_count": 1
}Diagrams#
Calculation flow#
Decision flow
flowchart LR
A["Validated point-in-time input"] --> B["Normalize rank components"]
B --> C["Apply declared weights"]
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.
References#
- TA-Lib function catalog and pattern-recognition group — TA-Lib project
- TA-Lib C/C++ Core API — TA-Lib project
- Binance Spot kline/candlestick stream — Binance
- CME Group chart types and support/resistance lessons — CME Group
- Foundations of Technical Analysis — Andrew W. Lo, Harry Mamaysky, and Jiang Wang
- Evidence and licensing boundary