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

High-Low Ratio

Install and import#

bash
npm install fintech-algorithms
ts
import { 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#

NameTypeNotes
recordsRecord[]Session records with evidence state.
decisionTimestringPoint-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#

records
[
  {
    "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
  }
]
decisionTime
"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#

High-Low Ratio — decision boundary
High-Low Ratio — family map
High-Low Ratio — worked state

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.

Read the article →

References#

  • Nasdaq Fundamental Data
  • How High/Low and New High/New Low Are Calculated
  • New 52-Week Highs and Lows for Exchanges
  • Evidence decision

The rest of the High/Low and Trend Breadth family#