UNPKG

@thuantan2060/technicalindicators

Version:
51 lines (48 loc) 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DEFAULT_BULLISH_MARUBOZU_CONFIG = void 0; exports.bullishmarubozu = bullishmarubozu; exports.default = void 0; var _CandlestickFinder = _interopRequireWildcard(require("./CandlestickFinder")); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } /** * Configuration interface for BullishMarubozu pattern. * Only uses the scale parameter for approximateEqual function precision. */ /** * Default configuration for BullishMarubozu pattern. */ const DEFAULT_BULLISH_MARUBOZU_CONFIG = exports.DEFAULT_BULLISH_MARUBOZU_CONFIG = { ..._CandlestickFinder.DEFAULT_CANDLESTICK_CONFIG }; class BullishMarubozu extends _CandlestickFinder.default { constructor(config) { const finalConfig = { ...DEFAULT_BULLISH_MARUBOZU_CONFIG, ...config }; super(finalConfig); this.name = 'BullishMarubozu'; this.requiredCount = 1; } logic(data) { let daysOpen = data.open[0]; let daysClose = data.close[0]; let daysHigh = data.high[0]; let daysLow = data.low[0]; // Bullish Marubozu: close > open, close = high, open = low (no shadows) let isBullish = daysClose > daysOpen; // Note: approximateEqual uses scale for price comparison precision let isCloseEqualsHigh = this.approximateEqual(daysClose, daysHigh); let isOpenEqualsLow = this.approximateEqual(daysOpen, daysLow); let isBullishMarubozu = isBullish && isCloseEqualsHigh && isOpenEqualsLow; return isBullishMarubozu; } } exports.default = BullishMarubozu; function bullishmarubozu(data, config = DEFAULT_BULLISH_MARUBOZU_CONFIG) { return new BullishMarubozu(config).hasPattern(data); } //# sourceMappingURL=BullishMarubozu.js.map