ohlcv-indicators 1.3.8 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{t.r(e),t.d(e,{default:()=>ne});var r=1e6,n="[big.js] ",o=n+"Invalid ",i=o+"decimal places",l=o+"rounding mode",c=n+"Division by zero",u={},a=void 0,s=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function h(t,e,r,n){var o=t.c;if(r===a&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(l);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==a))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==a||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function f(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}u.abs=function(){var t=new this.constructor(this);return t.s=1,t},u.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,l=t.s,c=r.e,u=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-l:0;if(i!=l)return i;if(e=i<0,c!=u)return c>u^e?1:-1;for(l=(c=n.length)<(u=o.length)?c:u,i=-1;++i<l;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return c==u?0:c>u^e?1:-1},u.div=function(t){var e=this,n=e.constructor,o=e.c,l=(t=new n(t)).c,u=e.s==t.s?1:-1,s=n.DP;if(s!==~~s||s<0||s>r)throw Error(i);if(!l[0])throw Error(c);if(!o[0])return t.s=u,t.c=[t.e=0],t;var f,p,v,y,b,m=l.slice(),d=f=l.length,g=o.length,w=o.slice(0,f),M=w.length,S=t,j=S.c=[],O=0,P=s+(S.e=e.e-t.e)+1;for(S.s=u,u=P<0?0:P,m.unshift(0);M++<f;)w.push(0);do{for(v=0;v<10;v++){if(f!=(M=w.length))y=f>M?1:-1;else for(b=-1,y=0;++b<f;)if(l[b]!=w[b]){y=l[b]>w[b]?1:-1;break}if(!(y<0))break;for(p=M==f?l:m;M;){if(w[--M]<p[M]){for(b=M;b&&!w[--b];)w[b]=9;--w[b],w[M]+=10}w[M]-=p[M]}for(;!w[0];)w.shift()}j[O++]=y?v:++v,w[0]&&y?w[M]=o[d]||0:w=[o[d]]}while((d++<g||w[0]!==a)&&u--);return j[0]||1==O||(j.shift(),S.e--,P--),O>P&&h(S,P,n.RM,w[0]!==a),S},u.eq=function(t){return 0===this.cmp(t)},u.gt=function(t){return this.cmp(t)>0},u.gte=function(t){return this.cmp(t)>-1},u.lt=function(t){return this.cmp(t)<0},u.lte=function(t){return this.cmp(t)<1},u.minus=u.sub=function(t){var e,r,n,o,i=this,l=i.constructor,c=i.s,u=(t=new l(t)).s;if(c!=u)return t.s=-u,i.plus(t);var a=i.c.slice(),s=i.e,h=t.c,f=t.e;if(!a[0]||!h[0])return h[0]?t.s=-u:a[0]?t=new l(i):t.s=1,t;if(c=s-f){for((o=c<0)?(c=-c,n=a):(f=s,n=h),n.reverse(),u=c;u--;)n.push(0);n.reverse()}else for(r=((o=a.length<h.length)?a:h).length,c=u=0;u<r;u++)if(a[u]!=h[u]){o=a[u]<h[u];break}if(o&&(n=a,a=h,h=n,t.s=-t.s),(u=(r=h.length)-(e=a.length))>0)for(;u--;)a[e++]=0;for(u=e;r>c;){if(a[--r]<h[r]){for(e=r;e&&!a[--e];)a[e]=9;--a[e],a[r]+=10}a[r]-=h[r]}for(;0===a[--u];)a.pop();for(;0===a[0];)a.shift(),--f;return a[0]||(t.s=1,a=[f=0]),t.c=a,t.e=f,t},u.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(c);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},u.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},u.plus=u.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var l=o.e,c=o.c,u=t.e,a=t.c;if(!c[0]||!a[0])return a[0]||(c[0]?t=new i(o):t.s=o.s),t;if(c=c.slice(),e=l-u){for(e>0?(u=l,n=a):(e=-e,n=c),n.reverse();e--;)n.push(0);n.reverse()}for(c.length-a.length<0&&(n=a,a=c,c=n),e=a.length,r=0;e;c[e]%=10)r=(c[--e]=c[e]+a[e]+r)/10|0;for(r&&(c.unshift(r),++u),e=c.length;0===c[--e];)c.pop();return t.c=c,t.e=u,t},u.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(o+"exponent");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},u.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(o+"precision");return h(new this.constructor(this),t,e)},u.round=function(t,e){if(t===a)t=0;else if(t!==~~t||t<-r||t>r)throw Error(i);return h(new this.constructor(this),t+this.e+1,e)},u.sqrt=function(){var t,e,r,o=this,i=o.constructor,l=o.s,c=o.e,u=new i("0.5");if(!o.c[0])return new i(o);if(l<0)throw Error(n+"No square root");0===(l=Math.sqrt(o+""))||l===1/0?((e=o.c.join("")).length+c&1||(e+="0"),c=((c+1)/2|0)-(c<0||1&c),t=new i(((l=Math.sqrt(e))==1/0?"5e":(l=l.toExponential()).slice(0,l.indexOf("e")+1))+c)):t=new i(l+""),c=t.e+(i.DP+=4);do{r=t,t=u.times(r.plus(o.div(r)))}while(r.c.slice(0,c).join("")!==t.c.slice(0,c).join(""));return h(t,(i.DP-=4)+t.e+1,i.RM)},u.times=u.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,l=o.length,c=i.length,u=r.e,a=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=u+a,l<c&&(e=o,o=i,i=e,a=l,l=c,c=a),e=new Array(a=l+c);a--;)e[a]=0;for(u=c;u--;){for(c=0,a=l+u;a>u;)c=e[a]+i[u]*o[a-u-1]+c,e[a--]=c%10,c=c/10|0;e[a]=c}for(c?++t.e:e.shift(),u=e.length;!e[--u];)e.pop();return t.c=e,t},u.toExponential=function(t,e){var n=this,o=n.c[0];if(t!==a){if(t!==~~t||t<0||t>r)throw Error(i);for(n=h(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return f(n,!0,!!o)},u.toFixed=function(t,e){var n=this,o=n.c[0];if(t!==a){if(t!==~~t||t<0||t>r)throw Error(i);for(t=t+(n=h(new n.constructor(n),t+n.e+1,e)).e+1;n.c.length<t;)n.c.push(0)}return f(n,!1,!!o)},u[Symbol.for("nodejs.util.inspect.custom")]=u.toJSON=u.toString=function(){var t=this,e=t.constructor;return f(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},u.toNumber=function(){var t=Number(f(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},u.toPrecision=function(t,e){var n=this,i=n.constructor,l=n.c[0];if(t!==a){if(t!==~~t||t<1||t>r)throw Error(o+"precision");for(n=h(new i(n),t,e);n.c.length<t;)n.c.push(0)}return f(n,t<=n.e||n.e<=i.NE||n.e>=i.PE,!!l)},u.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return f(t,t.e<=e.NE||t.e>=e.PE,!0)};const p=function t(){function e(r){var n=this;if(!(n instanceof e))return r===a?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(o+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,i;if(!s.test(e))throw Error(o+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&"0"==e.charAt(n);)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&"0"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=u,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(b())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&m(o,r.prototype),o}(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),m(r,t)},y(t)}function b(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(b=function(){return!!t})()}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}var g=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,b()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(y(Error));function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function M(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,j(n.key),n)}}function S(t,e,r){return(e=j(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function j(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=w(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==w(e)?e:e+""}var O=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),S(this,"previousHighest",void 0),S(this,"highest",void 0),S(this,"previousLowest",void 0),S(this,"lowest",void 0),S(this,"previousResult",void 0),S(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t.gt(this.highest)?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t.lt(this.lowest)?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&M(t.prototype,e),r&&M(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function _(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,A(n.key),n)}}function E(t,e,r){return e=R(e),function(t,e){if(e&&("object"==P(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,k()?Reflect.construct(e,r||[],R(t).constructor):e.apply(t,r))}function k(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(k=function(){return!!t})()}function R(t){return R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},R(t)}function T(t,e){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},T(t,e)}function A(t){var e=function(t,e){if("object"!=P(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}var x=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=E(this,e),i=void 0,(o=A(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&T(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&_(r.prototype,n),o&&_(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(O);function B(t){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(t)}function C(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,N(n.key),n)}}function I(t,e,r){return e=V(e),function(t,e){if(e&&("object"==B(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,D()?Reflect.construct(e,r||[],V(t).constructor):e.apply(t,r))}function D(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(D=function(){return!!t})()}function V(t){return V=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},V(t)}function F(t,e){return F=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},F(t,e)}function N(t){var e=function(t,e){if("object"!=B(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=B(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==B(e)?e:e+""}var H=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,l=new Array(i),c=0;c<i;c++)l[c]=arguments[c];return r=t=I(this,e,[].concat(l)),o=[],(n=N(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&F(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval)return this.setResult(e.getResultFromBatch(this.prices),r)}}],o=[{key:"getResultFromBatch",value:function(t){return t.reduce((function(t,e){return t.plus(e)}),new p("0")).div(t.length||1)}}],n&&C(r.prototype,n),o&&C(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(x);function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}function q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,K(n.key),n)}}function U(t,e,r){return e=W(e),function(t,e){if(e&&("object"==L(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,G()?Reflect.construct(e,r||[],W(t).constructor):e.apply(t,r))}function G(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(G=function(){return!!t})()}function W(t){return W=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},W(t)}function $(t,e){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$(t,e)}function z(t,e,r){return(e=K(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function K(t){var e=function(t,e){if("object"!=L(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=L(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==L(e)?e:e+""}var J=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),z(r=U(this,e,[t]),"interval",void 0),z(r,"indicator",void 0),z(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new H(t),r.smoothingFactor=new p(1).div(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t,e);if(e&&this.previousResult){var n=new p(t).minus(this.previousResult).mul(this.smoothingFactor);return this.setResult(n.plus(this.previousResult),e)}if(!e&&this.result){var o=new p(t).minus(this.result).mul(this.smoothingFactor);return this.setResult(o.plus(this.result),e)}if(void 0===this.result&&r)return this.setResult(r,e)}}],n&&q(r.prototype,n),o&&q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(x);function Q(t){return t.reduce((function(t,e){return t.add(e)}),new p(0)).div(t.length||1)}function X(t){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},X(t)}function Y(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,tt(n.key),n)}}function Z(t,e,r){return(e=tt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function tt(t){var e=function(t,e){if("object"!=X(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=X(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==X(e)?e:e+""}var et=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),Z(this,"interval",void 0),Z(this,"deviationMultiplier",void 0),Z(this,"prices",[]),Z(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){if(this.prices.push(new p(t)),this.prices.length>this.interval){this.prices.shift();var e=H.getResultFromBatch(this.prices),r=function(t,e){var r=e||Q(t);return Q(t.map((function(t){return new p(t).sub(r).pow(2)}))).sqrt()}(this.prices,e);return this.result={lower:e.sub(r.times(this.deviationMultiplier)),middle:e,upper:e.add(r.times(this.deviationMultiplier))}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}}])&&Y(t.prototype,e),r&&Y(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function rt(t){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rt(t)}function nt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,at(n.key),n)}}function ot(t,e,r){return e=lt(e),function(t,e){if(e&&("object"==rt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,it()?Reflect.construct(e,r||[],lt(t).constructor):e.apply(t,r))}function it(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(it=function(){return!!t})()}function lt(t){return lt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},lt(t)}function ct(t,e){return ct=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ct(t,e)}function ut(t,e,r){return(e=at(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function at(t){var e=function(t,e){if("object"!=rt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=rt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rt(e)?e:e+""}var st=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),ut(r=ot(this,e,[t]),"interval",void 0),ut(r,"pricesCounter",0),ut(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ct(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r?r&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++;var n=new p(t);return r&&this.previousResult?this.setResult(n.times(this.weightFactor).add(this.previousResult.times(1-this.weightFactor)),r):this.setResult(n.times(this.weightFactor).add((null!==(e=this.result)&&void 0!==e?e:n).times(1-this.weightFactor)),r)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new g;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&nt(r.prototype,n),o&&nt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(x);function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function ft(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vt(n.key),n)}}function pt(t,e,r){return(e=vt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vt(t){var e=function(t,e){if("object"!=ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ht(e)?e:e+""}var yt=function(){return t=function t(e){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),pt(this,"prices",[]),pt(this,"long",void 0),pt(this,"short",void 0),pt(this,"signal",void 0),pt(this,"result",void 0),this.long=new e.indicator(e.longInterval),this.short=new e.indicator(e.shortInterval),this.signal=new e.indicator(e.signalInterval)},e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new p(t);this.prices.length&&e?this.prices[this.prices.length-1]=r:this.prices.push(r);var n=this.short.update(r,e),o=this.long.update(r,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var i=n.sub(o),l=this.signal.update(i);return this.result={histogram:i.sub(l),macd:i,signal:l}}}},{key:"getResult",value:function(){if(!this.isStable||void 0===this.result)throw new g;return this.result}}],e&&ft(t.prototype,e),r&&ft(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function mt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function dt(t,e,r){return e=wt(e),function(t,e){if(e&&("object"==bt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,gt()?Reflect.construct(e,r||[],wt(t).constructor):e.apply(t,r))}function gt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(gt=function(){return!!t})()}function wt(t){return wt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},wt(t)}function Mt(t,e){return Mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mt(t,e)}function St(t,e,r){return(e=jt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jt(t){var e=function(t,e){if("object"!=bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bt(e)?e:e+""}var Ot=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),St(r=dt(this,e),"interval",void 0),St(r,"previousPrices",[]),St(r,"avgGain",void 0),St(r,"avgLoss",void 0),St(r,"maxValue",new p(100)),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Mt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=new p(t),n=new p(this.previousPrices[this.previousPrices.length-2]);if(r.gt(n)?(this.avgLoss.update(new p(0),e),this.avgGain.update(r.sub(n),e)):(this.avgLoss.update(n.sub(r),e),this.avgGain.update(new p(0),e)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(o.eq(0))return this.setResult(new p(100),e);var i=this.avgGain.getResult().div(o);return this.setResult(this.maxValue.minus(this.maxValue.div(i.add(1))),e)}}}}],n&&mt(r.prototype,n),o&&mt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(O);function Pt(t){return Pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pt(t)}var _t=function(t,e){for(var r=[],n=new st(e),o=t.length,i=0;i<o;i++){var l=null;n.update(t[i]);try{l=n.getResult()}catch(t){l=null}r.push(l)}return r};function Et(t){return Et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Et(t)}var kt=function(t,e){for(var r=[],n=new H(e),o=t.length,i=0;i<o;i++){var l=null;n.update(t[i]);try{l=n.getResult()}catch(t){l=null}r.push(l)}return r};function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Tt=function(t,e){t=t.filter((function(t){return t instanceof p})),e=e.filter((function(t){return t instanceof p}));var r=Math.min(t.length,e.length);t=t.slice(-r),e=e.slice(-r);var n=t.map((function(t,r){if(t.eq(e[r]))return"neutral";if(t.gt(e[r]))return"up";if(t.lt(e[r]))return"down";throw Error("undefined error in findCrosses")})),o=At(n),i=o.map((function(t){return t.length}));return o.map((function(t,e){var r=i[e];return t.map((function(t,e){var n=r-e;return"neutral"===t&&(n=0),"up"===t&&(n*=1),"down"===t&&(n*=-1),n})).reverse()})).flat()},At=function(t){return 0===t.length?[]:t.reduce((function(t,e,r,n){if(0===r)t.push([e]);else{var o=n[r-1],i=t[t.length-1];e!==o?t.push([e]):i.push(e)}return t}),[])},xt=function(t,e){for(var r=e.bollinger_bands_upper,n=e.bollinger_bands_lower,o=new Array(t.length),i=0;i<t.length;i++)if(null!=r[i]&&null!=n[i]&&null!=t[i]){var l=new p(r[i]),c=new p(n[i]),u=new p(t[i]),a=l.minus(c);o[i]=u.minus(c).div(a).times(100)}else o[i]=null;return o};function Bt(t){return Bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bt(t)}var Ct={getSMA:kt,getEMA:_t},It=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"SMA",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:14;if(t.length<e)return[];var o=[];e=parseInt(e),n=parseInt(n);for(var i=new Ot(e),l=t.length,c=0;c<l;c++){var u=null;i.update(t[c]);try{u=i.getResult()}catch(t){u=null}o.push(u)}o=o.filter((function(t){return t}));var a,s,h,f=(a={},s="rsi_".concat(e),h=o,(s=function(t){var e=function(t,e){if("object"!=Bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bt(e)?e:e+""}(s))in a?Object.defineProperty(a,s,{value:h,enumerable:!0,configurable:!0,writable:!0}):a[s]=h,a);if("string"==typeof r&&"number"==typeof n&&Ct.hasOwnProperty("get".concat(r))){var p=Ct["get".concat(r)](o,n);f["rsi_".concat(r,"_").concat(n)]=p,f["rsi_".concat(e,"_x_rsi_").concat(r,"_").concat(n)]=Tt(o,p)}return f};function Dt(t){return Dt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dt(t)}function Vt(t){return function(t){if(Array.isArray(t))return Ft(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ft(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ft(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Nt=function(t){if(!t||0===t.length)throw new Error("Bins array is empty or not provided");var e=t[0],r=t[0];return t.forEach((function(t){t.grossVolume>e.grossVolume&&(e=t),t.grossVolume<r.grossVolume&&(r=t)})),{high:e,low:r}},Ht=function(t,e,r){var n,o,i,l=new Date(t[r][t[r].length-1]),c=new Date(l);c.setDate(c.getDate()-e),c.setHours(0,0,0,0);for(var u=(n={open:[],high:[],low:[],close:[],volume:[]},i=[],(o=function(t){var e=function(t,e){if("object"!=Dt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Dt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dt(e)?e:e+""}(o=r))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,n),a=0;a<t[r].length;a++)new Date(t[r][a])>=c&&(u.open.push(t.open[a]),u.high.push(t.high[a]),u.low.push(t.low[a]),u.close.push(t.close[a]),u.volume.push(t.volume[a]),u[r].push(t[r][a]));return u};function Lt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var qt=function(t){var e=t.open,r=t.high,n=t.low,o=t.close,i=e.length;if(![e,r,n,o].every((function(t){return Array.isArray(t)&&t.length>1&&t.length===i})))return{pattern:Array(i).fill("Neutral"),name:Array(i).fill("No Pattern"),score:Array(i).fill(0)};for(var l=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-4;return Math.abs(t-e)<r},c=function(t){return t.close<t.open},u={bullish:[{name:"Marubozu",condition:function(t,e,r){return c(t)&&c(e)&&(n=r).close>n.open&&r>2*e;var n},score:2},{name:"Engulfing",condition:function(t,e){return e.open<t.close&&e.close>t.open&&e.low<t.low&&e.high>t.high},score:2},{name:"Kicker",condition:function(t,e){return e.open<t.open&&e.close>e.open&&t.close<t.open},score:2},{name:"Morning Star",condition:function(t,e,r){return t.close>t.open&&e.close<e.open&&r.close>e.open},score:3},{name:"Piercing Line",condition:function(t,e){return e.close>t.close&&e.open<t.open&&e.close>(t.open+t.close)/2},score:1},{name:"Belt Hold",condition:function(t,e){return e.open>t.open&&l(e.close,e.high)&&l(t.close,t.low)},score:1},{name:"Harami",condition:function(t,e){return e.open>t.close&&e.close<t.open&&e.open<t.open&&e.close>t.close},score:1},{name:"Doji",condition:function(t,e){return l(e.close,e.open)&&e.high-e.low>Math.abs(e.close-e.open)},score:0}],bearish:[{name:"Marubozu",condition:function(t,e){return l(e.open,e.high)&&l(e.close,e.low)},score:-2},{name:"Engulfing",condition:function(t,e){return e.open>t.close&&e.close<t.open&&e.high>t.high&&e.low<t.low},score:-2},{name:"Kicker",condition:function(t,e){return e.open>t.open&&e.close<e.open&&t.close>t.open},score:-2},{name:"Evening Star",condition:function(t,e,r){return t.close<t.open&&e.close>e.open&&r.close<e.open},score:-3},{name:"Dark Cloud Cover",condition:function(t,e){return e.close<t.close&&e.open>t.open&&e.close<(t.open+t.close)/2},score:-1},{name:"Belt Hold",condition:function(t,e){return e.open<t.open&&l(e.close,e.low)&&l(t.close,t.high)},score:-1},{name:"Harami",condition:function(t,e){return e.open<t.close&&e.close>t.open&&e.open>t.open&&e.close<t.close},score:-1},{name:"Doji",condition:function(t,e){return l(e.close,e.open)&&e.high-e.low>Math.abs(e.close-e.open)},score:0}]},a=function(t,e,r){var n,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Lt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Lt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return l=t.done,t},e:function(t){c=!0,i=t},f:function(){try{l||null==r.return||r.return()}finally{if(c)throw i}}}}(r);try{for(i.s();!(n=i.n()).done;){var l=n.value,c=l.name,u=l.condition,a=l.score;if(o){if(u(o,t,e))return{name:c,score:a}}else if(u(t,e))return{name:c,score:a}}}catch(t){i.e(t)}finally{i.f()}return null},s=["Neutral"],h=["No Pattern"],f=[0],p=2;p<i;p++){var v={open:e[p-1],high:r[p-1],low:n[p-1],close:o[p-1]},y={open:e[p],high:r[p],low:n[p],close:o[p]},b={open:e[p-2],high:r[p-2],low:n[p-2],close:o[p-2]},m=b?a(v,y,u.bullish,b)||a(v,y,u.bearish,b):a(v,y,u.bullish)||a(v,y,u.bearish);m?(s.push(m.score>0?"Bullish":"Bearish"),h.push(m.name),f.push(m.score)):(s.push("Neutral"),h.push("No Pattern"),f.push(0))}return{candle_pattern:s,candle_name:h,candle_score:f}};function Ut(t){return Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ut(t)}function Gt(t){return function(t){if(Array.isArray(t))return Wt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Wt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Wt(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function $t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,zt(n.key),n)}}function zt(t){var e=function(t,e){if("object"!=Ut(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ut(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ut(e)?e:e+""}var Kt=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=["open","high","low","close"];this.ohlcv={};for(var o=0,i=Object.keys(e);o<i.length;o++){var l=i[o];n.includes(l)&&(this.ohlcv[l]=e[l].slice(-r))}},(e=[{key:"init",value:function(){if(this.ohlcv.close.length<50)return console.log("PatternRecognizer requires at least 50 datapoints"),{chart_pattern:"Neutral",chart_score:0};for(var t=0,e=[{name:"Bullish Flag",condition:this.isBullishFlag.bind(this),score:2},{name:"Bearish Flag",condition:this.isBearishFlag.bind(this),score:-2},{name:"Bullish Pennant",condition:this.isBullishPennant.bind(this),score:2},{name:"Bearish Pennant",condition:this.isBearishPennant.bind(this),score:-2},{name:"Bearish Double Top",condition:this.isDoubleTop.bind(this),score:-1},{name:"Bullish Double Bottom",condition:this.isDoubleBottom.bind(this),score:1},{name:"Bearish Triple Top",condition:this.isTripleTop.bind(this),score:-1},{name:"Bullish Triple Bottom",condition:this.isTripleBottom.bind(this),score:1},{name:"Bearish Head And Shoulders",condition:this.isHeadAndShoulders.bind(this),score:-1},{name:"Bullish Inverse Head And Shoulders",condition:this.isInverseHeadAndShoulders.bind(this),score:1},{name:"Bearish Rising Wedge",condition:this.isRisingWedge.bind(this),score:-1},{name:"Bullish Falling Wedge",condition:this.isFallingWedge.bind(this),score:1},{name:"Bullish Triangle",condition:this.isBullishTriangle.bind(this),score:1},{name:"Bearish Triangle",condition:this.isBearishTriangle.bind(this),score:-1},{name:"Bullish Rectangle",condition:this.isBullishRectangle.bind(this),score:1},{name:"Bearish Rectangle",condition:this.isBearishRectangle.bind(this),score:-1}];t<e.length;t++){var r=e[t],n=r.name,o=r.condition,i=r.score;if(o())return{chart_pattern:n,chart_score:i}}return{chart_pattern:"Neutral",chart_score:0}}},{key:"isBullishFlag",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=(Math.floor(e/2),this.ohlcv.close[t-2*e]);if((this.ohlcv.close[t-e]-r)/r<.15)return!1;var n=this.ohlcv.close[t-e];if((n-this.ohlcv.close[t-1])/n>.05)return!1;for(var o=t-e;o<t-1;o++)if(this.ohlcv.high[o]>this.ohlcv.high[o+1]||this.ohlcv.low[o]>this.ohlcv.low[o+1])return!1;return!0}},{key:"isBearishFlag",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=(Math.floor(e/2),this.ohlcv.close[t-2*e]);if((r-this.ohlcv.close[t-e])/r<.15)return!1;var n=this.ohlcv.close[t-e];if((this.ohlcv.close[t-1]-n)/n>.05)return!1;for(var o=t-e;o<t-1;o++)if(this.ohlcv.high[o]<this.ohlcv.high[o+1]||this.ohlcv.low[o]<this.ohlcv.low[o+1])return!1;return!0}},{key:"isBullishPennant",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.floor(e/2),n=this.ohlcv.close[t-2*e];if((this.ohlcv.close[t-e]-n)/n<.15)return!1;var o=this.ohlcv.close[t-e];if((o-this.ohlcv.close[t-1])/o>.05)return!1;for(var i=t-r;i<t-1;i++)if(this.ohlcv.high[i]<this.ohlcv.high[i+1]&&this.ohlcv.low[i]<this.ohlcv.low[i+1]||this.ohlcv.high[i]>this.ohlcv.high[i+1]&&this.ohlcv.low[i]>this.ohlcv.low[i+1])return!1;return!0}},{key:"isBearishPennant",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.floor(e/2),n=this.ohlcv.close[t-2*e];if((n-this.ohlcv.close[t-e])/n<.15)return!1;var o=this.ohlcv.close[t-e];if((this.ohlcv.close[t-1]-o)/o>.05)return!1;for(var i=t-r;i<t-1;i++)if(this.ohlcv.high[i]>this.ohlcv.high[i+1]&&this.ohlcv.low[i]>this.ohlcv.low[i+1]||this.ohlcv.high[i]<this.ohlcv.high[i+1]&&this.ohlcv.low[i]<this.ohlcv.low[i+1])return!1;return!0}},{key:"isDoubleTop",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,Gt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Gt(this.ohlcv.close.slice(e)));if(r<=0||n<=0)return!1;var o=Math.min.apply(Math,Gt(this.ohlcv.close.slice(0,e))),i=Math.min.apply(Math,Gt(this.ohlcv.close.slice(e)));return!((r-o)/r<.1||(n-i)/n<.1)&&Math.abs(r-n)/r<.03}},{key:"isDoubleBottom",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.min.apply(Math,Gt(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,Gt(this.ohlcv.close.slice(e)));if(r<=0||n<=0)return!1;var o=Math.max.apply(Math,Gt(this.ohlcv.close.slice(0,e))),i=Math.max.apply(Math,Gt(this.ohlcv.close.slice(e)));return!((o-r)/r<.1||(i-n)/n<.1)&&Math.abs(r-n)/r<.03}},{key:"isTripleTop",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Gt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Gt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=(r-Math.min.apply(Math,Gt(this.ohlcv.close.slice(0,e))))/r,l=(n-Math.min.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))))/n,c=(o-Math.min.apply(Math,Gt(this.ohlcv.close.slice(2*e))))/o;return!(i<.1||l<.1||c<.1)&&Math.abs(r-n)/r<.03&&Math.abs(r-o)/r<.03}},{key:"isTripleBottom",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.min.apply(Math,Gt(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),o=Math.min.apply(Math,Gt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=(Math.max.apply(Math,Gt(this.ohlcv.close.slice(0,e)))-r)/r,l=(Math.max.apply(Math,Gt(this.ohlcv.close.slice(e,2*e)))-n)/n,c=(Math.max.apply(Math,Gt(this.ohlcv.close.slice(2*e)))-o)/o;return!(i<.1||l<.1||c<.1)&&Math.abs(r-n)/r<.03&&Math.abs(r-o)/r<.03}},{key:"isHeadAndShoulders",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Gt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Gt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=Math.min.apply(Math,Gt(this.ohlcv.close.slice(0,e))),l=Math.min.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),c=Math.min.apply(Math,Gt(this.ohlcv.close.slice(2*e))),u=(n-l)/n,a=(Math.max(i,c)-Math.min(i,c))/Math.min(i,c);return u>.15&&a<.03}},{key:"isInverseHeadAndShoulders",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.min.apply(Math,Gt(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),o=Math.min.apply(Math,Gt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=Math.max.apply(Math,Gt(this.ohlcv.close.slice(0,e))),l=Math.max.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),c=Math.max.apply(Math,Gt(this.ohlcv.close.slice(2*e))),u=(l-n)/n,a=(Math.min(i,c)-Math.max(i,c))/Math.max(i,c);return u>.15&&a<.03}},{key:"isRisingWedge",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Gt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Gt(this.ohlcv.close.slice(2*e))),i=Math.min.apply(Math,Gt(this.ohlcv.close.slice(0,e))),l=Math.min.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),c=Math.min.apply(Math,Gt(this.ohlcv.close.slice(2*e)));return r<n&&n<o&&i<l&&l<c}},{key:"isFallingWedge",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Gt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Gt(this.ohlcv.close.slice(2*e))),i=Math.min.apply(Math,Gt(this.ohlcv.close.slice(0,e))),l=Math.min.apply(Math,Gt(this.ohlcv.close.slice(e,2*e))),c=Math.min.apply(Math,Gt(this.ohlcv.close.slice(2*e)));return r>n&&n>o&&i>l&&l>c}},{key:"isBullishTriangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,Gt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Gt(this.ohlcv.high.slice(e))),o=Math.min.apply(Math,Gt(this.ohlcv.low.slice(0,e))),i=Math.min.apply(Math,Gt(this.ohlcv.low.slice(e)));return r>n&&o<i}},{key:"isBearishTriangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,Gt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Gt(this.ohlcv.high.slice(e)));return Math.min.apply(Math,Gt(this.ohlcv.low.slice(0,e)))<Math.min.apply(Math,Gt(this.ohlcv.low.slice(e)))&&r>n}},{key:"isBullishRectangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Gt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Gt(this.ohlcv.high.slice(e,2*e))),o=Math.max.apply(Math,Gt(this.ohlcv.high.slice(2*e))),i=Math.min.apply(Math,Gt(this.ohlcv.low.slice(0,e))),l=Math.min.apply(Math,Gt(this.ohlcv.low.slice(e,2*e))),c=Math.min.apply(Math,Gt(this.ohlcv.low.slice(2*e))),u=Math.abs(r-n)/r<.03&&Math.abs(n-o)/n<.03,a=Math.abs(i-l)/i<.03&&Math.abs(l-c)/l<.03;return u&&a}},{key:"isBearishRectangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Gt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Gt(this.ohlcv.high.slice(e,2*e))),o=Math.max.apply(Math,Gt(this.ohlcv.high.slice(2*e))),i=Math.min.apply(Math,Gt(this.ohlcv.low.slice(0,e))),l=Math.min.apply(Math,Gt(this.ohlcv.low.slice(e,2*e))),c=Math.min.apply(Math,Gt(this.ohlcv.low.slice(2*e))),u=Math.abs(r-n)/r<.03&&Math.abs(n-o)/n<.03,a=Math.abs(i-l)/i<.03&&Math.abs(l-c)/l<.03;return u&&a}}])&&$t(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Jt=["open","high","low","close","volume"];function Qt(t){return Qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qt(t)}function Xt(t){return function(t){if(Array.isArray(t))return te(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Zt(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,l,c=[],u=!0,a=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){a=!0,o=t}finally{try{if(!u&&null!=r.return&&(l=r.return(),Object(l)!==l))return}finally{if(a)throw o}}return c}}(t,e)||Zt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Zt(t,e){if(t){if("string"==typeof t)return te(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?te(t,e):void 0}}function te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ee(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,re(n.key),n)}}function re(t){var e=function(t,e){if("object"!=Qt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Qt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qt(e)?e:e+""}var ne=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.ChartPatterns=function(t){return new Kt(t).init()}},e=[{key:"init",value:function(t){return this.crossPairsArr=[],this.ohlcv=t.reduce((function(t,e){var r=e.open,n=e.high,o=e.low,i=e.close,l=e.volume,c=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.includes(r)||{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(e,Jt);t.open.push(new p(r)),t.high.push(new p(n)),t.low.push(new p(o)),t.close.push(new p(i)),t.volume.push(new p(l));for(var u=0,a=Object.keys(c);u<a.length;u++){var s=a[u];t[s]||(t[s]=[]),t[s].push(c[s])}return t}),{open:[],high:[],low:[],close:[],volume:[]}),this}},{key:"getData",value:function(){var t=this.ohlcv,e=Object.keys(t),r=e.length;return t.open.map((function(n,o){for(var i={},l=0;l<r;l++){var c=e[l],u=t[c][o];i[c]=u instanceof p?u.toNumber():u}return i}))}},{key:"getLastValues",value:function(){for(var t={},e=0,r=Object.entries(this.ohlcv);e<r.length;e++){var n=Yt(r[e],2),o=n[0],i=n[1],l=i[i.length-1];t[o]=l instanceof p?l.toNumber():l}return t}},{key:"addObjectColumns",value:function(t){for(var e=0,r=Object.entries(t);e<r.length;e++){var n=Yt(r[e],2),o=n[0],i=n[1];this.addColumn(o,i)}}},{key:"addColumn",value:function(t,e){t=t.toLowerCase();var r=this.ohlcv.open.length;if(e.length>r)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");var n=new Array(r-e.length).fill(null);e=[].concat(Xt(n),Xt(e)),this.ohlcv[t]=e}},{key:"crossPairs",value:function(t){var e=function(t,e){var r,n={},o={},i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return l=t.done,t},e:function(t){c=!0,i=t},f:function(){try{l||null==r.return||r.return()}finally{if(c)throw i}}}}(e);try{for(i.s();!(r=i.n()).done;){var l=r.value,c=l.fast,u=l.slow;if(c&&u){"number"!=typeof u||n[u]||(n[u]=Array(t.close.length).fill(new p(u)));var a="".concat(c,"_x_").concat(u);if(t[c]&&t[u]){var s=Tt(t[c],t[u]);o[a]=s}else if(t[c]&&n[u]){var h=Tt(t[c],n[u]);o[a]=h}else console.log("Missing ohlcv properties for ".concat(c," or ").concat(u))}}}catch(t){i.e(t)}finally{i.f()}return o}(this.ohlcv,t);return e&&this.addObjectColumns(e),this}},{key:"ema",value:function(t){var e=function(t,e){var r=_t(t,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Pt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"ema_".concat(e),r)}(this.ohlcv.close,t);return e&&this.addObjectColumns(e),this}},{key:"sma",value:function(t){var e=function(t,e){var r=kt(t,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Et(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"sma_".concat(e),r)}(this.ohlcv.close,t);return e&&this.addObjectColumns(e),this}},{key:"macd",value:function(t,e,r){var n=function(t,e,r,n){var o=Math.max(e,r,n);return function(t){for(var e=[],r=[],n=[],o=new yt({indicator:st,shortInterval:arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,longInterval:arguments.length>2&&void 0!==arguments[2]?arguments[2]:26,signalInterval:arguments.length>3&&void 0!==arguments[3]?arguments[3]:9}),i=t.length,l=0;l<i;l++){var c={};o.update(t[l]);try{c=o.getResult()}catch(t){c={macd:null,signal:null,histogram:null}}e.push(c.macd),r.push(c.signal),n.push(c.histogram)}return{macd_diff:e,macd_dea:r,macd_histogram:n,macd_diff_x_macd_dea:Tt(e,r)}}(t.slice(-3*o),e,r,n)}(this.ohlcv.close,t,e,r);return n&&this.addObjectColumns(n),this}},{key:"bollingerBands",value:function(t,e){var r=function(t,e,r){return function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=t.length,o={bollinger_bands_upper:[],bollinger_bands_middle:[],bollinger_bands_lower:[]},i=new et(e,r),l=0;l<n;l++){var c={};i.update(t[l]);try{c=i.getResult()}catch(t){c={upper:null,middle:null,lower:null}}o.bollinger_bands_upper.push(c.upper),o.bollinger_bands_middle.push(c.middle),o.bollinger_bands_lower.push(c.lower)}var u=o.bollinger_bands_upper,a=o.bollinger_bands_middle,s=o.bollinger_bands_lower;return{bollinger_bands_upper:u,bollinger_bands_middle:a,bollinger_bands_lower:s,bollinger_bands_range:xt(t,{bollinger_bands_upper:u,bollinger_bands_lower:s})}}(t.slice(-3*e),e,r)}(this.ohlcv.close,t,e);return r&&this.addObjectColumns(r),this}},{key:"rsi",value:function(t,e,r){var n=function(t,e,r,n){var o=t.slice(-3*e);return"number"==typeof e&&void 0===n&&(n=e),It(o,e,r,n)}(this.ohlcv.close,t,e,r);return n&&this.addObjectColumns(n),this}},{key:"candles",value:function(){var t,e=(t=this.ohlcv,qt(t));return e&&this.addObjectColumns(e),this}},{key:"volumeProfile",value:function(t,e,r){var n=function(t,e){var r=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,r=t.open,n=t.high,o=t.low,i=t.close,l=t.volume,c=Math.min.apply(Math,Vt(o)),u=(Math.max.apply(Math,Vt(n))-c)/e,a={upVolume:0,downVolume:0,grossVolume:0},s=Array.from({length:e},(function(t,e){return{price:c+u*e,upVolume:0,downVolume:0,grossVolume:0}})),h=1/u,f=0;f<i.length;f++)for(var p=i[f],v=r[f],y=n[f],b=o[f],m=l[f],d=p>=v?m:0,g=p<v?m:0,w=Math.max(0,Math.floor((b-c)*h)),M=Math.min(e,Math.ceil((y-c)*h)),S=w;S<M;S++)s[S].upVolume+=d,s[S].downVolume+=g,s[S].grossVolume+=d+g;for(var j=0,O=s;j<O.length;j++){var P=O[j],_=P.upVolume,E=P.downVolume,k=P.grossVolume;a.upVolume+=_,a.downVolume+=E,a.grossVolume+=k}return{bins:s,nodes:Nt(s)}}(Ht(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,arguments.length>3?arguments[3]:void 0),e);return{volume_profile_high:[r.nodes.high.price],volume_profile_low:[r.nodes.low.price]}}(this.ohlcv,t,e,r);return n&&this.addObjectColumns(n),this}}],e&&ee(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
1
+ var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{t.r(e),t.d(e,{default:()=>Ye});var r=1e6,n="[big.js] ",i=n+"Invalid ",o=i+"decimal places",s=i+"rounding mode",l=n+"Division by zero",u={},a=void 0,c=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function h(t,e,r,n){var i=t.c;if(r===a&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(s);if(e<1)n=3===r&&(n||!!i[0])||0===e&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(n||i[1]!==a))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=1===r&&i[e]>=5||2===r&&(i[e]>5||5===i[e]&&(n||i[e+1]!==a||1&i[e-1]))||3===r&&(n||!!i[0]),i.length=e,n)for(;++i[--e]>9;)if(i[e]=0,0===e){++t.e,i.unshift(1);break}for(e=i.length;!i[--e];)i.pop()}return t}function f(t,e,r){var n=t.e,i=t.c.join(""),o=i.length;if(e)i=i.charAt(0)+(o>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+="0";else n<o&&(i=i.slice(0,n)+"."+i.slice(n));else o>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}u.abs=function(){var t=new this.constructor(this);return t.s=1,t},u.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,s=t.s,l=r.e,u=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(e=o<0,l!=u)return l>u^e?1:-1;for(s=(l=n.length)<(u=i.length)?l:u,o=-1;++o<s;)if(n[o]!=i[o])return n[o]>i[o]^e?1:-1;return l==u?0:l>u^e?1:-1},u.div=function(t){var e=this,n=e.constructor,i=e.c,s=(t=new n(t)).c,u=e.s==t.s?1:-1,c=n.DP;if(c!==~~c||c<0||c>r)throw Error(o);if(!s[0])throw Error(l);if(!i[0])return t.s=u,t.c=[t.e=0],t;var f,p,v,y,d,m=s.slice(),b=f=s.length,g=i.length,w=i.slice(0,f),M=w.length,S=t,O=S.c=[],j=0,P=c+(S.e=e.e-t.e)+1;for(S.s=u,u=P<0?0:P,m.unshift(0);M++<f;)w.push(0);do{for(v=0;v<10;v++){if(f!=(M=w.length))y=f>M?1:-1;else for(d=-1,y=0;++d<f;)if(s[d]!=w[d]){y=s[d]>w[d]?1:-1;break}if(!(y<0))break;for(p=M==f?s:m;M;){if(w[--M]<p[M]){for(d=M;d&&!w[--d];)w[d]=9;--w[d],w[M]+=10}w[M]-=p[M]}for(;!w[0];)w.shift()}O[j++]=y?v:++v,w[0]&&y?w[M]=i[b]||0:w=[i[b]]}while((b++<g||w[0]!==a)&&u--);return O[0]||1==j||(O.shift(),S.e--,P--),j>P&&h(S,P,n.RM,w[0]!==a),S},u.eq=function(t){return 0===this.cmp(t)},u.gt=function(t){return this.cmp(t)>0},u.gte=function(t){return this.cmp(t)>-1},u.lt=function(t){return this.cmp(t)<0},u.lte=function(t){return this.cmp(t)<1},u.minus=u.sub=function(t){var e,r,n,i,o=this,s=o.constructor,l=o.s,u=(t=new s(t)).s;if(l!=u)return t.s=-u,o.plus(t);var a=o.c.slice(),c=o.e,h=t.c,f=t.e;if(!a[0]||!h[0])return h[0]?t.s=-u:a[0]?t=new s(o):t.s=1,t;if(l=c-f){for((i=l<0)?(l=-l,n=a):(f=c,n=h),n.reverse(),u=l;u--;)n.push(0);n.reverse()}else for(r=((i=a.length<h.length)?a:h).length,l=u=0;u<r;u++)if(a[u]!=h[u]){i=a[u]<h[u];break}if(i&&(n=a,a=h,h=n,t.s=-t.s),(u=(r=h.length)-(e=a.length))>0)for(;u--;)a[e++]=0;for(u=e;r>l;){if(a[--r]<h[r]){for(e=r;e&&!a[--e];)a[e]=9;--a[e],a[r]+=10}a[r]-=h[r]}for(;0===a[--u];)a.pop();for(;0===a[0];)a.shift(),--f;return a[0]||(t.s=1,a=[f=0]),t.c=a,t.e=f,t},u.mod=function(t){var e,r=this,n=r.constructor,i=r.s,o=(t=new n(t)).s;if(!t.c[0])throw Error(l);return r.s=t.s=1,e=1==t.cmp(r),r.s=i,t.s=o,e?new n(r):(i=n.DP,o=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=o,this.minus(r.times(t)))},u.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},u.plus=u.add=function(t){var e,r,n,i=this,o=i.constructor;if(t=new o(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var s=i.e,l=i.c,u=t.e,a=t.c;if(!l[0]||!a[0])return a[0]||(l[0]?t=new o(i):t.s=i.s),t;if(l=l.slice(),e=s-u){for(e>0?(u=s,n=a):(e=-e,n=l),n.reverse();e--;)n.push(0);n.reverse()}for(l.length-a.length<0&&(n=a,a=l,l=n),e=a.length,r=0;e;l[e]%=10)r=(l[--e]=l[e]+a[e]+r)/10|0;for(r&&(l.unshift(r),++u),e=l.length;0===l[--e];)l.pop();return t.c=l,t.e=u,t},u.pow=function(t){var e=this,r=new e.constructor("1"),n=r,o=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(i+"exponent");for(o&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return o?r.div(n):n},u.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(i+"precision");return h(new this.constructor(this),t,e)},u.round=function(t,e){if(t===a)t=0;else if(t!==~~t||t<-r||t>r)throw Error(o);return h(new this.constructor(this),t+this.e+1,e)},u.sqrt=function(){var t,e,r,i=this,o=i.constructor,s=i.s,l=i.e,u=new o("0.5");if(!i.c[0])return new o(i);if(s<0)throw Error(n+"No square root");0===(s=Math.sqrt(i+""))||s===1/0?((e=i.c.join("")).length+l&1||(e+="0"),l=((l+1)/2|0)-(l<0||1&l),t=new o(((s=Math.sqrt(e))==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+l)):t=new o(s+""),l=t.e+(o.DP+=4);do{r=t,t=u.times(r.plus(i.div(r)))}while(r.c.slice(0,l).join("")!==t.c.slice(0,l).join(""));return h(t,(o.DP-=4)+t.e+1,o.RM)},u.times=u.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,s=i.length,l=o.length,u=r.e,a=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=u+a,s<l&&(e=i,i=o,o=e,a=s,s=l,l=a),e=new Array(a=s+l);a--;)e[a]=0;for(u=l;u--;){for(l=0,a=s+u;a>u;)l=e[a]+o[u]*i[a-u-1]+l,e[a--]=l%10,l=l/10|0;e[a]=l}for(l?++t.e:e.shift(),u=e.length;!e[--u];)e.pop();return t.c=e,t},u.toExponential=function(t,e){var n=this,i=n.c[0];if(t!==a){if(t!==~~t||t<0||t>r)throw Error(o);for(n=h(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return f(n,!0,!!i)},u.toFixed=function(t,e){var n=this,i=n.c[0];if(t!==a){if(t!==~~t||t<0||t>r)throw Error(o);for(t=t+(n=h(new n.constructor(n),t+n.e+1,e)).e+1;n.c.length<t;)n.c.push(0)}return f(n,!1,!!i)},u[Symbol.for("nodejs.util.inspect.custom")]=u.toJSON=u.toString=function(){var t=this,e=t.constructor;return f(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},u.toNumber=function(){var t=Number(f(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},u.toPrecision=function(t,e){var n=this,o=n.constructor,s=n.c[0];if(t!==a){if(t!==~~t||t<1||t>r)throw Error(i+"precision");for(n=h(new o(n),t,e);n.c.length<t;)n.c.push(0)}return f(n,t<=n.e||n.e<=o.NE||n.e>=o.PE,!!s)},u.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return f(t,t.e<=e.NE||t.e>=e.PE,!0)};const p=function t(){function e(r){var n=this;if(!(n instanceof e))return r===a?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(i+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!c.test(e))throw Error(i+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),o=e.length,n=0;n<o&&"0"==e.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==e.charAt(--o););for(t.e=r-n-1,t.c=[],r=0;n<=o;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=u,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(d())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&m(i,r.prototype),i}(t,arguments,b(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),m(r,t)},y(t)}function d(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(d=function(){return!!t})()}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}function b(t){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},b(t)}var g=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=b(e),function(t,e){if(e&&("object"==v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,d()?Reflect.construct(e,r||[],b(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(y(Error));function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function M(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function S(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,P(n.key),n)}}function O(t,e,r){return e&&S(t.prototype,e),r&&S(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function j(t,e,r){return(e=P(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=w(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==w(e)?e:e+""}var _=function(){return O((function t(){M(this,t),j(this,"previousHighest",void 0),j(this,"highest",void 0),j(this,"previousLowest",void 0),j(this,"lowest",void 0),j(this,"previousResult",void 0),j(this,"result",void 0)}),[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t.gt(this.highest)?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t.lt(this.lowest)?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])}(),E=function(){return O((function t(){M(this,t),j(this,"previousHighest",void 0),j(this,"highest",void 0),j(this,"previousLowest",void 0),j(this,"lowest",void 0),j(this,"previousResult",void 0),j(this,"result",void 0)}),[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])}();function R(t){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(t)}function k(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function B(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,F(n.key),n)}}function T(t,e,r){return e&&B(t.prototype,e),r&&B(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function x(t,e,r){return e=C(e),function(t,e){if(e&&("object"==R(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,A()?Reflect.construct(e,r||[],C(t).constructor):e.apply(t,r))}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function C(t){return C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},C(t)}function I(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&H(t,e)}function H(t,e){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},H(t,e)}function D(t,e,r){return(e=F(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function F(t){var e=function(t,e){if("object"!=R(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=R(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==R(e)?e:e+""}var V=function(t){function e(t){var r;return k(this,e),D(r=x(this,e),"interval",void 0),r.interval=t,r}return I(e,t),T(e,[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])}(_),L=function(t){function e(t){var r;return k(this,e),D(r=x(this,e),"interval",void 0),r.interval=t,r}return I(e,t),T(e,[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])}(E);function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function G(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,X(n.key),n)}}function U(t,e,r){return e&&q(t.prototype,e),r&&q(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function W(t,e,r){return e=K(e),function(t,e){if(e&&("object"==N(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,$()?Reflect.construct(e,r||[],K(t).constructor):e.apply(t,r))}function $(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return($=function(){return!!t})()}function K(t){return K=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},K(t)}function z(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&J(t,e)}function J(t,e){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},J(t,e)}function Q(t,e,r){return(e=X(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function X(t){var e=function(t,e){if("object"!=N(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=N(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==N(e)?e:e+""}var Y=function(t){function e(){var t;G(this,e);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return Q(t=W(this,e,[].concat(n)),"prices",[]),t}return z(e,t),U(e,[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval)return this.setResult(e.getResultFromBatch(this.prices),r)}}],[{key:"getResultFromBatch",value:function(t){return t.reduce((function(t,e){return t.plus(e)}),new p("0")).div(t.length||1)}}])}(V),Z=function(t){function e(){var t;G(this,e);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return Q(t=W(this,e,[].concat(n)),"prices",[]),t}return z(e,t),U(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}])}(L);function tt(t){return tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tt(t)}function et(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function rt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ct(n.key),n)}}function nt(t,e,r){return e&&rt(t.prototype,e),r&&rt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function it(t,e,r){return e=st(e),function(t,e){if(e&&("object"==tt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ot()?Reflect.construct(e,r||[],st(t).constructor):e.apply(t,r))}function ot(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ot=function(){return!!t})()}function st(t){return st=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},st(t)}function lt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ut(t,e)}function ut(t,e){return ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ut(t,e)}function at(t,e,r){return(e=ct(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ct(t){var e=function(t,e){if("object"!=tt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=tt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==tt(e)?e:e+""}var ht=function(t){function e(t){var r;return et(this,e),at(r=it(this,e,[t]),"interval",void 0),at(r,"indicator",void 0),at(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new Y(t),r.smoothingFactor=new p(1).div(r.interval),r}return lt(e,t),nt(e,[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t,e);if(e&&this.previousResult){var n=new p(t).minus(this.previousResult).mul(this.smoothingFactor);return this.setResult(n.plus(this.previousResult),e)}if(!e&&this.result){var i=new p(t).minus(this.result).mul(this.smoothingFactor);return this.setResult(i.plus(this.result),e)}if(void 0===this.result&&r)return this.setResult(r,e)}}])}(V),ft=function(t){function e(t){var r;return et(this,e),at(r=it(this,e),"interval",void 0),at(r,"indicator",void 0),at(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new Z(t),r.smoothingFactor=1/r.interval,r}return lt(e,t),nt(e,[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var i=(t-this.result)*this.smoothingFactor;return this.setResult(i+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}])}(E);function pt(t){return t.reduce((function(t,e){return t.add(e)}),new p(0)).div(t.length||1)}function vt(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}function yt(t){return yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yt(t)}function dt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function mt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,wt(n.key),n)}}function bt(t,e,r){return e&&mt(t.prototype,e),r&&mt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function gt(t,e,r){return(e=wt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function wt(t){var e=function(t,e){if("object"!=yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}var Mt=function(){return bt((function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;dt(this,t),gt(this,"interval",void 0),gt(this,"deviationMultiplier",void 0),gt(this,"prices",[]),gt(this,"result",void 0),this.interval=e,this.deviationMultiplier=r}),[{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){if(this.prices.push(new p(t)),this.prices.length>this.interval){this.prices.shift();var e=Y.getResultFromBatch(this.prices),r=function(t,e){var r=e||pt(t);return pt(t.map((function(t){return new p(t).sub(r).pow(2)}))).sqrt()}(this.prices,e);return this.result={lower:e.sub(r.times(this.deviationMultiplier)),middle:e,upper:e.add(r.times(this.deviationMultiplier))}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}}])}(),St=function(){return bt((function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;dt(this,t),gt(this,"interval",void 0),gt(this,"deviationMultiplier",void 0),gt(this,"prices",[]),gt(this,"result",void 0),this.interval=e,this.deviationMultiplier=r}),[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=vt(this.prices),r=function(t,e){var r=e||vt(t),n=vt(t.map((function(t){return t-r})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,e);return this.result={lower:e-r*this.deviationMultiplier,middle:e,upper:e+r*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])}();function Ot(t){return Ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ot(t)}function jt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Pt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,At(n.key),n)}}function _t(t,e,r){return e&&Pt(t.prototype,e),r&&Pt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Et(t,e,r){return e=kt(e),function(t,e){if(e&&("object"==Ot(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Rt()?Reflect.construct(e,r||[],kt(t).constructor):e.apply(t,r))}function Rt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Rt=function(){return!!t})()}function kt(t){return kt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},kt(t)}function Bt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Tt(t,e)}function Tt(t,e){return Tt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Tt(t,e)}function xt(t,e,r){return(e=At(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function At(t){var e=function(t,e){if("object"!=Ot(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ot(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ot(e)?e:e+""}var Ct=function(t){function e(t){var r;return jt(this,e),xt(r=Et(this,e,[t]),"interval",void 0),xt(r,"pricesCounter",0),xt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return Bt(e,t),_t(e,[{key:"update",value:function(t){var e,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r?r&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++;var n=new p(t);return r&&this.previousResult?this.setResult(n.times(this.weightFactor).add(this.previousResult.times(1-this.weightFactor)),r):this.setResult(n.times(this.weightFactor).add((null!==(e=this.result)&&void 0!==e?e:n).times(1-this.weightFactor)),r)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new g;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}])}(V),It=function(t){function e(t){var r;return jt(this,e),xt(r=Et(this,e,[t]),"interval",void 0),xt(r,"pricesCounter",0),xt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return Bt(e,t),_t(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?e&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,e&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),e):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),e)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new g;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}])}(L);function Ht(t){return Ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ht(t)}function Dt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ft(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Nt(n.key),n)}}function Vt(t,e,r){return e&&Ft(t.prototype,e),r&&Ft(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Lt(t,e,r){return(e=Nt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Nt(t){var e=function(t,e){if("object"!=Ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ht(e)?e:e+""}var Gt=function(){return Vt((function t(e){Dt(this,t),Lt(this,"prices",[]),Lt(this,"long",void 0),Lt(this,"short",void 0),Lt(this,"signal",void 0),Lt(this,"result",void 0),this.long=new e.indicator(e.longInterval),this.short=new e.indicator(e.shortInterval),this.signal=new e.indicator(e.signalInterval)}),[{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new p(t);this.prices.length&&e?this.prices[this.prices.length-1]=r:this.prices.push(r);var n=this.short.update(r,e),i=this.long.update(r,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=n.sub(i),s=this.signal.update(o);return this.result={histogram:o.sub(s),macd:o,signal:s}}}},{key:"getResult",value:function(){if(!this.isStable||void 0===this.result)throw new g;return this.result}}])}(),qt=function(){return Vt((function t(e,r,n){Dt(this,t),Lt(this,"short",void 0),Lt(this,"long",void 0),Lt(this,"signal",void 0),Lt(this,"prices",[]),Lt(this,"result",void 0),this.short=e,this.long=r,this.signal=n}),[{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var i=r-n,o=this.signal.update(i,e);return this.result={histogram:i-o,macd:i,signal:o}}}}])}();function Ut(t){return Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ut(t)}function Wt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function $t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,te(n.key),n)}}function Kt(t,e,r){return e&&$t(t.prototype,e),r&&$t(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function zt(t,e,r){return e=Qt(e),function(t,e){if(e&&("object"==Ut(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Jt()?Reflect.construct(e,r||[],Qt(t).constructor):e.apply(t,r))}function Jt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Jt=function(){return!!t})()}function Qt(t){return Qt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Qt(t)}function Xt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Yt(t,e)}function Yt(t,e){return Yt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Yt(t,e)}function Zt(t,e,r){return(e=te(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function te(t){var e=function(t,e){if("object"!=Ut(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ut(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ut(e)?e:e+""}var ee=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ht;return Wt(this,e),Zt(r=zt(this,e),"interval",void 0),Zt(r,"previousPrices",[]),Zt(r,"avgGain",void 0),Zt(r,"avgLoss",void 0),Zt(r,"maxValue",new p(100)),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return Xt(e,t),Kt(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=new p(t),n=new p(this.previousPrices[this.previousPrices.length-2]);if(r.gt(n)?(this.avgLoss.update(new p(0),e),this.avgGain.update(r.sub(n),e)):(this.avgLoss.update(n.sub(r),e),this.avgGain.update(new p(0),e)),this.avgGain.isStable){var i=this.avgLoss.getResult();if(i.eq(0))return this.setResult(new p(100),e);var o=this.avgGain.getResult().div(i);return this.setResult(this.maxValue.minus(this.maxValue.div(o.add(1))),e)}}}}])}(_),re=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ft;return Wt(this,e),Zt(r=zt(this,e),"interval",void 0),Zt(r,"previousPrices",[]),Zt(r,"avgGain",void 0),Zt(r,"avgLoss",void 0),Zt(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return Xt(e,t),Kt(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var i=this.avgLoss.getResult();if(0===i)return this.setResult(100,e);var o=this.avgGain.getResult()/i;return this.setResult(this.maxValue-this.maxValue/(o+1),e)}}}}])}(E);function ne(t){return ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ne(t)}var ie=function(t,e,r){if(void 0===r||void 0===t||void 0===e)throw Error("undefined param in getEMA");for(var n=[],i=r?new Ct(e):new It(e),o=t.length,s=0;s<o;s++){var l=null;i.update(t[s]);try{l=i.getResult()}catch(t){l=null}n.push(l)}return n};function oe(t){return oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},oe(t)}var se=function(t,e,r){if(void 0===r||void 0===t||void 0===e)throw Error("undefined param in getSMA");for(var n=[],i=r?new Y(e):new Z(e),o=t.length,s=0;s<o;s++){var l=null;i.update(t[s]);try{l=i.getResult()}catch(t){l=null}n.push(l)}return n};function le(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ue=function(t,e,r){t=t.filter((function(t){return t instanceof p||"number"==typeof t})),e=e.filter((function(t){return t instanceof p||"number"==typeof t}));var n=Math.min(t.length,e.length);t=t.slice(-n),e=e.slice(-n);var i=t.map((function(t,n){if(r){if(t.eq(e[n]))return"neutral";if(t.gt(e[n]))return"up";if(t.lt(e[n]))return"down"}else{if(t===e[n])return"neutral";if(t>e[n])return"up";if(t<e[n])return"down"}throw Error("undefined error in findCrosses")})),o=ae(i),s=o.map((function(t){return t.length}));return o.map((function(t,e){var r=s[e];return t.map((function(t,e){var n=r-e;return"neutral"===t&&(n=0),"up"===t&&(n*=1),"down"===t&&(n*=-1),n})).reverse()})).flat()},ae=function(t){return 0===t.length?[]:t.reduce((function(t,e,r,n){if(0===r)t.push([e]);else{var i=n[r-1],o=t[t.length-1];e!==i?t.push([e]):o.push(e)}return t}),[])},ce=function(t,e,r){for(var n=e.bollinger_bands_upper,i=e.bollinger_bands_lower,o=new Array(t.length),s=0;s<t.length;s++)if(null!=n[s]&&null!=i[s]&&null!=t[s])if(r){var l=new p(n[s]),u=new p(i[s]),a=new p(t[s]),c=l.minus(u);o[s]=a.minus(u).div(c).times(100)}else{var h=n[s]-i[s];o[s]=(t[s]-i[s])/h*100}else o[s]=null;return o};function he(t){return he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},he(t)}var fe={getSMA:se,getEMA:ie},pe=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"SMA",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:14,i=arguments.length>4?arguments[4]:void 0;if(t.length<e)return[];var o=[];e=parseInt(e),n=parseInt(n);for(var s=i?new ee(e):new re(e),l=t.length,u=0;u<l;u++){var a=null;s.update(t[u]);try{a=s.getResult()}catch(t){a=null}o.push(a)}o=o.filter((function(t){return t}));var c,h,f,p=(c={},h="rsi_".concat(e),f=o,(h=function(t){var e=function(t,e){if("object"!=he(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=he(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==he(e)?e:e+""}(h))in c?Object.defineProperty(c,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[h]=f,c);if("string"==typeof r&&"number"==typeof n&&fe.hasOwnProperty("get".concat(r))){var v=fe["get".concat(r)](o,n,i);p["rsi_".concat(r,"_").concat(n)]=v,p["rsi_".concat(e,"_x_rsi_").concat(r,"_").concat(n)]=ue(o,v,i)}return p};function ve(t){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ve(t)}function ye(t){return function(t){if(Array.isArray(t))return de(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return de(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?de(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function de(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var me=function(t){if(!t||0===t.length)throw new Error("Bins array is empty or not provided");var e=t[0],r=t[0];return t.forEach((function(t){t.grossVolume>e.grossVolume&&(e=t),t.grossVolume<r.grossVolume&&(r=t)})),{high:e,low:r}},be=function(t,e,r){var n,i,o,s=new Date(t[r][t[r].length-1]),l=new Date(s);l.setDate(l.getDate()-e),l.setHours(0,0,0,0);for(var u=(n={open:[],high:[],low:[],close:[],volume:[]},o=[],(i=function(t){var e=function(t,e){if("object"!=ve(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ve(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ve(e)?e:e+""}(i=r))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o,n),a=0;a<t[r].length;a++)new Date(t[r][a])>=l&&(u.open.push(t.open[a]),u.high.push(t.high[a]),u.low.push(t.low[a]),u.close.push(t.close[a]),u.volume.push(t.volume[a]),u[r].push(t[r][a]));return u};function ge(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return we(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?we(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}function we(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Me=[{candle_name:"isHammer",candle_score:1,isSingleCandle:!0},{candle_name:"isInvertedHammer",candle_score:1,isSingleCandle:!0},{candle_name:"isBullishHammer",candle_score:1,isSingleCandle:!0},{candle_name:"isBearishHammer",candle_score:-1,isSingleCandle:!0},{candle_name:"isBullishInvertedHammer",candle_score:1,isSingleCandle:!0},{candle_name:"isBearishInvertedHammer",candle_score:-1,isSingleCandle:!0},{candle_name:"isHangingMan",candle_score:-1,isSingleCandle:!1},{candle_name:"isShootingStar",candle_score:-1,isSingleCandle:!1},{candle_name:"isBullishEngulfing",candle_score:1,isSingleCandle:!1},{candle_name:"isBearishEngulfing",candle_score:-1,isSingleCandle:!1},{candle_name:"isBullishHarami",candle_score:1,isSingleCandle:!1},{candle_name:"isBearishHarami",candle_score:-1},{candle_name:"isBullishKicker",candle_score:1,isSingleCandle:!1},{candle_name:"isBearishKicker",candle_score:-1,isSingleCandle:!1}],Se=function(t){return Math.abs(t.open-t.close)},Oe=function(t){return t.high-Math.max(t.open,t.close)},je=function(t){return Math.min(t.open,t.close)-t.low},Pe=function(t){return t.open<=t.close?{bottom:t.open,top:t.close}:{bottom:t.close,top:t.open}},_e=function(t){return t.open<t.close},Ee=function(t){return t.open>t.close},Re=function(t,e){return Pe(t).top<=Pe(e).top&&Pe(t).bottom>=Pe(e).bottom},ke=function(t,e){return Pe(t).top<Pe(e).bottom},Be=function(t){return je(t)>2*Se(t)&&Oe(t)<Se(t)},Te=function(t){return Oe(t)>2*Se(t)&&je(t)<Se(t)},xe=function(t){return Ee(t)&&Be(t)},Ae=function(t){return Ee(t)&&Te(t)},Ce={isHammer:Be,isInvertedHammer:Te,isBullishHammer:function(t){return _e(t)&&Be(t)},isBearishHammer:xe,isBullishInvertedHammer:function(t){return _e(t)&&Te(t)},isBearishInvertedHammer:Ae,isHangingMan:function(t,e){return _e(t)&&xe(e)&&ke(t,e)},isShootingStar:function(t,e){return _e(t)&&Ae(e)&&ke(t,e)},isBullishEngulfing:function(t,e){return Ee(t)&&_e(e)&&Re(t,e)},isBearishEngulfing:function(t,e){return _e(t)&&Ee(e)&&Re(t,e)},isBullishHarami:function(t,e){return Ee(t)&&_e(e)&&Re(e,t)},isBearishHarami:function(t,e){return _e(t)&&Ee(e)&&Re(e,t)},isBullishKicker:function(t,e){return Ee(t)&&_e(e)&&ke(t,e)&&!(Be(e)||Te(e))},isBearishKicker:function(t,e){return _e(t)&&Ee(e)&&function(t,e){return Pe(t).bottom>Pe(e).top}(t,e)&&!(Be(e)||Te(e))}};function Ie(t){return Ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ie(t)}function He(t){return function(t){if(Array.isArray(t))return De(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return De(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?De(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function De(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Fe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ve(n.key),n)}}function Ve(t){var e=function(t,e){if("object"!=Ie(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ie(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ie(e)?e:e+""}var Le=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=["open","high","low","close"];this.ohlcv={};for(var i=0,o=Object.keys(e);i<o.length;i++){var s=o[i];n.includes(s)&&(this.ohlcv[s]=e[s].slice(-r))}},(e=[{key:"init",value:function(){if(this.ohlcv.close.length<50)return console.log("PatternRecognizer requires at least 50 datapoints"),{chart_pattern:"Neutral",chart_score:0};for(var t=0,e=[{name:"Bullish Flag",condition:this.isBullishFlag.bind(this),score:2},{name:"Bearish Flag",condition:this.isBearishFlag.bind(this),score:-2},{name:"Bullish Pennant",condition:this.isBullishPennant.bind(this),score:2},{name:"Bearish Pennant",condition:this.isBearishPennant.bind(this),score:-2},{name:"Bearish Double Top",condition:this.isDoubleTop.bind(this),score:-1},{name:"Bullish Double Bottom",condition:this.isDoubleBottom.bind(this),score:1},{name:"Bearish Triple Top",condition:this.isTripleTop.bind(this),score:-1},{name:"Bullish Triple Bottom",condition:this.isTripleBottom.bind(this),score:1},{name:"Bearish Head And Shoulders",condition:this.isHeadAndShoulders.bind(this),score:-1},{name:"Bullish Inverse Head And Shoulders",condition:this.isInverseHeadAndShoulders.bind(this),score:1},{name:"Bearish Rising Wedge",condition:this.isRisingWedge.bind(this),score:-1},{name:"Bullish Falling Wedge",condition:this.isFallingWedge.bind(this),score:1},{name:"Bullish Triangle",condition:this.isBullishTriangle.bind(this),score:1},{name:"Bearish Triangle",condition:this.isBearishTriangle.bind(this),score:-1},{name:"Bullish Rectangle",condition:this.isBullishRectangle.bind(this),score:1},{name:"Bearish Rectangle",condition:this.isBearishRectangle.bind(this),score:-1}];t<e.length;t++){var r=e[t],n=r.name,i=r.condition,o=r.score;if(i())return{chart_pattern:n,chart_score:o}}return{chart_pattern:"Neutral",chart_score:0}}},{key:"isBullishFlag",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=(Math.floor(e/2),this.ohlcv.close[t-2*e]);if((this.ohlcv.close[t-e]-r)/r<.15)return!1;var n=this.ohlcv.close[t-e];if((n-this.ohlcv.close[t-1])/n>.05)return!1;for(var i=t-e;i<t-1;i++)if(this.ohlcv.high[i]>this.ohlcv.high[i+1]||this.ohlcv.low[i]>this.ohlcv.low[i+1])return!1;return!0}},{key:"isBearishFlag",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=(Math.floor(e/2),this.ohlcv.close[t-2*e]);if((r-this.ohlcv.close[t-e])/r<.15)return!1;var n=this.ohlcv.close[t-e];if((this.ohlcv.close[t-1]-n)/n>.05)return!1;for(var i=t-e;i<t-1;i++)if(this.ohlcv.high[i]<this.ohlcv.high[i+1]||this.ohlcv.low[i]<this.ohlcv.low[i+1])return!1;return!0}},{key:"isBullishPennant",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.floor(e/2),n=this.ohlcv.close[t-2*e];if((this.ohlcv.close[t-e]-n)/n<.15)return!1;var i=this.ohlcv.close[t-e];if((i-this.ohlcv.close[t-1])/i>.05)return!1;for(var o=t-r;o<t-1;o++)if(this.ohlcv.high[o]<this.ohlcv.high[o+1]&&this.ohlcv.low[o]<this.ohlcv.low[o+1]||this.ohlcv.high[o]>this.ohlcv.high[o+1]&&this.ohlcv.low[o]>this.ohlcv.low[o+1])return!1;return!0}},{key:"isBearishPennant",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.floor(e/2),n=this.ohlcv.close[t-2*e];if((n-this.ohlcv.close[t-e])/n<.15)return!1;var i=this.ohlcv.close[t-e];if((this.ohlcv.close[t-1]-i)/i>.05)return!1;for(var o=t-r;o<t-1;o++)if(this.ohlcv.high[o]>this.ohlcv.high[o+1]&&this.ohlcv.low[o]>this.ohlcv.low[o+1]||this.ohlcv.high[o]<this.ohlcv.high[o+1]&&this.ohlcv.low[o]<this.ohlcv.low[o+1])return!1;return!0}},{key:"isDoubleTop",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,He(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,He(this.ohlcv.close.slice(e)));if(r<=0||n<=0)return!1;var i=Math.min.apply(Math,He(this.ohlcv.close.slice(0,e))),o=Math.min.apply(Math,He(this.ohlcv.close.slice(e)));return!((r-i)/r<.1||(n-o)/n<.1)&&Math.abs(r-n)/r<.03}},{key:"isDoubleBottom",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.min.apply(Math,He(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,He(this.ohlcv.close.slice(e)));if(r<=0||n<=0)return!1;var i=Math.max.apply(Math,He(this.ohlcv.close.slice(0,e))),o=Math.max.apply(Math,He(this.ohlcv.close.slice(e)));return!((i-r)/r<.1||(o-n)/n<.1)&&Math.abs(r-n)/r<.03}},{key:"isTripleTop",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,He(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,He(this.ohlcv.close.slice(e,2*e))),i=Math.max.apply(Math,He(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||i<=0)return!1;var o=(r-Math.min.apply(Math,He(this.ohlcv.close.slice(0,e))))/r,s=(n-Math.min.apply(Math,He(this.ohlcv.close.slice(e,2*e))))/n,l=(i-Math.min.apply(Math,He(this.ohlcv.close.slice(2*e))))/i;return!(o<.1||s<.1||l<.1)&&Math.abs(r-n)/r<.03&&Math.abs(r-i)/r<.03}},{key:"isTripleBottom",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.min.apply(Math,He(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,He(this.ohlcv.close.slice(e,2*e))),i=Math.min.apply(Math,He(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||i<=0)return!1;var o=(Math.max.apply(Math,He(this.ohlcv.close.slice(0,e)))-r)/r,s=(Math.max.apply(Math,He(this.ohlcv.close.slice(e,2*e)))-n)/n,l=(Math.max.apply(Math,He(this.ohlcv.close.slice(2*e)))-i)/i;return!(o<.1||s<.1||l<.1)&&Math.abs(r-n)/r<.03&&Math.abs(r-i)/r<.03}},{key:"isHeadAndShoulders",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,He(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,He(this.ohlcv.close.slice(e,2*e))),i=Math.max.apply(Math,He(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||i<=0)return!1;var o=Math.min.apply(Math,He(this.ohlcv.close.slice(0,e))),s=Math.min.apply(Math,He(this.ohlcv.close.slice(e,2*e))),l=Math.min.apply(Math,He(this.ohlcv.close.slice(2*e))),u=(n-s)/n,a=(Math.max(o,l)-Math.min(o,l))/Math.min(o,l);return u>.15&&a<.03}},{key:"isInverseHeadAndShoulders",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.min.apply(Math,He(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,He(this.ohlcv.close.slice(e,2*e))),i=Math.min.apply(Math,He(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||i<=0)return!1;var o=Math.max.apply(Math,He(this.ohlcv.close.slice(0,e))),s=Math.max.apply(Math,He(this.ohlcv.close.slice(e,2*e))),l=Math.max.apply(Math,He(this.ohlcv.close.slice(2*e))),u=(s-n)/n,a=(Math.min(o,l)-Math.max(o,l))/Math.max(o,l);return u>.15&&a<.03}},{key:"isRisingWedge",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,He(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,He(this.ohlcv.close.slice(e,2*e))),i=Math.max.apply(Math,He(this.ohlcv.close.slice(2*e))),o=Math.min.apply(Math,He(this.ohlcv.close.slice(0,e))),s=Math.min.apply(Math,He(this.ohlcv.close.slice(e,2*e))),l=Math.min.apply(Math,He(this.ohlcv.close.slice(2*e)));return r<n&&n<i&&o<s&&s<l}},{key:"isFallingWedge",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,He(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,He(this.ohlcv.close.slice(e,2*e))),i=Math.max.apply(Math,He(this.ohlcv.close.slice(2*e))),o=Math.min.apply(Math,He(this.ohlcv.close.slice(0,e))),s=Math.min.apply(Math,He(this.ohlcv.close.slice(e,2*e))),l=Math.min.apply(Math,He(this.ohlcv.close.slice(2*e)));return r>n&&n>i&&o>s&&s>l}},{key:"isBullishTriangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,He(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,He(this.ohlcv.high.slice(e))),i=Math.min.apply(Math,He(this.ohlcv.low.slice(0,e))),o=Math.min.apply(Math,He(this.ohlcv.low.slice(e)));return r>n&&i<o}},{key:"isBearishTriangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,He(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,He(this.ohlcv.high.slice(e)));return Math.min.apply(Math,He(this.ohlcv.low.slice(0,e)))<Math.min.apply(Math,He(this.ohlcv.low.slice(e)))&&r>n}},{key:"isBullishRectangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,He(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,He(this.ohlcv.high.slice(e,2*e))),i=Math.max.apply(Math,He(this.ohlcv.high.slice(2*e))),o=Math.min.apply(Math,He(this.ohlcv.low.slice(0,e))),s=Math.min.apply(Math,He(this.ohlcv.low.slice(e,2*e))),l=Math.min.apply(Math,He(this.ohlcv.low.slice(2*e))),u=Math.abs(r-n)/r<.03&&Math.abs(n-i)/n<.03,a=Math.abs(o-s)/o<.03&&Math.abs(s-l)/s<.03;return u&&a}},{key:"isBearishRectangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,He(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,He(this.ohlcv.high.slice(e,2*e))),i=Math.max.apply(Math,He(this.ohlcv.high.slice(2*e))),o=Math.min.apply(Math,He(this.ohlcv.low.slice(0,e))),s=Math.min.apply(Math,He(this.ohlcv.low.slice(e,2*e))),l=Math.min.apply(Math,He(this.ohlcv.low.slice(2*e))),u=Math.abs(r-n)/r<.03&&Math.abs(n-i)/n<.03,a=Math.abs(o-s)/o<.03&&Math.abs(s-l)/s<.03;return u&&a}}])&&Fe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Ne=["open","high","low","close","volume"];function Ge(t){return Ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ge(t)}function qe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ue(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?qe(Object(r),!0).forEach((function(e){We(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):qe(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function We(t,e,r){return(e=Xe(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $e(t){return function(t){if(Array.isArray(t))return Je(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ze(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ke(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,s,l=[],u=!0,a=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){a=!0,i=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(a)throw i}}return l}}(t,e)||ze(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ze(t,e){if(t){if("string"==typeof t)return Je(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Je(t,e):void 0}}function Je(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Qe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Xe(n.key),n)}}function Xe(t){var e=function(t,e){if("object"!=Ge(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ge(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ge(e)?e:e+""}var Ye=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.ChartPatterns=function(t){return new Le(t).init()}},e=[{key:"init",value:function(t){var e=this,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.precision=r,this.big=function(t){return e.precision?new p(t):t},this.crossPairsArr=[],this.inputOhlcv=t,this.ohlcv=t.reduce((function(t,r){var n=r.open,i=r.high,o=r.low,s=r.close,l=r.volume,u=function(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)r=o[n],e.includes(r)||{}.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}(r,Ne);t.open.push(e.big(n)),t.high.push(e.big(i)),t.low.push(e.big(o)),t.close.push(e.big(s)),t.volume.push(e.big(l));for(var a=0,c=Object.keys(u);a<c.length;a++){var h=c[a];t[h]||(t[h]=[]),t[h].push(u[h])}return t}),{open:[],high:[],low:[],close:[],volume:[]}),this.indicators={},this.isComputed=!1,this}},{key:"getData",value:function(){this.computeIndicators();var t=this.ohlcv,e=Object.keys(t),r=e.length;return t.open.map((function(n,i){for(var o={},s=0;s<r;s++){var l=e[s],u=t[l][i];o[l]=u instanceof p?u.toNumber():u}return o}))}},{key:"getLastValues",value:function(){this.computeIndicators();for(var t={},e=0,r=Object.entries(this.ohlcv);e<r.length;e++){var n=Ke(r[e],2),i=n[0],o=n[1],s=o[o.length-1];t[i]=s instanceof p?s.toNumber():s}return t}},{key:"computeIndicators",value:function(){if(!0===this.isComputed)return!1;this.isComputed;for(var t=0,e=Object.entries(this.indicators);t<e.length;t++){var r=Ke(e[t],2),n=r[0],i=r[1];this.addColumn(n,i)}return!0}},{key:"addColumn",value:function(t,e){t=t.toLowerCase();var r=this.ohlcv.open.length;if(e.length>r)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");var n=new Array(r-e.length).fill(null);e=[].concat($e(n),$e(e)),this.ohlcv[t]=e}},{key:"crossPairs",value:function(t){this.computeIndicators();var e=function(t,e){var r,n=t.ohlcv,i=t.precision,o={},s={},l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return le(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?le(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){l=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw o}}}}(e);try{for(l.s();!(r=l.n()).done;){var u=r.value,a=u.fast,c=u.slow;if(a&&c){"number"!=typeof c||o[c]||(o[c]=Array(n.close.length).fill(new p(c)));var h="".concat(a,"_x_").concat(c);if(n[a]&&n[c]){var f=ue(n[a],n[c],i);s[h]=f}else if(n[a]&&o[c]){var v=ue(n[a],o[c],i);s[h]=v}else console.log("Missing ohlcv properties for ".concat(a," or ").concat(c))}}}catch(t){l.e(t)}finally{l.f()}return s}(this,t);return this.indicators=Ue(Ue({},this.indicators),e),this}},{key:"ema",value:function(t){var e=function(t,e){var r=t.ohlcv,n=t.precision,i=r.close,o=ie(i,e,n);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=ne(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ne(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ne(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"ema_".concat(e),o)}(this,t);return this.indicators=Ue(Ue({},this.indicators),e),this}},{key:"sma",value:function(t){var e=function(t,e){var r=t.ohlcv,n=t.precision,i=r.close,o=se(i,e,n);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=oe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==oe(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"sma_".concat(e),o)}(this,t);return this.indicators=Ue(Ue({},this.indicators),e),this}},{key:"macd",value:function(t,e,r){var n=function(t,e,r,n){var i=t.ohlcv,o=t.precision,s=i.close,l=Math.max(e,r,n);return function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:26,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:9,i=arguments.length>4?arguments[4]:void 0,o=[],s=[],l=[],u=i?new Gt({indicator:Ct,shortInterval:e,longInterval:r,signalInterval:n}):new qt(new It(e),new It(r),new It(n)),a=t.length,c=0;c<a;c++){var h={};u.update(t[c]);try{h=u.getResult()}catch(t){h={macd:null,signal:null,histogram:null}}o.push(h.macd),s.push(h.signal),l.push(h.histogram)}return{macd_diff:o,macd_dea:s,macd_histogram:l,macd_diff_x_macd_dea:ue(o,s,i)}}(s.slice(-3*l),e,r,n,o)}(this,t,e,r);return this.indicators=Ue(Ue({},this.indicators),n),this}},{key:"bollingerBands",value:function(t,e){var r=function(t,e,r){var n=t.ohlcv,i=t.precision;return function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=arguments.length>3?arguments[3]:void 0,i=t.length,o={bollinger_bands_upper:[],bollinger_bands_middle:[],bollinger_bands_lower:[]},s=n?new Mt(e,r):new St(e,r),l=0;l<i;l++){var u={};s.update(t[l]);try{u=s.getResult()}catch(t){u={upper:null,middle:null,lower:null}}o.bollinger_bands_upper.push(u.upper),o.bollinger_bands_middle.push(u.middle),o.bollinger_bands_lower.push(u.lower)}var a=o.bollinger_bands_upper,c=o.bollinger_bands_middle,h=o.bollinger_bands_lower;return{bollinger_bands_upper:a,bollinger_bands_middle:c,bollinger_bands_lower:h,bollinger_bands_range:ce(t,{bollinger_bands_upper:a,bollinger_bands_lower:h},n)}}(n.close.slice(-3*e),e,r,i)}(this,t,e);return this.indicators=Ue(Ue({},this.indicators),r),this}},{key:"rsi",value:function(t,e,r){var n=function(t,e,r,n){var i=t.ohlcv,o=t.precision,s=i.close.slice(-3*e);return"number"==typeof e&&void 0===n&&(n=e),pe(s,e,r,n,o)}(this,t,e,r);return this.indicators=Ue(Ue({},this.indicators),n),this}},{key:"candles",value:function(){var t=function(t){t=t.slice(-2);for(var e=[],r=[],n=[],i=1;i<2;i++){var o,s=t[i],l=t[i-1],u="Neutral",a="None",c=0,h=ge(Me);try{for(h.s();!(o=h.n()).done;){var f=o.value,p=f.isSingleCandle,v=f.candle_name,y=f.candle_score;if(p?Ce[v](s):Ce[v](l,s))if(0===c)u=1===y?"Bullish":"Bearish",a=v,c=y;else{if(c!==y){u="Neutral",a="None",c=0;break}a+=",".concat(v)}}}catch(t){h.e(t)}finally{h.f()}e.push(u),r.push(a),n.push(c)}return{candle_pattern:e,candle_name:r,candle_score:n}}(this.inputOhlcv);return this.indicators=Ue(Ue({},this.indicators),t),this}},{key:"volumeProfile",value:function(t,e,r){var n=function(t,e){var r=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,r=t.open,n=t.high,i=t.low,o=t.close,s=t.volume,l=Math.min.apply(Math,ye(i)),u=(Math.max.apply(Math,ye(n))-l)/e,a={upVolume:0,downVolume:0,grossVolume:0},c=Array.from({length:e},(function(t,e){return{price:l+u*e,upVolume:0,downVolume:0,grossVolume:0}})),h=1/u,f=0;f<o.length;f++)for(var p=o[f],v=r[f],y=n[f],d=i[f],m=s[f],b=p>=v?m:0,g=p<v?m:0,w=Math.max(0,Math.floor((d-l)*h)),M=Math.min(e,Math.ceil((y-l)*h)),S=w;S<M;S++)c[S].upVolume+=b,c[S].downVolume+=g,c[S].grossVolume+=b+g;for(var O=0,j=c;O<j.length;O++){var P=j[O],_=P.upVolume,E=P.downVolume,R=P.grossVolume;a.upVolume+=_,a.downVolume+=E,a.grossVolume+=R}return{bins:c,nodes:me(c)}}(be(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,arguments.length>3?arguments[3]:void 0),e);return{volume_profile_high:[r.nodes.high.price],volume_profile_low:[r.nodes.low.price]}}(this.ohlcv,t,e,r);return this.indicators=Ue(Ue({},this.indicators),n),this}}],e&&Qe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
package/index.js CHANGED
@@ -6,52 +6,57 @@ import { rsi } from './src/oscillators/rsi.js'
6
6
  import { volumeProfile } from './src/studies/volumeProfile.js'
7
7
  import {crossPairs} from './src/studies/findCrosses.js'
8
8
  import { candles } from './src/studies/candles.js'
9
- import ChartPatterns from './src/studies/chart.js'
10
9
  import {Big} from 'trading-signals';
11
10
 
12
11
  export default class OHLCV_INDICATORS {
13
- constructor() {
14
- this.ChartPatterns = ohlcv => new ChartPatterns(ohlcv).init()
15
- }
16
-
17
- init(ohlcv) {
18
-
12
+ constructor({input, precision = true}) {
13
+ this.precision = precision
14
+ this.big = num => (this.precision) ? new Big(num) : num
19
15
  this.crossPairsArr = []
20
- this.ohlcv = ohlcv.reduce((acc, { open, high, low, close, volume, ...rest }) => {
21
- acc.open.push(new Big(open))
22
- acc.high.push(new Big(high))
23
- acc.low.push(new Big(low))
24
- acc.close.push(new Big(close))
25
- acc.volume.push(new Big(volume))
16
+ this.inputOhlcv = input
17
+
18
+ this.verticalOhlcv = input.reduce((acc, { open, high, low, close, volume, ...rest }) => {
19
+ acc.open.push(this.big(open))
20
+ acc.high.push(this.big(high))
21
+ acc.low.push(this.big(low))
22
+ acc.close.push(this.big(close))
23
+ acc.volume.push(this.big(volume))
26
24
  for (const key of Object.keys(rest)) {
27
25
  if (!acc[key]) acc[key] = [];
28
26
  acc[key].push(rest[key]);
29
27
  }
30
28
  return acc;
31
29
  }, { open: [], high: [], low: [], close: [], volume: [] })
32
-
33
-
34
- return this
30
+
31
+ this.indicators = {}
32
+ this.isComputed = false
33
+ return this
35
34
  }
36
35
 
37
36
  getData() {
38
37
 
39
-
40
- const {ohlcv} = this
41
- const keys = Object.keys(ohlcv)
38
+ this.computeIndicators()
39
+ const {verticalOhlcv, precision} = this
40
+ const keys = Object.keys(verticalOhlcv)
42
41
  const keysLength = keys.length
43
42
 
44
- return ohlcv.open.map((_, i) => {
43
+ return verticalOhlcv.open.map((_, i) => {
45
44
 
46
45
  const row = {}
47
46
 
48
47
  for(let x = 0; x < keysLength; x++)
49
48
  {
50
49
  const header = keys[x]
51
- const value = ohlcv[header][i]
52
-
53
-
54
- row[header] = (value instanceof Big) ? value.toNumber() : value
50
+ const value = verticalOhlcv[header][i]
51
+
52
+ if(precision)
53
+ {
54
+ row[header] = (value instanceof Big) ? value.toNumber() : value
55
+ }
56
+ else
57
+ {
58
+ row[header] = value
59
+ }
55
60
  }
56
61
 
57
62
  return row
@@ -59,29 +64,49 @@ export default class OHLCV_INDICATORS {
59
64
  }
60
65
  getLastValues(){
61
66
 
62
-
67
+ this.computeIndicators()
68
+ const {verticalOhlcv, precision} = this
63
69
  const output = {}
64
70
 
65
- for (const [k, arr] of Object.entries(this.ohlcv)) {
71
+ for (const [k, arr] of Object.entries(verticalOhlcv)) {
66
72
  let value = arr[arr.length - 1]
67
- output[k] = (value instanceof Big) ? value.toNumber(): value;
73
+
74
+ if(precision)
75
+ {
76
+ output[k] = (value instanceof Big) ? value.toNumber(): value
77
+ }
78
+ else
79
+ {
80
+ output[k] = value
81
+ }
82
+
68
83
  }
69
84
 
70
85
  return output
71
86
  }
72
87
 
73
- addObjectColumns(obj) {
88
+ computeIndicators() {
89
+
90
+ if(this.isComputed === true){
91
+ return false
92
+ }
93
+ else
94
+ {
95
+ this.isComputed === true
96
+ }
74
97
 
75
- for(const [key, arr] of Object.entries(obj))
98
+ for(const [key, arr] of Object.entries(this.indicators))
76
99
  {
77
100
  this.addColumn(key, arr)
78
101
  }
102
+
103
+ return true
79
104
  }
80
105
 
81
106
  addColumn(key, arr) {
82
107
 
83
108
  key = key.toLowerCase()
84
- const ohlcvLength = this.ohlcv.open.length;
109
+ const ohlcvLength = this.verticalOhlcv.open.length;
85
110
 
86
111
  if (arr.length > ohlcvLength) {
87
112
  throw new Error(`Invalid column data: The length of the new column exceeds the length of the OHLCV data`);
@@ -91,58 +116,39 @@ export default class OHLCV_INDICATORS {
91
116
  const nanArray = new Array(ohlcvLength - arr.length).fill(null)
92
117
  arr = [...nanArray, ...arr]
93
118
 
94
- this.ohlcv[key] = arr
119
+ this.verticalOhlcv[key] = arr
95
120
  }
96
121
 
97
122
  crossPairs(arr)
98
123
  {
99
- const {ohlcv} = this
100
- const result = crossPairs(ohlcv, arr)
124
+
125
+ this.computeIndicators()
101
126
 
102
- if(result)
103
- {
104
- this.addObjectColumns(result)
105
- }
127
+ const result = crossPairs(this, arr)
128
+ this.indicators = {...this.indicators, ...result}
106
129
 
107
130
  return this
108
131
  }
109
132
 
110
133
  ema(size) {
111
134
 
112
- const {close} = this.ohlcv
113
135
 
114
- const result = ema(close, size)
115
-
116
- if(result)
117
- {
118
- this.addObjectColumns(result)
119
- }
136
+ const result = ema(this, size)
137
+ this.indicators = {...this.indicators, ...result}
120
138
 
121
139
  return this
122
140
  }
123
141
  sma(size) {
124
142
 
125
- const {close} = this.ohlcv
126
-
127
- const result = sma(close, size)
128
-
129
- if(result)
130
- {
131
- this.addObjectColumns(result)
132
- }
143
+ const result = sma(this, size)
144
+ this.indicators = {...this.indicators, ...result}
133
145
 
134
146
  return this
135
147
  }
136
148
  macd(fastLine, slowLine, signalLine) {
137
149
 
138
- const {close} = this.ohlcv
139
-
140
- const result = macd(close, fastLine, slowLine, signalLine)
141
-
142
- if(result)
143
- {
144
- this.addObjectColumns(result)
145
- }
150
+ const result = macd(this, fastLine, slowLine, signalLine)
151
+ this.indicators = {...this.indicators, ...result}
146
152
 
147
153
  return this
148
154
 
@@ -150,55 +156,33 @@ export default class OHLCV_INDICATORS {
150
156
  bollingerBands(size, times)
151
157
  {
152
158
 
153
- const {close} = this.ohlcv
154
-
155
- const result = bollingerBands(close, size, times)
156
-
157
- if(result)
158
- {
159
- this.addObjectColumns(result)
160
- }
159
+ const result = bollingerBands(this, size, times)
160
+ this.indicators = {...this.indicators, ...result}
161
161
 
162
162
  return this
163
163
  }
164
164
  rsi(period, movingAverage, movingAveragePeriod)
165
165
  {
166
- const {close} = this.ohlcv
167
166
 
168
- const result = rsi(close, period, movingAverage, movingAveragePeriod)
169
-
170
- if(result)
171
- {
172
- this.addObjectColumns(result)
173
- }
167
+ const result = rsi(this, period, movingAverage, movingAveragePeriod)
168
+ this.indicators = {...this.indicators, ...result}
174
169
 
175
170
  return this
176
171
  }
177
172
  candles()
178
173
  {
179
-
180
- const {ohlcv} = this
181
-
182
- const result = candles(ohlcv)
183
-
184
- if(result)
185
- {
186
- this.addObjectColumns(result)
187
- }
174
+ const result = candles(this)
175
+ this.indicators = {...this.indicators, ...result}
188
176
 
189
177
  return this
190
178
  }
191
179
  volumeProfile(numBins, daysBack, targetDateKey)
192
180
  {
193
181
 
194
- const {ohlcv} = this
195
-
196
- const result = volumeProfile(ohlcv, numBins, daysBack, targetDateKey)
182
+ const {verticalOhlcv} = this
197
183
 
198
- if(result)
199
- {
200
- this.addObjectColumns(result)
201
- }
184
+ const result = volumeProfile(verticalOhlcv, numBins, daysBack, targetDateKey)
185
+ this.indicators = {...this.indicators, ...result}
202
186
 
203
187
  return this
204
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohlcv-indicators",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "description": "A JavaScript library featuring optimized trading indicators for OHLCV arrays [{open, high, low, close, value}]. This library is optimized for backtesting and trading bot development.",
5
5
  "main": "index.js",
6
6
  "type": "module",