UNPKG

pricehistory

Version:

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

24 lines 952 B
import * as utilN from "@nameer/utils"; import { smaKeys } from "./keys.js"; import setCandleVwap from "./candle.setVwap.js"; import setCandleColor from "./candle.setColor.js"; function setCandleSma(opt, candle, ctx) { var _a; for (const period of opt.sma) { for (const smaKey of smaKeys) { const value = candle[smaKey]; if (value === undefined) continue; const winKey = `sma${period}${smaKey}`; (_a = ctx.window)[winKey] ?? (_a[winKey] = []); ctx.window[winKey].push(value); if (ctx.window[winKey].length > period) ctx.window[winKey].shift(); candle[`sma${period}${utilN.capitalize(smaKey)}`] = utilN.math.mean(ctx.window[winKey]); } setCandleVwap(opt, candle, ctx, period); setCandleColor(opt, candle, ctx, period); } } export default setCandleSma; //# sourceMappingURL=candle.setSma.js.map