ohlcv-indicators 1.4.1 → 1.4.2

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:()=>Ke});var r=1e6,n="[big.js] ",i=n+"Invalid ",o=i+"decimal places",u=i+"rounding mode",s=n+"Division by zero",c={},l=void 0,a=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(t,e,r,n){var i=t.c;if(r===l&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(u);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]!==l))),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]!==l||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 h(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}c.abs=function(){var t=new this.constructor(this);return t.s=1,t},c.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,u=t.s,s=r.e,c=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-u:0;if(o!=u)return o;if(e=o<0,s!=c)return s>c^e?1:-1;for(u=(s=n.length)<(c=i.length)?s:c,o=-1;++o<u;)if(n[o]!=i[o])return n[o]>i[o]^e?1:-1;return s==c?0:s>c^e?1:-1},c.div=function(t){var e=this,n=e.constructor,i=e.c,u=(t=new n(t)).c,c=e.s==t.s?1:-1,a=n.DP;if(a!==~~a||a<0||a>r)throw Error(o);if(!u[0])throw Error(s);if(!i[0])return t.s=c,t.c=[t.e=0],t;var h,p,v,y,d,b=u.slice(),m=h=u.length,g=i.length,w=i.slice(0,h),O=w.length,S=t,j=S.c=[],P=0,_=a+(S.e=e.e-t.e)+1;for(S.s=c,c=_<0?0:_,b.unshift(0);O++<h;)w.push(0);do{for(v=0;v<10;v++){if(h!=(O=w.length))y=h>O?1:-1;else for(d=-1,y=0;++d<h;)if(u[d]!=w[d]){y=u[d]>w[d]?1:-1;break}if(!(y<0))break;for(p=O==h?u:b;O;){if(w[--O]<p[O]){for(d=O;d&&!w[--d];)w[d]=9;--w[d],w[O]+=10}w[O]-=p[O]}for(;!w[0];)w.shift()}j[P++]=y?v:++v,w[0]&&y?w[O]=i[m]||0:w=[i[m]]}while((m++<g||w[0]!==l)&&c--);return j[0]||1==P||(j.shift(),S.e--,_--),P>_&&f(S,_,n.RM,w[0]!==l),S},c.eq=function(t){return 0===this.cmp(t)},c.gt=function(t){return this.cmp(t)>0},c.gte=function(t){return this.cmp(t)>-1},c.lt=function(t){return this.cmp(t)<0},c.lte=function(t){return this.cmp(t)<1},c.minus=c.sub=function(t){var e,r,n,i,o=this,u=o.constructor,s=o.s,c=(t=new u(t)).s;if(s!=c)return t.s=-c,o.plus(t);var l=o.c.slice(),a=o.e,f=t.c,h=t.e;if(!l[0]||!f[0])return f[0]?t.s=-c:l[0]?t=new u(o):t.s=1,t;if(s=a-h){for((i=s<0)?(s=-s,n=l):(h=a,n=f),n.reverse(),c=s;c--;)n.push(0);n.reverse()}else for(r=((i=l.length<f.length)?l:f).length,s=c=0;c<r;c++)if(l[c]!=f[c]){i=l[c]<f[c];break}if(i&&(n=l,l=f,f=n,t.s=-t.s),(c=(r=f.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;r>s;){if(l[--r]<f[r]){for(e=r;e&&!l[--e];)l[e]=9;--l[e],l[r]+=10}l[r]-=f[r]}for(;0===l[--c];)l.pop();for(;0===l[0];)l.shift(),--h;return l[0]||(t.s=1,l=[h=0]),t.c=l,t.e=h,t},c.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(s);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)))},c.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},c.plus=c.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 u=i.e,s=i.c,c=t.e,l=t.c;if(!s[0]||!l[0])return l[0]||(s[0]?t=new o(i):t.s=i.s),t;if(s=s.slice(),e=u-c){for(e>0?(c=u,n=l):(e=-e,n=s),n.reverse();e--;)n.push(0);n.reverse()}for(s.length-l.length<0&&(n=l,l=s,s=n),e=l.length,r=0;e;s[e]%=10)r=(s[--e]=s[e]+l[e]+r)/10|0;for(r&&(s.unshift(r),++c),e=s.length;0===s[--e];)s.pop();return t.c=s,t.e=c,t},c.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},c.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(i+"precision");return f(new this.constructor(this),t,e)},c.round=function(t,e){if(t===l)t=0;else if(t!==~~t||t<-r||t>r)throw Error(o);return f(new this.constructor(this),t+this.e+1,e)},c.sqrt=function(){var t,e,r,i=this,o=i.constructor,u=i.s,s=i.e,c=new o("0.5");if(!i.c[0])return new o(i);if(u<0)throw Error(n+"No square root");0===(u=Math.sqrt(i+""))||u===1/0?((e=i.c.join("")).length+s&1||(e+="0"),s=((s+1)/2|0)-(s<0||1&s),t=new o(((u=Math.sqrt(e))==1/0?"5e":(u=u.toExponential()).slice(0,u.indexOf("e")+1))+s)):t=new o(u+""),s=t.e+(o.DP+=4);do{r=t,t=c.times(r.plus(i.div(r)))}while(r.c.slice(0,s).join("")!==t.c.slice(0,s).join(""));return f(t,(o.DP-=4)+t.e+1,o.RM)},c.times=c.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,u=i.length,s=o.length,c=r.e,l=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=c+l,u<s&&(e=i,i=o,o=e,l=u,u=s,s=l),e=new Array(l=u+s);l--;)e[l]=0;for(c=s;c--;){for(s=0,l=u+c;l>c;)s=e[l]+o[c]*i[l-c-1]+s,e[l--]=s%10,s=s/10|0;e[l]=s}for(s?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},c.toExponential=function(t,e){var n=this,i=n.c[0];if(t!==l){if(t!==~~t||t<0||t>r)throw Error(o);for(n=f(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return h(n,!0,!!i)},c.toFixed=function(t,e){var n=this,i=n.c[0];if(t!==l){if(t!==~~t||t<0||t>r)throw Error(o);for(t=t+(n=f(new n.constructor(n),t+n.e+1,e)).e+1;n.c.length<t;)n.c.push(0)}return h(n,!1,!!i)},c[Symbol.for("nodejs.util.inspect.custom")]=c.toJSON=c.toString=function(){var t=this,e=t.constructor;return h(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},c.toNumber=function(){var t=Number(h(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},c.toPrecision=function(t,e){var n=this,o=n.constructor,u=n.c[0];if(t!==l){if(t!==~~t||t<1||t>r)throw Error(i+"precision");for(n=f(new o(n),t,e);n.c.length<t;)n.c.push(0)}return h(n,t<=n.e||n.e<=o.NE||n.e>=o.PE,!!u)},c.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return h(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===l?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(!a.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=c,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&&b(i,r.prototype),i}(t,arguments,m(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(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 b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function m(t){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},m(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=m(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||[],m(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&&b(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 O(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,_(n.key),n)}}function j(t,e,r){return e&&S(t.prototype,e),r&&S(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function P(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(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 E=function(){return j((function t(){O(this,t),P(this,"previousHighest",void 0),P(this,"highest",void 0),P(this,"previousLowest",void 0),P(this,"lowest",void 0),P(this,"previousResult",void 0),P(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)}}])}(),R=function(){return j((function t(){O(this,t),P(this,"previousHighest",void 0),P(this,"highest",void 0),P(this,"previousLowest",void 0),P(this,"lowest",void 0),P(this,"previousResult",void 0),P(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 k(t){return k="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},k(t)}function C(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function A(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,D(n.key),n)}}function M(t,e,r){return e&&A(t.prototype,e),r&&A(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function T(t,e,r){return e=B(e),function(t,e){if(e&&("object"==k(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,I()?Reflect.construct(e,r||[],B(t).constructor):e.apply(t,r))}function I(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(I=function(){return!!t})()}function B(t){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},B(t)}function H(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&&x(t,e)}function x(t,e){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},x(t,e)}function V(t,e,r){return(e=D(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function D(t){var e=function(t,e){if("object"!=k(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==k(e)?e:e+""}var F=function(t){function e(t){var r;return C(this,e),V(r=T(this,e),"interval",void 0),r.interval=t,r}return H(e,t),M(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),L=function(t){function e(t){var r;return C(this,e),V(r=T(this,e),"interval",void 0),r.interval=t,r}return H(e,t),M(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)}}])}(R);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 $(t,e,r){return e=z(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,K()?Reflect.construct(e,r||[],z(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 z(t){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},z(t)}function J(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&&Q(t,e)}function Q(t,e){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Q(t,e)}function W(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 W(t=$(this,e,[].concat(n)),"prices",[]),t}return J(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)}}])}(F),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 W(t=$(this,e,[].concat(n)),"prices",[]),t}return J(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,at(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=ut(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||[],ut(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 ut(t){return ut=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ut(t)}function st(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)}function ct(t,e){return ct=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ct(t,e)}function lt(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"!=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 ft=function(t){function e(t){var r;return et(this,e),lt(r=it(this,e,[t]),"interval",void 0),lt(r,"indicator",void 0),lt(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new Y(t),r.smoothingFactor=new p(1).div(r.interval),r}return st(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)}}])}(F),ht=function(t){function e(t){var r;return et(this,e),lt(r=it(this,e),"interval",void 0),lt(r,"indicator",void 0),lt(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new Z(t),r.smoothingFactor=1/r.interval,r}return st(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)}}])}(R);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 bt(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 mt(t,e,r){return e&&bt(t.prototype,e),r&&bt(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 Ot=function(){return mt((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 mt((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 jt(t){return jt="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},jt(t)}function Pt(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,It(n.key),n)}}function Et(t,e,r){return e&&_t(t.prototype,e),r&&_t(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Rt(t,e,r){return e=Ct(e),function(t,e){if(e&&("object"==jt(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,kt()?Reflect.construct(e,r||[],Ct(t).constructor):e.apply(t,r))}function kt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(kt=function(){return!!t})()}function Ct(t){return Ct=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ct(t)}function At(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)}function Mt(t,e){return Mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mt(t,e)}function Tt(t,e,r){return(e=It(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function It(t){var e=function(t,e){if("object"!=jt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=jt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jt(e)?e:e+""}var Bt=function(t){function e(t){var r;return Pt(this,e),Tt(r=Rt(this,e,[t]),"interval",void 0),Tt(r,"pricesCounter",0),Tt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return At(e,t),Et(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}}}])}(F),Ht=function(t){function e(t){var r;return Pt(this,e),Tt(r=Rt(this,e,[t]),"interval",void 0),Tt(r,"pricesCounter",0),Tt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return At(e,t),Et(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 xt(t){return xt="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},xt(t)}function Vt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Dt(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 Ft(t,e,r){return e&&Dt(t.prototype,e),r&&Dt(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"!=xt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=xt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xt(e)?e:e+""}var Gt=function(){return Ft((function t(e){Vt(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),u=this.signal.update(o);return this.result={histogram:o.sub(u),macd:o,signal:u}}}},{key:"getResult",value:function(){if(!this.isStable||void 0===this.result)throw new g;return this.result}}])}(),qt=function(){return Ft((function t(e,r,n){Vt(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 $t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Kt(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 zt(t,e,r){return e&&Kt(t.prototype,e),r&&Kt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Jt(t,e,r){return e=Wt(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,Qt()?Reflect.construct(e,r||[],Wt(t).constructor):e.apply(t,r))}function Qt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Qt=function(){return!!t})()}function Wt(t){return Wt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Wt(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]:ft;return $t(this,e),Zt(r=Jt(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),zt(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)}}}}])}(E),re=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ht;return $t(this,e),Zt(r=Jt(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),zt(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)}}}}])}(R);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 Bt(e):new Ht(e),o=t.length,u=0;u<o;u++){var s=null;i.update(t[u]);try{s=i.getResult()}catch(t){s=null}n.push(s)}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 ue=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,u=0;u<o;u++){var s=null;i.update(t[u]);try{s=i.getResult()}catch(t){s=null}n.push(s)}return n};function se(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 ce=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=le(i),u=o.map((function(t){return t.length}));return o.map((function(t,e){var r=u[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()},le=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}),[])},ae=function(t,e,r){for(var n=e.bollinger_bands_upper,i=e.bollinger_bands_lower,o=new Array(t.length),u=0;u<t.length;u++)if(null!=n[u]&&null!=i[u]&&null!=t[u])if(r){var s=new p(n[u]),c=new p(i[u]),l=new p(t[u]),a=s.minus(c);o[u]=l.minus(c).div(a).times(100)}else{var f=n[u]-i[u];o[u]=(t[u]-i[u])/f*100}else o[u]=null;return o};function fe(t){return fe="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},fe(t)}var he={getSMA:ue,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 u=i?new ee(e):new re(e),s=t.length,c=0;c<s;c++){var l=null;u.update(t[c]);try{l=u.getResult()}catch(t){l=null}o.push(l)}o=o.filter((function(t){return t}));var a,f,h,p=(a={},f="rsi_".concat(e),h=o,(f=function(t){var e=function(t,e){if("object"!=fe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fe(e)?e:e+""}(f))in a?Object.defineProperty(a,f,{value:h,enumerable:!0,configurable:!0,writable:!0}):a[f]=h,a);if("string"==typeof r&&"number"==typeof n&&he.hasOwnProperty("get".concat(r))){var v=he["get".concat(r)](o,n,i);p["rsi_".concat(r,"_").concat(n)]=v,p["rsi_".concat(e,"_x_rsi_").concat(r,"_").concat(n)]=ce(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 be=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}},me=function(t,e,r){var n,i,o,u=new Date(t[r][t[r].length-1]),s=new Date(u);s.setDate(s.getDate()-e),s.setHours(0,0,0,0);for(var c=(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),l=0;l<t[r].length;l++)new Date(t[r][l])>=s&&(c.open.push(t.open[l]),c.high.push(t.high[l]),c.low.push(t.low[l]),c.close.push(t.close[l]),c.volume.push(t.volume[l]),c[r].push(t[r][l]));return c};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,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)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 Oe=[{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)},je=function(t){return t.high-Math.max(t.open,t.close)},Pe=function(t){return Math.min(t.open,t.close)-t.low},_e=function(t){return t.open<=t.close?{bottom:t.open,top:t.close}:{bottom:t.close,top:t.open}},Ee=function(t){return t.open<t.close},Re=function(t){return t.open>t.close},ke=function(t,e){return _e(t).top<=_e(e).top&&_e(t).bottom>=_e(e).bottom},Ce=function(t,e){return _e(t).top<_e(e).bottom},Ae=function(t){return Pe(t)>2*Se(t)&&je(t)<Se(t)},Me=function(t){return je(t)>2*Se(t)&&Pe(t)<Se(t)},Te=function(t){return Re(t)&&Ae(t)},Ie=function(t){return Re(t)&&Me(t)},Be={isHammer:Ae,isInvertedHammer:Me,isBullishHammer:function(t){return Ee(t)&&Ae(t)},isBearishHammer:Te,isBullishInvertedHammer:function(t){return Ee(t)&&Me(t)},isBearishInvertedHammer:Ie,isHangingMan:function(t,e){return Ee(t)&&Te(e)&&Ce(t,e)},isShootingStar:function(t,e){return Ee(t)&&Ie(e)&&Ce(t,e)},isBullishEngulfing:function(t,e){return Re(t)&&Ee(e)&&ke(t,e)},isBearishEngulfing:function(t,e){return Ee(t)&&Re(e)&&ke(t,e)},isBullishHarami:function(t,e){return Re(t)&&Ee(e)&&ke(e,t)},isBearishHarami:function(t,e){return Ee(t)&&Re(e)&&ke(e,t)},isBullishKicker:function(t,e){return Re(t)&&Ee(e)&&Ce(t,e)&&!(Ae(e)||Me(e))},isBearishKicker:function(t,e){return Ee(t)&&Re(e)&&function(t,e){return _e(t).bottom>_e(e).top}(t,e)&&!(Ae(e)||Me(e))}},He=["open","high","low","close","volume"];function xe(t){return xe="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},xe(t)}function Ve(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 De(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ve(Object(r),!0).forEach((function(e){Fe(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ve(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Fe(t,e,r){return(e=$e(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Le(t){return function(t){if(Array.isArray(t))return qe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ge(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 Ne(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,u,s=[],c=!0,l=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);c=!0);}catch(t){l=!0,i=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(l)throw i}}return s}}(t,e)||Ge(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 Ge(t,e){if(t){if("string"==typeof t)return qe(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)?qe(t,e):void 0}}function qe(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 Ue(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,$e(n.key),n)}}function $e(t){var e=function(t,e){if("object"!=xe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=xe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xe(e)?e:e+""}var Ke=function(){return t=function t(e){var r=this,n=e.input,i=e.precision,o=void 0===i||i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.precision=o,this.big=function(t){return r.precision?new p(t):t},this.crossPairsArr=[],this.inputOhlcv=n,this.verticalOhlcv=n.reduce((function(t,e){var n=e.open,i=e.high,o=e.low,u=e.close,s=e.volume,c=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}(e,He);t.open.push(r.big(n)),t.high.push(r.big(i)),t.low.push(r.big(o)),t.close.push(r.big(u)),t.volume.push(r.big(s));for(var l=0,a=Object.keys(c);l<a.length;l++){var f=a[l];t[f]||(t[f]=[]),t[f].push(c[f])}return t}),{open:[],high:[],low:[],close:[],volume:[]}),this.indicators={},this.isComputed=!1,this},e=[{key:"getData",value:function(){this.computeIndicators();var t=this.verticalOhlcv,e=this.precision,r=Object.keys(t),n=r.length;return t.open.map((function(i,o){for(var u={},s=0;s<n;s++){var c=r[s],l=t[c][o];u[c]=e&&l instanceof p?l.toNumber():l}return u}))}},{key:"getLastValues",value:function(){this.computeIndicators();for(var t=this.verticalOhlcv,e=this.precision,r={},n=0,i=Object.entries(t);n<i.length;n++){var o=Ne(i[n],2),u=o[0],s=o[1],c=s[s.length-1];r[u]=e&&c instanceof p?c.toNumber():c}return r}},{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=Ne(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.verticalOhlcv.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(Le(n),Le(e)),this.verticalOhlcv[t]=e}},{key:"crossPairs",value:function(t){this.computeIndicators();var e=function(t,e){var r,n=t.verticalOhlcv,i=t.precision,o={},u={},s=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 se(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)?se(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,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw o}}}}(e);try{for(s.s();!(r=s.n()).done;){var c=r.value,l=c.fast,a=c.slow;if(l&&a){"number"!=typeof a||o[a]||(o[a]=Array(n.close.length).fill(new p(a)));var f="".concat(l,"_x_").concat(a);if(n[l]&&n[a]){var h=ce(n[l],n[a],i);u[f]=h}else if(n[l]&&o[a]){var v=ce(n[l],o[a],i);u[f]=v}else console.log("Missing ohlcv properties for ".concat(l," or ").concat(a))}}}catch(t){s.e(t)}finally{s.f()}return u}(this,t);return this.indicators=De(De({},this.indicators),e),this}},{key:"ema",value:function(t){var e=function(t,e){var r=t.verticalOhlcv,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=De(De({},this.indicators),e),this}},{key:"sma",value:function(t){var e=function(t,e){var r=t.verticalOhlcv,n=t.precision,i=r.close,o=ue(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=De(De({},this.indicators),e),this}},{key:"macd",value:function(t,e,r){var n=function(t,e,r,n){var i=t.verticalOhlcv,o=t.precision,u=i.close,s=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=[],u=[],s=[],c=i?new Gt({indicator:Bt,shortInterval:e,longInterval:r,signalInterval:n}):new qt(new Ht(e),new Ht(r),new Ht(n)),l=t.length,a=0;a<l;a++){var f={};c.update(t[a]);try{f=c.getResult()}catch(t){f={macd:null,signal:null,histogram:null}}o.push(f.macd),u.push(f.signal),s.push(f.histogram)}return{macd_diff:o,macd_dea:u,macd_histogram:s,macd_diff_x_macd_dea:ce(o,u,i)}}(u.slice(-3*s),e,r,n,o)}(this,t,e,r);return this.indicators=De(De({},this.indicators),n),this}},{key:"bollingerBands",value:function(t,e){var r=function(t,e,r){var n=t.verticalOhlcv,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:[]},u=n?new Ot(e,r):new St(e,r),s=0;s<i;s++){var c={};u.update(t[s]);try{c=u.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 l=o.bollinger_bands_upper,a=o.bollinger_bands_middle,f=o.bollinger_bands_lower;return{bollinger_bands_upper:l,bollinger_bands_middle:a,bollinger_bands_lower:f,bollinger_bands_range:ae(t,{bollinger_bands_upper:l,bollinger_bands_lower:f},n)}}(n.close.slice(-3*e),e,r,i)}(this,t,e);return this.indicators=De(De({},this.indicators),r),this}},{key:"rsi",value:function(t,e,r){var n=function(t,e,r,n){var i=t.verticalOhlcv,o=t.precision,u=i.close.slice(-3*e);return"number"==typeof e&&void 0===n&&(n=e),pe(u,e,r,n,o)}(this,t,e,r);return this.indicators=De(De({},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,u=t[i],s=t[i-1],c="Neutral",l="None",a=0,f=ge(Oe);try{for(f.s();!(o=f.n()).done;){var h=o.value,p=h.isSingleCandle,v=h.candle_name,y=h.candle_score;if(p?Be[v](u):Be[v](s,u))if(0===a)c=1===y?"Bullish":"Bearish",l=v,a=y;else{if(a!==y){c="Neutral",l="None",a=0;break}l+=",".concat(v)}}}catch(t){f.e(t)}finally{f.f()}e.push(c),r.push(l),n.push(a)}return{candle_pattern:e,candle_name:r,candle_score:n}}(this.inputOhlcv);return this.indicators=De(De({},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,u=t.volume,s=Math.min.apply(Math,ye(i)),c=(Math.max.apply(Math,ye(n))-s)/e,l={upVolume:0,downVolume:0,grossVolume:0},a=Array.from({length:e},(function(t,e){return{price:s+c*e,upVolume:0,downVolume:0,grossVolume:0}})),f=1/c,h=0;h<o.length;h++)for(var p=o[h],v=r[h],y=n[h],d=i[h],b=u[h],m=p>=v?b:0,g=p<v?b:0,w=Math.max(0,Math.floor((d-s)*f)),O=Math.min(e,Math.ceil((y-s)*f)),S=w;S<O;S++)a[S].upVolume+=m,a[S].downVolume+=g,a[S].grossVolume+=m+g;for(var j=0,P=a;j<P.length;j++){var _=P[j],E=_.upVolume,R=_.downVolume,k=_.grossVolume;l.upVolume+=E,l.downVolume+=R,l.grossVolume+=k}return{bins:a,nodes:be(a)}}(me(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.verticalOhlcv,t,e,r);return this.indicators=De(De({},this.indicators),n),this}}],e&&Ue(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:()=>Ke});var r=1e6,n="[big.js] ",i=n+"Invalid ",o=i+"decimal places",u=i+"rounding mode",s=n+"Division by zero",c={},l=void 0,a=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(t,e,r,n){var i=t.c;if(r===l&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(u);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]!==l))),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]!==l||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 h(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}c.abs=function(){var t=new this.constructor(this);return t.s=1,t},c.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,u=t.s,s=r.e,c=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-u:0;if(o!=u)return o;if(e=o<0,s!=c)return s>c^e?1:-1;for(u=(s=n.length)<(c=i.length)?s:c,o=-1;++o<u;)if(n[o]!=i[o])return n[o]>i[o]^e?1:-1;return s==c?0:s>c^e?1:-1},c.div=function(t){var e=this,n=e.constructor,i=e.c,u=(t=new n(t)).c,c=e.s==t.s?1:-1,a=n.DP;if(a!==~~a||a<0||a>r)throw Error(o);if(!u[0])throw Error(s);if(!i[0])return t.s=c,t.c=[t.e=0],t;var h,p,v,y,d,b=u.slice(),m=h=u.length,g=i.length,w=i.slice(0,h),O=w.length,S=t,j=S.c=[],P=0,_=a+(S.e=e.e-t.e)+1;for(S.s=c,c=_<0?0:_,b.unshift(0);O++<h;)w.push(0);do{for(v=0;v<10;v++){if(h!=(O=w.length))y=h>O?1:-1;else for(d=-1,y=0;++d<h;)if(u[d]!=w[d]){y=u[d]>w[d]?1:-1;break}if(!(y<0))break;for(p=O==h?u:b;O;){if(w[--O]<p[O]){for(d=O;d&&!w[--d];)w[d]=9;--w[d],w[O]+=10}w[O]-=p[O]}for(;!w[0];)w.shift()}j[P++]=y?v:++v,w[0]&&y?w[O]=i[m]||0:w=[i[m]]}while((m++<g||w[0]!==l)&&c--);return j[0]||1==P||(j.shift(),S.e--,_--),P>_&&f(S,_,n.RM,w[0]!==l),S},c.eq=function(t){return 0===this.cmp(t)},c.gt=function(t){return this.cmp(t)>0},c.gte=function(t){return this.cmp(t)>-1},c.lt=function(t){return this.cmp(t)<0},c.lte=function(t){return this.cmp(t)<1},c.minus=c.sub=function(t){var e,r,n,i,o=this,u=o.constructor,s=o.s,c=(t=new u(t)).s;if(s!=c)return t.s=-c,o.plus(t);var l=o.c.slice(),a=o.e,f=t.c,h=t.e;if(!l[0]||!f[0])return f[0]?t.s=-c:l[0]?t=new u(o):t.s=1,t;if(s=a-h){for((i=s<0)?(s=-s,n=l):(h=a,n=f),n.reverse(),c=s;c--;)n.push(0);n.reverse()}else for(r=((i=l.length<f.length)?l:f).length,s=c=0;c<r;c++)if(l[c]!=f[c]){i=l[c]<f[c];break}if(i&&(n=l,l=f,f=n,t.s=-t.s),(c=(r=f.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;r>s;){if(l[--r]<f[r]){for(e=r;e&&!l[--e];)l[e]=9;--l[e],l[r]+=10}l[r]-=f[r]}for(;0===l[--c];)l.pop();for(;0===l[0];)l.shift(),--h;return l[0]||(t.s=1,l=[h=0]),t.c=l,t.e=h,t},c.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(s);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)))},c.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},c.plus=c.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 u=i.e,s=i.c,c=t.e,l=t.c;if(!s[0]||!l[0])return l[0]||(s[0]?t=new o(i):t.s=i.s),t;if(s=s.slice(),e=u-c){for(e>0?(c=u,n=l):(e=-e,n=s),n.reverse();e--;)n.push(0);n.reverse()}for(s.length-l.length<0&&(n=l,l=s,s=n),e=l.length,r=0;e;s[e]%=10)r=(s[--e]=s[e]+l[e]+r)/10|0;for(r&&(s.unshift(r),++c),e=s.length;0===s[--e];)s.pop();return t.c=s,t.e=c,t},c.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},c.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(i+"precision");return f(new this.constructor(this),t,e)},c.round=function(t,e){if(t===l)t=0;else if(t!==~~t||t<-r||t>r)throw Error(o);return f(new this.constructor(this),t+this.e+1,e)},c.sqrt=function(){var t,e,r,i=this,o=i.constructor,u=i.s,s=i.e,c=new o("0.5");if(!i.c[0])return new o(i);if(u<0)throw Error(n+"No square root");0===(u=Math.sqrt(i+""))||u===1/0?((e=i.c.join("")).length+s&1||(e+="0"),s=((s+1)/2|0)-(s<0||1&s),t=new o(((u=Math.sqrt(e))==1/0?"5e":(u=u.toExponential()).slice(0,u.indexOf("e")+1))+s)):t=new o(u+""),s=t.e+(o.DP+=4);do{r=t,t=c.times(r.plus(i.div(r)))}while(r.c.slice(0,s).join("")!==t.c.slice(0,s).join(""));return f(t,(o.DP-=4)+t.e+1,o.RM)},c.times=c.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,u=i.length,s=o.length,c=r.e,l=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=c+l,u<s&&(e=i,i=o,o=e,l=u,u=s,s=l),e=new Array(l=u+s);l--;)e[l]=0;for(c=s;c--;){for(s=0,l=u+c;l>c;)s=e[l]+o[c]*i[l-c-1]+s,e[l--]=s%10,s=s/10|0;e[l]=s}for(s?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},c.toExponential=function(t,e){var n=this,i=n.c[0];if(t!==l){if(t!==~~t||t<0||t>r)throw Error(o);for(n=f(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return h(n,!0,!!i)},c.toFixed=function(t,e){var n=this,i=n.c[0];if(t!==l){if(t!==~~t||t<0||t>r)throw Error(o);for(t=t+(n=f(new n.constructor(n),t+n.e+1,e)).e+1;n.c.length<t;)n.c.push(0)}return h(n,!1,!!i)},c[Symbol.for("nodejs.util.inspect.custom")]=c.toJSON=c.toString=function(){var t=this,e=t.constructor;return h(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},c.toNumber=function(){var t=Number(h(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},c.toPrecision=function(t,e){var n=this,o=n.constructor,u=n.c[0];if(t!==l){if(t!==~~t||t<1||t>r)throw Error(i+"precision");for(n=f(new o(n),t,e);n.c.length<t;)n.c.push(0)}return h(n,t<=n.e||n.e<=o.NE||n.e>=o.PE,!!u)},c.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return h(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===l?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(!a.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=c,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&&b(i,r.prototype),i}(t,arguments,m(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(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 b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function m(t){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},m(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=m(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||[],m(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&&b(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 O(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,_(n.key),n)}}function j(t,e,r){return e&&S(t.prototype,e),r&&S(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function P(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(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 E=function(){return j((function t(){O(this,t),P(this,"previousHighest",void 0),P(this,"highest",void 0),P(this,"previousLowest",void 0),P(this,"lowest",void 0),P(this,"previousResult",void 0),P(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)}}])}(),R=function(){return j((function t(){O(this,t),P(this,"previousHighest",void 0),P(this,"highest",void 0),P(this,"previousLowest",void 0),P(this,"lowest",void 0),P(this,"previousResult",void 0),P(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 k(t){return k="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},k(t)}function A(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}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,D(n.key),n)}}function M(t,e,r){return e&&C(t.prototype,e),r&&C(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function T(t,e,r){return e=B(e),function(t,e){if(e&&("object"==k(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,I()?Reflect.construct(e,r||[],B(t).constructor):e.apply(t,r))}function I(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(I=function(){return!!t})()}function B(t){return B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},B(t)}function H(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&&x(t,e)}function x(t,e){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},x(t,e)}function V(t,e,r){return(e=D(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function D(t){var e=function(t,e){if("object"!=k(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==k(e)?e:e+""}var F=function(t){function e(t){var r;return A(this,e),V(r=T(this,e),"interval",void 0),r.interval=t,r}return H(e,t),M(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),L=function(t){function e(t){var r;return A(this,e),V(r=T(this,e),"interval",void 0),r.interval=t,r}return H(e,t),M(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)}}])}(R);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 $(t,e,r){return e=z(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,K()?Reflect.construct(e,r||[],z(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 z(t){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},z(t)}function J(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&&Q(t,e)}function Q(t,e){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Q(t,e)}function W(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 W(t=$(this,e,[].concat(n)),"prices",[]),t}return J(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)}}])}(F),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 W(t=$(this,e,[].concat(n)),"prices",[]),t}return J(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,at(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=ut(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||[],ut(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 ut(t){return ut=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ut(t)}function st(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)}function ct(t,e){return ct=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ct(t,e)}function lt(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"!=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 ft=function(t){function e(t){var r;return et(this,e),lt(r=it(this,e,[t]),"interval",void 0),lt(r,"indicator",void 0),lt(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new Y(t),r.smoothingFactor=new p(1).div(r.interval),r}return st(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)}}])}(F),ht=function(t){function e(t){var r;return et(this,e),lt(r=it(this,e),"interval",void 0),lt(r,"indicator",void 0),lt(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new Z(t),r.smoothingFactor=1/r.interval,r}return st(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)}}])}(R);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 bt(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 mt(t,e,r){return e&&bt(t.prototype,e),r&&bt(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 Ot=function(){return mt((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 mt((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 jt(t){return jt="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},jt(t)}function Pt(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,It(n.key),n)}}function Et(t,e,r){return e&&_t(t.prototype,e),r&&_t(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Rt(t,e,r){return e=At(e),function(t,e){if(e&&("object"==jt(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,kt()?Reflect.construct(e,r||[],At(t).constructor):e.apply(t,r))}function kt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(kt=function(){return!!t})()}function At(t){return At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},At(t)}function Ct(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)}function Mt(t,e){return Mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mt(t,e)}function Tt(t,e,r){return(e=It(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function It(t){var e=function(t,e){if("object"!=jt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=jt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jt(e)?e:e+""}var Bt=function(t){function e(t){var r;return Pt(this,e),Tt(r=Rt(this,e,[t]),"interval",void 0),Tt(r,"pricesCounter",0),Tt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return Ct(e,t),Et(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}}}])}(F),Ht=function(t){function e(t){var r;return Pt(this,e),Tt(r=Rt(this,e,[t]),"interval",void 0),Tt(r,"pricesCounter",0),Tt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return Ct(e,t),Et(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 xt(t){return xt="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},xt(t)}function Vt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Dt(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 Ft(t,e,r){return e&&Dt(t.prototype,e),r&&Dt(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"!=xt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=xt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xt(e)?e:e+""}var Gt=function(){return Ft((function t(e){Vt(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),u=this.signal.update(o);return this.result={histogram:o.sub(u),macd:o,signal:u}}}},{key:"getResult",value:function(){if(!this.isStable||void 0===this.result)throw new g;return this.result}}])}(),qt=function(){return Ft((function t(e,r,n){Vt(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 $t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Kt(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 zt(t,e,r){return e&&Kt(t.prototype,e),r&&Kt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Jt(t,e,r){return e=Wt(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,Qt()?Reflect.construct(e,r||[],Wt(t).constructor):e.apply(t,r))}function Qt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Qt=function(){return!!t})()}function Wt(t){return Wt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Wt(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]:ft;return $t(this,e),Zt(r=Jt(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),zt(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)}}}}])}(E),re=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ht;return $t(this,e),Zt(r=Jt(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),zt(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)}}}}])}(R);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 Bt(e):new Ht(e),o=t.length,u=0;u<o;u++){var s=null;i.update(t[u]);try{s=i.getResult()}catch(t){s=null}n.push(s)}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 ue=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,u=0;u<o;u++){var s=null;i.update(t[u]);try{s=i.getResult()}catch(t){s=null}n.push(s)}return n};function se(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 ce=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=le(i),u=o.map((function(t){return t.length}));return o.map((function(t,e){var r=u[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()},le=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}),[])},ae=function(t,e,r){for(var n=e.bollinger_bands_upper,i=e.bollinger_bands_lower,o=new Array(t.length),u=0;u<t.length;u++)if(null!=n[u]&&null!=i[u]&&null!=t[u])if(r){var s=new p(n[u]),c=new p(i[u]),l=new p(t[u]),a=s.minus(c);o[u]=l.minus(c).div(a).times(100)}else{var f=n[u]-i[u];o[u]=(t[u]-i[u])/f*100}else o[u]=null;return o};function fe(t){return fe="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},fe(t)}var he={getSMA:ue,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=t.slice(-4*e)).length<e)return[];var o=[];e=parseInt(e),n=parseInt(n);for(var u=i?new ee(e):new re(e),s=t.length,c=0;c<s;c++){var l=null;u.update(t[c]);try{l=u.getResult()}catch(t){l=null}o.push(l)}o=o.filter((function(t){return t}));var a,f,h,p=(a={},f="rsi_".concat(e),h=o,(f=function(t){var e=function(t,e){if("object"!=fe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fe(e)?e:e+""}(f))in a?Object.defineProperty(a,f,{value:h,enumerable:!0,configurable:!0,writable:!0}):a[f]=h,a);if("string"==typeof r&&"number"==typeof n&&he.hasOwnProperty("get".concat(r))){var v=he["get".concat(r)](o,n,i);p["rsi_".concat(r,"_").concat(n)]=v,p["rsi_".concat(e,"_x_rsi_").concat(r,"_").concat(n)]=ce(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 be=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}},me=function(t,e,r){var n,i,o,u=new Date(t[r][t[r].length-1]),s=new Date(u);s.setDate(s.getDate()-e),s.setHours(0,0,0,0);for(var c=(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),l=0;l<t[r].length;l++)new Date(t[r][l])>=s&&(c.open.push(t.open[l]),c.high.push(t.high[l]),c.low.push(t.low[l]),c.close.push(t.close[l]),c.volume.push(t.volume[l]),c[r].push(t[r][l]));return c};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,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)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 Oe=[{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)},je=function(t){return t.high-Math.max(t.open,t.close)},Pe=function(t){return Math.min(t.open,t.close)-t.low},_e=function(t){return t.open<=t.close?{bottom:t.open,top:t.close}:{bottom:t.close,top:t.open}},Ee=function(t){return t.open<t.close},Re=function(t){return t.open>t.close},ke=function(t,e){return _e(t).top<=_e(e).top&&_e(t).bottom>=_e(e).bottom},Ae=function(t,e){return _e(t).top<_e(e).bottom},Ce=function(t){return Pe(t)>2*Se(t)&&je(t)<Se(t)},Me=function(t){return je(t)>2*Se(t)&&Pe(t)<Se(t)},Te=function(t){return Re(t)&&Ce(t)},Ie=function(t){return Re(t)&&Me(t)},Be={isHammer:Ce,isInvertedHammer:Me,isBullishHammer:function(t){return Ee(t)&&Ce(t)},isBearishHammer:Te,isBullishInvertedHammer:function(t){return Ee(t)&&Me(t)},isBearishInvertedHammer:Ie,isHangingMan:function(t,e){return Ee(t)&&Te(e)&&Ae(t,e)},isShootingStar:function(t,e){return Ee(t)&&Ie(e)&&Ae(t,e)},isBullishEngulfing:function(t,e){return Re(t)&&Ee(e)&&ke(t,e)},isBearishEngulfing:function(t,e){return Ee(t)&&Re(e)&&ke(t,e)},isBullishHarami:function(t,e){return Re(t)&&Ee(e)&&ke(e,t)},isBearishHarami:function(t,e){return Ee(t)&&Re(e)&&ke(e,t)},isBullishKicker:function(t,e){return Re(t)&&Ee(e)&&Ae(t,e)&&!(Ce(e)||Me(e))},isBearishKicker:function(t,e){return Ee(t)&&Re(e)&&function(t,e){return _e(t).bottom>_e(e).top}(t,e)&&!(Ce(e)||Me(e))}},He=["open","high","low","close","volume"];function xe(t){return xe="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},xe(t)}function Ve(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 De(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ve(Object(r),!0).forEach((function(e){Fe(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ve(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Fe(t,e,r){return(e=$e(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Le(t){return function(t){if(Array.isArray(t))return qe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ge(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 Ne(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,u,s=[],c=!0,l=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);c=!0);}catch(t){l=!0,i=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(l)throw i}}return s}}(t,e)||Ge(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 Ge(t,e){if(t){if("string"==typeof t)return qe(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)?qe(t,e):void 0}}function qe(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 Ue(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,$e(n.key),n)}}function $e(t){var e=function(t,e){if("object"!=xe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=xe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xe(e)?e:e+""}var Ke=function(){return t=function t(e){var r=this,n=e.input,i=e.precision,o=void 0!==i&&i,u=e.ticker,s=void 0===u?"undefined":u;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(n))throw Error("input ohlcv must be an array: "+s);if(0===n.length)throw Error("input ohlcv must not be empty: "+s);if(!n[0].hasOwnProperty("close"))throw Error("input ohlcv array objects require at least close property: "+s);return this.precision=o,this.big=function(t){return r.precision?new p(t):t},this.crossPairsArr=[],this.inputOhlcv=n,this.verticalOhlcv=n.reduce((function(t,e){var n=e.open,i=e.high,o=e.low,u=e.close,s=e.volume,c=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}(e,He);t.open.push(r.big(n)),t.high.push(r.big(i)),t.low.push(r.big(o)),t.close.push(r.big(u)),t.volume.push(r.big(s));for(var l=0,a=Object.keys(c);l<a.length;l++){var f=a[l];t[f]||(t[f]=[]),t[f].push(c[f])}return t}),{open:[],high:[],low:[],close:[],volume:[]}),this.indicators={},this.isComputed=!1,this},e=[{key:"getData",value:function(){this.computeIndicators();var t=this.verticalOhlcv,e=this.precision,r=Object.keys(t),n=r.length;return t.open.map((function(i,o){for(var u={},s=0;s<n;s++){var c=r[s],l=t[c][o];u[c]=e&&l instanceof p?l.toNumber():l}return u}))}},{key:"getLastValues",value:function(){this.computeIndicators();for(var t=this.verticalOhlcv,e=this.precision,r={},n=0,i=Object.entries(t);n<i.length;n++){var o=Ne(i[n],2),u=o[0],s=o[1],c=s[s.length-1];r[u]=e&&c instanceof p?c.toNumber():c}return r}},{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=Ne(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.verticalOhlcv.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(Le(n),Le(e)),this.verticalOhlcv[t]=e}},{key:"crossPairs",value:function(t){this.computeIndicators();var e=function(t,e){var r,n=t.verticalOhlcv,i=t.precision,o={},u={},s=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 se(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)?se(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,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,o=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw o}}}}(e);try{for(s.s();!(r=s.n()).done;){var c=r.value,l=c.fast,a=c.slow;if(l&&a){"number"!=typeof a||o[a]||(o[a]=Array(n.close.length).fill(new p(a)));var f="".concat(l,"_x_").concat(a);if(n[l]&&n[a]){var h=ce(n[l],n[a],i);u[f]=h}else if(n[l]&&o[a]){var v=ce(n[l],o[a],i);u[f]=v}else console.log("Missing ohlcv properties for ".concat(l," or ").concat(a))}}}catch(t){s.e(t)}finally{s.f()}return u}(this,t);return this.indicators=De(De({},this.indicators),e),this}},{key:"ema",value:function(t){var e=function(t,e){var r=t.verticalOhlcv,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=De(De({},this.indicators),e),this}},{key:"sma",value:function(t){var e=function(t,e){var r=t.verticalOhlcv,n=t.precision,i=r.close,o=ue(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=De(De({},this.indicators),e),this}},{key:"macd",value:function(t,e,r){var n=function(t,e,r,n){var i=t.verticalOhlcv,o=t.precision;return function(t){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=Math.max(e,r,n);t=t.slice(-4*o);for(var u=[],s=[],c=[],l=i?new Gt({indicator:Bt,shortInterval:e,longInterval:r,signalInterval:n}):new qt(new Ht(e),new Ht(r),new Ht(n)),a=t.length,f=0;f<a;f++){var h={};l.update(t[f]);try{h=l.getResult()}catch(t){h={macd:null,signal:null,histogram:null}}u.push(h.macd),s.push(h.signal),c.push(h.histogram)}return{macd_diff:u,macd_dea:s,macd_histogram:c,macd_diff_x_macd_dea:ce(u,s,i)}}(i.close,e,r,n,o)}(this,t,e,r);return this.indicators=De(De({},this.indicators),n),this}},{key:"bollingerBands",value:function(t,e){var r=function(t,e,r){var n=t.verticalOhlcv,i=t.precision;return function(t){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;t=t.slice(-4*e);for(var i={bollinger_bands_upper:[],bollinger_bands_middle:[],bollinger_bands_lower:[]},o=n?new Ot(e,r):new St(e,r),u=0;u<t.length;u++){var s={};o.update(t[u]);try{s=o.getResult()}catch(t){s={upper:null,middle:null,lower:null}}i.bollinger_bands_upper.push(s.upper),i.bollinger_bands_middle.push(s.middle),i.bollinger_bands_lower.push(s.lower)}var c=i.bollinger_bands_upper,l=i.bollinger_bands_middle,a=i.bollinger_bands_lower;return{bollinger_bands_upper:c,bollinger_bands_middle:l,bollinger_bands_lower:a,bollinger_bands_range:ae(t,{bollinger_bands_upper:c,bollinger_bands_lower:a},n)}}(n.close.slice(-3*e),e,r,i)}(this,t,e);return this.indicators=De(De({},this.indicators),r),this}},{key:"rsi",value:function(t,e,r){var n=function(t,e,r,n){var i=t.verticalOhlcv,o=t.precision,u=i.close;return"number"==typeof e&&void 0===n&&(n=e),pe(u,e,r,n,o)}(this,t,e,r);return this.indicators=De(De({},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,u=t[i],s=t[i-1],c="Neutral",l="None",a=0,f=ge(Oe);try{for(f.s();!(o=f.n()).done;){var h=o.value,p=h.isSingleCandle,v=h.candle_name,y=h.candle_score;if(p?Be[v](u):Be[v](s,u))if(0===a)c=1===y?"Bullish":"Bearish",l=v,a=y;else{if(a!==y){c="Neutral",l="None",a=0;break}l+=",".concat(v)}}}catch(t){f.e(t)}finally{f.f()}e.push(c),r.push(l),n.push(a)}return{candle_pattern:e,candle_name:r,candle_score:n}}(this.inputOhlcv);return this.indicators=De(De({},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,u=t.volume,s=Math.min.apply(Math,ye(i)),c=(Math.max.apply(Math,ye(n))-s)/e,l={upVolume:0,downVolume:0,grossVolume:0},a=Array.from({length:e},(function(t,e){return{price:s+c*e,upVolume:0,downVolume:0,grossVolume:0}})),f=1/c,h=0;h<o.length;h++)for(var p=o[h],v=r[h],y=n[h],d=i[h],b=u[h],m=p>=v?b:0,g=p<v?b:0,w=Math.max(0,Math.floor((d-s)*f)),O=Math.min(e,Math.ceil((y-s)*f)),S=w;S<O;S++)a[S].upVolume+=m,a[S].downVolume+=g,a[S].grossVolume+=m+g;for(var j=0,P=a;j<P.length;j++){var _=P[j],E=_.upVolume,R=_.downVolume,k=_.grossVolume;l.upVolume+=E,l.downVolume+=R,l.grossVolume+=k}return{bins:a,nodes:be(a)}}(me(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.verticalOhlcv,t,e,r);return this.indicators=De(De({},this.indicators),n),this}}],e&&Ue(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
package/index.js CHANGED
@@ -10,8 +10,7 @@ import {Big} from 'trading-signals';
10
10
 
11
11
 
12
12
  export default class OHLCV_INDICATORS {
13
- constructor({input, precision = true, ticker = 'undefined'}) {
14
-
13
+ constructor({input, precision = false, ticker = 'undefined'}) {
15
14
 
16
15
  if(!Array.isArray(input)) throw Error('input ohlcv must be an array: ' + ticker)
17
16
  if(input.length === 0) throw Error('input ohlcv must not be empty: ' + ticker)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohlcv-indicators",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
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",
@@ -14,11 +14,12 @@ export const bollingerBands = (main, size, times) => {
14
14
 
15
15
  export const getBollingerBands = (data, size = 20, times = 2, precision) => {
16
16
 
17
- const dataLength = data.length
17
+ data = data.slice(-(size*4))
18
+
18
19
  const output = {bollinger_bands_upper: [], bollinger_bands_middle: [], bollinger_bands_lower: []}
19
20
  const instance = (precision) ? new BollingerBands(size, times) : new FasterBollingerBands(size, times)
20
21
 
21
- for(let x = 0; x < dataLength; x++) {
22
+ for(let x = 0; x < data.length; x++) {
22
23
  let obj = {}
23
24
  instance.update(data[x])
24
25
 
@@ -6,15 +6,16 @@ export const macd = (main, fastLine, slowLine, signalLine) => {
6
6
 
7
7
  const {verticalOhlcv, precision} = main
8
8
  const {close} = verticalOhlcv
9
- const maxSize = Math.max(fastLine, slowLine, signalLine)
10
- const sliceData = close.slice(-(maxSize*3))
11
- const col = getMACD(sliceData, fastLine, slowLine, signalLine, precision)
9
+ const col = getMACD(close, fastLine, slowLine, signalLine, precision)
12
10
 
13
11
  return col
14
12
  }
15
13
 
16
14
  export const getMACD = (data, fastLine = 12, slowLine = 26, signalLine = 9, precision) => {
17
15
 
16
+ const maxSize = Math.max(fastLine, slowLine, signalLine)
17
+ data = data.slice(-(maxSize*4))
18
+
18
19
  const diff = []
19
20
  const dea = []
20
21
  const histogram = []
@@ -10,20 +10,19 @@ export const rsi = (main, period, movingAverage, movingAveragePeriod) => {
10
10
  const {verticalOhlcv, precision} = main
11
11
  const {close} = verticalOhlcv
12
12
 
13
- const sliceData = close.slice(-(period*3))
14
-
15
13
  if(typeof period === 'number' && typeof movingAveragePeriod === 'undefined')
16
14
  {
17
15
  movingAveragePeriod = period
18
16
  }
19
17
 
20
- const col = getRSI(sliceData, period, movingAverage, movingAveragePeriod, precision)
18
+ const col = getRSI(close, period, movingAverage, movingAveragePeriod, precision)
21
19
 
22
20
  return col
23
21
  }
24
22
 
25
23
  export const getRSI = (data, period = 14, movingAverage = 'SMA', movingAveragePeriod = 14, precision) => {
26
24
 
25
+ data = data.slice(-(period*4))
27
26
 
28
27
  if (data.length < period) {
29
28
  return [];
@@ -32,6 +32,8 @@ export const findCrosses = (fast, slow, precision) => {
32
32
  const groups = groupConsecutiveValues(state)
33
33
  const groupLengths = groups.map(g => g.length)
34
34
 
35
+ //console.log(groups)
36
+
35
37
  return groups.map((group, gIndex) => {
36
38
  let initialValue = groupLengths[gIndex]
37
39