Overlapping-Pattern Conflict Resolver
Install and import#
npm install fintech-algorithmsimport { resolveConflicts } from "fintech-algorithms/price-action-and-candlesticks/candlestick-scanning-and-context/overlapping-pattern-conflict-resolver";Signature#
resolveConflicts(data)form connected overlap components and choose one reproducible winner using declared precedence and stable tie-breaks.
Parameters#
| Name | Type | Notes |
|---|---|---|
data | { occurrences: { occurrence_id: string; instrument_id: string; interval: string; pattern_id: string; direction: string; start_index: number; end_index: number; priority: number; confidence: number; geometry_score: number }[] } | Topic input record; the required fields are fixed by this topic data-contract. |
Returns#
{ state, winner_count, suppressed_count, winners, suppressed }
One ready conflict-resolution record containing the deterministic winners and reason-coded suppressed occurrences with aggregate 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#
{
"occurrences": [
{
"occurrence_id": "A",
"instrument_id": "SYNTH:AAA",
"interval": "5m",
"pattern_id": "D06-F02-A01",
"direction": "neutral",
"start_index": 10,
"end_index": 10,
"priority": 1,
"confidence": 90,
"geometry_score": 0.95
},
{
"occurrence_id": "B",
"instrument_id": "SYNTH:AAA",
"interval": "5m",
"pattern_id": "D06-F03-A01",
"direction": "bullish",
"start_index": 10,
"end_index": 11,
"priority": 2,
"confidence": 70,
"geometry_score": 0.85
},
{
"occurrence_id": "C",
"instrument_id": "SYNTH:AAA",
"interval": "5m",
"pattern_id": "D06-F02-A04",
"direction": "bullish",
"start_index": 15,
"end_index": 15,
"priority": 1,
"confidence": 80,
"geometry_score": 0.9
}
]
}Call#
resolveConflicts(data)Returns#
object with 3 fields: state, winner_count, suppressed_count
{
"state": "ready",
"winner_count": 2,
"suppressed_count": 1
}Diagrams#
Calculation flow#
Decision flow
flowchart LR
A["Validated point-in-time input"] --> B["Partition by instrument and interval"]
B --> C["Sort inclusive spans"]
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