ohlcv-indicators 2.0.4 → 2.0.6

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={};(()=>{function r(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 n(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)?n(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},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 a,l=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return l=t.done,t},e:function(t){u=!0,a=t},f:function(){try{l||null==r.return||r.return()}finally{if(u)throw a}}}}function n(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}t.r(e),t.d(e,{default:()=>ke});var o=function(t){return"string"==typeof t&&/^\d{4}-\d{2}-\d{2}/.test(t)},i=function(t){if(0!==t.lastComputedIndex)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" or "getData" methods are called.')},a=1e6,l="[big.js] ",u=l+"Invalid ",c=u+"decimal places",s=u+"rounding mode",f=l+"Division by zero",h={},v=void 0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function y(t,e,r,n){var o=t.c;if(r===v&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(s);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==v))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==v||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function d(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function b(t){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(t)}function m(t){var e="function"==typeof Map?new Map:void 0;return m=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(g())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&w(o,r.prototype),o}(t,arguments,O(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)},m(t)}function g(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(g=function(){return!!t})()}function w(t,e){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},w(t,e)}function O(t){return O=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},O(t)}h.abs=function(){var t=new this.constructor(this);return t.s=1,t},h.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,a=t.s,l=r.e,u=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=i<0,l!=u)return l>u^e?1:-1;for(a=(l=n.length)<(u=o.length)?l:u,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return l==u?0:l>u^e?1:-1},h.div=function(t){var e=this,r=e.constructor,n=e.c,o=(t=new r(t)).c,i=e.s==t.s?1:-1,l=r.DP;if(l!==~~l||l<0||l>a)throw Error(c);if(!o[0])throw Error(f);if(!n[0])return t.s=i,t.c=[t.e=0],t;var u,s,h,p,d,b=o.slice(),m=u=o.length,g=n.length,w=n.slice(0,u),O=w.length,_=t,S=_.c=[],j=0,A=l+(_.e=e.e-t.e)+1;for(_.s=i,i=A<0?0:A,b.unshift(0);O++<u;)w.push(0);do{for(h=0;h<10;h++){if(u!=(O=w.length))p=u>O?1:-1;else for(d=-1,p=0;++d<u;)if(o[d]!=w[d]){p=o[d]>w[d]?1:-1;break}if(!(p<0))break;for(s=O==u?o:b;O;){if(w[--O]<s[O]){for(d=O;d&&!w[--d];)w[d]=9;--w[d],w[O]+=10}w[O]-=s[O]}for(;!w[0];)w.shift()}S[j++]=p?h:++h,w[0]&&p?w[O]=n[m]||0:w=[n[m]]}while((m++<g||w[0]!==v)&&i--);return S[0]||1==j||(S.shift(),_.e--,A--),j>A&&y(_,A,r.RM,w[0]!==v),_},h.eq=function(t){return 0===this.cmp(t)},h.gt=function(t){return this.cmp(t)>0},h.gte=function(t){return this.cmp(t)>-1},h.lt=function(t){return this.cmp(t)<0},h.lte=function(t){return this.cmp(t)<1},h.minus=h.sub=function(t){var e,r,n,o,i=this,a=i.constructor,l=i.s,u=(t=new a(t)).s;if(l!=u)return t.s=-u,i.plus(t);var c=i.c.slice(),s=i.e,f=t.c,h=t.e;if(!c[0]||!f[0])return f[0]?t.s=-u:c[0]?t=new a(i):t.s=1,t;if(l=s-h){for((o=l<0)?(l=-l,n=c):(h=s,n=f),n.reverse(),u=l;u--;)n.push(0);n.reverse()}else for(r=((o=c.length<f.length)?c:f).length,l=u=0;u<r;u++)if(c[u]!=f[u]){o=c[u]<f[u];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(u=(r=f.length)-(e=c.length))>0)for(;u--;)c[e++]=0;for(u=e;r>l;){if(c[--r]<f[r]){for(e=r;e&&!c[--e];)c[e]=9;--c[e],c[r]+=10}c[r]-=f[r]}for(;0===c[--u];)c.pop();for(;0===c[0];)c.shift(),--h;return c[0]||(t.s=1,c=[h=0]),t.c=c,t.e=h,t},h.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(f);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},h.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},h.plus=h.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var a=o.e,l=o.c,u=t.e,c=t.c;if(!l[0]||!c[0])return c[0]||(l[0]?t=new i(o):t.s=o.s),t;if(l=l.slice(),e=a-u){for(e>0?(u=a,n=c):(e=-e,n=l),n.reverse();e--;)n.push(0);n.reverse()}for(l.length-c.length<0&&(n=c,c=l,l=n),e=c.length,r=0;e;l[e]%=10)r=(l[--e]=l[e]+c[e]+r)/10|0;for(r&&(l.unshift(r),++u),e=l.length;0===l[--e];)l.pop();return t.c=l,t.e=u,t},h.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(u+"exponent");for(o&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return o?r.div(n):n},h.prec=function(t,e){if(t!==~~t||t<1||t>a)throw Error(u+"precision");return y(new this.constructor(this),t,e)},h.round=function(t,e){if(t===v)t=0;else if(t!==~~t||t<-a||t>a)throw Error(c);return y(new this.constructor(this),t+this.e+1,e)},h.sqrt=function(){var t,e,r,n=this,o=n.constructor,i=n.s,a=n.e,u=new o("0.5");if(!n.c[0])return new o(n);if(i<0)throw Error(l+"No square root");0===(i=Math.sqrt(n+""))||i===1/0?((e=n.c.join("")).length+a&1||(e+="0"),a=((a+1)/2|0)-(a<0||1&a),t=new o(((i=Math.sqrt(e))==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):t=new o(i+""),a=t.e+(o.DP+=4);do{r=t,t=u.times(r.plus(n.div(r)))}while(r.c.slice(0,a).join("")!==t.c.slice(0,a).join(""));return y(t,(o.DP-=4)+t.e+1,o.RM)},h.times=h.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,a=o.length,l=i.length,u=r.e,c=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=u+c,a<l&&(e=o,o=i,i=e,c=a,a=l,l=c),e=new Array(c=a+l);c--;)e[c]=0;for(u=l;u--;){for(l=0,c=a+u;c>u;)l=e[c]+i[u]*o[c-u-1]+l,e[c--]=l%10,l=l/10|0;e[c]=l}for(l?++t.e:e.shift(),u=e.length;!e[--u];)e.pop();return t.c=e,t},h.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==v){if(t!==~~t||t<0||t>a)throw Error(c);for(r=y(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return d(r,!0,!!n)},h.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==v){if(t!==~~t||t<0||t>a)throw Error(c);for(t=t+(r=y(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length<t;)r.c.push(0)}return d(r,!1,!!n)},h[Symbol.for("nodejs.util.inspect.custom")]=h.toJSON=h.toString=function(){var t=this,e=t.constructor;return d(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},h.toNumber=function(){var t=Number(d(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(l+"Imprecise conversion");return t},h.toPrecision=function(t,e){var r=this,n=r.constructor,o=r.c[0];if(t!==v){if(t!==~~t||t<1||t>a)throw Error(u+"precision");for(r=y(new n(r),t,e);r.c.length<t;)r.c.push(0)}return d(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!o)},h.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(l+"valueOf disallowed");return d(t,t.e<=e.NE||t.e>=e.PE,!0)},function t(){function e(r){var n=this;if(!(n instanceof e))return r===v?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(u+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!p.test(e))throw Error(u+"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=h,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}();var _=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=O(e),function(t,e){if(e&&("object"==b(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,g()?Reflect.construct(e,r||[],O(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&&w(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(m(Error));function S(t){return S="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},S(t)}function j(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,P(n.key),n)}}function A(t,e,r){return(e=P(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(t){var e=function(t,e){if("object"!=S(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==S(e)?e:e+""}var E=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),A(this,"previousHighest",void 0),A(this,"highest",void 0),A(this,"previousLowest",void 0),A(this,"lowest",void 0),A(this,"previousResult",void 0),A(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new _;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)}}])&&j(t.prototype,e),r&&j(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function I(t){return I="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},I(t)}function R(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,C(n.key),n)}}function k(t,e,r){return e=M(e),function(t,e){if(e&&("object"==I(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,T()?Reflect.construct(e,r||[],M(t).constructor):e.apply(t,r))}function T(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(T=function(){return!!t})()}function M(t){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},M(t)}function x(t,e){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},x(t,e)}function C(t){var e=function(t,e){if("object"!=I(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=I(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==I(e)?e:e+""}var D=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=k(this,e),i=void 0,(o=C(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&x(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&R(r.prototype,n),o&&R(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}function z(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 B(t,e,r){return e=H(e),function(t,e){if(e&&("object"==L(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,V()?Reflect.construct(e,r||[],H(t).constructor):e.apply(t,r))}function V(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(V=function(){return!!t})()}function H(t){return H=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},H(t)}function U(t,e){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},U(t,e)}function $(t){var e=function(t,e){if("object"!=L(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=L(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==L(e)?e:e+""}var F=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,a=new Array(i),l=0;l<i;l++)a[l]=arguments[l];return r=t=B(this,e,[].concat(a)),o=[],(n=$(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&U(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.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)}}}],n&&z(r.prototype,n),o&&z(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);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 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,Q(n.key),n)}}function G(t,e,r){return e=Y(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||[],Y(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 Y(t){return Y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Y(t)}function J(t,e){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},J(t,e)}function W(t,e,r){return(e=Q(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Q(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 X=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),W(r=G(this,e),"interval",void 0),W(r,"indicator",void 0),W(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new F(t),r.smoothingFactor=1/r.interval,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&J(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);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 o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&q(r.prototype,n),o&&q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);function Z(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}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){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 rt(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"!=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 ot=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),rt(this,"interval",void 0),rt(this,"deviationMultiplier",void 0),rt(this,"prices",[]),rt(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=Z(this.prices),r=function(t,e){var r=e||Z(t),n=Z(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 _;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&et(t.prototype,e),r&&et(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function it(t){return it="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},it(t)}function at(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,ht(n.key),n)}}function lt(t,e,r){return e=ct(e),function(t,e){if(e&&("object"==it(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,ut()?Reflect.construct(e,r||[],ct(t).constructor):e.apply(t,r))}function ut(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ut=function(){return!!t})()}function ct(t){return ct=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ct(t)}function st(t,e){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},st(t,e)}function ft(t,e,r){return(e=ht(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ht(t){var e=function(t,e){if("object"!=it(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=it(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==it(e)?e:e+""}var vt=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),ft(r=lt(this,e,[t]),"interval",void 0),ft(r,"pricesCounter",0),ft(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&st(t,e)}(e,t),r=e,n=[{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 _;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&at(r.prototype,n),o&&at(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function pt(t){return pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pt(t)}function yt(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,bt(n.key),n)}}function dt(t,e,r){return(e=bt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function bt(t){var e=function(t,e){if("object"!=pt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pt(e)?e:e+""}var mt=function(){return t=function t(e,r,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),dt(this,"short",void 0),dt(this,"long",void 0),dt(this,"signal",void 0),dt(this,"prices",[]),dt(this,"result",void 0),this.short=e,this.long=r,this.signal=n},e=[{key:"getResult",value:function(){if(void 0===this.result)throw new _;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 o=r-n,i=this.signal.update(o,e);return this.result={histogram:o-i,macd:o,signal:i}}}}],e&&yt(t.prototype,e),r&&yt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function gt(t){return gt="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},gt(t)}function wt(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,Pt(n.key),n)}}function Ot(t,e,r){return e=St(e),function(t,e){if(e&&("object"==gt(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,_t()?Reflect.construct(e,r||[],St(t).constructor):e.apply(t,r))}function _t(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_t=function(){return!!t})()}function St(t){return St=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},St(t)}function jt(t,e){return jt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},jt(t,e)}function At(t,e,r){return(e=Pt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pt(t){var e=function(t,e){if("object"!=gt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=gt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gt(e)?e:e+""}var Et=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),At(r=Ot(this,e),"interval",void 0),At(r,"previousPrices",[]),At(r,"avgGain",void 0),At(r,"avgLoss",void 0),At(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&jt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=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 o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&wt(r.prototype,n),o&&wt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);function It(t){return It="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},It(t)}function Rt(t){return function(t){if(Array.isArray(t))return kt(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 kt(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)?kt(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 kt(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 Tt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=It(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=It(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==It(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Mt(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 xt(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 Ct(t){return function(t){if(Array.isArray(t))return Dt(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 Dt(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)?Dt(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 Dt(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 Lt(t){return Lt="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},Lt(t)}function zt(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 Bt(t){return function(t){if(Array.isArray(t))return Vt(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 Vt(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)?Vt(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 Vt(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 Ht=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5;if(null===t||null===e||null===r)return null;if(n<2)throw new Error("numLevels must be at least 2");for(var o=4*r/(n-1),i=[],a=0;a<n-1;a++)i.push(e-2*r+a*o);for(var l=i.length-1;l>=0;l--)if(t>i[l])return(l+1)/(n-1);return 0};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){return function(t){if(Array.isArray(t))return Ft(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ft(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ft(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Nt(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 qt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Nt(Object(r),!0).forEach((function(e){Gt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Nt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Gt(t,e,r){return(e=function(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+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Kt(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 Yt(t){return function(t){if(Array.isArray(t))return Jt(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 Jt(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)?Jt(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 Jt(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 Wt(t){return function(t){if(Array.isArray(t))return Zt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Xt(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 Qt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Xt(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}function Xt(t,e){if(t){if("string"==typeof t)return Zt(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)?Zt(t,e):void 0}}function Zt(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 te(t){return te="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},te(t)}var ee=function(t,e){if(0===e){var r=t.inputParams.filter((function(t){return"lag"===t.key}));if("object"!==te(r))return;var n=r.map((function(t){return t.params}));t.instances.lag={lagParams:n}}var o,i,a,l=Qt(t.instances.lag.lagParams);try{for(l.s();!(o=l.n()).done;){var u,c=(i=o.value,a=2,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(i,a)||Xt(i,a)||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.")}()),s=c[0],f=c[1],h=Qt(s);try{for(h.s();!(u=h.n()).done;){var v=u.value,p=t.verticalOhlcv[v];if(0===e)for(var y=1;y<=f;y++){var d="".concat(v,"_lag_").concat(y);t.verticalOhlcv[d]=Wt(t.nullArray)}for(var b=1;b<=f;b++){var m="".concat(v,"_lag_").concat(b),g=e-b;if(g<=0)break;t.verticalOhlcv[m][e]=p[g]}}}catch(t){h.e(t)}finally{h.f()}}}catch(t){l.e(t)}finally{l.f()}return!0};function re(t,e){if(t){if("string"==typeof t)return ne(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)?ne(t,e):void 0}}function ne(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 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)}function ie(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,ae(n.key),n)}}function ae(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+""}var le=function(t,e){return t>e},ue=function(t,e){return t<e},ce=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,{interval:0,prevState:.5,prevFast:null,prevSlow:null,prevHigh:null,prevLow:null,areHighAndLowUndefined:!1,index:0,crossIndexes:{up:[],down:[]}})},(e=[{key:"update",value:function(t){var e=t.fast,r=t.high,n=t.slow,o=t.low,i=this.prevState;this.areHighAndLowUndefined||void 0!==r&&void 0!==o||(this.areHighAndLowUndefined=!0),null===e||null===n||function(t,e){return t===e}(e,n)?i=.5:le(e,n)?i=this.areHighAndLowUndefined?1:[o,n,this.prevLow,this.prevSlow].every((function(t){return null!==t}))&&ue(o,n)&&le(this.prevLow,this.prevSlow)?0:1:ue(e,n)&&(i=this.areHighAndLowUndefined?0:[r,n,this.prevHigh,this.prevSlow].every((function(t){return null!==t}))&&le(r,n)&&ue(this.prevHigh,this.prevSlow)?1:0),.5===i?this.interval=0:1===i?this.prevState<=.5?this.interval=1:this.interval++:0===i&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(this.index),-1===this.interval&&this.crossIndexes.down.push(this.index),Object.assign(this,{index:this.index+1,prevState:i,prevFast:e,prevSlow:n,prevHigh:r,prevLow:o})}},{key:"getResult",value:function(){return this.interval}}])&&ie(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),se=function(t,e){if(0===e){var r=t.inputParams.filter((function(t){return"crossPairs"===t.key}));if("object"!==oe(r))return;t.instances.crossPairs={crossPairsList:r.flatMap((function(t){return t.params.flat()}))}}var n,o,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=re(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}(t.instances.crossPairs.crossPairsList);try{for(i.s();!(n=i.n()).done;){var a=n.value,l=a.fast,u=a.slow;if(l&&u){var c="".concat(l,"_x_").concat(u);if(0===e){if("number"==typeof u&&(t.verticalOhlcv[u]=new Array(t.len).fill(u)),"price"!==l&&!t.verticalOhlcv.hasOwnProperty(l))throw Error('fast "'.concat(l,' not found in crossPairs"'));if(!t.verticalOhlcv.hasOwnProperty(u))throw Error('slow "'.concat(u,' not found in crossPairs"'));t.instances[c]=new ce,t.verticalOhlcv[c]=function(t){if(Array.isArray(t))return ne(t)}(o=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||re(o)||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.")}()}var s=void 0,f=void 0,h=void 0,v=void 0,p=void 0;"price"===l?(f=t.verticalOhlcv.close[e],h=t.verticalOhlcv.high[e],v=t.verticalOhlcv.low[e],p=t.verticalOhlcv[u][e],t.instances[c].update({fast:f,slow:p,high:h,low:v})):(s=t.verticalOhlcv[l][e],p=t.verticalOhlcv[u][e],t.instances[c].update({fast:s,slow:p})),t.verticalOhlcv[c][e]=t.instances[c].getResult()}}}catch(t){i.e(t)}finally{i.f()}};function fe(t){return function(t){if(Array.isArray(t))return he(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 he(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)?he(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 he(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 ve(t){return function(t){if(Array.isArray(t))return pe(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 pe(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)?pe(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 pe(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 ye(t){return ye="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},ye(t)}function de(t){return function(t){if(Array.isArray(t))return be(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 be(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)?be(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 be(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var me={dateTime:function(t,e){if(0===e){if(!t.isValidDate)throw Error('dateTime method found and invalid "date" in input ohlcv');var r=t.verticalOhlcv.date[0].slice(0,10);Object.assign(t.instances,{dateTime:{prevDateStr:r,sessionDailyIndexCount:0,sessionIntradayIndexCount:0,cachedDayInfo:r}}),Object.assign(t.verticalOhlcv,{day_of_the_week:fe(t.nullArray),day_of_the_month:fe(t.nullArray),week_of_the_month:fe(t.nullArray),hour:fe(t.nullArray),month:fe(t.nullArray),year:fe(t.nullArray),session_daily_index:fe(t.nullArray),session_intraday_index:fe(t.nullArray)})}var n=t.verticalOhlcv.date[e],o=function(t){var e=new Date(t),r=e.getMonth(),n=e.getFullYear(),o=e.getHours(),i=e.getMinutes(),a=e.getDay(),l=e.getDate(),u=new Date(e.getFullYear(),e.getMonth(),1).getDay();return{month:r,year:n,hour:o,minute:i,day_of_the_week:a,day_of_the_month:l,week_of_the_month:Math.ceil((l+u)/7)}}(n),i=o.day_of_the_week,a=o.day_of_the_month,l=o.week_of_the_month,u=o.month,c=o.year,s=o.hour,f=n.slice(0,10);f!==t.instances.dateTime.prevDateStr&&(t.instances.dateTime.prevDateStr=f,t.instances.dateTime.sessionDailyIndexCount++,t.instances.dateTime.sessionIntradayIndexCount=0),t.verticalOhlcv.session_daily_index[e]=t.instances.dateTime.sessionDailyIndexCount,t.verticalOhlcv.session_intraday_index[e]=t.instances.dateTime.sessionIntradayIndexCount,t.verticalOhlcv.day_of_the_week[e]=i,t.verticalOhlcv.day_of_the_month[e]=a,t.verticalOhlcv.week_of_the_month[e]=l,t.verticalOhlcv.month[e]=u,t.verticalOhlcv.year[e]=c,t.verticalOhlcv.hour[e]=s},priceVariations:function(t,e){0===e&&(t.priceBased=ve(new Set([].concat(ve(t.priceBased),["mid_price_open_close","mid_price_high_low"]))),Object.assign(t.verticalOhlcv,{mid_price_open_close:ve(t.nullArray),mid_price_high_low:ve(t.nullArray)}));var r=t.verticalOhlcv.open[e],n=t.verticalOhlcv.high[e],o=t.verticalOhlcv.low[e],i=t.verticalOhlcv.close[e];t.verticalOhlcv.mid_price_open_close[e]=(r+i)/2,t.verticalOhlcv.mid_price_high_low[e]=(n+o)/2},rsi:function(t,e,r){var n,o,i=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"rsi_".concat(r),slow:"rsi_sma_".concat(r),isDefault:!0}),Object.assign(t.instances,Tt(Tt({},"rsi_".concat(r),new Et(r)),"rsi_sma_".concat(r),new F(r))),Object.assign(t.verticalOhlcv,Tt(Tt({},"rsi_".concat(r),Rt(t.nullArray)),"rsi_sma_".concat(r),Rt(t.nullArray)))),t.instances["rsi_".concat(r)].update(i,t.lastIndexReplace);try{n=t.instances["rsi_".concat(r)].getResult()}catch(t){n=null}n&&(t.verticalOhlcv["rsi_".concat(r)][e]=n,t.instances["rsi_sma_".concat(r)].update(n,t.lastIndexReplace));try{o=t.instances["rsi_sma_".concat(r)].getResult()}catch(t){o=null}return o&&(t.verticalOhlcv["rsi_sma_".concat(r)][e]=o),!0},sma:function(t,e,r,n){var o,i,a=t.verticalOhlcv.close[e],l="string"==typeof n&&t.verticalOhlcv.hasOwnProperty(n)&&"close"!==n?"".concat(n,"_"):"",u="".concat(l,"sma_").concat(r);0===e&&(t.instances[u]=new F(r),t.verticalOhlcv[u]=function(t){if(Array.isArray(t))return Mt(t)}(i=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return Mt(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)?Mt(t,e):void 0}}(i)||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.")}()),t.instances[u].update(a,t.lastIndexReplace);try{o=t.instances[u].getResult()}catch(t){}o&&(t.verticalOhlcv[u][e]=o)},ema:function(t,e,r,n){var o,i,a=t.verticalOhlcv.close[e],l="string"==typeof n&&t.verticalOhlcv.hasOwnProperty(n)&&"close"!==n?"".concat(n,"_"):"",u="".concat(l,"ema_").concat(r);0===e&&(t.instances[u]=new vt(r),t.verticalOhlcv[u]=function(t){if(Array.isArray(t))return xt(t)}(i=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return xt(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)?xt(t,e):void 0}}(i)||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.")}()),t.instances[u].update(a,t.lastIndexReplace);try{o=t.instances[u].getResult()}catch(t){o=null}o&&(t.verticalOhlcv[u][e]=o)},macd:function(t,e,r,n,o){var i=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"macd_diff",slow:"macd_dea",isDefault:!0}),t.instances.macd=new mt(new vt(r),new vt(n),new vt(o)),Object.assign(t.verticalOhlcv,{macd_diff:Ct(t.nullArray),macd_dea:Ct(t.nullArray),macd_histogram:Ct(t.nullArray)}));var a,l=t.instances.macd;l.update(i,t.lastIndexReplace);try{a=l.getResult()}catch(t){}return a&&(t.verticalOhlcv.macd_diff[e]=a.macd,t.verticalOhlcv.macd_dea[e]=a.signal,t.verticalOhlcv.macd_histogram[e]=a.histogram),!0},relativeVolume:function(t,e){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=t.verticalOhlcv.volume[e];0===e&&(t.instances["relative_volume_".concat(n)]={instance:new F(n),prevRelativeVolumeSma:null},Object.assign(t.verticalOhlcv,function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Lt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Lt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"relative_volume_".concat(n),function(t){if(Array.isArray(t))return zt(t)}(r=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return zt(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)?zt(t,e):void 0}}(r)||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.")}())));var i,a=t.instances["relative_volume_".concat(n)].instance;a.update(o,t.lastIndexReplace);try{i=a.getResult()}catch(t){}var l=t.instances["relative_volume_".concat(n)].prevRelativeVolumeSma;return t.verticalOhlcv["relative_volume_".concat(n)][e]=null!==i&&null!==l?o/l:null,t.instances["relative_volume_".concat(n)].prevRelativeVolumeSma=i,!0},donchianChannels:function(t,e,r,n){var o=t.verticalOhlcv.high,i=t.verticalOhlcv.low;0===e&&Object.assign(t.verticalOhlcv,{donchian_channel_upper:Bt(t.nullArray),donchian_channel_basis:Bt(t.nullArray),donchian_channel_lower:Bt(t.nullArray)});var a=e-n+1,l=a-r;if(l<0||a>t.len)return!0;var u=o.slice(l,a),c=i.slice(l,a),s=Math.max.apply(Math,Bt(u)),f=Math.min.apply(Math,Bt(c)),h=(s+f)/2,v=e;return v>=0&&v<t.len&&(t.verticalOhlcv.donchian_channel_upper[v]=s,t.verticalOhlcv.donchian_channel_basis[v]=h,t.verticalOhlcv.donchian_channel_lower[v]=f),!0},bollingerBands:function(t,e,r,n,o){var i=o.height,a=o.range,l=o.target,u="close"===l?"":"_".concat(l);if(0===e){if(!t.verticalOhlcv.hasOwnProperty(l))throw new Error('bollingerBands could not find target "'.concat(l,'"'));Object.assign(t.instances,Gt({},"bollinger_bands".concat(u),{instance:new ot(r,n),heightInstance:i?new F(r):null})),Object.assign(t.verticalOhlcv,qt(qt(Gt(Gt(Gt({},"bollinger_bands_upper".concat(u),$t(t.nullArray)),"bollinger_bands_middle".concat(u),$t(t.nullArray)),"bollinger_bands_lower".concat(u),$t(t.nullArray)),i&&Gt({},"bollinger_bands_height".concat(u),$t(t.nullArray))),a&&Gt({},"bollinger_bands_range".concat(u),$t(t.nullArray))))}var c,s=t.instances["bollinger_bands".concat(u)],f=s.instance,h=s.heightInstance,v=t.verticalOhlcv[l][e];f.update(v,t.lastIndexReplace);try{c=f.getResult()}catch(t){}if(!c)return!0;var p,y,d,b=c,m=b.upper,g=b.middle,w=b.lower;if(t.verticalOhlcv["bollinger_bands_upper".concat(u)][e]=m,t.verticalOhlcv["bollinger_bands_middle".concat(u)][e]=g,t.verticalOhlcv["bollinger_bands_lower".concat(u)][e]=w,!i&&!a)return!0;p=(v-w)/(m-w),y=m-w,h.update(y,t.lastIndexReplace);try{d=h.getResult()}catch(t){}return t.verticalOhlcv["bollinger_bands_range".concat(u)][e]=p,d&&(t.verticalOhlcv["bollinger_bands_height".concat(u)][e]=Ht(y,d,1.5)),!0},volumeOscillator:function(t,e,r,n){var o,i=t.verticalOhlcv.volume[e];0===e&&(Object.assign(t.instances,{volume_oscillator:{fastEMA:new vt(r),slowEMA:new vt(n)}}),t.verticalOhlcv.volume_oscillator=function(t){if(Array.isArray(t))return Kt(t)}(o=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return Kt(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)?Kt(t,e):void 0}}(o)||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.")}(),t.crossPairsList.push({fast:"volume_oscillator",slow:0,isDefault:!0}));var a=t.instances.volume_oscillator,l=a.fastEMA,u=a.slowEMA;l.update(i,t.lastIndexReplace),u.update(i,t.lastIndexReplace);var c=null,s=null;try{c=l.getResult()}catch(t){c=null}try{s=u.getResult()}catch(t){s=null}return t.verticalOhlcv.volume_oscillator[e]="number"==typeof c&&"number"==typeof s&&0!==s?100*(c-s)/s:null,!0},candleStudies:function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=o.changeLevel,a=void 0===i?7:i,l=o.sizeLevel,u=void 0===l?5:l;0===e&&Object.assign(t.verticalOhlcv,{candle_gap_size:Yt(t.nullArray),candle_body_size:Yt(t.nullArray),candle_top_size:Yt(t.nullArray),candle_bottom_size:Yt(t.nullArray),candle_shadow_size:Yt(t.nullArray),candle_close_direction:Yt(t.nullArray),candle_high_direction:Yt(t.nullArray),candle_low_direction:Yt(t.nullArray),candle_open_direction:Yt(t.nullArray)}),n&&0===e&&Object.assign(t.instances,{candleStudies:{topInstance:new F(r),bottomInstance:new F(r),gapInstance:new F(r),bodySizeInstance:new F(r),shadowSizeInstance:new F(r),closeDirectionInstance:new F(r),highDirectionInstance:new F(r),lowDirectionInstance:new F(r),openDirectionInstance:new F(r)}});var c=t.verticalOhlcv.open[e-1],s=t.verticalOhlcv.high[e-1],f=t.verticalOhlcv.low[e-1],h=t.verticalOhlcv.close[e-1];if(0===e)return!0;var v=t.verticalOhlcv.open[e],p=t.verticalOhlcv.high[e],y=t.verticalOhlcv.low[e],d=t.verticalOhlcv.close[e],b=d>v,m=Math.abs(d-v),g=Math.abs(p-y),w=p-Math.max(v,d),O=Math.min(v,d)-y,_=Math.abs(h-v),S=Math.abs(d-h),j=Math.abs(p-s),A=Math.abs(y-f),P=Math.abs(v-c),E=null,I=null,R=null,k=null,T=null,M=null,x=null,C=null,D=null;if(n){var L=t.instances.candleStudies,z=L.topInstance,B=L.bottomInstance,V=L.gapInstance,H=L.bodySizeInstance,U=L.shadowSizeInstance,$=L.closeDirectionInstance,N=L.highDirectionInstance,q=L.lowDirectionInstance,G=L.openDirectionInstance;z.update(Math.abs(w),t.lastIndexReplace),B.update(Math.abs(O),t.lastIndexReplace),U.update(Math.abs(g),t.lastIndexReplace),V.update(_,t.lastIndexReplace),H.update(m,t.lastIndexReplace),$.update(S,t.lastIndexReplace),N.update(j,t.lastIndexReplace),q.update(A,t.lastIndexReplace),G.update(P,t.lastIndexReplace);try{R=z.getResult(),I=B.getResult(),E=V.getResult(),k=H.getResult(),T=U.getResult(),M=$.getResult(),x=N.getResult(),C=q.getResult(),D=G.getResult()}catch(t){}t.verticalOhlcv.candle_body_size[e]=b?Ht(m,k,2,a):-Math.abs(Ht(m,k,2,a))||0,t.verticalOhlcv.candle_gap_size[e]=b?Ht(_,E,2,a):-Math.abs(Ht(_,E,2,a))||0,t.verticalOhlcv.candle_close_direction[e]=b?Ht(S,M,2,a):-Math.abs(Ht(S,M,2,a))||0,t.verticalOhlcv.candle_high_direction[e]=b?Ht(j,x,2,a):-Math.abs(Ht(j,x,2,a))||0,t.verticalOhlcv.candle_low_direction[e]=b?Ht(A,C,2,a):-Math.abs(Ht(A,C,2,a))||0,t.verticalOhlcv.candle_open_direction[e]=b?Ht(P,D,2,a):-Math.abs(Ht(P,D,2,a))||0,t.verticalOhlcv.candle_top_size[e]=Ht(w,R,.5,u),t.verticalOhlcv.candle_bottom_size[e]=Ht(O,I,.5,u),t.verticalOhlcv.candle_shadow_size[e]=Ht(g,T,.5,u)}else t.verticalOhlcv.candle_body_size[e]=b?m:-m,t.verticalOhlcv.candle_gap_size[e]=b?_:-_,t.verticalOhlcv.candle_close_direction[e]=b?S:-S,t.verticalOhlcv.candle_high_direction[e]=b?j:-j,t.verticalOhlcv.candle_low_direction[e]=b?A:-A,t.verticalOhlcv.candle_open_direction[e]=b?P:-P,t.verticalOhlcv.candle_top_size[e]=w,t.verticalOhlcv.candle_bottom_size[e]=O,t.verticalOhlcv.candle_shadow_size[e]=g;return!0}},ge=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=e.len,i=e.inputParams;if(e.nullArray=new Array(o).fill(null),0===n){!function(t){var e,n=t.inputParams,o=t.len,i=r(n);try{for(i.s();!(e=i.n()).done;){var a,l=r(e.value.params);try{for(l.s();!(a=l.n()).done;){var u=a.value;if("number"==typeof u&&u>o)throw console.log(u,o),new Error("At least one of the params of the indicator is greater than the input OHLCV length. Make sure to have enough datapoints in the input OHLCV.")}}catch(t){l.e(t)}finally{l.f()}}}catch(t){i.e(t)}finally{i.f()}}(e);for(var a=["open","high","low","close","volume"],l=new Set(a),u=0;u<a.length;u++)e.verticalOhlcv[a[u]]=de(e.nullArray);for(var c=Object.keys(t[0]),s=[],f=0;f<c.length;f++){var h=c[f];l.has(h)||(e.verticalOhlcv[h]=de(e.nullArray),s.push(h))}e.otherKeys=s}else if(!e.otherKeys)throw new Error("otherKeys not found in main. Ensure you run with startIndex=0 first to initialize.");for(var v=we(i),p=n;p<o;p++){var y=t[p];e.verticalOhlcv.open[p]=y.open,e.verticalOhlcv.high[p]=y.high,e.verticalOhlcv.low[p]=y.low,e.verticalOhlcv.close[p]=y.close,e.verticalOhlcv.volume[p]=y.volume;for(var d=0;d<e.otherKeys.length;d++){var b=e.otherKeys[d];e.verticalOhlcv[b][p]=y[b]}for(var m=0;m<v.length;m++){var g=v[m],w=g.fn,O=g.args,_=g.key;"crossPairs"!==_&&"lag"!==_&&w.apply(void 0,[e,p].concat(de(O)))}ee(e,p),se(e,p),e.lastComputedIndex++}},we=function(t){if(!t||"object"!==ye(t))return[];for(var e=[],r=0;r<t.length;r++){var n=t[r],o=n.key,i=n.params;e.push({key:o,fn:me[o],args:i})}return e},Oe=function(t,e){for(var r=t.length,n=new F(e),o=new Array(r),i=0,a=0,l=0,u=0;u<r;u++)if(n.update(t[u]),n.isStable){var c=n.getResult();o[u]=c,i+=c,a+=c*c,l++}else o[u]=null;var s=i/l,f=a/l-s*s,h=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/h:null}))},_e=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)throw new Error("Both arrays must have the same length");for(var n=Oe(t,r),o=Oe(e,r),i=t.length,a=[],l=0,u=0,c=0,s=0,f=0,h=0,v=-1,p=0;p<i;p++){if(null!==n[p]&&null!==o[p]){v=p;break}a.push(0)}if(-1===v)return new Array(i).fill(0);for(var y=v;y<i;y++){var d=n[y],b=o[y];if(null!==d&&null!==b)if(l+=d,u+=b,c+=d*b,s+=d*d,f+=b*b,++h<2)a.push(0);else{var m=h*c-l*u,g=Math.sqrt((h*s-l*l)*(h*f-u*u)),w=0===g?0:m/g;a.push(w)}else l=u=c=s=f=h=0,a.push(0)}return a};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 je=function(t){for(var e=t.input,r=t.inputParams,n=new(0,t.OHLCV_INDICATORS)({input:e}),o=0;o<r.length;o++){var i=r[o],a=i.key,l=i.params;Array.isArray(l)&&(l.length>0?(Array.isArray(l)&&"crossPairs"===a&&Array.isArray(l[0])&&(l[0]=l[0].filter((function(t){return!t.isDefault}))),n[a].apply(n,function(t){if(Array.isArray(t))return Se(t)}(u=l)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(u)||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}}(u)||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.")}())):n[a]())}var u;return n};function Ae(t){return function(t){if(Array.isArray(t))return Pe(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 Pe(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)?Pe(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 Pe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ee(t){return Ee="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},Ee(t)}function Ie(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Re(n.key),n)}}function Re(t){var e=function(t,e){if("object"!=Ee(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ee(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ee(e)?e:e+""}var ke=function(){return t=function t(e){var r=e.input,n=e.ticker,o=void 0===n?null:n;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(r))throw Error("input OHLCV must be an array: "+o);if(0===r.length)throw Error("input OHLCV must not be empty: "+o);if(!r[0].hasOwnProperty("close"))throw Error("input OHLCV array objects require at least close property: "+o);return this.lastComputedIndex=0,this.input=r,this.priceBased=["open","high","low","close"],this.len=r.length,this.lastIndexReplace=!1,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.inputParams=[],this.studies={},this.utilities={correlation:_e},this.setIndicatorsFromInputParams=je,this},e=[{key:"getData",value:function(){this.compute();for(var t=this.verticalOhlcv,e=Object.keys(t),r=t[e[0]].length,n=e.length,o=[],i=0;i<r;i++){for(var a={},l=!1,u=0;u<n;u++){var c=e[u],s=t[c][i];if(null==s){l=!0;break}a[c]=s}l||o.push(a)}return o}},{key:"getLastValues",value:function(){return this.getData()[this.getData().length-1]}},{key:"compute",value:function(t){if(this.isValidDate=this.input[0].hasOwnProperty("date")&&o(this.input[0].date),this.len>this.lastComputedIndex&&!t&&ge(this.input,this,0),t&&"object"===Ee(t)){var e;if(!["open","high","low","close","volume","date"].every((function(e){return Object.keys(t).includes(e)})))throw Error('Invalid OHLCV object sent in "compute". Correct usage: .compute({open: 108.25, high: 108.410004, low: 108.25, close: 99999999, volume: 875903, date: "2024-12-16 15:45:00" || "2024-12-16"})');if(!this.isValidDate)throw Error('All the OHLCV rows require a valid date property to access the compute change method. Correct date format: "2024-12-16 15:45:00" or "2024-12-16"');if(!o(t.date))throw Error('The date in the new OHLCV row is invalid. Correct date format: "2024-12-16 15:45:00" or "2024-12-16"');var r=t.date,n=this.len-1,i=null===(e=this.input[n])||void 0===e?void 0:e.date;0===this.lastComputedIndex&&this.compute(),i!==r?(this.len++,this.input.push(t),ge(this.input,this,this.len)):(this.input[n]=t,ge(this.input,this,n))}return this}},{key:"crossPairs",value:function(t){return i(this),this.crossPairsList=[].concat(Ae(this.crossPairsList),Ae(t)),this.inputParams.push({key:"crossPairs",params:[this.crossPairsList]}),this}},{key:"lag",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;i(this),this.inputParams.push({key:"lag",params:[e,r]});for(var n=function(){var r=e[o];t.priceBased.find((function(t){return r.startsWith(t)}))&&t.priceBased.push(r)},o=0;o<e.length;o++)n();return this}},{key:"relativeVolume",value:function(t){return i(this),this.inputParams.push({key:"relativeVolume",params:[t]}),this}},{key:"ema",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),!e||"object"!==Ee(e))throw new Error('"options" must be an object in ema. eg: {target, height, range}');var r=e.target,n=void 0===r?"close":r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in ema.');return this.inputParams.push({key:"ema",params:[t,n]}),this.priceBased.push("ema_".concat(t)),this}},{key:"sma",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),!e||"object"!==Ee(e))throw new Error('"options" must be an object in sma. eg: {target, height, range}');var r=e.target,n=void 0===r?"close":r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in sma.');return this.inputParams.push({key:"sma",params:[t,n]}),this.priceBased.push("sma_".concat(t)),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9;if(i(this),"number"!=typeof t||t<=0)throw new Error('"fast" must be a positive number in macd.');if("number"!=typeof e||e<=t)throw new Error('"slow" must be a positive number greater than "fast" in macd.');if("number"!=typeof r||r<=0)throw new Error('"signal" must be a positive number in macd.');return this.inputParams.push({key:"macd",params:[t,e,r]}),this}},{key:"bollingerBands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(i(this),!r||"object"!==Ee(r))throw new Error('"options" must be an object in bollingerBands. eg: {target, height, range}');var n=r.target,o=void 0===n?"close":n,a=r.height,l=void 0!==a&&a,u=r.range,c=void 0!==u&&u;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in bollingerBands.');if("number"!=typeof e||e<=0)throw new Error('"stdDev" must be a positive number in bollingerBands.');return this.inputParams.push({key:"bollingerBands",params:[t,e,{target:o,height:l,range:c}]}),this.priceBased.push("bollinger_bands_middle","bollinger_bands_upper","bollinger_bands_lower"),this}},{key:"rsi",value:function(t){if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in rsi.');return this.inputParams.push({key:"rsi",params:[t]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number or 0 in donchianChannels.');if("number"!=typeof e||e<=0)throw new Error('"offset" must be a positive number or 0 in donchianChannels.');return this.inputParams.push({key:"donchianChannels",params:[t,e]}),this.priceBased.push("donchian_channel_upper","donchian_channel_lower","donchian_channel_basis"),this}},{key:"candleStudies",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0;if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number or 0 in candleStudies.');if("boolean"!=typeof e)throw new Error('"classify" must be a true or false in candleStudies.');return this.inputParams.push({key:"candleStudies",params:[t,e,r]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;if(i(this),"number"!=typeof t||t<=0)throw new Error('fastSize" must be a positive number in volumeOscillator.');if("number"!=typeof e||e<=t)throw new Error('"slowSize" must be a positive number greater than the "fastSize" in volumeOscillator.');return this.inputParams.push({key:"volumeOscillator",params:[t,e]}),this}},{key:"dateTime",value:function(){return i(this),this.inputParams.push({key:"dateTime",params:[]}),this}},{key:"priceVariations",value:function(){return i(this),this.inputParams.push({key:"priceVariations",params:[]}),this}}],e&&Ie(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={};(()=>{function r(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 n(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)?n(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},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 a,l=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return l=t.done,t},e:function(t){c=!0,a=t},f:function(){try{l||null==r.return||r.return()}finally{if(c)throw a}}}}function n(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}t.r(e),t.d(e,{default:()=>Ce});var o=function(t){return"string"==typeof t&&/^\d{4}-\d{2}-\d{2}/.test(t)},i=function(t){if(0!==t.lastComputedIndex)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" or "getData" methods are called.')},a=1e6,l="[big.js] ",c=l+"Invalid ",u=c+"decimal places",s=c+"rounding mode",f=l+"Division by zero",h={},v=void 0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function y(t,e,r,n){var o=t.c;if(r===v&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(s);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==v))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==v||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function b(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function d(t){return d="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},d(t)}function m(t){var e="function"==typeof Map?new Map:void 0;return m=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(g())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&w(o,r.prototype),o}(t,arguments,O(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)},m(t)}function g(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(g=function(){return!!t})()}function w(t,e){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},w(t,e)}function O(t){return O=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},O(t)}h.abs=function(){var t=new this.constructor(this);return t.s=1,t},h.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,a=t.s,l=r.e,c=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=i<0,l!=c)return l>c^e?1:-1;for(a=(l=n.length)<(c=o.length)?l:c,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return l==c?0:l>c^e?1:-1},h.div=function(t){var e=this,r=e.constructor,n=e.c,o=(t=new r(t)).c,i=e.s==t.s?1:-1,l=r.DP;if(l!==~~l||l<0||l>a)throw Error(u);if(!o[0])throw Error(f);if(!n[0])return t.s=i,t.c=[t.e=0],t;var c,s,h,p,b,d=o.slice(),m=c=o.length,g=n.length,w=n.slice(0,c),O=w.length,_=t,S=_.c=[],j=0,A=l+(_.e=e.e-t.e)+1;for(_.s=i,i=A<0?0:A,d.unshift(0);O++<c;)w.push(0);do{for(h=0;h<10;h++){if(c!=(O=w.length))p=c>O?1:-1;else for(b=-1,p=0;++b<c;)if(o[b]!=w[b]){p=o[b]>w[b]?1:-1;break}if(!(p<0))break;for(s=O==c?o:d;O;){if(w[--O]<s[O]){for(b=O;b&&!w[--b];)w[b]=9;--w[b],w[O]+=10}w[O]-=s[O]}for(;!w[0];)w.shift()}S[j++]=p?h:++h,w[0]&&p?w[O]=n[m]||0:w=[n[m]]}while((m++<g||w[0]!==v)&&i--);return S[0]||1==j||(S.shift(),_.e--,A--),j>A&&y(_,A,r.RM,w[0]!==v),_},h.eq=function(t){return 0===this.cmp(t)},h.gt=function(t){return this.cmp(t)>0},h.gte=function(t){return this.cmp(t)>-1},h.lt=function(t){return this.cmp(t)<0},h.lte=function(t){return this.cmp(t)<1},h.minus=h.sub=function(t){var e,r,n,o,i=this,a=i.constructor,l=i.s,c=(t=new a(t)).s;if(l!=c)return t.s=-c,i.plus(t);var u=i.c.slice(),s=i.e,f=t.c,h=t.e;if(!u[0]||!f[0])return f[0]?t.s=-c:u[0]?t=new a(i):t.s=1,t;if(l=s-h){for((o=l<0)?(l=-l,n=u):(h=s,n=f),n.reverse(),c=l;c--;)n.push(0);n.reverse()}else for(r=((o=u.length<f.length)?u:f).length,l=c=0;c<r;c++)if(u[c]!=f[c]){o=u[c]<f[c];break}if(o&&(n=u,u=f,f=n,t.s=-t.s),(c=(r=f.length)-(e=u.length))>0)for(;c--;)u[e++]=0;for(c=e;r>l;){if(u[--r]<f[r]){for(e=r;e&&!u[--e];)u[e]=9;--u[e],u[r]+=10}u[r]-=f[r]}for(;0===u[--c];)u.pop();for(;0===u[0];)u.shift(),--h;return u[0]||(t.s=1,u=[h=0]),t.c=u,t.e=h,t},h.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(f);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},h.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},h.plus=h.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var a=o.e,l=o.c,c=t.e,u=t.c;if(!l[0]||!u[0])return u[0]||(l[0]?t=new i(o):t.s=o.s),t;if(l=l.slice(),e=a-c){for(e>0?(c=a,n=u):(e=-e,n=l),n.reverse();e--;)n.push(0);n.reverse()}for(l.length-u.length<0&&(n=u,u=l,l=n),e=u.length,r=0;e;l[e]%=10)r=(l[--e]=l[e]+u[e]+r)/10|0;for(r&&(l.unshift(r),++c),e=l.length;0===l[--e];)l.pop();return t.c=l,t.e=c,t},h.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(c+"exponent");for(o&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return o?r.div(n):n},h.prec=function(t,e){if(t!==~~t||t<1||t>a)throw Error(c+"precision");return y(new this.constructor(this),t,e)},h.round=function(t,e){if(t===v)t=0;else if(t!==~~t||t<-a||t>a)throw Error(u);return y(new this.constructor(this),t+this.e+1,e)},h.sqrt=function(){var t,e,r,n=this,o=n.constructor,i=n.s,a=n.e,c=new o("0.5");if(!n.c[0])return new o(n);if(i<0)throw Error(l+"No square root");0===(i=Math.sqrt(n+""))||i===1/0?((e=n.c.join("")).length+a&1||(e+="0"),a=((a+1)/2|0)-(a<0||1&a),t=new o(((i=Math.sqrt(e))==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):t=new o(i+""),a=t.e+(o.DP+=4);do{r=t,t=c.times(r.plus(n.div(r)))}while(r.c.slice(0,a).join("")!==t.c.slice(0,a).join(""));return y(t,(o.DP-=4)+t.e+1,o.RM)},h.times=h.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,a=o.length,l=i.length,c=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=c+u,a<l&&(e=o,o=i,i=e,u=a,a=l,l=u),e=new Array(u=a+l);u--;)e[u]=0;for(c=l;c--;){for(l=0,u=a+c;u>c;)l=e[u]+i[c]*o[u-c-1]+l,e[u--]=l%10,l=l/10|0;e[u]=l}for(l?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},h.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==v){if(t!==~~t||t<0||t>a)throw Error(u);for(r=y(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return b(r,!0,!!n)},h.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==v){if(t!==~~t||t<0||t>a)throw Error(u);for(t=t+(r=y(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length<t;)r.c.push(0)}return b(r,!1,!!n)},h[Symbol.for("nodejs.util.inspect.custom")]=h.toJSON=h.toString=function(){var t=this,e=t.constructor;return b(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},h.toNumber=function(){var t=Number(b(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(l+"Imprecise conversion");return t},h.toPrecision=function(t,e){var r=this,n=r.constructor,o=r.c[0];if(t!==v){if(t!==~~t||t<1||t>a)throw Error(c+"precision");for(r=y(new n(r),t,e);r.c.length<t;)r.c.push(0)}return b(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!o)},h.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(l+"valueOf disallowed");return b(t,t.e<=e.NE||t.e>=e.PE,!0)},function t(){function e(r){var n=this;if(!(n instanceof e))return r===v?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(c+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!p.test(e))throw Error(c+"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=h,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}();var _=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=O(e),function(t,e){if(e&&("object"==d(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,g()?Reflect.construct(e,r||[],O(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&&w(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(m(Error));function S(t){return S="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},S(t)}function j(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,P(n.key),n)}}function A(t,e,r){return(e=P(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(t){var e=function(t,e){if("object"!=S(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==S(e)?e:e+""}var E=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),A(this,"previousHighest",void 0),A(this,"highest",void 0),A(this,"previousLowest",void 0),A(this,"lowest",void 0),A(this,"previousResult",void 0),A(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new _;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)}}])&&j(t.prototype,e),r&&j(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function I(t){return I="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},I(t)}function R(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,C(n.key),n)}}function k(t,e,r){return e=x(e),function(t,e){if(e&&("object"==I(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,T()?Reflect.construct(e,r||[],x(t).constructor):e.apply(t,r))}function T(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(T=function(){return!!t})()}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}function M(t,e){return M=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},M(t,e)}function C(t){var e=function(t,e){if("object"!=I(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=I(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==I(e)?e:e+""}var D=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=k(this,e),i=void 0,(o=C(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&M(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&R(r.prototype,n),o&&R(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}function z(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 B(t,e,r){return e=H(e),function(t,e){if(e&&("object"==L(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,V()?Reflect.construct(e,r||[],H(t).constructor):e.apply(t,r))}function V(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(V=function(){return!!t})()}function H(t){return H=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},H(t)}function U(t,e){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},U(t,e)}function $(t){var e=function(t,e){if("object"!=L(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=L(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==L(e)?e:e+""}var F=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,a=new Array(i),l=0;l<i;l++)a[l]=arguments[l];return r=t=B(this,e,[].concat(a)),o=[],(n=$(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&U(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.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)}}}],n&&z(r.prototype,n),o&&z(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);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 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,Q(n.key),n)}}function G(t,e,r){return e=Y(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||[],Y(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 Y(t){return Y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Y(t)}function J(t,e){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},J(t,e)}function W(t,e,r){return(e=Q(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Q(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 X=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),W(r=G(this,e),"interval",void 0),W(r,"indicator",void 0),W(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new F(t),r.smoothingFactor=1/r.interval,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&J(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);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 o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&q(r.prototype,n),o&&q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);function Z(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}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){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 rt(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"!=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 ot=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),rt(this,"interval",void 0),rt(this,"deviationMultiplier",void 0),rt(this,"prices",[]),rt(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=Z(this.prices),r=function(t,e){var r=e||Z(t),n=Z(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 _;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&et(t.prototype,e),r&&et(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function it(t){return it="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},it(t)}function at(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,ht(n.key),n)}}function lt(t,e,r){return e=ut(e),function(t,e){if(e&&("object"==it(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,ct()?Reflect.construct(e,r||[],ut(t).constructor):e.apply(t,r))}function ct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ct=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){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},st(t,e)}function ft(t,e,r){return(e=ht(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ht(t){var e=function(t,e){if("object"!=it(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=it(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==it(e)?e:e+""}var vt=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),ft(r=lt(this,e,[t]),"interval",void 0),ft(r,"pricesCounter",0),ft(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&st(t,e)}(e,t),r=e,n=[{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 _;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&at(r.prototype,n),o&&at(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function pt(t){return pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pt(t)}function yt(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,dt(n.key),n)}}function bt(t,e,r){return(e=dt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function dt(t){var e=function(t,e){if("object"!=pt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pt(e)?e:e+""}var mt=function(){return t=function t(e,r,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),bt(this,"short",void 0),bt(this,"long",void 0),bt(this,"signal",void 0),bt(this,"prices",[]),bt(this,"result",void 0),this.short=e,this.long=r,this.signal=n},e=[{key:"getResult",value:function(){if(void 0===this.result)throw new _;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 o=r-n,i=this.signal.update(o,e);return this.result={histogram:o-i,macd:o,signal:i}}}}],e&&yt(t.prototype,e),r&&yt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function gt(t){return gt="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},gt(t)}function wt(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,Pt(n.key),n)}}function Ot(t,e,r){return e=St(e),function(t,e){if(e&&("object"==gt(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,_t()?Reflect.construct(e,r||[],St(t).constructor):e.apply(t,r))}function _t(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_t=function(){return!!t})()}function St(t){return St=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},St(t)}function jt(t,e){return jt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},jt(t,e)}function At(t,e,r){return(e=Pt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pt(t){var e=function(t,e){if("object"!=gt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=gt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gt(e)?e:e+""}var Et=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),At(r=Ot(this,e),"interval",void 0),At(r,"previousPrices",[]),At(r,"avgGain",void 0),At(r,"avgLoss",void 0),At(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&jt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=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 o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&wt(r.prototype,n),o&&wt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);function It(t){return It="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},It(t)}function Rt(t){return function(t){if(Array.isArray(t))return kt(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 kt(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)?kt(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 kt(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 Tt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=It(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=It(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==It(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function xt(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 Mt(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 Ct(t){return function(t){if(Array.isArray(t))return Dt(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 Dt(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)?Dt(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 Dt(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 Lt(t){return Lt="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},Lt(t)}function zt(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 Bt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5;if(null===t||null===e||null===r)return null;if(n<2)throw new Error("numLevels must be at least 2");for(var o=4*r/(n-1),i=[],a=0;a<n-1;a++)i.push(e-2*r+a*o);for(var l=i.length-1;l>=0;l--)if(t>i[l])return(l+1)/(n-1);return 0};function Vt(t){return Vt="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},Vt(t)}function Ht(t){return function(t){if(Array.isArray(t))return Ut(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 Ut(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)?Ut(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 Ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function $t(t,e){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 Ft(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$t(Object(r),!0).forEach((function(e){Nt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$t(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Nt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Vt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Vt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Vt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qt(t){return qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qt(t)}function Gt(t){return function(t){if(Array.isArray(t))return Kt(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 Kt(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)?Kt(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 Kt(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 Yt(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 Jt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Yt(Object(r),!0).forEach((function(e){Wt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Yt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Wt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=qt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=qt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Qt(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 Xt(t){return function(t){if(Array.isArray(t))return Zt(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 Zt(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)?Zt(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 Zt(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 te(t){return function(t){if(Array.isArray(t))return ne(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||re(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 ee(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=re(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}function re(t,e){if(t){if("string"==typeof t)return ne(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)?ne(t,e):void 0}}function ne(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 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 ie=function(t,e){if(0===e){var r=t.inputParams.filter((function(t){return"lag"===t.key}));if("object"!==oe(r))return;var n=r.map((function(t){return t.params}));t.instances.lag={lagParams:n}}var o,i,a,l=ee(t.instances.lag.lagParams);try{for(l.s();!(o=l.n()).done;){var c,u=(i=o.value,a=2,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(t){u=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return l}}(i,a)||re(i,a)||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.")}()),s=u[0],f=u[1],h=ee(s);try{for(h.s();!(c=h.n()).done;){var v=c.value,p=t.verticalOhlcv[v];if(0===e)for(var y=1;y<=f;y++){var b="".concat(v,"_lag_").concat(y);t.verticalOhlcv[b]=te(t.nullArray)}for(var d=1;d<=f;d++){var m="".concat(v,"_lag_").concat(d),g=e-d;if(g<=0)break;t.verticalOhlcv[m][e]=p[g]}}}catch(t){h.e(t)}finally{h.f()}}}catch(t){l.e(t)}finally{l.f()}return!0};function ae(t,e){if(t){if("string"==typeof t)return le(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?le(t,e):void 0}}function le(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ce(t){return ce="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},ce(t)}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,se(n.key),n)}}function se(t){var e=function(t,e){if("object"!=ce(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ce(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ce(e)?e:e+""}var fe=function(t,e){return t>e},he=function(t,e){return t<e},ve=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,{interval:0,prevState:.5,prevFast:null,prevSlow:null,prevHigh:null,prevLow:null,areHighAndLowUndefined:!1,index:0,crossIndexes:{up:[],down:[]}})},(e=[{key:"update",value:function(t){var e=t.fast,r=t.high,n=t.slow,o=t.low,i=this.prevState;this.areHighAndLowUndefined||void 0!==r&&void 0!==o||(this.areHighAndLowUndefined=!0),null===e||null===n||function(t,e){return t===e}(e,n)?i=.5:fe(e,n)?i=this.areHighAndLowUndefined?1:[o,n,this.prevLow,this.prevSlow].every((function(t){return null!==t}))&&he(o,n)&&fe(this.prevLow,this.prevSlow)?0:1:he(e,n)&&(i=this.areHighAndLowUndefined?0:[r,n,this.prevHigh,this.prevSlow].every((function(t){return null!==t}))&&fe(r,n)&&he(this.prevHigh,this.prevSlow)?1:0),.5===i?this.interval=0:1===i?this.prevState<=.5?this.interval=1:this.interval++:0===i&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(this.index),-1===this.interval&&this.crossIndexes.down.push(this.index),Object.assign(this,{index:this.index+1,prevState:i,prevFast:e,prevSlow:n,prevHigh:r,prevLow:o})}},{key:"getResult",value:function(){return this.interval}}])&&ue(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),pe=function(t,e){if(0===e){var r=t.inputParams.filter((function(t){return"crossPairs"===t.key}));if("object"!==ce(r))return;t.instances.crossPairs={crossPairsList:r.flatMap((function(t){return t.params.flat()}))}}var n,o,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ae(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}(t.instances.crossPairs.crossPairsList);try{for(i.s();!(n=i.n()).done;){var a=n.value,l=a.fast,c=a.slow;if(l&&c){var u="".concat(l,"_x_").concat(c);if(0===e){if("number"==typeof c&&(t.verticalOhlcv[c]=new Array(t.len).fill(c)),"price"!==l&&!t.verticalOhlcv.hasOwnProperty(l))throw Error('fast "'.concat(l,' not found in crossPairs"'));if(!t.verticalOhlcv.hasOwnProperty(c))throw Error('slow "'.concat(c,' not found in crossPairs"'));t.instances[u]=new ve,t.verticalOhlcv[u]=function(t){if(Array.isArray(t))return le(t)}(o=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||ae(o)||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.")}()}var s=void 0,f=void 0,h=void 0,v=void 0,p=void 0;"price"===l?(f=t.verticalOhlcv.close[e],h=t.verticalOhlcv.high[e],v=t.verticalOhlcv.low[e],p=t.verticalOhlcv[c][e],t.instances[u].update({fast:f,slow:p,high:h,low:v})):(s=t.verticalOhlcv[l][e],p=t.verticalOhlcv[c][e],t.instances[u].update({fast:s,slow:p})),t.verticalOhlcv[u][e]=t.instances[u].getResult()}}}catch(t){i.e(t)}finally{i.f()}};function ye(t){return function(t){if(Array.isArray(t))return be(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 be(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)?be(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 be(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 de(t){return function(t){if(Array.isArray(t))return me(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 me(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)?me(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 me(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 ge(t){return ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ge(t)}function we(t){return function(t){if(Array.isArray(t))return Oe(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 Oe(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)?Oe(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 Oe(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 _e={dateTime:function(t,e){if(0===e){if(!t.isValidDate)throw Error('dateTime method found and invalid "date" in input ohlcv');var r=t.verticalOhlcv.date[0].slice(0,10);Object.assign(t.instances,{dateTime:{prevDateStr:r,sessionDailyIndexCount:0,sessionIntradayIndexCount:0,cachedDayInfo:r}}),Object.assign(t.verticalOhlcv,{day_of_the_week:ye(t.nullArray),day_of_the_month:ye(t.nullArray),week_of_the_month:ye(t.nullArray),hour:ye(t.nullArray),month:ye(t.nullArray),year:ye(t.nullArray),session_daily_index:ye(t.nullArray),session_intraday_index:ye(t.nullArray)})}var n=t.verticalOhlcv.date[e],o=function(t){var e=new Date(t),r=e.getMonth(),n=e.getFullYear(),o=e.getHours(),i=e.getMinutes(),a=e.getDay(),l=e.getDate(),c=new Date(e.getFullYear(),e.getMonth(),1).getDay();return{month:r,year:n,hour:o,minute:i,day_of_the_week:a,day_of_the_month:l,week_of_the_month:Math.ceil((l+c)/7)}}(n),i=o.day_of_the_week,a=o.day_of_the_month,l=o.week_of_the_month,c=o.month,u=o.year,s=o.hour,f=n.slice(0,10);f!==t.instances.dateTime.prevDateStr&&(t.instances.dateTime.prevDateStr=f,t.instances.dateTime.sessionDailyIndexCount++,t.instances.dateTime.sessionIntradayIndexCount=0),t.verticalOhlcv.session_daily_index[e]=t.instances.dateTime.sessionDailyIndexCount,t.verticalOhlcv.session_intraday_index[e]=t.instances.dateTime.sessionIntradayIndexCount,t.verticalOhlcv.day_of_the_week[e]=i,t.verticalOhlcv.day_of_the_month[e]=a,t.verticalOhlcv.week_of_the_month[e]=l,t.verticalOhlcv.month[e]=c,t.verticalOhlcv.year[e]=u,t.verticalOhlcv.hour[e]=s},priceVariations:function(t,e){0===e&&(t.priceBased=de(new Set([].concat(de(t.priceBased),["mid_price_open_close","mid_price_high_low"]))),Object.assign(t.verticalOhlcv,{mid_price_open_close:de(t.nullArray),mid_price_high_low:de(t.nullArray)}));var r=t.verticalOhlcv.open[e],n=t.verticalOhlcv.high[e],o=t.verticalOhlcv.low[e],i=t.verticalOhlcv.close[e];t.verticalOhlcv.mid_price_open_close[e]=(r+i)/2,t.verticalOhlcv.mid_price_high_low[e]=(n+o)/2},rsi:function(t,e,r){var n,o,i=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"rsi_".concat(r),slow:"rsi_sma_".concat(r),isDefault:!0}),Object.assign(t.instances,Tt(Tt({},"rsi_".concat(r),new Et(r)),"rsi_sma_".concat(r),new F(r))),Object.assign(t.verticalOhlcv,Tt(Tt({},"rsi_".concat(r),Rt(t.nullArray)),"rsi_sma_".concat(r),Rt(t.nullArray)))),t.instances["rsi_".concat(r)].update(i,t.lastIndexReplace);try{n=t.instances["rsi_".concat(r)].getResult()}catch(t){n=null}n&&(t.verticalOhlcv["rsi_".concat(r)][e]=n,t.instances["rsi_sma_".concat(r)].update(n,t.lastIndexReplace));try{o=t.instances["rsi_sma_".concat(r)].getResult()}catch(t){o=null}return o&&(t.verticalOhlcv["rsi_sma_".concat(r)][e]=o),!0},sma:function(t,e,r,n){var o,i,a=t.verticalOhlcv.close[e],l="string"==typeof n&&t.verticalOhlcv.hasOwnProperty(n)&&"close"!==n?"".concat(n,"_"):"",c="".concat(l,"sma_").concat(r);0===e&&(t.instances[c]=new F(r),t.verticalOhlcv[c]=function(t){if(Array.isArray(t))return xt(t)}(i=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return xt(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)?xt(t,e):void 0}}(i)||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.")}()),t.instances[c].update(a,t.lastIndexReplace);try{o=t.instances[c].getResult()}catch(t){}o&&(t.verticalOhlcv[c][e]=o)},ema:function(t,e,r,n){var o,i,a=t.verticalOhlcv.close[e],l="string"==typeof n&&t.verticalOhlcv.hasOwnProperty(n)&&"close"!==n?"".concat(n,"_"):"",c="".concat(l,"ema_").concat(r);0===e&&(t.instances[c]=new vt(r),t.verticalOhlcv[c]=function(t){if(Array.isArray(t))return Mt(t)}(i=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return Mt(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)?Mt(t,e):void 0}}(i)||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.")}()),t.instances[c].update(a,t.lastIndexReplace);try{o=t.instances[c].getResult()}catch(t){o=null}o&&(t.verticalOhlcv[c][e]=o)},macd:function(t,e,r,n,o){var i=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"macd_diff",slow:"macd_dea",isDefault:!0}),t.instances.macd=new mt(new vt(r),new vt(n),new vt(o)),Object.assign(t.verticalOhlcv,{macd_diff:Ct(t.nullArray),macd_dea:Ct(t.nullArray),macd_histogram:Ct(t.nullArray)}));var a,l=t.instances.macd;l.update(i,t.lastIndexReplace);try{a=l.getResult()}catch(t){}return a&&(t.verticalOhlcv.macd_diff[e]=a.macd,t.verticalOhlcv.macd_dea[e]=a.signal,t.verticalOhlcv.macd_histogram[e]=a.histogram),!0},relativeVolume:function(t,e){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=t.verticalOhlcv.volume[e];0===e&&(t.instances["relative_volume_".concat(n)]={instance:new F(n),prevRelativeVolumeSma:null},Object.assign(t.verticalOhlcv,function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Lt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Lt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"relative_volume_".concat(n),function(t){if(Array.isArray(t))return zt(t)}(r=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return zt(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)?zt(t,e):void 0}}(r)||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.")}())));var i,a=t.instances["relative_volume_".concat(n)].instance;a.update(o,t.lastIndexReplace);try{i=a.getResult()}catch(t){}var l=t.instances["relative_volume_".concat(n)].prevRelativeVolumeSma;return t.verticalOhlcv["relative_volume_".concat(n)][e]=null!==i&&null!==l?o/l:null,t.instances["relative_volume_".concat(n)].prevRelativeVolumeSma=i,!0},donchianChannels:function(t,e,r,n,o){var i=t.verticalOhlcv.high,a=t.verticalOhlcv.low,l=o.height,c=o.range;0===e&&(Object.assign(t.verticalOhlcv,Ft(Ft({donchian_channel_upper:Ht(t.nullArray),donchian_channel_basis:Ht(t.nullArray),donchian_channel_lower:Ht(t.nullArray)},l&&Nt({},"donchian_channel_height",Ht(t.nullArray))),c&&Nt({},"donchian_channel_range",Ht(t.nullArray)))),Object.assign(t.instances,Nt({},"donchian_channel",{heightInstance:l?new F("number"==typeof l&&l>0?l:r):null})));var u=t.instances.donchian_channel.heightInstance,s=e-n+1,f=s-r;if(f<0||s>t.len)return!0;var h=i.slice(f,s),v=a.slice(f,s),p=Math.max.apply(Math,Ht(h)),y=Math.min.apply(Math,Ht(v)),b=(p+y)/2,d=(t.verticalOhlcv.close[e]-y)/(p-y),m=p-y;l&&u.update(m,t.lastIndexReplace);var g=e;if(g>=0&&g<t.len&&(t.verticalOhlcv.donchian_channel_upper[g]=p,t.verticalOhlcv.donchian_channel_basis[g]=b,t.verticalOhlcv.donchian_channel_lower[g]=y,c&&(t.verticalOhlcv.donchian_channel_range[g]=d),l)){var w;try{w=u.getResult()}catch(t){}w&&(t.verticalOhlcv.donchian_channel_height[g]=Bt(m,w,1.5))}return!0},bollingerBands:function(t,e,r,n,o){var i=o.height,a=o.range,l=o.target,c="close"===l?"":"_".concat(l);if(0===e){if(!t.verticalOhlcv.hasOwnProperty(l))throw new Error('bollingerBands could not find target "'.concat(l,'"'));Object.assign(t.instances,Wt({},"bollinger_bands".concat(c),{instance:new ot(r,n),heightInstance:i?new F(r):null})),Object.assign(t.verticalOhlcv,Jt(Jt(Wt(Wt(Wt({},"bollinger_bands_upper".concat(c),Gt(t.nullArray)),"bollinger_bands_middle".concat(c),Gt(t.nullArray)),"bollinger_bands_lower".concat(c),Gt(t.nullArray)),i&&Wt({},"bollinger_bands_height".concat(c),Gt(t.nullArray))),a&&Wt({},"bollinger_bands_range".concat(c),Gt(t.nullArray))))}var u,s=t.instances["bollinger_bands".concat(c)],f=s.instance,h=s.heightInstance,v=t.verticalOhlcv[l][e];f.update(v,t.lastIndexReplace);try{u=f.getResult()}catch(t){}if(!u)return!0;var p,y=u,b=y.upper,d=y.middle,m=y.lower;if(t.verticalOhlcv["bollinger_bands_upper".concat(c)][e]=b,t.verticalOhlcv["bollinger_bands_middle".concat(c)][e]=d,t.verticalOhlcv["bollinger_bands_lower".concat(c)][e]=m,!i&&!a)return!0;var g=(v-m)/(b-m),w=b-m;h.update(w,t.lastIndexReplace);try{p=h.getResult()}catch(t){}return t.verticalOhlcv["bollinger_bands_range".concat(c)][e]=g,p&&(t.verticalOhlcv["bollinger_bands_height".concat(c)][e]=Bt(w,p,1.5)),!0},volumeOscillator:function(t,e,r,n){var o,i=t.verticalOhlcv.volume[e];0===e&&(Object.assign(t.instances,{volume_oscillator:{fastEMA:new vt(r),slowEMA:new vt(n)}}),t.verticalOhlcv.volume_oscillator=function(t){if(Array.isArray(t))return Qt(t)}(o=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return Qt(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)?Qt(t,e):void 0}}(o)||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.")}(),t.crossPairsList.push({fast:"volume_oscillator",slow:0,isDefault:!0}));var a=t.instances.volume_oscillator,l=a.fastEMA,c=a.slowEMA;l.update(i,t.lastIndexReplace),c.update(i,t.lastIndexReplace);var u=null,s=null;try{u=l.getResult()}catch(t){u=null}try{s=c.getResult()}catch(t){s=null}return t.verticalOhlcv.volume_oscillator[e]="number"==typeof u&&"number"==typeof s&&0!==s?100*(u-s)/s:null,!0},candleStudies:function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=o.changeLevel,a=void 0===i?7:i,l=o.sizeLevel,c=void 0===l?5:l;0===e&&Object.assign(t.verticalOhlcv,{candle_gap_size:Xt(t.nullArray),candle_body_size:Xt(t.nullArray),candle_top_size:Xt(t.nullArray),candle_bottom_size:Xt(t.nullArray),candle_shadow_size:Xt(t.nullArray),candle_close_direction:Xt(t.nullArray),candle_high_direction:Xt(t.nullArray),candle_low_direction:Xt(t.nullArray),candle_open_direction:Xt(t.nullArray)}),n&&0===e&&Object.assign(t.instances,{candleStudies:{topInstance:new F(r),bottomInstance:new F(r),gapInstance:new F(r),bodySizeInstance:new F(r),shadowSizeInstance:new F(r),closeDirectionInstance:new F(r),highDirectionInstance:new F(r),lowDirectionInstance:new F(r),openDirectionInstance:new F(r)}});var u=t.verticalOhlcv.open[e-1],s=t.verticalOhlcv.high[e-1],f=t.verticalOhlcv.low[e-1],h=t.verticalOhlcv.close[e-1];if(0===e)return!0;var v=t.verticalOhlcv.open[e],p=t.verticalOhlcv.high[e],y=t.verticalOhlcv.low[e],b=t.verticalOhlcv.close[e],d=b>v,m=Math.abs(b-v),g=Math.abs(p-y),w=p-Math.max(v,b),O=Math.min(v,b)-y,_=Math.abs(h-v),S=Math.abs(b-h),j=Math.abs(p-s),A=Math.abs(y-f),P=Math.abs(v-u),E=null,I=null,R=null,k=null,T=null,x=null,M=null,C=null,D=null;if(n){var L=t.instances.candleStudies,z=L.topInstance,B=L.bottomInstance,V=L.gapInstance,H=L.bodySizeInstance,U=L.shadowSizeInstance,$=L.closeDirectionInstance,N=L.highDirectionInstance,q=L.lowDirectionInstance,G=L.openDirectionInstance;z.update(Math.abs(w),t.lastIndexReplace),B.update(Math.abs(O),t.lastIndexReplace),U.update(Math.abs(g),t.lastIndexReplace),V.update(_,t.lastIndexReplace),H.update(m,t.lastIndexReplace),$.update(S,t.lastIndexReplace),N.update(j,t.lastIndexReplace),q.update(A,t.lastIndexReplace),G.update(P,t.lastIndexReplace);try{R=z.getResult(),I=B.getResult(),E=V.getResult(),k=H.getResult(),T=U.getResult(),x=$.getResult(),M=N.getResult(),C=q.getResult(),D=G.getResult()}catch(t){}t.verticalOhlcv.candle_body_size[e]=d?Bt(m,k,2,a):-Math.abs(Bt(m,k,2,a))||0,t.verticalOhlcv.candle_gap_size[e]=d?Bt(_,E,2,a):-Math.abs(Bt(_,E,2,a))||0,t.verticalOhlcv.candle_close_direction[e]=d?Bt(S,x,2,a):-Math.abs(Bt(S,x,2,a))||0,t.verticalOhlcv.candle_high_direction[e]=d?Bt(j,M,2,a):-Math.abs(Bt(j,M,2,a))||0,t.verticalOhlcv.candle_low_direction[e]=d?Bt(A,C,2,a):-Math.abs(Bt(A,C,2,a))||0,t.verticalOhlcv.candle_open_direction[e]=d?Bt(P,D,2,a):-Math.abs(Bt(P,D,2,a))||0,t.verticalOhlcv.candle_top_size[e]=Bt(w,R,.5,c),t.verticalOhlcv.candle_bottom_size[e]=Bt(O,I,.5,c),t.verticalOhlcv.candle_shadow_size[e]=Bt(g,T,.5,c)}else t.verticalOhlcv.candle_body_size[e]=d?m:-m,t.verticalOhlcv.candle_gap_size[e]=d?_:-_,t.verticalOhlcv.candle_close_direction[e]=d?S:-S,t.verticalOhlcv.candle_high_direction[e]=d?j:-j,t.verticalOhlcv.candle_low_direction[e]=d?A:-A,t.verticalOhlcv.candle_open_direction[e]=d?P:-P,t.verticalOhlcv.candle_top_size[e]=w,t.verticalOhlcv.candle_bottom_size[e]=O,t.verticalOhlcv.candle_shadow_size[e]=g;return!0}},Se=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=e.len,i=e.inputParams;if(e.nullArray=new Array(o).fill(null),0===n){!function(t){var e,n=t.inputParams,o=t.len,i=r(n);try{for(i.s();!(e=i.n()).done;){var a,l=r(e.value.params);try{for(l.s();!(a=l.n()).done;){var c=a.value;if("number"==typeof c&&c>o)throw console.log(c,o),new Error("At least one of the params of the indicator is greater than the input OHLCV length. Make sure to have enough datapoints in the input OHLCV.")}}catch(t){l.e(t)}finally{l.f()}}}catch(t){i.e(t)}finally{i.f()}}(e);for(var a=["open","high","low","close","volume"],l=new Set(a),c=0;c<a.length;c++)e.verticalOhlcv[a[c]]=we(e.nullArray);for(var u=Object.keys(t[0]),s=[],f=0;f<u.length;f++){var h=u[f];l.has(h)||(e.verticalOhlcv[h]=we(e.nullArray),s.push(h))}e.otherKeys=s}else if(!e.otherKeys)throw new Error("otherKeys not found in main. Ensure you run with startIndex=0 first to initialize.");for(var v=je(i),p=n;p<o;p++){var y=t[p];e.verticalOhlcv.open[p]=y.open,e.verticalOhlcv.high[p]=y.high,e.verticalOhlcv.low[p]=y.low,e.verticalOhlcv.close[p]=y.close,e.verticalOhlcv.volume[p]=y.volume;for(var b=0;b<e.otherKeys.length;b++){var d=e.otherKeys[b];e.verticalOhlcv[d][p]=y[d]}for(var m=0;m<v.length;m++){var g=v[m],w=g.fn,O=g.args,_=g.key;"crossPairs"!==_&&"lag"!==_&&w.apply(void 0,[e,p].concat(we(O)))}ie(e,p),pe(e,p),e.lastComputedIndex++}},je=function(t){if(!t||"object"!==ge(t))return[];for(var e=[],r=0;r<t.length;r++){var n=t[r],o=n.key,i=n.params;e.push({key:o,fn:_e[o],args:i})}return e},Ae=function(t,e){for(var r=t.length,n=new F(e),o=new Array(r),i=0,a=0,l=0,c=0;c<r;c++)if(n.update(t[c]),n.isStable){var u=n.getResult();o[c]=u,i+=u,a+=u*u,l++}else o[c]=null;var s=i/l,f=a/l-s*s,h=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/h:null}))},Pe=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)throw new Error("Both arrays must have the same length");for(var n=Ae(t,r),o=Ae(e,r),i=t.length,a=[],l=0,c=0,u=0,s=0,f=0,h=0,v=-1,p=0;p<i;p++){if(null!==n[p]&&null!==o[p]){v=p;break}a.push(0)}if(-1===v)return new Array(i).fill(0);for(var y=v;y<i;y++){var b=n[y],d=o[y];if(null!==b&&null!==d)if(l+=b,c+=d,u+=b*d,s+=b*b,f+=d*d,++h<2)a.push(0);else{var m=h*u-l*c,g=Math.sqrt((h*s-l*l)*(h*f-c*c)),w=0===g?0:m/g;a.push(w)}else l=c=u=s=f=h=0,a.push(0)}return a};function Ee(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 Ie=function(t){for(var e=t.input,r=t.inputParams,n=new(0,t.OHLCV_INDICATORS)({input:e}),o=0;o<r.length;o++){var i=r[o],a=i.key,l=i.params;Array.isArray(l)&&(l.length>0?(Array.isArray(l)&&"crossPairs"===a&&Array.isArray(l[0])&&(l[0]=l[0].filter((function(t){return!t.isDefault}))),n[a].apply(n,function(t){if(Array.isArray(t))return Ee(t)}(c=l)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(c)||function(t,e){if(t){if("string"==typeof t)return Ee(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)?Ee(t,e):void 0}}(c)||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.")}())):n[a]())}var c;return n};function Re(t){return function(t){if(Array.isArray(t))return ke(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 ke(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)?ke(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 ke(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 Te(t){return Te="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},Te(t)}function xe(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,Me(n.key),n)}}function Me(t){var e=function(t,e){if("object"!=Te(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Te(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Te(e)?e:e+""}var Ce=function(){return t=function t(e){var r=e.input,n=e.ticker,o=void 0===n?null:n;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(r))throw Error("input OHLCV must be an array: "+o);if(0===r.length)throw Error("input OHLCV must not be empty: "+o);if(!r[0].hasOwnProperty("close"))throw Error("input OHLCV array objects require at least close property: "+o);return this.lastComputedIndex=0,this.input=r,this.priceBased=["open","high","low","close"],this.len=r.length,this.lastIndexReplace=!1,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.inputParams=[],this.studies={},this.utilities={correlation:Pe},this.setIndicatorsFromInputParams=Ie,this},e=[{key:"getData",value:function(){this.compute();for(var t=this.verticalOhlcv,e=Object.keys(t),r=t[e[0]].length,n=e.length,o=[],i=0;i<r;i++){for(var a={},l=!1,c=0;c<n;c++){var u=e[c],s=t[u][i];if(null==s){l=!0;break}a[u]=s}l||o.push(a)}return o}},{key:"getLastValues",value:function(){return this.getData()[this.getData().length-1]}},{key:"compute",value:function(t){if(this.isValidDate=this.input[0].hasOwnProperty("date")&&o(this.input[0].date),this.len>this.lastComputedIndex&&!t&&Se(this.input,this,0),t&&"object"===Te(t)){var e;if(!["open","high","low","close","volume","date"].every((function(e){return Object.keys(t).includes(e)})))throw Error('Invalid OHLCV object sent in "compute". Correct usage: .compute({open: 108.25, high: 108.410004, low: 108.25, close: 99999999, volume: 875903, date: "2024-12-16 15:45:00" || "2024-12-16"})');if(!this.isValidDate)throw Error('All the OHLCV rows require a valid date property to access the compute change method. Correct date format: "2024-12-16 15:45:00" or "2024-12-16"');if(!o(t.date))throw Error('The date in the new OHLCV row is invalid. Correct date format: "2024-12-16 15:45:00" or "2024-12-16"');var r=t.date,n=this.len-1,i=null===(e=this.input[n])||void 0===e?void 0:e.date;0===this.lastComputedIndex&&this.compute(),i!==r?(this.len++,this.input.push(t),Se(this.input,this,this.len)):(this.input[n]=t,Se(this.input,this,n))}return this}},{key:"crossPairs",value:function(t){return i(this),this.crossPairsList=[].concat(Re(this.crossPairsList),Re(t)),this.inputParams.push({key:"crossPairs",params:[this.crossPairsList]}),this}},{key:"lag",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;i(this),this.inputParams.push({key:"lag",params:[e,r]});for(var n=function(){var r=e[o];t.priceBased.find((function(t){return r.startsWith(t)}))&&t.priceBased.push(r)},o=0;o<e.length;o++)n();return this}},{key:"relativeVolume",value:function(t){return i(this),this.inputParams.push({key:"relativeVolume",params:[t]}),this}},{key:"ema",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),!e||"object"!==Te(e))throw new Error('"options" must be an object in ema. eg: {target, height, range}');var r=e.target,n=void 0===r?"close":r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in ema.');return this.inputParams.push({key:"ema",params:[t,n]}),this.priceBased.push("ema_".concat(t)),this}},{key:"sma",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),!e||"object"!==Te(e))throw new Error('"options" must be an object in sma. eg: {target, height, range}');var r=e.target,n=void 0===r?"close":r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in sma.');return this.inputParams.push({key:"sma",params:[t,n]}),this.priceBased.push("sma_".concat(t)),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9;if(i(this),"number"!=typeof t||t<=0)throw new Error('"fast" must be a positive number in macd.');if("number"!=typeof e||e<=t)throw new Error('"slow" must be a positive number greater than "fast" in macd.');if("number"!=typeof r||r<=0)throw new Error('"signal" must be a positive number in macd.');return this.inputParams.push({key:"macd",params:[t,e,r]}),this}},{key:"bollingerBands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(i(this),!r||"object"!==Te(r))throw new Error('"options" must be an object in bollingerBands. eg: {target, height, range}');var n=r.target,o=void 0===n?"close":n,a=r.height,l=void 0!==a&&a,c=r.range,u=void 0!==c&&c;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in bollingerBands.');if("number"!=typeof e||e<=0)throw new Error('"stdDev" must be a positive number in bollingerBands.');return this.inputParams.push({key:"bollingerBands",params:[t,e,{target:o,height:l,range:u}]}),this.priceBased.push("bollinger_bands_middle","bollinger_bands_upper","bollinger_bands_lower"),this}},{key:"rsi",value:function(t){if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in rsi.');return this.inputParams.push({key:"rsi",params:[t]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number or 0 in donchianChannels.');if("number"!=typeof e||e<=0)throw new Error('"offset" must be a positive number or 0 in donchianChannels.');var n=r.height,o=void 0!==n&&n,a=r.range,l=void 0!==a&&a;return this.inputParams.push({key:"donchianChannels",params:[t,e,{height:o,range:l}]}),this.priceBased.push("donchian_channel_upper","donchian_channel_lower","donchian_channel_basis"),this}},{key:"candleStudies",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0;if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number or 0 in candleStudies.');if("boolean"!=typeof e)throw new Error('"classify" must be a true or false in candleStudies.');return this.inputParams.push({key:"candleStudies",params:[t,e,r]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;if(i(this),"number"!=typeof t||t<=0)throw new Error('fastSize" must be a positive number in volumeOscillator.');if("number"!=typeof e||e<=t)throw new Error('"slowSize" must be a positive number greater than the "fastSize" in volumeOscillator.');return this.inputParams.push({key:"volumeOscillator",params:[t,e]}),this}},{key:"dateTime",value:function(){return i(this),this.inputParams.push({key:"dateTime",params:[]}),this}},{key:"priceVariations",value:function(){return i(this),this.inputParams.push({key:"priceVariations",params:[]}),this}}],e&&xe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
package/index.js CHANGED
@@ -12,14 +12,15 @@ export default class OHLCV_INDICATORS {
12
12
  if(!input[0].hasOwnProperty('close')) throw Error('input OHLCV array objects require at least close property: ' + ticker)
13
13
 
14
14
  this.lastComputedIndex = 0
15
-
16
15
  this.input = input
16
+ this.inputTypes = {open: '', high: '', low: '', close: '', volume: ''}
17
17
  this.priceBased = ['open', 'high', 'low', 'close']
18
18
  this.len = input.length
19
19
  this.lastIndexReplace = false
20
20
  this.instances = {}
21
21
  this.crossPairsList = []
22
22
  this.verticalOhlcv = {}
23
+ this.horizontalOhlcv = new Array(this.len).fill({})
23
24
 
24
25
  this.inputParams = []
25
26
 
@@ -28,59 +29,52 @@ export default class OHLCV_INDICATORS {
28
29
  correlation
29
30
  }
30
31
 
31
-
32
+ this.precisionMultiplier = 0
32
33
  this.setIndicatorsFromInputParams = setIndicatorsFromInputParams
33
34
 
34
35
  return this
35
36
  }
36
37
 
38
+ pushToMain({index, key, value})
39
+ {
40
+ this.verticalOhlcv[key][index] = value
41
+ this.horizontalOhlcv[index][key] = value
42
+ }
37
43
 
38
- getData() {
44
+ getDataAsCols(){
39
45
 
40
- //getData method returns the last object (row) of the new OHLCV with indicators: {open, high, low, close, rsi_14, bollinger_bands_upper}
41
46
  this.compute()
42
-
43
- const {verticalOhlcv} = this
44
- const keys = Object.keys(verticalOhlcv);
45
- const len = verticalOhlcv[keys[0]].length;
46
- const keysLength = keys.length;
47
-
48
- // Pre-allocate array to improve memory efficiency
49
- const result = [];
50
-
51
- // Iterate over the rows
52
- for (let i = 0; i < len; i++) {
53
- const row = {};
54
- let isInvalidValue = false; // Flag to track if any null value is found
55
-
56
- // Loop over keys to fill row data
57
- for (let x = 0; x < keysLength; x++) {
58
- const header = keys[x];
59
47
 
60
- const value = verticalOhlcv[header][i];
61
-
62
- // If value is null, mark the row to be skipped and break
63
- if (value === null || typeof value === 'undefined') {
64
- isInvalidValue = true;
65
- break;
66
- }
67
-
68
- row[header] = value
69
- }
70
-
71
- // If no null values were found, add row to result
72
- if (!isInvalidValue) {
73
- result.push(row);
48
+ const {precisionMultiplier} = this
49
+ const verticalClone = {...this.verticalOhlcv}
50
+
51
+ for(const [key, arr] of Object.entries(verticalClone))
52
+ {
53
+ if(this.priceBased.includes(key))
54
+ {
55
+ verticalClone[key] = arr.map(v => v / precisionMultiplier)
74
56
  }
75
57
  }
76
-
77
- return result;
58
+
59
+ return verticalClone
60
+
61
+ }
62
+
63
+ getData() {
64
+
65
+ //getData method returns the last object (row) of the new OHLCV with indicators: {open, high, low, close, rsi_14, bollinger_bands_upper}
66
+ this.compute()
67
+ return this.horizontalOhlcv.filter(row =>
68
+ !Object.values(row).some(value => value === undefined || value === null)
69
+ )
78
70
  }
79
71
 
80
72
 
81
73
  getLastValues(){
82
74
 
83
- return this.getData()[this.getData().length -1]
75
+ this.compute()
76
+
77
+ return this.horizontalOhlcv[this.horizontalOhlcv.length - 1]
84
78
 
85
79
  }
86
80
 
@@ -222,7 +216,7 @@ export default class OHLCV_INDICATORS {
222
216
 
223
217
  return this
224
218
  }
225
- macd(fast = 12, slow = 26, signal = 9) {
219
+ macd(fast = 12, slow = 26, signal = 9, options = {}) {
226
220
 
227
221
  isAlreadyComputed(this)
228
222
 
@@ -236,14 +230,20 @@ export default class OHLCV_INDICATORS {
236
230
  throw new Error('"signal" must be a positive number in macd.');
237
231
  }
238
232
 
239
- this.inputParams.push({key: 'macd', params: [fast, slow, signal]})
233
+ if(typeof options !== 'object')
234
+ {
235
+ throw new Error('"options" must be an object in macd. eg: {target}');
236
+ }
237
+
238
+ const {target = 'close'} = options
239
+
240
+ this.inputParams.push({key: 'macd', params: [fast, slow, signal, {target}]})
240
241
 
241
242
  return this
242
243
 
243
244
  }
244
245
  bollingerBands(size = 20, stdDev = 2, options = {}) {
245
246
 
246
-
247
247
  isAlreadyComputed(this)
248
248
 
249
249
  if(!options || typeof options !== 'object')
@@ -251,7 +251,7 @@ export default class OHLCV_INDICATORS {
251
251
  throw new Error('"options" must be an object in bollingerBands. eg: {target, height, range}');
252
252
  }
253
253
 
254
- const {target = 'close', height = false, range = false} = options
254
+ const {target = 'close', height = 0, range = [], zScore = []} = options
255
255
 
256
256
  // Validate size and times
257
257
  if (typeof size !== 'number' || size <= 0) {
@@ -260,8 +260,17 @@ export default class OHLCV_INDICATORS {
260
260
  if (typeof stdDev !== 'number' || stdDev <= 0) {
261
261
  throw new Error('"stdDev" must be a positive number in bollingerBands.');
262
262
  }
263
+ if (!Array.isArray(range)) {
264
+ throw new Error('If set, "range" must be a array of column names in bollingerBands.');
265
+ }
266
+ if (!Array.isArray(zScore)) {
267
+ throw new Error('If set, "zScore" must be a array of column names in bollingerBands.');
268
+ }
269
+ if (typeof height !== 'number' || height < size) {
270
+ throw new Error('"height" must be a number greater than or equal to "size" in bollingerBands.');
271
+ }
263
272
 
264
- this.inputParams.push({key: 'bollingerBands', params: [size, stdDev, {target, height, range}]});
273
+ this.inputParams.push({key: 'bollingerBands', params: [size, stdDev, {target, height, range, zScore}]});
265
274
  this.priceBased.push('bollinger_bands_middle', 'bollinger_bands_upper', 'bollinger_bands_lower');
266
275
 
267
276
  return this;
@@ -280,7 +289,7 @@ export default class OHLCV_INDICATORS {
280
289
 
281
290
  return this
282
291
  }
283
- donchianChannels(size = 20, offset = 0)
292
+ donchianChannels(size = 20, offset = 0, options = {})
284
293
  {
285
294
  isAlreadyComputed(this)
286
295
 
@@ -292,7 +301,9 @@ export default class OHLCV_INDICATORS {
292
301
  throw new Error('"offset" must be a positive number or 0 in donchianChannels.');
293
302
  }
294
303
 
295
- this.inputParams.push({key: 'donchianChannels', params: [size, offset]})
304
+ const {height = false, range = false} = options
305
+
306
+ this.inputParams.push({key: 'donchianChannels', params: [size, offset, {height, range}]})
296
307
  this.priceBased.push('donchian_channel_upper', 'donchian_channel_lower', 'donchian_channel_basis')
297
308
 
298
309
  return this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohlcv-indicators",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
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",