Skip to content

svm/pools/ohlc: open or close can fall outside [low, high] #492

@0237h

Description

@0237h

/v1/svm/pools/ohlc exposes the p5 / p95 quantiles of price as low and high, while open and close come from argMin / argMax over time. When a candle's open or close trade falls in the lowest 5% or highest 5% of fills, that price sits outside the [low, high] band — a violation of standard OHLC semantics.

src/routes/ohlcv/svm.sql:14-15:

quantileDeterministicMerge(0.95)(quantile0) AS high_raw,
quantileDeterministicMerge(0.05)(quantile0) AS low_raw,

Suggested fix

Clamp high_raw to greatest(high_quantile, open, close) and low_raw to least(low_quantile, open, close) so that low ≤ {open, close} ≤ high holds for every row.


🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions