UNPKG

pricehistory

Version:

Transforms raw OHLCV series data into enriched candles with technical indicators, pattern recognition, and trend analysis.

29 lines 921 B
import * as utilN from "@nameer/utils"; function setCandleVolume(opt, curr, candle, ctx) { const volume = curr[opt.volume]; if (!utilN.isNumber(volume)) return; candle.volume = volume; const price = candle.priceMean ?? candle.priceClose; if (price !== undefined) { candle.volumeValue = Math.round(volume * price); } if (opt.obv !== true || candle.priceOpen === undefined || candle.priceClose === undefined) { return; } const volumeValue = candle.volumeValue ?? 0; if (candle.priceClose > candle.priceOpen) { ctx.obv += volume; ctx.obvValue += volumeValue; } else if (candle.priceClose < candle.priceOpen) { ctx.obv -= volume; ctx.obvValue -= volumeValue; } candle.obv = ctx.obv; candle.obvValue = ctx.obvValue; } export default setCandleVolume; //# sourceMappingURL=candle.setVolume.js.map