Socket
Socket
Sign inDemoInstall

technicalindicators

Package Overview
Dependencies
47
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.3 to 2.0.4

2

dist/browser.es6.js

@@ -1,1 +0,1 @@

var tf = window.tf || {};(function(e,r){'use strict';function t(e){return ue[e]}function o(e){let r=t('precision');return r?parseFloat(e.toPrecision(r)):e}function a(e){he.reverseInputs(e);var r=new pe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function l(e){he.reverseInputs(e);var r=new de(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function n(e){he.reverseInputs(e);var r=new ge(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function s(e){he.reverseInputs(e);var r=new ce(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function u(e){he.reverseInputs(e);var r=new ve(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function i(e){he.reverseInputs(e);var r=new me(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function h(e){he.reverseInputs(e);var r=new xe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function p(e){he.reverseInputs(e);var r=new we(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function d(e){he.reverseInputs(e);var r=new fe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function g(e){he.reverseInputs(e);var r=new Ie(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function c(e){he.reverseInputs(e);var r=new qe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function v(e){he.reverseInputs(e);var r=new Ce(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function m(e){he.reverseInputs(e);var r=new Ee(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function x(e){he.reverseInputs(e);var r=new Ve(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function w(e){he.reverseInputs(e);var r=new ke(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function f(e){he.reverseInputs(e);var r=new He(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function I(e){he.reverseInputs(e);var r=new Te(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function P(e){he.reverseInputs(e);var r=new Ae(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function _(e){he.reverseInputs(e);var r=new De(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function b(e){he.reverseInputs(e);var r=new Be(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function q(e){he.reverseInputs(e);var r=new ze(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function S(e){he.reverseInputs(e);var r=new Le(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function C(e){he.reverseInputs(e);var r=new Me(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function E(e){he.reverseInputs(e);var r=new je(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function V(e){he.reverseInputs(e);var r=new Re(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function k(e,r,t,o){return e<=t&&r>=t||t<=e&&o>=e}function H(e){he.reverseInputs(e);var r=new ye(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function T(e){he.reverseInputs(e);var r=new Fe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function A(e){he.reverseInputs(e);var r=new Ue(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function D(e){he.reverseInputs(e);var r=new We(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function B(e){he.reverseInputs(e);var r=new Ne(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function z(e){he.reverseInputs(e);var r=new Ge(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function L(e){he.reverseInputs(e);var r=new Xe(e).result;return e.reversedInput&&(r.open.reverse(),r.high.reverse(),r.low.reverse(),r.close.reverse(),r.volume.reverse(),r.timestamp.reverse()),he.reverseInputs(e),r}function M(e){he.reverseInputs(e);var r=new Ke(e).result;return e.reversedInput&&(r.open.reverse(),r.high.reverse(),r.low.reverse(),r.close.reverse(),r.volume.reverse(),r.timestamp.reverse()),he.reverseInputs(e),r}function j(e){return new nr().hasPattern(e)}function R(e){return new sr().hasPattern(e)}function y(e){return new ur().hasPattern(e)}function O(e){return new ir().hasPattern(e)}function F(e,r){var t=function(e,r,t){return e+(r-e)*t},o=[],a=new Number((e.length-1)/(r-1));o[0]=e[0];for(var l=1;l<r-1;l++){var n=l*a,s=new Number(Math.floor(n)).toFixed(),u=new Number(Math.ceil(n)).toFixed();o[l]=t(e[s],e[u],n-s)}return o[r-1]=e[e.length-1],o}function U(e){var r=e.reduce((e,r)=>e+r*r,0),t=oe(r);return e.map((e)=>e/t)}function W(){return Lr(this,void 0,void 0,function*(){return yr?Promise.resolve(!0):Or?Rr:(Rr=new Promise(function(e){return Lr(this,void 0,void 0,function*(){if(Mr){console.log('Nodejs Environment detected ');var t=require('@tensorflow/tfjs-node'),o=require('path').resolve(__dirname,'../tf_model/model.json');zr=yield r.loadModel(t.io.fileSystem(o))}else{if(console.log('Browser Environment detected '),'undefined'==typeof r||'undefined'==typeof r.loadModel)return console.log('Tensorflow js not imported, pattern detection may not work'),yr=!1,Or=!1,void e();zr=yield r.loadModel('/tf_model/model.json')}return yr=!0,Or=!1,void e()})}),void(Or=!0))})}function N(e){return Lr(this,void 0,void 0,function*(){yield W(),300>e.values.length&&console.warn('Pattern detector requires atleast 300 data points for a reliable prediction, received just ',e.values.length),he.reverseInputs(e);var t=e.values,o=yield zr.predict(r.tensor2d([U(F(t,400))])),a=r.argMax(o,1).get(0);return he.reverseInputs(e),{patternId:a,pattern:jr[a],probability:100*o.get(0,4)}})}function G(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.DB})}function X(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.DT})}function K(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.HS})}function Q(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.IHS})}function Y(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.TU})}function Z(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.TD})}function $(e){he.reverseInputs(e);var r=new Ur(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function J(){return['sma','ema','wma','wema','macd','rsi','bollingerbands','adx','atr','truerange','roc','kst','psar','stochastic','williamsr','adl','obv','trix','cci','awesomeoscillator','forceindex','vwap','volumeprofile','renko','heikinashi','stochasticrsi','mfi','averagegain','averageloss','highest','lowest','sum','FixedSizeLinkedList','sd','bullish','bearish','abandonedbaby','doji','bearishengulfingpattern','bullishengulfingpattern','darkcloudcover','downsidetasukigap','dragonflydoji','gravestonedoji','bullishharami','bearishharami','bullishharamicross','bearishharamicross','eveningdojistar','eveningstar','morningdojistar','morningstar','bullishmarubozu','bearishmarubozu','piercingline','bullishspinningtop','bearishspinningtop','threeblackcrows','threewhitesoldiers','bullishhammerstick','bearishhammerstick','bullishinvertedhammerstick','bearishinvertedhammerstick','hammerpattern','hammerpatternunconfirmed','hangingman','hangingmanunconfirmed','shootingstar','shootingstarunconfirmed','tweezertop','tweezerbottom','predictPattern','hasDoubleBottom','hasDoubleTop','hasHeadAndShoulder','hasInverseHeadAndShoulder','isTrendingUp','isTrendingDown','ichimokucloud']}var ee=Math.min,re=Math.max,te=Math.abs,oe=Math.sqrt;class ae{constructor(e,r,t){this.next=t,t&&(t.prev=this),this.prev=r,r&&(r.next=this),this.data=e}}class le{constructor(){this._length=0}get head(){return this._head&&this._head.data}get tail(){return this._tail&&this._tail.data}get current(){return this._current&&this._current.data}get length(){return this._length}push(e){this._tail=new ae(e,this._tail),0===this._length&&(this._head=this._tail,this._current=this._head,this._next=this._head),this._length++}pop(){var e=this._tail;if(0!==this._length)return(this._length--,0===this._length)?(this._head=this._tail=this._current=this._next=void 0,e.data):(this._tail=e.prev,this._tail.next=void 0,this._current===e&&(this._current=this._tail,this._next=void 0),e.data)}shift(){var e=this._head;if(0!==this._length)return(this._length--,0===this._length)?(this._head=this._tail=this._current=this._next=void 0,e.data):(this._head=this._head.next,this._current===e&&(this._current=this._head,this._next=this._current.next),e.data)}unshift(e){this._head=new ae(e,void 0,this._head),0===this._length&&(this._tail=this._head,this._next=this._head),this._length++}unshiftCurrent(){var e=this._current;return e===this._head||2>this._length?e&&e.data:(e===this._tail?(this._tail=e.prev,this._tail.next=void 0,this._current=this._tail):(e.next.prev=e.prev,e.prev.next=e.next,this._current=e.prev),this._next=this._current.next,e.next=this._head,e.prev=void 0,this._head.prev=e,this._head=e,e.data)}removeCurrent(){var e=this._current;if(0!==this._length)return(this._length--,0===this._length)?(this._head=this._tail=this._current=this._next=void 0,e.data):(e===this._tail?(this._tail=e.prev,this._tail.next=void 0,this._current=this._tail):e===this._head?(this._head=e.next,this._head.prev=void 0,this._current=this._head):(e.next.prev=e.prev,e.prev.next=e.next,this._current=e.prev),this._next=this._current.next,e.data)}resetCursor(){return this._current=this._next=this._head,this}next(){var e=this._next;if(void 0!==e)return this._next=e.next,this._current=e,e.data}}class ne extends le{constructor(e,r,t,o){if(super(),this.size=e,this.maintainHigh=r,this.maintainLow=t,this.maintainSum=o,this.totalPushed=0,this.periodHigh=0,this.periodLow=Infinity,this.periodSum=0,!e||'number'!=typeof e)throw'Size required and should be a number.';this._push=this.push,this.push=function(e){this.add(e),this.totalPushed++}}add(e){this.length===this.size?(this.lastShift=this.shift(),this._push(e),this.maintainHigh&&this.lastShift==this.periodHigh&&this.calculatePeriodHigh(),this.maintainLow&&this.lastShift==this.periodLow&&this.calculatePeriodLow(),this.maintainSum&&(this.periodSum-=this.lastShift)):this._push(e),this.maintainHigh&&this.periodHigh<=e&&(this.periodHigh=e),this.maintainLow&&this.periodLow>=e&&(this.periodLow=e),this.maintainSum&&(this.periodSum+=e)}*iterator(){for(this.resetCursor();this.next();)yield this.current}calculatePeriodHigh(){for(this.resetCursor(),this.next()&&(this.periodHigh=this.current);this.next();)this.periodHigh<=this.current&&(this.periodHigh=this.current)}calculatePeriodLow(){for(this.resetCursor(),this.next()&&(this.periodLow=this.current);this.next();)this.periodLow>=this.current&&(this.periodLow=this.current)}}class se{constructor(){this.open=[],this.high=[],this.low=[],this.close=[],this.volume=[],this.timestamp=[]}}let ue={};class ie{}class he{constructor(e){this.format=e.format||o}static reverseInputs(e){e.reversedInput&&(e.values?e.values.reverse():void 0,e.open?e.open.reverse():void 0,e.high?e.high.reverse():void 0,e.low?e.low.reverse():void 0,e.close?e.close.reverse():void 0,e.volume?e.volume.reverse():void 0,e.timestamp?e.timestamp.reverse():void 0)}getResult(){return this.result}}class pe extends he{constructor(e){super(e),this.period=e.period,this.price=e.values;this.generator=function*(e){var r,t=new le,o=0,a=1,l=yield;for(t.push(0);;)a<e?(a++,t.push(l),o+=l):(o=o-t.shift()+l,r=o/e,t.push(l)),l=yield r}(this.period),this.generator.next(),this.result=[],this.price.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}pe.calculate=a;class de extends he{constructor(e){super(e);var r,t=e.period,o=e.values;this.result=[],r=new pe({period:t,values:[]});this.generator=function*(){for(var e,o=yield;;)void 0!=e&&void 0!==o?(e=(o-e)*(2/(t+1))+e,o=yield e):(o=yield,e=r.nextValue(o),e&&(o=yield e))}(),this.generator.next(),this.generator.next(),o.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}de.calculate=l;class ge extends he{constructor(e){super(e);var r=e.period,t=e.values;this.result=[],this.generator=function*(){for(let t=new le;;)if(t.length<r)t.push((yield));else{t.resetCursor();let o=0;for(let e=1;e<=r;e++)o+=t.next()*e/(r*(r+1)/2);var e=yield o;t.shift(),t.push(e)}}(),this.generator.next(),t.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}ge.calculate=n;class ce extends he{constructor(e){super(e);var r,t=e.period,o=e.values;this.result=[],r=new pe({period:t,values:[]});this.generator=function*(){for(var e,o=yield;;)void 0!=e&&void 0!==o?(e=(o-e)*(1/t)+e,o=yield e):(o=yield,e=r.nextValue(o),void 0!==e&&(o=yield e))}(),this.generator.next(),this.generator.next(),o.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}ce.calculate=s;class ve extends he{constructor(e){super(e);var r=e.SimpleMAOscillator?pe:de,t=e.SimpleMASignal?pe:de,o=new r({period:e.fastPeriod,values:[],format:(e)=>e}),a=new r({period:e.slowPeriod,values:[],format:(e)=>e}),l=new t({period:e.signalPeriod,values:[],format:(e)=>e}),n=this.format;this.result=[],this.generator=function*(){for(var r,t,s,u,i,h,p=0;;){if(p<e.slowPeriod){r=yield,i=o.nextValue(r),h=a.nextValue(r),p++;continue}i&&h&&(t=i-h,s=l.nextValue(t)),u=t-s,r=yield{MACD:n(t),signal:s?n(s):void 0,histogram:isNaN(u)?void 0:n(u)},i=o.nextValue(r),h=a.nextValue(r)}}(),this.generator.next(),e.values.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e).value;return r}}ve.calculate=u;class me extends he{constructor(e){super(e);let r=e.values,t=e.period,o=this.format;this.generator=function*(e){var r,t,a=yield,l=1,n=0,s=a;for(a=yield;;)t=a-s,t=0<t?t:0,0<t&&(n+=t),l<e?l++:void 0==r?r=n/e:r=(r*(e-1)+t)/e,s=a,r=void 0===r?void 0:o(r),a=yield r}(t),this.generator.next(),this.result=[],r.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}me.calculate=i;class xe extends he{constructor(e){super(e);let r=e.values,t=e.period,o=this.format;this.generator=function*(e){var r,t,a=yield,l=1,n=0,s=a;for(a=yield;;)t=s-a,t=0<t?t:0,0<t&&(n+=t),l<e?l++:void 0==r?r=n/e:r=(r*(e-1)+t)/e,s=a,r=void 0===r?void 0:o(r),a=yield r}(t),this.generator.next(),this.result=[],r.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}xe.calculate=h;class we extends he{constructor(e){super(e);var r=e.period,t=e.values,o=new me({period:r,values:[]}),a=new xe({period:r,values:[]});let l=1;this.generator=function*(){for(var e,r,t,n,s=yield;;)e=o.nextValue(s),r=a.nextValue(s),void 0!==e&&void 0!==r&&(0===r?n=100:0===e?n=0:(t=e/r,t=isNaN(t)?0:t,n=parseFloat((100-100/(1+t)).toFixed(2)))),l++,s=yield n}(r),this.generator.next(),this.result=[],t.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}we.calculate=p;class fe extends he{constructor(e){super(e);var r=e.period,t=e.values,o=new pe({period:r,values:[],format:(e)=>e});this.result=[],this.generator=function*(){var e,t,a=new ne(r);e=yield;for(var l;;){if(a.push(e),t=o.nextValue(e),t){let e=0;for(let r of a.iterator())e+=Math.pow(r-t,2);l=oe(e/r)}e=yield l}}(),this.generator.next(),t.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return this.format(r.value)}}fe.calculate=d;class Ie extends he{constructor(e){super(e);var r,t,o=e.period,a=e.values,l=e.stdDev,n=this.format;this.result=[],r=new pe({period:o,values:[],format:(e)=>e}),t=new fe({period:o,values:[],format:(e)=>e}),this.generator=function*(){var e,o,a,s;for(o=yield;;){if(a=r.nextValue(o),s=t.nextValue(o),a){let r=n(a),t=n(a+s*l),u=n(a-s*l),i=n((o-u)/(t-u));e={middle:r,upper:t,lower:u,pb:i}}o=yield e}}(),this.generator.next(),a.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}Ie.calculate=g;class Pe extends he{constructor(e){super(e),this.period=e.period,this.price=e.values;this.generator=function*(e){for(var r=new le,t=0,o=1,a=yield,l=0;;)o<e?(o++,t+=a,l=void 0):o==e?(o++,t+=a,l=t):l=l-l/e+a,a=yield l}(this.period),this.generator.next(),this.result=[],this.price.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}Pe.calculate=function(e){he.reverseInputs(e);var r=new Pe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r};class _e extends he{constructor(e){super(e);var r=e.low,t=e.high,o=this.format;if(r.length!=t.length)throw'Inputs(low,high) not of equal size';this.result=[],this.generator=function*(){for(var e,r,t=yield;;){if(r){let a=t.high-r.high,l=r.low-t.low;e=o(l>a&&0<l?l:0)}r=t,t=yield e}}(),this.generator.next(),r.forEach((e,o)=>{var a=this.generator.next({high:t[o],low:r[o]});a.value!==void 0&&this.result.push(a.value)})}static calculate(e){he.reverseInputs(e);var r=new _e(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}nextValue(e){return this.generator.next(e).value}}class be extends he{constructor(e){super(e);var r=e.low,t=e.high,o=this.format;if(r.length!=t.length)throw'Inputs(low,high) not of equal size';this.result=[],this.generator=function*(){for(var e,r,t=yield;;){if(r){let a=t.high-r.high,l=r.low-t.low;e=o(a>l&&0<a?a:0)}r=t,t=yield e}}(),this.generator.next(),r.forEach((e,o)=>{var a=this.generator.next({high:t[o],low:r[o]});a.value!==void 0&&this.result.push(a.value)})}static calculate(e){he.reverseInputs(e);var r=new be(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}nextValue(e){return this.generator.next(e).value}}class qe extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=this.format;if(r.length!=t.length)throw'Inputs(low,high) not of equal size';this.result=[],this.generator=function*(){for(var e,r,t=yield;;)void 0==e&&(e=t.close,t=yield r),r=re(t.high-t.low,isNaN(te(t.high-e))?0:te(t.high-e),isNaN(te(t.low-e))?0:te(t.low-e)),e=t.close,void 0!=r&&(r=a(r)),t=yield r}(),this.generator.next(),r.forEach((e,a)=>{var l=this.generator.next({high:t[a],low:r[a],close:o[a]});l.value!=void 0&&this.result.push(l.value)})}nextValue(e){return this.generator.next(e).value}}qe.calculate=c;class Se extends ie{}class Ce extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=e.period,l=this.format,n=new be({high:[],low:[]}),s=new _e({high:[],low:[]}),u=new Pe({period:a,values:[],format:(e)=>e}),i=new Pe({period:a,values:[],format:(e)=>e}),h=new Pe({period:a,values:[],format:(e)=>e}),p=new ce({period:a,values:[],format:(e)=>e}),d=new qe({low:[],high:[],close:[]});if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],Se,this.generator=function*(){var e,r,t,o,a,l,g,c=yield;for(e=0,r=0,t=0;;){let e=d.nextValue(c),r=n.nextValue(c),t=s.nextValue(c);if(e===void 0){c=yield;continue}let v=h.nextValue(e),m=u.nextValue(r),x=i.nextValue(t);if(v!=void 0&&m!=void 0&&x!=void 0){o=100*m/v,a=100*x/v;let e=te(o-a),r=o+a;l=100*(e/r),g=p.nextValue(l)}c=yield{adx:g,pdi:o,mdi:a}}}(),this.generator.next(),r.forEach((e,a)=>{var n=this.generator.next({high:t[a],low:r[a],close:o[a]});n.value!=void 0&&n.value.adx!=void 0&&this.result.push({adx:l(n.value.adx),pdi:l(n.value.pdi),mdi:l(n.value.mdi)})})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0&&r.adx!=void 0)return{adx:this.format(r.adx),pdi:this.format(r.pdi),mdi:this.format(r.mdi)}}}Ce.calculate=v;class Ee extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=e.period,l=this.format;if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';var n=new qe({low:[],high:[],close:[]}),s=new ce({period:a,values:[],format:(e)=>e});this.result=[],this.generator=function*(){for(var e,r,t=yield;;)r=n.nextValue({low:t.low,high:t.high,close:t.close}),e=void 0===r?void 0:s.nextValue(r),t=yield e}(),this.generator.next(),r.forEach((e,a)=>{var n=this.generator.next({high:t[a],low:r[a],close:o[a]});n.value!==void 0&&this.result.push(l(n.value))})}nextValue(e){return this.generator.next(e).value}}Ee.calculate=m;class Ve extends he{constructor(e){super(e);var r=e.period,t=e.values;this.result=[],this.generator=function*(){let e=1;for(var t,o=new ne(r),a=yield;;)o.push(a),e<r?e++:t=100*((a-o.lastShift)/o.lastShift),a=yield t}(),this.generator.next(),t.forEach((e)=>{var r=this.generator.next(e);r.value==void 0||isNaN(r.value)||this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0&&!isNaN(r.value))return this.format(r.value)}}Ve.calculate=x;class ke extends he{constructor(e){super(e);let r=e.values,t=e.ROCPer1,o=e.ROCPer2,a=e.ROCPer3,l=e.ROCPer4,n=e.SMAROCPer1,s=e.SMAROCPer2,u=e.SMAROCPer3,i=e.SMAROCPer4,h=e.signalPeriod,p=new Ve({period:t,values:[]}),d=new Ve({period:o,values:[]}),g=new Ve({period:a,values:[]}),c=new Ve({period:l,values:[]}),v=new pe({period:n,values:[],format:(e)=>e}),m=new pe({period:s,values:[],format:(e)=>e}),x=new pe({period:u,values:[],format:(e)=>e}),w=new pe({period:i,values:[],format:(e)=>e}),f=new pe({period:h,values:[],format:(e)=>e});var I=this.format;this.result=[];let P=re(t+n,o+s,a+u,l+i);this.generator=function*(){for(let e,r,t,o,a,l,n,s=1,u=yield;;){let i=p.nextValue(u),h=d.nextValue(u),_=g.nextValue(u),b=c.nextValue(u);r=i===void 0?void 0:v.nextValue(i),t=h===void 0?void 0:m.nextValue(h),o=_===void 0?void 0:x.nextValue(_),a=b===void 0?void 0:w.nextValue(b),s<P?s++:e=1*r+2*t+3*o+4*a,l=e===void 0?void 0:f.nextValue(e),n=e===void 0?void 0:{kst:I(e),signal:l?I(l):void 0},u=yield n}}(),this.generator.next(),r.forEach((e)=>{let r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!=void 0)return r.value}}ke.calculate=w;class He extends he{constructor(e){super(e);let r=e.high||[],t=e.low||[];this.result=[],this.generator=function*(e,r){for(let t,o,a,l,n=!0,s=e,u=yield;;)t?(a+=s*(o-a),n?(a=ee(a,l.low,u.low),t.high>o&&(o=t.high,s=ee(s+e,r))):(a=re(a,l.high,u.high),t.low<o&&(o=t.low,s=ee(s+e,r))),(n&&t.low<a||!n&&t.high>a)&&(s=e,a=o,n=!n,o=n?t.high:t.low)):(a=u.low,o=u.high),l=u,t&&(u=t),t=yield a}(e.step,e.max),this.generator.next(),t.forEach((e,o)=>{var a=this.generator.next({high:r[o],low:t[o]});a.value!==void 0&&this.result.push(a.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}He.calculate=f;class Te extends he{constructor(e){super(e);let r=e.low,t=e.high,o=e.close,a=e.period,l=e.signalPeriod,n=this.format;if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){let e,r,t=1,o=new ne(a,!0,!1),s=new ne(a,!1,!0),u=new pe({period:l,values:[],format:(e)=>e});for(var i=yield;;){if(o.push(i.high),s.push(i.low),t<a){t++,i=yield;continue}let l=s.periodLow;e=100*((i.close-l)/(o.periodHigh-l)),e=isNaN(e)?0:e,r=u.nextValue(e),i=yield{k:n(e),d:void 0===r?void 0:n(r)}}}(),this.generator.next(),r.forEach((e,a)=>{var l=this.generator.next({high:t[a],low:r[a],close:o[a]});l.value!==void 0&&this.result.push(l.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}Te.calculate=I;class Ae extends he{constructor(e){super(e);let r=e.low,t=e.high,o=e.close,a=e.period,l=this.format;if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){let e,r,t=1,o=new ne(a,!0,!1),n=new ne(a,!1,!0);var s=yield;for(let u;;){if(o.push(s.high),n.push(s.low),t<a){t++,s=yield;continue}e=n.periodLow,r=o.periodHigh,u=l(-100*((r-s.close)/(r-e))),s=yield u}}(),this.generator.next(),r.forEach((e,a)=>{var l=this.generator.next({high:t[a],low:r[a],close:o[a]});l.value!==void 0&&this.result.push(l.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return this.format(r.value)}}Ae.calculate=P;class De extends he{constructor(e){super(e);var r=e.high,t=e.low,o=e.close,a=e.volume;if(t.length!==r.length||r.length!==o.length||r.length!==a.length)throw'Inputs(low,high, close, volumes) not of equal size';this.result=[],this.generator=function*(){var e,r=0;for(e=yield;;){let t=(e.close-e.low-(e.high-e.close))/(e.high-e.low);t=isNaN(t)?1:t;let o=t*e.volume;r+=o,e=yield Math.round(r)}}(),this.generator.next(),r.forEach((e,r)=>{var l={high:e,low:t[r],close:o[r],volume:a[r]},n=this.generator.next(l);n.value!=void 0&&this.result.push(n.value)})}nextValue(e){return this.generator.next(e).value}}De.calculate=_;class Be extends he{constructor(e){super(e);var r=e.close,t=e.volume;this.result=[],this.generator=function*(){var e,r,t=0;for(e=yield,e.close&&'number'==typeof e.close&&(r=e.close,e=yield);;)r<e.close?t+=e.volume:e.close<r&&(t-=e.volume),r=e.close,e=yield t}(),this.generator.next(),r.forEach((e,o)=>{let a={close:r[o],volume:t[o]},l=this.generator.next(a);l.value!=void 0&&this.result.push(l.value)})}nextValue(e){return this.generator.next(e).value}}Be.calculate=b;class ze extends he{constructor(e){super(e);let r=e.values,t=e.period,o=this.format,a=new de({period:t,values:[],format:(e)=>e}),l=new de({period:t,values:[],format:(e)=>e}),n=new de({period:t,values:[],format:(e)=>e}),s=new Ve({period:1,values:[],format:(e)=>e});this.result=[],this.generator=function*(){for(let e=yield;;){let r=a.nextValue(e),t=r?l.nextValue(r):void 0,u=t?n.nextValue(t):void 0,i=u?s.nextValue(u):void 0;e=yield i?o(i):void 0}}(),this.generator.next(),r.forEach((e)=>{let r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}ze.calculate=q;class Le extends he{constructor(e){super(e);var r=e.close,t=e.volume,o=e.period||1;if(t.length!==r.length)throw'Inputs(volume, close) not of equal size';let a=new de({values:[],period:o});this.result=[],this.generator=function*(){var e=yield,r=yield;for(let t;;)t=(r.close-e.close)*r.volume,e=r,r=yield a.nextValue(t)}(),this.generator.next(),t.forEach((e,o)=>{var a=this.generator.next({close:r[o],volume:t[o]});a.value!=void 0&&this.result.push(a.value)})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0)return r}}Le.calculate=S;class Me extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=e.period,l=this.format;var n=new ne(a),s=new pe({period:a,values:[],format:(e)=>e});if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){for(var e=yield;;){let r=(e.high+e.low+e.close)/3;n.push(r);let t,o=s.nextValue(r),a=null,l=0;if(o!=void 0){for(let e of n.iterator())l+=te(e-o);a=l/20,t=(r-o)/(.015*a)}e=yield t}}(),this.generator.next(),r.forEach((e,a)=>{var l=this.generator.next({high:t[a],low:r[a],close:o[a]});l.value!=void 0&&this.result.push(l.value)})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0)return r}}Me.calculate=C;class je extends he{constructor(e){super(e);var r=e.high,t=e.low,o=e.fastPeriod,a=e.slowPeriod,l=new pe({values:[],period:a}),n=new pe({values:[],period:o});this.result=[],this.generator=function*(){var e,r,t,o,a;for(r=yield;;)t=(r.high+r.low)/2,o=l.nextValue(t),a=n.nextValue(t),void 0!==o&&void 0!==a&&(e=a-o),r=yield e}(),this.generator.next(),r.forEach((e,r)=>{var o={high:e,low:t[r]},a=this.generator.next(o);a.value!=void 0&&this.result.push(this.format(a.value))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return this.format(r.value)}}je.calculate=E;class Re extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=e.volume,l=this.format;if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){var e=yield;for(let r=0,t=0;;){let o=(e.high+e.low+e.close)/3,a=e.volume*o;r+=a,t+=e.volume,e=yield r/t}}(),this.generator.next(),r.forEach((e,l)=>{var n=this.generator.next({high:t[l],low:r[l],close:o[l],volume:a[l]});n.value!=void 0&&this.result.push(n.value)})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0)return r}}Re.calculate=V;class ye extends he{constructor(e){super(e);var r=e.high,t=e.low,o=e.close,a=e.open,l=e.volume,n=e.noOfBars;if(t.length!==r.length||r.length!==o.length||r.length!==l.length)throw'Inputs(low,high, close, volumes) not of equal size';this.result=[];var s=re(...r,...t,...o,...a),u=ee(...r,...t,...o,...a),i=u;for(let h=0;h<n;h++){let e=i,h=e+(s-u)/n;i=h;let p=0,d=0,g=0;for(let n=0;n<r.length;n++){let s=t[n],u=r[n],i=a[n],c=o[n],v=l[n];k(e,h,s,u)&&(g+=v,i>c?d+=v:p+=v)}this.result.push({rangeStart:e,rangeEnd:h,bullishVolume:p,bearishVolume:d,totalVolume:g})}}nextValue(){throw'Next value not supported for volume profile'}}ye.calculate=H;class Oe extends he{constructor(e){super(e),this.result=[],this.generator=function*(){for(let e=yield;;)e=yield(e.high+e.low+e.close)/3}(),this.generator.next(),e.low.forEach((r,t)=>{var o=this.generator.next({high:e.high[t],low:e.low[t],close:e.close[t]});this.result.push(o.value)})}nextValue(e){var r=this.generator.next(e).value;return r}}Oe.calculate=function(e){he.reverseInputs(e);var r=new Oe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r};class Fe extends he{constructor(e){super(e);var r=e.high,t=e.low,o=e.close,a=e.volume,l=e.period,n=new Oe({low:[],high:[],close:[]}),s=new ne(l,!1,!1,!0),u=new ne(l,!1,!1,!0);if(t.length!==r.length||r.length!==o.length||r.length!==a.length)throw'Inputs(low,high, close, volumes) not of equal size';this.result=[],this.generator=function*(){var e,r,t,o,a,i,h=0;let p=null,d=null;for(r=yield,t=r.close,r=yield;;){var{high:g,low:c,close:v,volume:m}=r,x=0,w=0;p=n.nextValue({high:g,low:c,close:v}),h=p*m,null!=p&&null!=d&&(p>d?x=h:w=h,s.push(x),u.push(w),o=s.periodSum,i=u.periodSum,s.totalPushed>=l&&s.totalPushed>=l&&(a=o/i,e=100-100/(1+a))),d=p,r=yield e}}(),this.generator.next(),r.forEach((e,r)=>{var l={high:e,low:t[r],close:o[r],volume:a[r]},n=this.generator.next(l);n.value!=void 0&&this.result.push(parseFloat(n.value.toFixed(2)))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return parseFloat(r.value.toFixed(2))}}Fe.calculate=T;class Ue extends he{constructor(e){super(e);let r=e.values,t=e.rsiPeriod,o=e.stochasticPeriod,a=e.kPeriod,l=e.dPeriod,n=this.format;this.result=[],this.generator=function*(){let e,r,n,s,u=new we({period:t,values:[]}),i=new Te({period:o,high:[],low:[],close:[],signalPeriod:a}),h=new pe({period:l,values:[],format:(e)=>e});for(var p=yield;;){if(e=u.nextValue(p),void 0!==e){var g={high:e,low:e,close:e};r=i.nextValue(g),void 0!==r&&void 0!==r.d&&(n=h.nextValue(r.d),void 0!==n&&(s={stochRSI:r.k,k:r.d,d:n}))}p=yield s}}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}Ue.calculate=A;class We extends he{constructor(e){super(e);var r=e.values,t=e.period;this.result=[];var o=new ne(t,!0,!1,!1);this.generator=function*(){var e,r;for(e=yield;;)o.push(e),o.totalPushed>=t&&(r=o.periodHigh),e=yield r}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}We.calculate=D;class Ne extends he{constructor(e){super(e);var r=e.values,t=e.period;this.result=[];var o=new ne(t,!1,!0,!1);this.generator=function*(){var e,r;for(e=yield;;)o.push(e),o.totalPushed>=t&&(r=o.periodLow),e=yield r}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}Ne.calculate=B;class Ge extends he{constructor(e){super(e);var r=e.values,t=e.period;this.result=[];var o=new ne(t,!1,!1,!0);this.generator=function*(){var e,r;for(e=yield;;)o.push(e),o.totalPushed>=t&&(r=o.periodSum),e=yield r}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}Ge.calculate=z;class Xe extends he{constructor(e){super(e);this.format;let r=e.useATR,t=e.brickSize||0;if(r){let r=m(Object.assign({},e));t=r[r.length-1]}if(this.result=new se,0===t)return void console.error('Not enough data to calculate brickSize for renko when using ATR');let o=0,a=0,l=Infinity,n=0,s=0,u=0;this.generator=function*(){for(let e=yield;;){if(0==o){o=e.close,a=e.high,l=e.low,n=e.close,s=e.volume,u=e.timestamp,e=yield;continue}let r=te(e.close-n),i=te(e.close-o);if(r>=t&&i>=t){let u=r>i?o:n,h={open:u,high:a>e.high?a:e.high,low:l<e.Low?l:e.low,close:u>e.close?u-t:u+t,volume:s+e.volume,timestamp:e.timestamp};o=h.open,a=h.close,l=h.close,n=h.close,s=0,e=yield h}else a=a>e.high?a:e.high,l=l<e.Low?l:e.low,s+=e.volume,u=e.timestamp,e=yield}}(),this.generator.next(),e.low.forEach((r,t)=>{var o=this.generator.next({open:e.open[t],high:e.high[t],low:e.low[t],close:e.close[t],volume:e.volume[t],timestamp:e.timestamp[t]});o.value&&(this.result.open.push(o.value.open),this.result.high.push(o.value.high),this.result.low.push(o.value.low),this.result.close.push(o.value.close),this.result.volume.push(o.value.volume),this.result.timestamp.push(o.value.timestamp))})}nextValue(){return console.error('Cannot calculate next value on Renko, Every value has to be recomputed for every change, use calcualte method'),null}}Xe.calculate=L;class Ke extends he{constructor(e){super(e);this.format;this.result=new se;let r=null,t=0,o=Infinity,a=0,l=0,n=0;this.generator=function*(){for(let e=yield,s=null;;){if(null==r)r=(e.close+e.open)/2,t=e.high,o=e.low,a=(e.close+e.open+e.high+e.low)/4,l=e.volume||0,n=e.timestamp||0,s={open:r,high:t,low:o,close:a,volume:e.volume||0,timestamp:e.timestamp||0};else{let l=(e.close+e.open+e.high+e.low)/4,n=(r+a)/2,u=re(n,l,e.high),i=ee(e.low,n,l);s={close:l,open:n,high:u,low:i,volume:e.volume||0,timestamp:e.timestamp||0},a=l,r=n,t=u,o=i}e=yield s}}(),this.generator.next(),e.low.forEach((r,t)=>{var o=this.generator.next({open:e.open[t],high:e.high[t],low:e.low[t],close:e.close[t],volume:e.volume?e.volume[t]:e.volume,timestamp:e.timestamp?e.timestamp[t]:e.timestamp});o.value&&(this.result.open.push(o.value.open),this.result.high.push(o.value.high),this.result.low.push(o.value.low),this.result.close.push(o.value.close),this.result.volume.push(o.value.volume),this.result.timestamp.push(o.value.timestamp))})}nextValue(e){var r=this.generator.next(e).value;return r}}Ke.calculate=M;class Qe{constructor(){}approximateEqual(e,r){let t=1*parseFloat(te(e-r).toPrecision(4)),o=1*parseFloat((1e-3*e).toPrecision(4));return t<=o}logic(){throw'this has to be implemented'}getAllPatternIndex(e){if(e.close.length<this.requiredCount)return console.warn('Data count less than data required for the strategy ',this.name),[];e.reversedInput&&(e.open.reverse(),e.high.reverse(),e.low.reverse(),e.close.reverse());let r=this.logic;return this._generateDataForCandleStick(e).map((e,t)=>r.call(this,e)?t:void 0).filter((e)=>e)}hasPattern(e){if(e.close.length<this.requiredCount)return console.warn('Data count less than data required for the strategy ',this.name),!1;e.reversedInput&&(e.open.reverse(),e.high.reverse(),e.low.reverse(),e.close.reverse());let r=this.logic;return r.call(this,this._getLastDataForCandleStick(e))}_getLastDataForCandleStick(e){let r=this.requiredCount;if(e.close.length===r)return e;else{let t={open:[],high:[],low:[],close:[]},o=0,a=e.close.length-r;for(;o<r;)t.open.push(e.open[a+o]),t.high.push(e.high[a+o]),t.low.push(e.low[a+o]),t.close.push(e.close[a+o]),o++;return t}}_generateDataForCandleStick(e){let r=this.requiredCount,t=e.close.map(function(t,o){let a=0,l={open:[],high:[],low:[],close:[]};for(;a<r;)l.open.push(e.open[o+a]),l.high.push(e.high[o+a]),l.low.push(e.low[o+a]),l.close.push(e.close[o+a]),a++;return l}).filter((t,o)=>o<=e.close.length-r);return t}}class Ye extends Qe{constructor(){super(),this.name='MorningStar',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],d=e.low[2];return t<r&&a>u&&a>s&&s<a&&u<a&&i>s&&n<i&&i<h&&h>(r+t)/2}}class Ze extends Qe{constructor(){super(),this.name='BullishEngulfingPattern',this.requiredCount=2}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return t<r&&r>l&&t>l&&r<n}}class $e extends Qe{constructor(){super(),this.requiredCount=2,this.name='BullishHarami'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return r>l&&t<l&&t<n&&r>u&&o>s}}class Je extends Qe{constructor(){super(),this.requiredCount=2,this.name='BullishHaramiCross'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=this.approximateEqual(l,n);return r>l&&t<l&&t<n&&r>u&&o>s&&i}}class er extends Qe{constructor(){super(),this.name='Doji',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(r,t),n=l&&this.approximateEqual(r,o),s=l&&this.approximateEqual(t,a);return l&&n==s}}class rr extends Qe{constructor(){super(),this.name='MorningDojiStar',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],d=e.low[2],g=new er().hasPattern({open:[l],close:[n],high:[s],low:[u]});return t<r&&g&&i<h&&s<a&&u<a&&i>s&&n<i&&h>(r+t)/2}}class tr extends Qe{constructor(){super(),this.requiredCount=3,this.name='DownsideTasukiGap'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],d=e.low[2];return t<r&&n<l&&h>i&&s<a&&l>i&&n<i&&h>l&&h<t}}class or extends Qe{constructor(){super(),this.name='BullishMarubozu',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(t,o)&&this.approximateEqual(a,r)&&r<t&&r<o;return l}}class ar extends Qe{constructor(){super(),this.requiredCount=2,this.name='PiercingLine'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return u<a&&t<r&&a>l&&n>(r+t)/2&&n>l}}class lr extends Qe{constructor(){super(),this.name='ThreeWhiteSoldiers',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],d=e.low[2];return s>o&&p>s&&r<t&&l<n&&i<h&&t>l&&l<o&&s>i&&i<n}}class nr extends Qe{constructor(){super(),this.name='BullishHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=t>r;return l=l&&this.approximateEqual(t,o),l=l&&t-r<=2*(r-a),l}}class sr extends Qe{constructor(){super(),this.name='BullishInvertedHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=t>r;return l=l&&this.approximateEqual(r,a),l=l&&t-r<=2*(o-t),l}}class ur extends Qe{constructor(){super(),this.name='BearishHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=r>t;return l=l&&this.approximateEqual(r,o),l=l&&r-t<=2*(t-a),l}}class ir extends Qe{constructor(){super(),this.name='BearishInvertedHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=r>t;return l=l&&this.approximateEqual(t,a),l=l&&r-t<=2*(o-r),l}}class hr extends Qe{constructor(){super(),this.name='HammerPattern',this.requiredCount=5}logic(e){let r=this.downwardTrend(e);return r=r&&this.includesHammer(e),r=r&&this.hasConfirmation(e),r}downwardTrend(e,r=!0){let t=r?3:4,o=i({values:e.close.slice(0,t),period:t-1}),a=h({values:e.close.slice(0,t),period:t-1});return a>o}includesHammer(e,r=!0){let t=r?3:4,o=r?4:void 0,a={open:e.open.slice(t,o),close:e.close.slice(t,o),low:e.low.slice(t,o),high:e.high.slice(t,o)},l=y(a);return l=l||O(a),l=l||j(a),l=l||R(a),l}hasConfirmation(e){let r={open:e.open[3],close:e.close[3],low:e.low[3],high:e.high[3]},t={open:e.open[4],close:e.close[4],low:e.low[4],high:e.high[4]},o=t.open<t.close;return o&&r.close<t.close}}class pr extends hr{constructor(){super(),this.name='HammerPatternUnconfirmed'}logic(e){let r=this.downwardTrend(e,!1);return r=r&&this.includesHammer(e,!1),r}}class dr extends Qe{constructor(){super(),this.name='TweezerBottom',this.requiredCount=5}logic(e){return this.downwardTrend(e)&&e.low[3]==e.low[4]}downwardTrend(e){let r=i({values:e.close.slice(0,3),period:2}),t=h({values:e.close.slice(0,3),period:2});return t>r}}let gr=[new Ze,new tr,new $e,new Je,new rr,new Ye,new or,new ar,new lr,new nr,new sr,new hr,new pr,new dr];class cr extends Qe{constructor(){super(),this.name='Bullish Candlesticks'}hasPattern(e){return gr.reduce(function(r,t){let o=t.hasPattern(e);return r||o},!1)}}class vr extends Qe{constructor(){super(),this.name='BearishEngulfingPattern',this.requiredCount=2}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return t>r&&r<l&&t<l&&r>n}}class mr extends Qe{constructor(){super(),this.requiredCount=2,this.name='BearishHarami'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return r<l&&t>l&&t>n&&r<u&&o>s}}class xr extends Qe{constructor(){super(),this.requiredCount=2,this.name='BearishHaramiCross'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=this.approximateEqual(l,n);return r<l&&t>l&&t>n&&r<u&&o>s&&i}}class wr extends Qe{constructor(){super(),this.name='EveningDojiStar',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],d=e.low[2],g=new er().hasPattern({open:[l],close:[n],high:[s],low:[u]});return t>r&&g&&s>o&&u>o&&i<u&&n>i&&i>h&&h<(r+t)/2}}class fr extends Qe{constructor(){super(),this.name='EveningStar',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],d=e.low[2];return t>r&&o<u&&o<s&&s>o&&u>o&&i<u&&n>i&&i>h&&h<(r+t)/2}}class Ir extends Qe{constructor(){super(),this.name='BearishMarubozu',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(r,o)&&this.approximateEqual(a,t)&&r>t&&r>a;return l}}class Pr extends Qe{constructor(){super(),this.name='ThreeBlackCrows',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],d=e.low[2];return a>u&&u>d&&r>t&&l>n&&i>h&&r>l&&l>t&&l>i&&i>n}}class _r extends Qe{constructor(){super(),this.name='HangingMan',this.requiredCount=5}logic(e){let r=this.upwardTrend(e);return r=r&&this.includesHammer(e),r=r&&this.hasConfirmation(e),r}upwardTrend(e,r=!0){let t=r?3:4,o=i({values:e.close.slice(0,t),period:t-1}),a=h({values:e.close.slice(0,t),period:t-1});return o>a}includesHammer(e,r=!0){let t=r?3:4,o=r?4:void 0,a={open:e.open.slice(t,o),close:e.close.slice(t,o),low:e.low.slice(t,o),high:e.high.slice(t,o)},l=y(a);return l=l||j(a),l}hasConfirmation(e){let r={open:e.open[3],close:e.close[3],low:e.low[3],high:e.high[3]},t={open:e.open[4],close:e.close[4],low:e.low[4],high:e.high[4]},o=t.open>t.close;return o&&r.close>t.close}}class br extends _r{constructor(){super(),this.name='HangingManUnconfirmed'}logic(e){let r=this.upwardTrend(e,!1);return r=r&&this.includesHammer(e,!1),r}}class qr extends Qe{constructor(){super(),this.name='ShootingStar',this.requiredCount=5}logic(e){let r=this.upwardTrend(e);return r=r&&this.includesHammer(e),r=r&&this.hasConfirmation(e),r}upwardTrend(e,r=!0){let t=r?3:4,o=i({values:e.close.slice(0,t),period:t-1}),a=h({values:e.close.slice(0,t),period:t-1});return o>a}includesHammer(e,r=!0){let t=r?3:4,o=r?4:void 0,a={open:e.open.slice(t,o),close:e.close.slice(t,o),low:e.low.slice(t,o),high:e.high.slice(t,o)},l=O(a);return l=l||R(a),l}hasConfirmation(e){let r={open:e.open[3],close:e.close[3],low:e.low[3],high:e.high[3]},t={open:e.open[4],close:e.close[4],low:e.low[4],high:e.high[4]},o=t.open>t.close;return o&&r.close>t.close}}class Sr extends qr{constructor(){super(),this.name='ShootingStarUnconfirmed'}logic(e){let r=this.upwardTrend(e,!1);return r=r&&this.includesHammer(e,!1),r}}class Cr extends Qe{constructor(){super(),this.name='TweezerTop',this.requiredCount=5}logic(e){return this.upwardTrend(e)&&e.high[3]==e.high[4]}upwardTrend(e){let r=i({values:e.close.slice(0,3),period:2}),t=h({values:e.close.slice(0,3),period:2});return r>t}}let Er=[new vr,new mr,new xr,new wr,new fr,new Ir,new Pr,new ur,new ir,new _r,new br,new qr,new Sr,new Cr];class Vr extends Qe{constructor(){super(),this.name='Bearish Candlesticks'}hasPattern(e){return Er.reduce(function(r,t){return r||t.hasPattern(e)},!1)}}class kr extends Qe{constructor(){super(),this.name='AbandonedBaby',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],d=e.low[2],g=new er().hasPattern({open:[l],close:[n],high:[s],low:[u]});return t<r&&g&&s<a&&d>s&&h>i&&p<r}}class Hr extends Qe{constructor(){super(),this.name='DarkCloudCover',this.requiredCount=2}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return t>r&&n<l&&l>o&&n<(t+r)/2&&n>r}}class Tr extends Qe{constructor(){super(),this.requiredCount=1,this.name='DragonFlyDoji'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(r,t),n=l&&this.approximateEqual(r,o),s=l&&this.approximateEqual(t,a);return l&&n&&!s}}class Ar extends Qe{constructor(){super(),this.requiredCount=1,this.name='GraveStoneDoji'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(r,t),n=l&&this.approximateEqual(r,o),s=l&&this.approximateEqual(t,a);return l&&s&&!n}}class Dr extends Qe{constructor(){super(),this.name='BullishSpinningTop',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=te(t-r),n=te(o-t),s=te(r-a);return l<n&&l<s}}class Br extends Qe{constructor(){super(),this.name='BearishSpinningTop',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=te(t-r),n=te(o-r),s=te(o-a);return l<n&&l<s}}var zr,Lr=function(e,r,t,o){return new(t||(t=Promise))(function(a,l){function n(e){try{u(o.next(e))}catch(r){l(r)}}function s(e){try{u(o['throw'](e))}catch(r){l(r)}}function u(e){e.done?a(e.value):new t(function(r){r(e.value)}).then(n,s)}u((o=o.apply(e,r||[])).next())})},Mr=!1,jr=['IHS','TU','DB','HS','TD','DT'];try{Mr='[object process]'===Object.prototype.toString.call(global.process)}catch(r){}(function(e){e[e.IHS=0]='IHS',e[e.TU=1]='TU',e[e.DB=2]='DB',e[e.HS=3]='HS',e[e.TD=4]='TD',e[e.DT=5]='DT'})(e.AvailablePatterns||(e.AvailablePatterns={}));var Rr,yr=!1,Or=!1;Mr&&W();class Fr extends he{}Fr.predictPattern=N,Fr.hasDoubleBottom=G,Fr.hasDoubleTop=X,Fr.hasHeadAndShoulder=K,Fr.hasInverseHeadAndShoulder=Q,Fr.isTrendingUp=Y,Fr.isTrendingDown=Z;class Ur extends he{constructor(e){super(e),this.result=[];var r=Object.assign({},{conversionPeriod:9,basePeriod:26,spanPeriod:52,displacement:26},e);this.generator=function*(){let e,t,o,a,l,n,s,u,i=re(r.conversionPeriod,r.basePeriod,r.spanPeriod,r.displacement),h=0,p=0,d=[],g=[],c=[],v=[];for(t=yield;;){if(d.push(t.high),g.push(t.low),h<i)h++;else{d.shift(),g.shift(),o=g.slice(-r.conversionPeriod).reduce((e,r)=>ee(e,r)),a=d.slice(-r.conversionPeriod).reduce((e,r)=>re(e,r));let t=(a+o)/2;l=g.slice(-r.basePeriod).reduce((e,r)=>ee(e,r)),n=d.slice(-r.basePeriod).reduce((e,r)=>re(e,r));let i=(n+l)/2,h=0;c.push((t+i)/2);let m=0;s=g.slice(-r.spanPeriod).reduce((e,r)=>ee(e,r)),u=d.slice(-r.spanPeriod).reduce((e,r)=>re(e,r)),v.push((u+s)/2),p<r.displacement?p++:(h=c.shift(),m=v.shift()),e={conversion:t,base:i,spanA:h,spanB:m}}t=yield e}}(),this.generator.next(),e.low.forEach((r,t)=>{var o=this.generator.next({high:e.high[t],low:e.low[t]});o.value&&this.result.push(o.value)})}nextValue(e){return this.generator.next(e).value}}Ur.calculate=$;let Wr=J();e.getAvailableIndicators=J,e.AvailableIndicators=Wr,e.FixedSizeLinkedList=ne,e.CandleData=class{},e.CandleList=se,e.sma=a,e.SMA=pe,e.ema=l,e.EMA=de,e.wma=n,e.WMA=ge,e.wema=s,e.WEMA=ce,e.macd=u,e.MACD=ve,e.rsi=p,e.RSI=we,e.bollingerbands=g,e.BollingerBands=Ie,e.adx=v,e.ADX=Ce,e.atr=m,e.ATR=Ee,e.truerange=c,e.TrueRange=qe,e.roc=x,e.ROC=Ve,e.kst=w,e.KST=ke,e.psar=f,e.PSAR=He,e.stochastic=I,e.Stochastic=Te,e.williamsr=P,e.WilliamsR=Ae,e.adl=_,e.ADL=De,e.obv=b,e.OBV=Be,e.trix=q,e.TRIX=ze,e.forceindex=S,e.ForceIndex=Le,e.cci=C,e.CCI=Me,e.awesomeoscillator=E,e.AwesomeOscillator=je,e.vwap=V,e.VWAP=Re,e.volumeprofile=H,e.VolumeProfile=ye,e.mfi=T,e.MFI=Fe,e.stochasticrsi=A,e.StochasticRSI=Ue,e.averagegain=i,e.AverageGain=me,e.averageloss=h,e.AverageLoss=xe,e.sd=d,e.SD=fe,e.highest=D,e.Highest=We,e.lowest=B,e.Lowest=Ne,e.sum=z,e.Sum=Ge,e.renko=L,e.HeikinAshi=Ke,e.heikinashi=M,e.bullish=function(e){return new cr().hasPattern(e)},e.bearish=function(e){return new Vr().hasPattern(e)},e.abandonedbaby=function(e){return new kr().hasPattern(e)},e.doji=function(e){return new er().hasPattern(e)},e.bearishengulfingpattern=function(e){return new vr().hasPattern(e)},e.bullishengulfingpattern=function(e){return new Ze().hasPattern(e)},e.darkcloudcover=function(e){return new Hr().hasPattern(e)},e.downsidetasukigap=function(e){return new tr().hasPattern(e)},e.dragonflydoji=function(e){return new Tr().hasPattern(e)},e.gravestonedoji=function(e){return new Ar().hasPattern(e)},e.bullishharami=function(e){return new $e().hasPattern(e)},e.bearishharami=function(e){return new mr().hasPattern(e)},e.bullishharamicross=function(e){return new Je().hasPattern(e)},e.bearishharamicross=function(e){return new xr().hasPattern(e)},e.eveningdojistar=function(e){return new wr().hasPattern(e)},e.eveningstar=function(e){return new fr().hasPattern(e)},e.morningdojistar=function(e){return new rr().hasPattern(e)},e.morningstar=function(e){return new Ye().hasPattern(e)},e.bullishmarubozu=function(e){return new or().hasPattern(e)},e.bearishmarubozu=function(e){return new Ir().hasPattern(e)},e.piercingline=function(e){return new ar().hasPattern(e)},e.bullishspinningtop=function(e){return new Dr().hasPattern(e)},e.bearishspinningtop=function(e){return new Br().hasPattern(e)},e.threeblackcrows=function(e){return new Pr().hasPattern(e)},e.threewhitesoldiers=function(e){return new lr().hasPattern(e)},e.bullishhammerstick=j,e.bearishhammerstick=y,e.bullishinvertedhammerstick=R,e.bearishinvertedhammerstick=O,e.hammerpattern=function(e){return new hr().hasPattern(e)},e.hammerpatternunconfirmed=function(e){return new pr().hasPattern(e)},e.hangingman=function(e){return new _r().hasPattern(e)},e.hangingmanunconfirmed=function(e){return new br().hasPattern(e)},e.shootingstar=function(e){return new qr().hasPattern(e)},e.shootingstarunconfirmed=function(e){return new Sr().hasPattern(e)},e.tweezertop=function(e){return new Cr().hasPattern(e)},e.tweezerbottom=function(e){return new dr().hasPattern(e)},e.fibonacciretracement=function(e,r){let t,o=[0,23.6,38.2,50,61.8,78.6,100,127.2,161.8,261.8,423.6];return t=e<r?o.map(function(t){let o=r-te(e-r)*t/100;return 0<o?o:0}):o.map(function(t){let o=r+te(e-r)*t/100;return 0<o?o:0}),t},e.predictPattern=N,e.PatternDetector=Fr,e.hasDoubleBottom=G,e.hasDoubleTop=X,e.hasHeadAndShoulder=K,e.hasInverseHeadAndShoulder=Q,e.isTrendingUp=Y,e.isTrendingDown=Z,e.ichimokucloud=$,e.IchimokuCloud=Ur,e.setConfig=function(e,r){ue[e]=r},e.getConfig=t})(this.window=this.window||{},tf);
var tf = window.tf || {};(function(e,r){'use strict';function t(e){return ue[e]}function o(e){let r=t('precision');return r?parseFloat(e.toPrecision(r)):e}function a(e){he.reverseInputs(e);var r=new pe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function l(e){he.reverseInputs(e);var r=new ge(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function n(e){he.reverseInputs(e);var r=new de(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function s(e){he.reverseInputs(e);var r=new ve(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function u(e){he.reverseInputs(e);var r=new ce(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function i(e){he.reverseInputs(e);var r=new me(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function h(e){he.reverseInputs(e);var r=new xe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function p(e){he.reverseInputs(e);var r=new we(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function g(e){he.reverseInputs(e);var r=new fe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function d(e){he.reverseInputs(e);var r=new Ie(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function v(e){he.reverseInputs(e);var r=new qe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function c(e){he.reverseInputs(e);var r=new Ce(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function m(e){he.reverseInputs(e);var r=new Ee(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function x(e){he.reverseInputs(e);var r=new He(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function w(e){he.reverseInputs(e);var r=new ke(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function f(e){he.reverseInputs(e);var r=new Ve(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function I(e){he.reverseInputs(e);var r=new Te(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function P(e){he.reverseInputs(e);var r=new Ae(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function _(e){he.reverseInputs(e);var r=new De(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function b(e){he.reverseInputs(e);var r=new Be(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function q(e){he.reverseInputs(e);var r=new ze(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function S(e){he.reverseInputs(e);var r=new Le(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function C(e){he.reverseInputs(e);var r=new Me(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function E(e){he.reverseInputs(e);var r=new je(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function H(e){he.reverseInputs(e);var r=new Re(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function k(e,r,t,o){return e<=t&&r>=t||t<=e&&o>=e}function V(e){he.reverseInputs(e);var r=new ye(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function T(e){he.reverseInputs(e);var r=new Fe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function A(e){he.reverseInputs(e);var r=new Ue(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function D(e){he.reverseInputs(e);var r=new We(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function B(e){he.reverseInputs(e);var r=new Ne(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function z(e){he.reverseInputs(e);var r=new Ge(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function L(e){he.reverseInputs(e);var r=new Xe(e).result;return e.reversedInput&&(r.open.reverse(),r.high.reverse(),r.low.reverse(),r.close.reverse(),r.volume.reverse(),r.timestamp.reverse()),he.reverseInputs(e),r}function M(e){he.reverseInputs(e);var r=new Ke(e).result;return e.reversedInput&&(r.open.reverse(),r.high.reverse(),r.low.reverse(),r.close.reverse(),r.volume.reverse(),r.timestamp.reverse()),he.reverseInputs(e),r}function j(e){return new nr().hasPattern(e)}function R(e){return new sr().hasPattern(e)}function y(e){return new ur().hasPattern(e)}function O(e){return new ir().hasPattern(e)}function F(e,r){var t=function(e,r,t){return e+(r-e)*t},o=[],a=new Number((e.length-1)/(r-1));o[0]=e[0];for(var l=1;l<r-1;l++){var n=l*a,s=new Number(Math.floor(n)).toFixed(),u=new Number(Math.ceil(n)).toFixed();o[l]=t(e[s],e[u],n-s)}return o[r-1]=e[e.length-1],o}function U(e){var r=e.reduce((e,r)=>e+r*r,0),t=oe(r);return e.map((e)=>e/t)}function W(){return Lr(this,void 0,void 0,function*(){return yr?Promise.resolve(!0):Or?Rr:(Rr=new Promise(function(e){return Lr(this,void 0,void 0,function*(){if(Mr){console.log('Nodejs Environment detected ');var t=require('@tensorflow/tfjs-node'),o=require('path').resolve(__dirname,'../tf_model/model.json');zr=yield r.loadModel(t.io.fileSystem(o))}else{if(console.log('Browser Environment detected '),'undefined'==typeof r||'undefined'==typeof r.loadModel)return console.log('Tensorflow js not imported, pattern detection may not work'),yr=!1,Or=!1,void e();zr=yield r.loadModel('/tf_model/model.json')}return yr=!0,Or=!1,void e()})}),void(Or=!0))})}function N(e){return Lr(this,void 0,void 0,function*(){yield W(),300>e.values.length&&console.warn('Pattern detector requires atleast 300 data points for a reliable prediction, received just ',e.values.length),he.reverseInputs(e);var t=e.values,o=yield zr.predict(r.tensor2d([U(F(t,400))])),a=r.argMax(o,1).get(0);return he.reverseInputs(e),{patternId:a,pattern:jr[a],probability:100*o.get(0,4)}})}function G(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.DB})}function X(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.DT})}function K(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.HS})}function Q(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.IHS})}function Y(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.TU})}function Z(r){return Lr(this,void 0,void 0,function*(){var t=yield N(r);return t.patternId===e.AvailablePatterns.TD})}function $(e){he.reverseInputs(e);var r=new Ur(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}function J(){return['sma','ema','wma','wema','macd','rsi','bollingerbands','adx','atr','truerange','roc','kst','psar','stochastic','williamsr','adl','obv','trix','cci','awesomeoscillator','forceindex','vwap','volumeprofile','renko','heikinashi','stochasticrsi','mfi','averagegain','averageloss','highest','lowest','sum','FixedSizeLinkedList','sd','bullish','bearish','abandonedbaby','doji','bearishengulfingpattern','bullishengulfingpattern','darkcloudcover','downsidetasukigap','dragonflydoji','gravestonedoji','bullishharami','bearishharami','bullishharamicross','bearishharamicross','eveningdojistar','eveningstar','morningdojistar','morningstar','bullishmarubozu','bearishmarubozu','piercingline','bullishspinningtop','bearishspinningtop','threeblackcrows','threewhitesoldiers','bullishhammerstick','bearishhammerstick','bullishinvertedhammerstick','bearishinvertedhammerstick','hammerpattern','hammerpatternunconfirmed','hangingman','hangingmanunconfirmed','shootingstar','shootingstarunconfirmed','tweezertop','tweezerbottom','predictPattern','hasDoubleBottom','hasDoubleTop','hasHeadAndShoulder','hasInverseHeadAndShoulder','isTrendingUp','isTrendingDown','ichimokucloud']}var ee=Math.min,re=Math.max,te=Math.abs,oe=Math.sqrt;class ae{constructor(e,r,t){this.next=t,t&&(t.prev=this),this.prev=r,r&&(r.next=this),this.data=e}}class le{constructor(){this._length=0}get head(){return this._head&&this._head.data}get tail(){return this._tail&&this._tail.data}get current(){return this._current&&this._current.data}get length(){return this._length}push(e){this._tail=new ae(e,this._tail),0===this._length&&(this._head=this._tail,this._current=this._head,this._next=this._head),this._length++}pop(){var e=this._tail;if(0!==this._length)return(this._length--,0===this._length)?(this._head=this._tail=this._current=this._next=void 0,e.data):(this._tail=e.prev,this._tail.next=void 0,this._current===e&&(this._current=this._tail,this._next=void 0),e.data)}shift(){var e=this._head;if(0!==this._length)return(this._length--,0===this._length)?(this._head=this._tail=this._current=this._next=void 0,e.data):(this._head=this._head.next,this._current===e&&(this._current=this._head,this._next=this._current.next),e.data)}unshift(e){this._head=new ae(e,void 0,this._head),0===this._length&&(this._tail=this._head,this._next=this._head),this._length++}unshiftCurrent(){var e=this._current;return e===this._head||2>this._length?e&&e.data:(e===this._tail?(this._tail=e.prev,this._tail.next=void 0,this._current=this._tail):(e.next.prev=e.prev,e.prev.next=e.next,this._current=e.prev),this._next=this._current.next,e.next=this._head,e.prev=void 0,this._head.prev=e,this._head=e,e.data)}removeCurrent(){var e=this._current;if(0!==this._length)return(this._length--,0===this._length)?(this._head=this._tail=this._current=this._next=void 0,e.data):(e===this._tail?(this._tail=e.prev,this._tail.next=void 0,this._current=this._tail):e===this._head?(this._head=e.next,this._head.prev=void 0,this._current=this._head):(e.next.prev=e.prev,e.prev.next=e.next,this._current=e.prev),this._next=this._current.next,e.data)}resetCursor(){return this._current=this._next=this._head,this}next(){var e=this._next;if(void 0!==e)return this._next=e.next,this._current=e,e.data}}class ne extends le{constructor(e,r,t,o){if(super(),this.size=e,this.maintainHigh=r,this.maintainLow=t,this.maintainSum=o,this.totalPushed=0,this.periodHigh=0,this.periodLow=Infinity,this.periodSum=0,!e||'number'!=typeof e)throw'Size required and should be a number.';this._push=this.push,this.push=function(e){this.add(e),this.totalPushed++}}add(e){this.length===this.size?(this.lastShift=this.shift(),this._push(e),this.maintainHigh&&this.lastShift==this.periodHigh&&this.calculatePeriodHigh(),this.maintainLow&&this.lastShift==this.periodLow&&this.calculatePeriodLow(),this.maintainSum&&(this.periodSum-=this.lastShift)):this._push(e),this.maintainHigh&&this.periodHigh<=e&&(this.periodHigh=e),this.maintainLow&&this.periodLow>=e&&(this.periodLow=e),this.maintainSum&&(this.periodSum+=e)}*iterator(){for(this.resetCursor();this.next();)yield this.current}calculatePeriodHigh(){for(this.resetCursor(),this.next()&&(this.periodHigh=this.current);this.next();)this.periodHigh<=this.current&&(this.periodHigh=this.current)}calculatePeriodLow(){for(this.resetCursor(),this.next()&&(this.periodLow=this.current);this.next();)this.periodLow>=this.current&&(this.periodLow=this.current)}}class se{constructor(){this.open=[],this.high=[],this.low=[],this.close=[],this.volume=[],this.timestamp=[]}}let ue={};class ie{}class he{constructor(e){this.format=e.format||o}static reverseInputs(e){e.reversedInput&&(e.values?e.values.reverse():void 0,e.open?e.open.reverse():void 0,e.high?e.high.reverse():void 0,e.low?e.low.reverse():void 0,e.close?e.close.reverse():void 0,e.volume?e.volume.reverse():void 0,e.timestamp?e.timestamp.reverse():void 0)}getResult(){return this.result}}class pe extends he{constructor(e){super(e),this.period=e.period,this.price=e.values;this.generator=function*(e){var r,t=new le,o=0,a=1,l=yield;for(t.push(0);;)a<e?(a++,t.push(l),o+=l):(o=o-t.shift()+l,r=o/e,t.push(l)),l=yield r}(this.period),this.generator.next(),this.result=[],this.price.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}pe.calculate=a;class ge extends he{constructor(e){super(e);var r,t=e.period,o=e.values;this.result=[],r=new pe({period:t,values:[]});this.generator=function*(){for(var e,o=yield;;)void 0!=e&&void 0!==o?(e=(o-e)*(2/(t+1))+e,o=yield e):(o=yield,e=r.nextValue(o),e&&(o=yield e))}(),this.generator.next(),this.generator.next(),o.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}ge.calculate=l;class de extends he{constructor(e){super(e);var r=e.period,t=e.values;this.result=[],this.generator=function*(){for(let t=new le;;)if(t.length<r)t.push((yield));else{t.resetCursor();let o=0;for(let e=1;e<=r;e++)o+=t.next()*e/(r*(r+1)/2);var e=yield o;t.shift(),t.push(e)}}(),this.generator.next(),t.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}de.calculate=n;class ve extends he{constructor(e){super(e);var r,t=e.period,o=e.values;this.result=[],r=new pe({period:t,values:[]});this.generator=function*(){for(var e,o=yield;;)void 0!=e&&void 0!==o?(e=(o-e)*(1/t)+e,o=yield e):(o=yield,e=r.nextValue(o),void 0!==e&&(o=yield e))}(),this.generator.next(),this.generator.next(),o.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}ve.calculate=s;class ce extends he{constructor(e){super(e);var r=e.SimpleMAOscillator?pe:ge,t=e.SimpleMASignal?pe:ge,o=new r({period:e.fastPeriod,values:[],format:(e)=>e}),a=new r({period:e.slowPeriod,values:[],format:(e)=>e}),l=new t({period:e.signalPeriod,values:[],format:(e)=>e}),n=this.format;this.result=[],this.generator=function*(){for(var r,t,s,u,i,h,p=0;;){if(p<e.slowPeriod){r=yield,i=o.nextValue(r),h=a.nextValue(r),p++;continue}i&&h&&(t=i-h,s=l.nextValue(t)),u=t-s,r=yield{MACD:n(t),signal:s?n(s):void 0,histogram:isNaN(u)?void 0:n(u)},i=o.nextValue(r),h=a.nextValue(r)}}(),this.generator.next(),e.values.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e).value;return r}}ce.calculate=u;class me extends he{constructor(e){super(e);let r=e.values,t=e.period,o=this.format;this.generator=function*(e){var r,t,a=yield,l=1,n=0,s=a;for(a=yield;;)t=a-s,t=0<t?t:0,0<t&&(n+=t),l<e?l++:void 0==r?r=n/e:r=(r*(e-1)+t)/e,s=a,r=void 0===r?void 0:o(r),a=yield r}(t),this.generator.next(),this.result=[],r.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}me.calculate=i;class xe extends he{constructor(e){super(e);let r=e.values,t=e.period,o=this.format;this.generator=function*(e){var r,t,a=yield,l=1,n=0,s=a;for(a=yield;;)t=s-a,t=0<t?t:0,0<t&&(n+=t),l<e?l++:void 0==r?r=n/e:r=(r*(e-1)+t)/e,s=a,r=void 0===r?void 0:o(r),a=yield r}(t),this.generator.next(),this.result=[],r.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}xe.calculate=h;class we extends he{constructor(e){super(e);var r=e.period,t=e.values,o=new me({period:r,values:[]}),a=new xe({period:r,values:[]});let l=1;this.generator=function*(){for(var e,r,t,n,s=yield;;)e=o.nextValue(s),r=a.nextValue(s),void 0!==e&&void 0!==r&&(0===r?n=100:0===e?n=0:(t=e/r,t=isNaN(t)?0:t,n=parseFloat((100-100/(1+t)).toFixed(2)))),l++,s=yield n}(r),this.generator.next(),this.result=[],t.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}we.calculate=p;class fe extends he{constructor(e){super(e);var r=e.period,t=e.values,o=new pe({period:r,values:[],format:(e)=>e});this.result=[],this.generator=function*(){var e,t,a=new ne(r);e=yield;for(var l;;){if(a.push(e),t=o.nextValue(e),t){let e=0;for(let r of a.iterator())e+=Math.pow(r-t,2);l=oe(e/r)}e=yield l}}(),this.generator.next(),t.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return this.format(r.value)}}fe.calculate=g;class Ie extends he{constructor(e){super(e);var r,t,o=e.period,a=e.values,l=e.stdDev,n=this.format;this.result=[],r=new pe({period:o,values:[],format:(e)=>e}),t=new fe({period:o,values:[],format:(e)=>e}),this.generator=function*(){var e,o,a,s;for(o=yield;;){if(a=r.nextValue(o),s=t.nextValue(o),a){let r=n(a),t=n(a+s*l),u=n(a-s*l),i=n((o-u)/(t-u));e={middle:r,upper:t,lower:u,pb:i}}o=yield e}}(),this.generator.next(),a.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}Ie.calculate=d;class Pe extends he{constructor(e){super(e),this.period=e.period,this.price=e.values;this.generator=function*(e){for(var r=new le,t=0,o=1,a=yield,l=0;;)o<e?(o++,t+=a,l=void 0):o==e?(o++,t+=a,l=t):l=l-l/e+a,a=yield l}(this.period),this.generator.next(),this.result=[],this.price.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}Pe.calculate=function(e){he.reverseInputs(e);var r=new Pe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r};class _e extends he{constructor(e){super(e);var r=e.low,t=e.high,o=this.format;if(r.length!=t.length)throw'Inputs(low,high) not of equal size';this.result=[],this.generator=function*(){for(var e,r,t=yield;;){if(r){let a=t.high-r.high,l=r.low-t.low;e=o(l>a&&0<l?l:0)}r=t,t=yield e}}(),this.generator.next(),r.forEach((e,o)=>{var a=this.generator.next({high:t[o],low:r[o]});a.value!==void 0&&this.result.push(a.value)})}static calculate(e){he.reverseInputs(e);var r=new _e(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}nextValue(e){return this.generator.next(e).value}}class be extends he{constructor(e){super(e);var r=e.low,t=e.high,o=this.format;if(r.length!=t.length)throw'Inputs(low,high) not of equal size';this.result=[],this.generator=function*(){for(var e,r,t=yield;;){if(r){let a=t.high-r.high,l=r.low-t.low;e=o(a>l&&0<a?a:0)}r=t,t=yield e}}(),this.generator.next(),r.forEach((e,o)=>{var a=this.generator.next({high:t[o],low:r[o]});a.value!==void 0&&this.result.push(a.value)})}static calculate(e){he.reverseInputs(e);var r=new be(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r}nextValue(e){return this.generator.next(e).value}}class qe extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=this.format;if(r.length!=t.length)throw'Inputs(low,high) not of equal size';this.result=[],this.generator=function*(){for(var e,r,t=yield;;)void 0==e&&(e=t.close,t=yield r),r=re(t.high-t.low,isNaN(te(t.high-e))?0:te(t.high-e),isNaN(te(t.low-e))?0:te(t.low-e)),e=t.close,void 0!=r&&(r=a(r)),t=yield r}(),this.generator.next(),r.forEach((e,a)=>{var l=this.generator.next({high:t[a],low:r[a],close:o[a]});l.value!=void 0&&this.result.push(l.value)})}nextValue(e){return this.generator.next(e).value}}qe.calculate=v;class Se extends ie{}class Ce extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=e.period,l=this.format,n=new be({high:[],low:[]}),s=new _e({high:[],low:[]}),u=new Pe({period:a,values:[],format:(e)=>e}),i=new Pe({period:a,values:[],format:(e)=>e}),h=new Pe({period:a,values:[],format:(e)=>e}),p=new ve({period:a,values:[],format:(e)=>e}),g=new qe({low:[],high:[],close:[]});if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],Se,this.generator=function*(){var e,r,t,o,a,l,d,v=yield;for(e=0,r=0,t=0;;){let e=g.nextValue(v),r=n.nextValue(v),t=s.nextValue(v);if(e===void 0){v=yield;continue}let c=h.nextValue(e),m=u.nextValue(r),x=i.nextValue(t);if(c!=void 0&&m!=void 0&&x!=void 0){o=100*m/c,a=100*x/c;let e=te(o-a),r=o+a;l=100*(e/r),d=p.nextValue(l)}v=yield{adx:d,pdi:o,mdi:a}}}(),this.generator.next(),r.forEach((e,a)=>{var n=this.generator.next({high:t[a],low:r[a],close:o[a]});n.value!=void 0&&n.value.adx!=void 0&&this.result.push({adx:l(n.value.adx),pdi:l(n.value.pdi),mdi:l(n.value.mdi)})})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0&&r.adx!=void 0)return{adx:this.format(r.adx),pdi:this.format(r.pdi),mdi:this.format(r.mdi)}}}Ce.calculate=c;class Ee extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=e.period,l=this.format;if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';var n=new qe({low:[],high:[],close:[]}),s=new ve({period:a,values:[],format:(e)=>e});this.result=[],this.generator=function*(){for(var e,r,t=yield;;)r=n.nextValue({low:t.low,high:t.high,close:t.close}),e=void 0===r?void 0:s.nextValue(r),t=yield e}(),this.generator.next(),r.forEach((e,a)=>{var n=this.generator.next({high:t[a],low:r[a],close:o[a]});n.value!==void 0&&this.result.push(l(n.value))})}nextValue(e){return this.generator.next(e).value}}Ee.calculate=m;class He extends he{constructor(e){super(e);var r=e.period,t=e.values;this.result=[],this.generator=function*(){let e=1;for(var t,o=new ne(r),a=yield;;)o.push(a),e<r?e++:t=100*((a-o.lastShift)/o.lastShift),a=yield t}(),this.generator.next(),t.forEach((e)=>{var r=this.generator.next(e);r.value==void 0||isNaN(r.value)||this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0&&!isNaN(r.value))return this.format(r.value)}}He.calculate=x;class ke extends he{constructor(e){super(e);let r=e.values,t=e.ROCPer1,o=e.ROCPer2,a=e.ROCPer3,l=e.ROCPer4,n=e.SMAROCPer1,s=e.SMAROCPer2,u=e.SMAROCPer3,i=e.SMAROCPer4,h=e.signalPeriod,p=new He({period:t,values:[]}),g=new He({period:o,values:[]}),d=new He({period:a,values:[]}),v=new He({period:l,values:[]}),c=new pe({period:n,values:[],format:(e)=>e}),m=new pe({period:s,values:[],format:(e)=>e}),x=new pe({period:u,values:[],format:(e)=>e}),w=new pe({period:i,values:[],format:(e)=>e}),f=new pe({period:h,values:[],format:(e)=>e});var I=this.format;this.result=[];let P=re(t+n,o+s,a+u,l+i);this.generator=function*(){for(let e,r,t,o,a,l,n,s=1,u=yield;;){let i=p.nextValue(u),h=g.nextValue(u),_=d.nextValue(u),b=v.nextValue(u);r=i===void 0?void 0:c.nextValue(i),t=h===void 0?void 0:m.nextValue(h),o=_===void 0?void 0:x.nextValue(_),a=b===void 0?void 0:w.nextValue(b),s<P?s++:e=1*r+2*t+3*o+4*a,l=e===void 0?void 0:f.nextValue(e),n=e===void 0?void 0:{kst:I(e),signal:l?I(l):void 0},u=yield n}}(),this.generator.next(),r.forEach((e)=>{let r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!=void 0)return r.value}}ke.calculate=w;class Ve extends he{constructor(e){super(e);let r=e.high||[],t=e.low||[];this.result=[],this.generator=function*(e,r){for(let t,o,a,l,n=!0,s=e,u=yield;;)t?(a+=s*(o-a),n?(a=ee(a,l.low,u.low),t.high>o&&(o=t.high,s=ee(s+e,r))):(a=re(a,l.high,u.high),t.low<o&&(o=t.low,s=ee(s+e,r))),(n&&t.low<a||!n&&t.high>a)&&(s=e,a=o,n=!n,o=n?t.high:t.low)):(a=u.low,o=u.high),l=u,t&&(u=t),t=yield a}(e.step,e.max),this.generator.next(),t.forEach((e,o)=>{var a=this.generator.next({high:r[o],low:t[o]});a.value!==void 0&&this.result.push(a.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}Ve.calculate=f;class Te extends he{constructor(e){super(e);let r=e.low,t=e.high,o=e.close,a=e.period,l=e.signalPeriod,n=this.format;if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){let e,r,t=1,o=new ne(a,!0,!1),s=new ne(a,!1,!0),u=new pe({period:l,values:[],format:(e)=>e});for(var i=yield;;){if(o.push(i.high),s.push(i.low),t<a){t++,i=yield;continue}let l=s.periodLow;e=100*((i.close-l)/(o.periodHigh-l)),e=isNaN(e)?0:e,r=u.nextValue(e),i=yield{k:n(e),d:void 0===r?void 0:n(r)}}}(),this.generator.next(),r.forEach((e,a)=>{var l=this.generator.next({high:t[a],low:r[a],close:o[a]});l.value!==void 0&&this.result.push(l.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}Te.calculate=I;class Ae extends he{constructor(e){super(e);let r=e.low,t=e.high,o=e.close,a=e.period,l=this.format;if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){let e,r,t=1,o=new ne(a,!0,!1),n=new ne(a,!1,!0);var s=yield;for(let u;;){if(o.push(s.high),n.push(s.low),t<a){t++,s=yield;continue}e=n.periodLow,r=o.periodHigh,u=l(-100*((r-s.close)/(r-e))),s=yield u}}(),this.generator.next(),r.forEach((e,a)=>{var l=this.generator.next({high:t[a],low:r[a],close:o[a]});l.value!==void 0&&this.result.push(l.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return this.format(r.value)}}Ae.calculate=P;class De extends he{constructor(e){super(e);var r=e.high,t=e.low,o=e.close,a=e.volume;if(t.length!==r.length||r.length!==o.length||r.length!==a.length)throw'Inputs(low,high, close, volumes) not of equal size';this.result=[],this.generator=function*(){var e,r=0;for(e=yield;;){let t=(e.close-e.low-(e.high-e.close))/(e.high-e.low);t=isNaN(t)?1:t;let o=t*e.volume;r+=o,e=yield Math.round(r)}}(),this.generator.next(),r.forEach((e,r)=>{var l={high:e,low:t[r],close:o[r],volume:a[r]},n=this.generator.next(l);n.value!=void 0&&this.result.push(n.value)})}nextValue(e){return this.generator.next(e).value}}De.calculate=_;class Be extends he{constructor(e){super(e);var r=e.close,t=e.volume;this.result=[],this.generator=function*(){var e,r,t=0;for(e=yield,e.close&&'number'==typeof e.close&&(r=e.close,e=yield);;)r<e.close?t+=e.volume:e.close<r&&(t-=e.volume),r=e.close,e=yield t}(),this.generator.next(),r.forEach((e,o)=>{let a={close:r[o],volume:t[o]},l=this.generator.next(a);l.value!=void 0&&this.result.push(l.value)})}nextValue(e){return this.generator.next(e).value}}Be.calculate=b;class ze extends he{constructor(e){super(e);let r=e.values,t=e.period,o=this.format,a=new ge({period:t,values:[],format:(e)=>e}),l=new ge({period:t,values:[],format:(e)=>e}),n=new ge({period:t,values:[],format:(e)=>e}),s=new He({period:1,values:[],format:(e)=>e});this.result=[],this.generator=function*(){for(let e=yield;;){let r=a.nextValue(e),t=r?l.nextValue(r):void 0,u=t?n.nextValue(t):void 0,i=u?s.nextValue(u):void 0;e=yield i?o(i):void 0}}(),this.generator.next(),r.forEach((e)=>{let r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}ze.calculate=q;class Le extends he{constructor(e){super(e);var r=e.close,t=e.volume,o=e.period||1;if(t.length!==r.length)throw'Inputs(volume, close) not of equal size';let a=new ge({values:[],period:o});this.result=[],this.generator=function*(){var e=yield,r=yield;for(let t;;)t=(r.close-e.close)*r.volume,e=r,r=yield a.nextValue(t)}(),this.generator.next(),t.forEach((e,o)=>{var a=this.generator.next({close:r[o],volume:t[o]});a.value!=void 0&&this.result.push(a.value)})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0)return r}}Le.calculate=S;class Me extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=e.period,l=this.format;var n=new ne(a),s=new pe({period:a,values:[],format:(e)=>e});if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){for(var e=yield;;){let r=(e.high+e.low+e.close)/3;n.push(r);let t,o=s.nextValue(r),a=null,l=0;if(o!=void 0){for(let e of n.iterator())l+=te(e-o);a=l/20,t=(r-o)/(.015*a)}e=yield t}}(),this.generator.next(),r.forEach((e,a)=>{var l=this.generator.next({high:t[a],low:r[a],close:o[a]});l.value!=void 0&&this.result.push(l.value)})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0)return r}}Me.calculate=C;class je extends he{constructor(e){super(e);var r=e.high,t=e.low,o=e.fastPeriod,a=e.slowPeriod,l=new pe({values:[],period:a}),n=new pe({values:[],period:o});this.result=[],this.generator=function*(){var e,r,t,o,a;for(r=yield;;)t=(r.high+r.low)/2,o=l.nextValue(t),a=n.nextValue(t),void 0!==o&&void 0!==a&&(e=a-o),r=yield e}(),this.generator.next(),r.forEach((e,r)=>{var o={high:e,low:t[r]},a=this.generator.next(o);a.value!=void 0&&this.result.push(this.format(a.value))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return this.format(r.value)}}je.calculate=E;class Re extends he{constructor(e){super(e);var r=e.low,t=e.high,o=e.close,a=e.volume,l=this.format;if(r.length!==t.length||t.length!==o.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){var e=yield;for(let r=0,t=0;;){let o=(e.high+e.low+e.close)/3,a=e.volume*o;r+=a,t+=e.volume,e=yield r/t}}(),this.generator.next(),r.forEach((e,l)=>{var n=this.generator.next({high:t[l],low:r[l],close:o[l],volume:a[l]});n.value!=void 0&&this.result.push(n.value)})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0)return r}}Re.calculate=H;class ye extends he{constructor(e){super(e);var r=e.high,t=e.low,o=e.close,a=e.open,l=e.volume,n=e.noOfBars;if(t.length!==r.length||r.length!==o.length||r.length!==l.length)throw'Inputs(low,high, close, volumes) not of equal size';this.result=[];var s=re(...r,...t,...o,...a),u=ee(...r,...t,...o,...a),i=u;for(let h=0;h<n;h++){let e=i,h=e+(s-u)/n;i=h;let p=0,g=0,d=0;for(let n=0;n<r.length;n++){let s=t[n],u=r[n],i=a[n],v=o[n],c=l[n];k(e,h,s,u)&&(d+=c,i>v?g+=c:p+=c)}this.result.push({rangeStart:e,rangeEnd:h,bullishVolume:p,bearishVolume:g,totalVolume:d})}}nextValue(){throw'Next value not supported for volume profile'}}ye.calculate=V;class Oe extends he{constructor(e){super(e),this.result=[],this.generator=function*(){for(let e=yield;;)e=yield(e.high+e.low+e.close)/3}(),this.generator.next(),e.low.forEach((r,t)=>{var o=this.generator.next({high:e.high[t],low:e.low[t],close:e.close[t]});this.result.push(o.value)})}nextValue(e){var r=this.generator.next(e).value;return r}}Oe.calculate=function(e){he.reverseInputs(e);var r=new Oe(e).result;return e.reversedInput&&r.reverse(),he.reverseInputs(e),r};class Fe extends he{constructor(e){super(e);var r=e.high,t=e.low,o=e.close,a=e.volume,l=e.period,n=new Oe({low:[],high:[],close:[]}),s=new ne(l,!1,!1,!0),u=new ne(l,!1,!1,!0);if(t.length!==r.length||r.length!==o.length||r.length!==a.length)throw'Inputs(low,high, close, volumes) not of equal size';this.result=[],this.generator=function*(){var e,r,t,o,a,i,h=0;let p=null,g=null;for(r=yield,t=r.close,r=yield;;){var{high:d,low:v,close:c,volume:m}=r,x=0,w=0;p=n.nextValue({high:d,low:v,close:c}),h=p*m,null!=p&&null!=g&&(p>g?x=h:w=h,s.push(x),u.push(w),o=s.periodSum,i=u.periodSum,s.totalPushed>=l&&s.totalPushed>=l&&(a=o/i,e=100-100/(1+a))),g=p,r=yield e}}(),this.generator.next(),r.forEach((e,r)=>{var l={high:e,low:t[r],close:o[r],volume:a[r]},n=this.generator.next(l);n.value!=void 0&&this.result.push(parseFloat(n.value.toFixed(2)))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return parseFloat(r.value.toFixed(2))}}Fe.calculate=T;class Ue extends he{constructor(e){super(e);let r=e.values,t=e.rsiPeriod,o=e.stochasticPeriod,a=e.kPeriod,l=e.dPeriod,n=this.format;this.result=[],this.generator=function*(){let e,r,n,s,u=new we({period:t,values:[]}),i=new Te({period:o,high:[],low:[],close:[],signalPeriod:a}),h=new pe({period:l,values:[],format:(e)=>e});for(var p=yield;;){if(e=u.nextValue(p),void 0!==e){var g={high:e,low:e,close:e};r=i.nextValue(g),void 0!==r&&void 0!==r.d&&(n=h.nextValue(r.d),void 0!==n&&(s={stochRSI:r.k,k:r.d,d:n}))}p=yield s}}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}Ue.calculate=A;class We extends he{constructor(e){super(e);var r=e.values,t=e.period;this.result=[];var o=new ne(t,!0,!1,!1);this.generator=function*(){var e,r;for(e=yield;;)o.push(e),o.totalPushed>=t&&(r=o.periodHigh),e=yield r}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}We.calculate=D;class Ne extends he{constructor(e){super(e);var r=e.values,t=e.period;this.result=[];var o=new ne(t,!1,!0,!1);this.generator=function*(){var e,r;for(e=yield;;)o.push(e),o.totalPushed>=t&&(r=o.periodLow),e=yield r}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}Ne.calculate=B;class Ge extends he{constructor(e){super(e);var r=e.values,t=e.period;this.result=[];var o=new ne(t,!1,!1,!0);this.generator=function*(){var e,r;for(e=yield;;)o.push(e),o.totalPushed>=t&&(r=o.periodSum),e=yield r}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}Ge.calculate=z;class Xe extends he{constructor(e){super(e);this.format;let r=e.useATR,t=e.brickSize||0;if(r){let r=m(Object.assign({},e));t=r[r.length-1]}if(this.result=new se,0===t)return void console.error('Not enough data to calculate brickSize for renko when using ATR');let o=0,a=0,l=Infinity,n=0,s=0,u=0;this.generator=function*(){for(let e=yield;;){if(0==o){o=e.close,a=e.high,l=e.low,n=e.close,s=e.volume,u=e.timestamp,e=yield;continue}let r=te(e.close-n),i=te(e.close-o);if(r>=t&&i>=t){let u=r>i?o:n,h={open:u,high:a>e.high?a:e.high,low:l<e.Low?l:e.low,close:u>e.close?u-t:u+t,volume:s+e.volume,timestamp:e.timestamp};o=h.open,a=h.close,l=h.close,n=h.close,s=0,e=yield h}else a=a>e.high?a:e.high,l=l<e.Low?l:e.low,s+=e.volume,u=e.timestamp,e=yield}}(),this.generator.next(),e.low.forEach((r,t)=>{var o=this.generator.next({open:e.open[t],high:e.high[t],low:e.low[t],close:e.close[t],volume:e.volume[t],timestamp:e.timestamp[t]});o.value&&(this.result.open.push(o.value.open),this.result.high.push(o.value.high),this.result.low.push(o.value.low),this.result.close.push(o.value.close),this.result.volume.push(o.value.volume),this.result.timestamp.push(o.value.timestamp))})}nextValue(){return console.error('Cannot calculate next value on Renko, Every value has to be recomputed for every change, use calcualte method'),null}}Xe.calculate=L;class Ke extends he{constructor(e){super(e);this.format;this.result=new se;let r=null,t=0,o=Infinity,a=0,l=0,n=0;this.generator=function*(){for(let e=yield,s=null;;){if(null==r)r=(e.close+e.open)/2,t=e.high,o=e.low,a=(e.close+e.open+e.high+e.low)/4,l=e.volume||0,n=e.timestamp||0,s={open:r,high:t,low:o,close:a,volume:e.volume||0,timestamp:e.timestamp||0};else{let l=(e.close+e.open+e.high+e.low)/4,n=(r+a)/2,u=re(n,l,e.high),i=ee(e.low,n,l);s={close:l,open:n,high:u,low:i,volume:e.volume||0,timestamp:e.timestamp||0},a=l,r=n,t=u,o=i}e=yield s}}(),this.generator.next(),e.low.forEach((r,t)=>{var o=this.generator.next({open:e.open[t],high:e.high[t],low:e.low[t],close:e.close[t],volume:e.volume?e.volume[t]:e.volume,timestamp:e.timestamp?e.timestamp[t]:e.timestamp});o.value&&(this.result.open.push(o.value.open),this.result.high.push(o.value.high),this.result.low.push(o.value.low),this.result.close.push(o.value.close),this.result.volume.push(o.value.volume),this.result.timestamp.push(o.value.timestamp))})}nextValue(e){var r=this.generator.next(e).value;return r}}Ke.calculate=M;class Qe{constructor(){}approximateEqual(e,r){let t=1*parseFloat(te(e-r).toPrecision(4)),o=1*parseFloat((1e-3*e).toPrecision(4));return t<=o}logic(){throw'this has to be implemented'}getAllPatternIndex(e){if(e.close.length<this.requiredCount)return console.warn('Data count less than data required for the strategy ',this.name),[];e.reversedInput&&(e.open.reverse(),e.high.reverse(),e.low.reverse(),e.close.reverse());let r=this.logic;return this._generateDataForCandleStick(e).map((e,t)=>r.call(this,e)?t:void 0).filter((e)=>e)}hasPattern(e){if(e.close.length<this.requiredCount)return console.warn('Data count less than data required for the strategy ',this.name),!1;e.reversedInput&&(e.open.reverse(),e.high.reverse(),e.low.reverse(),e.close.reverse());let r=this.logic;return r.call(this,this._getLastDataForCandleStick(e))}_getLastDataForCandleStick(e){let r=this.requiredCount;if(e.close.length===r)return e;else{let t={open:[],high:[],low:[],close:[]},o=0,a=e.close.length-r;for(;o<r;)t.open.push(e.open[a+o]),t.high.push(e.high[a+o]),t.low.push(e.low[a+o]),t.close.push(e.close[a+o]),o++;return t}}_generateDataForCandleStick(e){let r=this.requiredCount,t=e.close.map(function(t,o){let a=0,l={open:[],high:[],low:[],close:[]};for(;a<r;)l.open.push(e.open[o+a]),l.high.push(e.high[o+a]),l.low.push(e.low[o+a]),l.close.push(e.close[o+a]),a++;return l}).filter((t,o)=>o<=e.close.length-r);return t}}class Ye extends Qe{constructor(){super(),this.name='MorningStar',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],g=e.low[2];return t<r&&a>u&&a>s&&s<a&&u<a&&i>s&&n<i&&i<h&&h>(r+t)/2}}class Ze extends Qe{constructor(){super(),this.name='BullishEngulfingPattern',this.requiredCount=2}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return t<r&&r>l&&t>l&&r<n}}class $e extends Qe{constructor(){super(),this.requiredCount=2,this.name='BullishHarami'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return r>l&&t<l&&t<n&&r>u&&o>s}}class Je extends Qe{constructor(){super(),this.requiredCount=2,this.name='BullishHaramiCross'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=this.approximateEqual(l,n);return r>l&&t<l&&t<n&&r>u&&o>s&&i}}class er extends Qe{constructor(){super(),this.name='Doji',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(r,t),n=l&&this.approximateEqual(r,o),s=l&&this.approximateEqual(t,a);return l&&n==s}}class rr extends Qe{constructor(){super(),this.name='MorningDojiStar',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],g=e.low[2],d=new er().hasPattern({open:[l],close:[n],high:[s],low:[u]});return t<r&&d&&i<h&&s<a&&u<a&&i>s&&n<i&&h>(r+t)/2}}class tr extends Qe{constructor(){super(),this.requiredCount=3,this.name='DownsideTasukiGap'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],g=e.low[2];return t<r&&n<l&&h>i&&s<a&&l>i&&n<i&&h>l&&h<t}}class or extends Qe{constructor(){super(),this.name='BullishMarubozu',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(t,o)&&this.approximateEqual(a,r)&&r<t&&r<o;return l}}class ar extends Qe{constructor(){super(),this.requiredCount=2,this.name='PiercingLine'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return u<a&&t<r&&a>l&&n>(r+t)/2&&n>l}}class lr extends Qe{constructor(){super(),this.name='ThreeWhiteSoldiers',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],g=e.low[2];return s>o&&p>s&&r<t&&l<n&&i<h&&t>l&&l<o&&s>i&&i<n}}class nr extends Qe{constructor(){super(),this.name='BullishHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=t>r;return l=l&&this.approximateEqual(t,o),l=l&&t-r<=2*(r-a),l}}class sr extends Qe{constructor(){super(),this.name='BullishInvertedHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=t>r;return l=l&&this.approximateEqual(r,a),l=l&&t-r<=2*(o-t),l}}class ur extends Qe{constructor(){super(),this.name='BearishHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=r>t;return l=l&&this.approximateEqual(r,o),l=l&&r-t<=2*(t-a),l}}class ir extends Qe{constructor(){super(),this.name='BearishInvertedHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=r>t;return l=l&&this.approximateEqual(t,a),l=l&&r-t<=2*(o-r),l}}class hr extends Qe{constructor(){super(),this.name='HammerPattern',this.requiredCount=5}logic(e){let r=this.downwardTrend(e);return r=r&&this.includesHammer(e),r=r&&this.hasConfirmation(e),r}downwardTrend(e,r=!0){let t=r?3:4,o=i({values:e.close.slice(0,t),period:t-1}),a=h({values:e.close.slice(0,t),period:t-1});return a>o}includesHammer(e,r=!0){let t=r?3:4,o=r?4:void 0,a={open:e.open.slice(t,o),close:e.close.slice(t,o),low:e.low.slice(t,o),high:e.high.slice(t,o)},l=y(a);return l=l||O(a),l=l||j(a),l=l||R(a),l}hasConfirmation(e){let r={open:e.open[3],close:e.close[3],low:e.low[3],high:e.high[3]},t={open:e.open[4],close:e.close[4],low:e.low[4],high:e.high[4]},o=t.open<t.close;return o&&r.close<t.close}}class pr extends hr{constructor(){super(),this.name='HammerPatternUnconfirmed'}logic(e){let r=this.downwardTrend(e,!1);return r=r&&this.includesHammer(e,!1),r}}class gr extends Qe{constructor(){super(),this.name='TweezerBottom',this.requiredCount=5}logic(e){return this.downwardTrend(e)&&e.low[3]==e.low[4]}downwardTrend(e){let r=i({values:e.close.slice(0,3),period:2}),t=h({values:e.close.slice(0,3),period:2});return t>r}}let dr=[new Ze,new tr,new $e,new Je,new rr,new Ye,new or,new ar,new lr,new nr,new sr,new hr,new pr,new gr];class vr extends Qe{constructor(){super(),this.name='Bullish Candlesticks'}hasPattern(e){return dr.reduce(function(r,t){let o=t.hasPattern(e);return r||o},!1)}}class cr extends Qe{constructor(){super(),this.name='BearishEngulfingPattern',this.requiredCount=2}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return t>r&&r<l&&t<l&&r>n}}class mr extends Qe{constructor(){super(),this.requiredCount=2,this.name='BearishHarami'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return r<l&&t>l&&t>n&&r<u&&o>s}}class xr extends Qe{constructor(){super(),this.requiredCount=2,this.name='BearishHaramiCross'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=this.approximateEqual(l,n);return r<l&&t>l&&t>n&&r<u&&o>s&&i}}class wr extends Qe{constructor(){super(),this.name='EveningDojiStar',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],g=e.low[2],d=new er().hasPattern({open:[l],close:[n],high:[s],low:[u]});return t>r&&d&&s>o&&u>o&&i<u&&n>i&&i>h&&h<(r+t)/2}}class fr extends Qe{constructor(){super(),this.name='EveningStar',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],g=e.low[2];return t>r&&o<u&&o<s&&s>o&&u>o&&i<u&&n>i&&i>h&&h<(r+t)/2}}class Ir extends Qe{constructor(){super(),this.name='BearishMarubozu',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(r,o)&&this.approximateEqual(a,t)&&r>t&&r>a;return l}}class Pr extends Qe{constructor(){super(),this.name='ThreeBlackCrows',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],g=e.low[2];return a>u&&u>g&&r>t&&l>n&&i>h&&r>l&&l>t&&l>i&&i>n}}class _r extends Qe{constructor(){super(),this.name='HangingMan',this.requiredCount=5}logic(e){let r=this.upwardTrend(e);return r=r&&this.includesHammer(e),r=r&&this.hasConfirmation(e),r}upwardTrend(e,r=!0){let t=r?3:4,o=i({values:e.close.slice(0,t),period:t-1}),a=h({values:e.close.slice(0,t),period:t-1});return o>a}includesHammer(e,r=!0){let t=r?3:4,o=r?4:void 0,a={open:e.open.slice(t,o),close:e.close.slice(t,o),low:e.low.slice(t,o),high:e.high.slice(t,o)},l=y(a);return l=l||j(a),l}hasConfirmation(e){let r={open:e.open[3],close:e.close[3],low:e.low[3],high:e.high[3]},t={open:e.open[4],close:e.close[4],low:e.low[4],high:e.high[4]},o=t.open>t.close;return o&&r.close>t.close}}class br extends _r{constructor(){super(),this.name='HangingManUnconfirmed'}logic(e){let r=this.upwardTrend(e,!1);return r=r&&this.includesHammer(e,!1),r}}class qr extends Qe{constructor(){super(),this.name='ShootingStar',this.requiredCount=5}logic(e){let r=this.upwardTrend(e);return r=r&&this.includesHammer(e),r=r&&this.hasConfirmation(e),r}upwardTrend(e,r=!0){let t=r?3:4,o=i({values:e.close.slice(0,t),period:t-1}),a=h({values:e.close.slice(0,t),period:t-1});return o>a}includesHammer(e,r=!0){let t=r?3:4,o=r?4:void 0,a={open:e.open.slice(t,o),close:e.close.slice(t,o),low:e.low.slice(t,o),high:e.high.slice(t,o)},l=O(a);return l=l||R(a),l}hasConfirmation(e){let r={open:e.open[3],close:e.close[3],low:e.low[3],high:e.high[3]},t={open:e.open[4],close:e.close[4],low:e.low[4],high:e.high[4]},o=t.open>t.close;return o&&r.close>t.close}}class Sr extends qr{constructor(){super(),this.name='ShootingStarUnconfirmed'}logic(e){let r=this.upwardTrend(e,!1);return r=r&&this.includesHammer(e,!1),r}}class Cr extends Qe{constructor(){super(),this.name='TweezerTop',this.requiredCount=5}logic(e){return this.upwardTrend(e)&&e.high[3]==e.high[4]}upwardTrend(e){let r=i({values:e.close.slice(0,3),period:2}),t=h({values:e.close.slice(0,3),period:2});return r>t}}let Er=[new cr,new mr,new xr,new wr,new fr,new Ir,new Pr,new ur,new ir,new _r,new br,new qr,new Sr,new Cr];class Hr extends Qe{constructor(){super(),this.name='Bearish Candlesticks'}hasPattern(e){return Er.reduce(function(r,t){return r||t.hasPattern(e)},!1)}}class kr extends Qe{constructor(){super(),this.name='AbandonedBaby',this.requiredCount=3}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],g=e.low[2],d=new er().hasPattern({open:[l],close:[n],high:[s],low:[u]});return t<r&&d&&s<a&&g>s&&h>i&&p<r}}class Vr extends Qe{constructor(){super(),this.name='DarkCloudCover',this.requiredCount=2}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return t>r&&n<l&&l>o&&n<(t+r)/2&&n>r}}class Tr extends Qe{constructor(){super(),this.requiredCount=1,this.name='DragonFlyDoji'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(r,t),n=l&&this.approximateEqual(r,o),s=l&&this.approximateEqual(t,a);return l&&n&&!s}}class Ar extends Qe{constructor(){super(),this.requiredCount=1,this.name='GraveStoneDoji'}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=this.approximateEqual(r,t),n=l&&this.approximateEqual(r,o),s=l&&this.approximateEqual(t,a);return l&&s&&!n}}class Dr extends Qe{constructor(){super(),this.name='BullishSpinningTop',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=te(t-r),n=te(o-t),s=te(r-a);return l<n&&l<s}}class Br extends Qe{constructor(){super(),this.name='BearishSpinningTop',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],o=e.high[0],a=e.low[0],l=te(t-r),n=te(o-r),s=te(o-a);return l<n&&l<s}}var zr,Lr=function(e,r,t,o){return new(t||(t=Promise))(function(a,l){function n(e){try{u(o.next(e))}catch(r){l(r)}}function s(e){try{u(o['throw'](e))}catch(r){l(r)}}function u(e){e.done?a(e.value):new t(function(r){r(e.value)}).then(n,s)}u((o=o.apply(e,r||[])).next())})},Mr=!1,jr=['IHS','TU','DB','HS','TD','DT'];try{Mr='[object process]'===Object.prototype.toString.call(global.process)}catch(r){}(function(e){e[e.IHS=0]='IHS',e[e.TU=1]='TU',e[e.DB=2]='DB',e[e.HS=3]='HS',e[e.TD=4]='TD',e[e.DT=5]='DT'})(e.AvailablePatterns||(e.AvailablePatterns={}));var Rr,yr=!1,Or=!1;Mr&&W();class Fr extends he{}Fr.predictPattern=N,Fr.hasDoubleBottom=G,Fr.hasDoubleTop=X,Fr.hasHeadAndShoulder=K,Fr.hasInverseHeadAndShoulder=Q,Fr.isTrendingUp=Y,Fr.isTrendingDown=Z;class Ur extends he{constructor(e){super(e),this.result=[];var r=Object.assign({},{conversionPeriod:9,basePeriod:26,spanPeriod:52,displacement:26},e),t=new ne(2*r.conversionPeriod,!0,!0,!1),o=new ne(2*r.basePeriod,!0,!0,!1),a=new ne(2*r.spanPeriod,!0,!0,!1);this.generator=function*(){let e,l,n=re(r.conversionPeriod,r.basePeriod,r.spanPeriod,r.displacement),s=1;for(l=yield;;){if(t.push(l.high),t.push(l.low),o.push(l.high),o.push(l.low),a.push(l.high),a.push(l.low),s<n)s++;else{let r=(t.periodHigh+t.periodLow)/2,l=(o.periodHigh+o.periodLow)/2,n=(a.periodHigh+a.periodLow)/2;e={conversion:r,base:l,spanA:(r+l)/2,spanB:n}}l=yield e}}(),this.generator.next(),e.low.forEach((r,t)=>{var o=this.generator.next({high:e.high[t],low:e.low[t]});o.value&&this.result.push(o.value)})}nextValue(e){return this.generator.next(e).value}}Ur.calculate=$;let Wr=J();e.getAvailableIndicators=J,e.AvailableIndicators=Wr,e.FixedSizeLinkedList=ne,e.CandleData=class{},e.CandleList=se,e.sma=a,e.SMA=pe,e.ema=l,e.EMA=ge,e.wma=n,e.WMA=de,e.wema=s,e.WEMA=ve,e.macd=u,e.MACD=ce,e.rsi=p,e.RSI=we,e.bollingerbands=d,e.BollingerBands=Ie,e.adx=c,e.ADX=Ce,e.atr=m,e.ATR=Ee,e.truerange=v,e.TrueRange=qe,e.roc=x,e.ROC=He,e.kst=w,e.KST=ke,e.psar=f,e.PSAR=Ve,e.stochastic=I,e.Stochastic=Te,e.williamsr=P,e.WilliamsR=Ae,e.adl=_,e.ADL=De,e.obv=b,e.OBV=Be,e.trix=q,e.TRIX=ze,e.forceindex=S,e.ForceIndex=Le,e.cci=C,e.CCI=Me,e.awesomeoscillator=E,e.AwesomeOscillator=je,e.vwap=H,e.VWAP=Re,e.volumeprofile=V,e.VolumeProfile=ye,e.mfi=T,e.MFI=Fe,e.stochasticrsi=A,e.StochasticRSI=Ue,e.averagegain=i,e.AverageGain=me,e.averageloss=h,e.AverageLoss=xe,e.sd=g,e.SD=fe,e.highest=D,e.Highest=We,e.lowest=B,e.Lowest=Ne,e.sum=z,e.Sum=Ge,e.renko=L,e.HeikinAshi=Ke,e.heikinashi=M,e.bullish=function(e){return new vr().hasPattern(e)},e.bearish=function(e){return new Hr().hasPattern(e)},e.abandonedbaby=function(e){return new kr().hasPattern(e)},e.doji=function(e){return new er().hasPattern(e)},e.bearishengulfingpattern=function(e){return new cr().hasPattern(e)},e.bullishengulfingpattern=function(e){return new Ze().hasPattern(e)},e.darkcloudcover=function(e){return new Vr().hasPattern(e)},e.downsidetasukigap=function(e){return new tr().hasPattern(e)},e.dragonflydoji=function(e){return new Tr().hasPattern(e)},e.gravestonedoji=function(e){return new Ar().hasPattern(e)},e.bullishharami=function(e){return new $e().hasPattern(e)},e.bearishharami=function(e){return new mr().hasPattern(e)},e.bullishharamicross=function(e){return new Je().hasPattern(e)},e.bearishharamicross=function(e){return new xr().hasPattern(e)},e.eveningdojistar=function(e){return new wr().hasPattern(e)},e.eveningstar=function(e){return new fr().hasPattern(e)},e.morningdojistar=function(e){return new rr().hasPattern(e)},e.morningstar=function(e){return new Ye().hasPattern(e)},e.bullishmarubozu=function(e){return new or().hasPattern(e)},e.bearishmarubozu=function(e){return new Ir().hasPattern(e)},e.piercingline=function(e){return new ar().hasPattern(e)},e.bullishspinningtop=function(e){return new Dr().hasPattern(e)},e.bearishspinningtop=function(e){return new Br().hasPattern(e)},e.threeblackcrows=function(e){return new Pr().hasPattern(e)},e.threewhitesoldiers=function(e){return new lr().hasPattern(e)},e.bullishhammerstick=j,e.bearishhammerstick=y,e.bullishinvertedhammerstick=R,e.bearishinvertedhammerstick=O,e.hammerpattern=function(e){return new hr().hasPattern(e)},e.hammerpatternunconfirmed=function(e){return new pr().hasPattern(e)},e.hangingman=function(e){return new _r().hasPattern(e)},e.hangingmanunconfirmed=function(e){return new br().hasPattern(e)},e.shootingstar=function(e){return new qr().hasPattern(e)},e.shootingstarunconfirmed=function(e){return new Sr().hasPattern(e)},e.tweezertop=function(e){return new Cr().hasPattern(e)},e.tweezerbottom=function(e){return new gr().hasPattern(e)},e.fibonacciretracement=function(e,r){let t,o=[0,23.6,38.2,50,61.8,78.6,100,127.2,161.8,261.8,423.6];return t=e<r?o.map(function(t){let o=r-te(e-r)*t/100;return 0<o?o:0}):o.map(function(t){let o=r+te(e-r)*t/100;return 0<o?o:0}),t},e.predictPattern=N,e.PatternDetector=Fr,e.hasDoubleBottom=G,e.hasDoubleTop=X,e.hasHeadAndShoulder=K,e.hasInverseHeadAndShoulder=Q,e.isTrendingUp=Y,e.isTrendingDown=Z,e.ichimokucloud=$,e.IchimokuCloud=Ur,e.setConfig=function(e,r){ue[e]=r},e.getConfig=t})(this.window=this.window||{},tf);
import { Indicator, IndicatorInput } from '../indicator/indicator';
import LinkedList from '../Utils/FixedSizeLinkedList';
export class IchimokuCloudInput extends IndicatorInput {

@@ -24,2 +25,5 @@ constructor() {

var params = Object.assign({}, defaults, input);
var currentConversionData = new LinkedList(params.conversionPeriod * 2, true, true, false);
var currentBaseData = new LinkedList(params.basePeriod * 2, true, true, false);
var currenSpanData = new LinkedList(params.spanPeriod * 2, true, true, false);
this.generator = (function* () {

@@ -29,16 +33,12 @@ let result;

let period = Math.max(params.conversionPeriod, params.basePeriod, params.spanPeriod, params.displacement);
let periodCounter = 0;
let spanCounter = 0;
let highs = [];
let lows = [];
let spanAs = [];
let spanBs = [];
let conversionPeriodLow, conversionPeriodHigh;
let basePeriodLow, basePeriodHigh;
let spanbPeriodLow, spanbPeriodHigh;
let periodCounter = 1;
tick = yield;
while (true) {
// Keep a list of lows/highs for the max period
highs.push(tick.high);
lows.push(tick.low);
currentConversionData.push(tick.high);
currentConversionData.push(tick.low);
currentBaseData.push(tick.high);
currentBaseData.push(tick.low);
currenSpanData.push(tick.high);
currenSpanData.push(tick.low);
if (periodCounter < period) {

@@ -48,28 +48,17 @@ periodCounter++;

else {
highs.shift();
lows.shift();
// Tenkan-sen (ConversionLine): (9-period high + 9-period low)/2))
conversionPeriodLow = lows.slice(-params.conversionPeriod).reduce((a, b) => Math.min(a, b));
conversionPeriodHigh = highs.slice(-params.conversionPeriod).reduce((a, b) => Math.max(a, b));
let conversionLine = (conversionPeriodHigh + conversionPeriodLow) / 2;
let conversionLine = (currentConversionData.periodHigh + currentConversionData.periodLow) / 2;
// Kijun-sen (Base Line): (26-period high + 26-period low)/2))
basePeriodLow = lows.slice(-params.basePeriod).reduce((a, b) => Math.min(a, b));
basePeriodHigh = highs.slice(-params.basePeriod).reduce((a, b) => Math.max(a, b));
let baseLine = (basePeriodHigh + basePeriodLow) / 2;
let baseLine = (currentBaseData.periodHigh + currentBaseData.periodLow) / 2;
// Senkou Span A (Leading Span A): (Conversion Line + Base Line)/2))
let spanA = 0;
spanAs.push((conversionLine + baseLine) / 2);
let spanA = (conversionLine + baseLine) / 2;
// Senkou Span B (Leading Span B): (52-period high + 52-period low)/2))
let spanB = 0;
spanbPeriodLow = lows.slice(-params.spanPeriod).reduce((a, b) => Math.min(a, b));
spanbPeriodHigh = highs.slice(-params.spanPeriod).reduce((a, b) => Math.max(a, b));
spanBs.push((spanbPeriodHigh + spanbPeriodLow) / 2);
let spanB = (currenSpanData.periodHigh + currenSpanData.periodLow) / 2;
// Senkou Span A / Senkou Span B offset by 26 periods
if (spanCounter < params.displacement) {
spanCounter++;
}
else {
spanA = spanAs.shift();
spanB = spanBs.shift();
}
// if(spanCounter < params.displacement) {
// spanCounter++
// } else {
// spanA = spanAs.shift()
// spanB = spanBs.shift()
// }
result = {

@@ -76,0 +65,0 @@ conversion: conversionLine,

{
"name": "technicalindicators",
"version": "2.0.3",
"version": "2.0.4",
"description": "Techincal Indicators written in javascript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc