UNPKG

pricehistory

Version:
40 lines (39 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function setOptions(option, series) { var _a, _b; Object.assign(option, Object.assign({ datetime: "datetime", open: "open", high: "high", low: "low", close: "close", volume: "volume", volumeFill: false, date: false, time: false, price: false, leverage: null, limit: false, obv: false, vwap: false, rsi: false, ema: false, macd: false, color: false, periods: [], sma: false, smaStats: [], candlestick: false, trend: false, crossover: false, valueCap: 100, anchor: [], normalize: [], signalize: false }, option)); if (typeof option.basePrice !== "number" && option.open) { for (const curr of series) { const open = curr[option.open]; if (typeof open === "number") { option.basePrice = open; break; } } } if (option.volumeFill === true) { option.price = true; } if (option.sma === true && !((_a = option.periods) === null || _a === void 0 ? void 0 : _a.length)) { option.periods = [5, 10, 50, 200]; } if (option.signalize === true) { option.price = true; option.color = true; option.sma = true; option.candlestick = true; if (!option.periods) option.periods = []; option.periods.push(10); } if ((_b = option.periods) === null || _b === void 0 ? void 0 : _b.length) { option.periods = option.periods.filter((p) => typeof p === "number"); option.periods = [...new Set(option.periods)]; option.periods.sort(); } if (option.smaStats === true) { option.smaStats = ["variance", "standarddeviation", "zscore", "trendSlope"]; } } exports.default = setOptions;