UNPKG

pricehistory

Version:

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

20 lines 876 B
import * as utilN from "@nameer/utils"; function setCandleSignal(opt, candle, ctx) { var _a; for (const [anchor, ...keys] of opt.signal) { for (const k of keys) { const key = `signal${utilN.capitalize(anchor)}To${utilN.capitalize(k)}`; candle[key] = utilN.math.change.percent(candle[anchor], candle[k]); for (const period of opt.sma) { const winKey = `signal${period}${key}`; (_a = ctx.window)[winKey] ?? (_a[winKey] = []); ctx.window[winKey].push(candle[key]); if (ctx.window[winKey].length > period) ctx.window[winKey].shift(); candle[`sma${period}${utilN.capitalize(key)}`] = utilN.math.mean(ctx.window[winKey]); } } } } export default setCandleSignal; //# sourceMappingURL=candle.setSignal.js.map