Function validateCandles

Validates that all candles have valid OHLCV data without anomalies.

Guards the candle cache against corrupt adapter output before it is persisted:

  • Rejects non-finite values (NaN / Infinity / -Infinity), which JSON would silently serialize to null and break VWAP on the next read.
  • Rejects zero / negative prices and negative volume.
  • Detects incomplete candles from exchange APIs (abnormally low prices, e.g. 0.1 instead of 100,000) by comparing against a reference price.

Error if any candle has anomalous OHLCV values