High-Low Ratio
Install and import#
npm install fintech-algorithmsimport { calculate } from "fintech-algorithms/market-breadth-and-internals/high-low-and-trend-breadth/high-low-ratio";Signature#
calculate(records, decisionTime)New highs as a share of new highs plus new lows — the scale-free form, comparable across universes and eras.
Parameters#
| Name | Type | Notes |
|---|---|---|
records | Record[] | Session records with evidence state. |
decisionTime | string | Point-in-time bound. |
Returns#
Row[] · length same-as-input
The ratio per session with the counts behind it.
Errors#
- When highs and lows are both zero, making the ratio undefined — reported per row rather than thrown
Complexity: time O(records),
space O(sessions).
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#
[
{
"session_date": "2026-01-15",
"available_at": "2026-01-15T21:30:00Z",
"source_evidence_state": "ready",
"venue_id": "SYNTH-X",
"universe_id": "SYNTH-HIGH-LOW-12",
"methodology_id": "synthetic-high-low-v1",
"lookback_sessions": 252,
"new_highs": 2,
"new_lows": 10,
"eligible_issues": 12,
"overlap_issues": 0
}
]"2026-03-01T00:00:00Z"Call#
calculate(records, decisionTime)Returns#
object with 1 field: 0
{
"0": {
"session_date": "2026-01-15",
"new_highs": 2,
"new_lows": 10,
"value": 0.2,
"status": "resolved",
"reason": null
}
}Diagrams#
Calculation flow#
Topic decision flow — High-Low Ratio
flowchart LR
A["Ready NH and NL counts"] --> B{"NL = 0?"}
B -->|"No"| C["Publish NH / NL"]
B -->|"Yes"| D{"NH > 0?"}
D -->|"Yes"| E["Unbounded: no infinity token"]
D -->|"No"| F["Incomplete: no new extremes"]
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#
- Nasdaq Fundamental Data
- How High/Low and New High/New Low Are Calculated
- New 52-Week Highs and Lows for Exchanges
- Evidence decision