ohlcv-indicators 3.1.8 → 3.1.9

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,u=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){l=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(l)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:()=>or});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" , "getDataAsCols" or "getData" methods are called.')},a=1e6,u="[big.js] ",l=u+"Invalid ",c=l+"decimal places",s=l+"rounding mode",f=u+"Division by zero",h={},y=void 0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function v(t,e,r,n){var o=t.c;if(r===y&&(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]!==y))),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]!==y||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 m(t){return m="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},m(t)}function b(t){var e="function"==typeof Map?new Map:void 0;return b=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,S(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)},b(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 S(t){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},S(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,u=r.e,l=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=i<0,u!=l)return u>l^e?1:-1;for(a=(u=n.length)<(l=o.length)?u:l,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return u==l?0:u>l^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,u=r.DP;if(u!==~~u||u<0||u>a)throw Error(c);if(!o[0])throw Error(f);if(!n[0])return t.s=i,t.c=[t.e=0],t;var l,s,h,p,d,m=o.slice(),b=l=o.length,g=n.length,w=n.slice(0,l),S=w.length,O=t,_=O.c=[],j=0,P=u+(O.e=e.e-t.e)+1;for(O.s=i,i=P<0?0:P,m.unshift(0);S++<l;)w.push(0);do{for(h=0;h<10;h++){if(l!=(S=w.length))p=l>S?1:-1;else for(d=-1,p=0;++d<l;)if(o[d]!=w[d]){p=o[d]>w[d]?1:-1;break}if(!(p<0))break;for(s=S==l?o:m;S;){if(w[--S]<s[S]){for(d=S;d&&!w[--d];)w[d]=9;--w[d],w[S]+=10}w[S]-=s[S]}for(;!w[0];)w.shift()}_[j++]=p?h:++h,w[0]&&p?w[S]=n[b]||0:w=[n[b]]}while((b++<g||w[0]!==y)&&i--);return _[0]||1==j||(_.shift(),O.e--,P--),j>P&&v(O,P,r.RM,w[0]!==y),O},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,u=i.s,l=(t=new a(t)).s;if(u!=l)return t.s=-l,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=-l:c[0]?t=new a(i):t.s=1,t;if(u=s-h){for((o=u<0)?(u=-u,n=c):(h=s,n=f),n.reverse(),l=u;l--;)n.push(0);n.reverse()}else for(r=((o=c.length<f.length)?c:f).length,u=l=0;l<r;l++)if(c[l]!=f[l]){o=c[l]<f[l];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(l=(r=f.length)-(e=c.length))>0)for(;l--;)c[e++]=0;for(l=e;r>u;){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[--l];)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,u=o.c,l=t.e,c=t.c;if(!u[0]||!c[0])return c[0]||(u[0]?t=new i(o):t.s=o.s),t;if(u=u.slice(),e=a-l){for(e>0?(l=a,n=c):(e=-e,n=u),n.reverse();e--;)n.push(0);n.reverse()}for(u.length-c.length<0&&(n=c,c=u,u=n),e=c.length,r=0;e;u[e]%=10)r=(u[--e]=u[e]+c[e]+r)/10|0;for(r&&(u.unshift(r),++l),e=u.length;0===u[--e];)u.pop();return t.c=u,t.e=l,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(l+"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(l+"precision");return v(new this.constructor(this),t,e)},h.round=function(t,e){if(t===y)t=0;else if(t!==~~t||t<-a||t>a)throw Error(c);return v(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,l=new o("0.5");if(!n.c[0])return new o(n);if(i<0)throw Error(u+"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=l.times(r.plus(n.div(r)))}while(r.c.slice(0,a).join("")!==t.c.slice(0,a).join(""));return v(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,u=i.length,l=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=l+c,a<u&&(e=o,o=i,i=e,c=a,a=u,u=c),e=new Array(c=a+u);c--;)e[c]=0;for(l=u;l--;){for(u=0,c=a+l;c>l;)u=e[c]+i[l]*o[c-l-1]+u,e[c--]=u%10,u=u/10|0;e[c]=u}for(u?++t.e:e.shift(),l=e.length;!e[--l];)e.pop();return t.c=e,t},h.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==y){if(t!==~~t||t<0||t>a)throw Error(c);for(r=v(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!==y){if(t!==~~t||t<0||t>a)throw Error(c);for(t=t+(r=v(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(u+"Imprecise conversion");return t},h.toPrecision=function(t,e){var r=this,n=r.constructor,o=r.c[0];if(t!==y){if(t!==~~t||t<1||t>a)throw Error(l+"precision");for(r=v(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(u+"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===y?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(l+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!p.test(e))throw Error(l+"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 O=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=S(e),function(t,e){if(e&&("object"==m(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||[],S(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}(b(Error));function _(t){return _="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},_(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,A(n.key),n)}}function P(t,e,r){return(e=A(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function A(t){var e=function(t,e){if("object"!=_(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_(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),P(this,"previousHighest",void 0),P(this,"highest",void 0),P(this,"previousLowest",void 0),P(this,"lowest",void 0),P(this,"previousResult",void 0),P(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new O;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 k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}function x(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 T(t,e,r){return e=M(e),function(t,e){if(e&&("object"==k(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,I()?Reflect.construct(e,r||[],M(t).constructor):e.apply(t,r))}function I(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(I=function(){return!!t})()}function M(t){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},M(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}function C(t){var e=function(t,e){if("object"!=k(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==k(e)?e:e+""}var 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=T(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&&R(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)}}])&&x(r.prototype,n),o&&x(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);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 V(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,U(n.key),n)}}function L(t,e,r){return e=z(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,N()?Reflect.construct(e,r||[],z(t).constructor):e.apply(t,r))}function N(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(N=function(){return!!t})()}function z(t){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},z(t)}function H(t,e){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},H(t,e)}function U(t){var e=function(t,e){if("object"!=B(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=B(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==B(e)?e:e+""}var q=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),u=0;u<i;u++)a[u]=arguments[u];return r=t=L(this,e,[].concat(a)),o=[],(n=U(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&&H(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&&V(r.prototype,n),o&&V(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function $(t){return $="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},$(t)}function F(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=K(e),function(t,e){if(e&&("object"==$(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,J()?Reflect.construct(e,r||[],K(t).constructor):e.apply(t,r))}function J(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(J=function(){return!!t})()}function K(t){return K=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},K(t)}function W(t,e){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},W(t,e)}function Y(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"!=$(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$(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),Y(r=G(this,e),"interval",void 0),Y(r,"indicator",void 0),Y(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new q(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&&W(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&&F(r.prototype,n),o&&F(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 O;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 ut(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,lt()?Reflect.construct(e,r||[],ct(t).constructor):e.apply(t,r))}function lt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(lt=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 yt=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=ut(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 O;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 vt(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,mt(n.key),n)}}function dt(t,e,r){return(e=mt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function mt(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 bt=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 O;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&&vt(t.prototype,e),r&&vt(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,At(n.key),n)}}function St(t,e,r){return e=_t(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,Ot()?Reflect.construct(e,r||[],_t(t).constructor):e.apply(t,r))}function Ot(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ot=function(){return!!t})()}function _t(t){return _t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_t(t)}function jt(t,e){return jt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},jt(t,e)}function Pt(t,e,r){return(e=At(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function At(t){var e=function(t,e){if("object"!=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),Pt(r=St(this,e),"interval",void 0),Pt(r,"previousPrices",[]),Pt(r,"avgGain",void 0),Pt(r,"avgLoss",void 0),Pt(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 kt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||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}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function 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}var Tt=function(t){var e=1/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:.1);return Math.round(t*e)/e},It=function(t){return t.replace(/(?!^-)[^0-9.]/g,"")};function Mt(t){return Mt="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},Mt(t)}function Rt(t){return function(t){if(Array.isArray(t))return Ct(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 Ct(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)?Ct(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 Ct(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 Dt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Mt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Mt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Mt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Bt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.05;if(null==t||null==e)return null;var n=t>=0,o=Math.abs(t),i=e.upper,a=e.middle,u=e.lower;if(o<u)return 0;if(o>i)return n?1:-1;var l=Number.EPSILON*Math.max(o,Math.abs(a));if(Math.abs(o-a)<l)return n?.5:-.5;if(i===u)return null;var c=Tt((o-u)/(i-u),r);return n?c:-c};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 Lt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=zt(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Nt(t){return function(t){if(Array.isArray(t))return Ht(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||zt(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function zt(t,e){if(t){if("string"==typeof t)return Ht(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)?Ht(t,e):void 0}}function Ht(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 Ut={ema:yt,sma:q},qt=function(t,e,r,n){if(!r||"object"!==Vt(r))throw new Error('"options" must be an object in '.concat(t,". eg: {target, height, range}"));var o=r.target,i=void 0===o?"close":o,a=r.diff,u=void 0===a?null:a;if("string"!=typeof i)throw new Error('"target" must be a valid keyName '.concat(t,"."));if("number"!=typeof e||e<=0)throw new Error('"size" must be a positive number in '.concat(t,"."));var l={target:i,diff:null};if(null!==u&&("object"===Vt(u)||"boolean"==typeof u&&!0===u)){var c=u=!0===u?{}:u,s=c.stdDev,f=void 0===s?2:s,h=c.scale,y=void 0===h?.05:h,p=c.targets,v=void 0===p?["close"]:p,d=c.size,m=void 0===d?e:d,b=c.lag,g=void 0===b?0:b;if("number"!=typeof f||f<=0)throw new Error('"diff.stdDev" must be a number greater than 0 in '.concat(t,"."));if("number"!=typeof y||!n.includes(y))throw new Error('"diff.scale" must be a number between 0.01 and 1 in '.concat(t,"."));if("number"!=typeof m||!Number.isInteger(m)||m<=0)throw new Error('"diff.size" must be an integer greater than or equal to size in '.concat(t,"."));if(!Array.isArray(v))throw new Error('"diff.targest" must be an array of keyNames with at least 1 item in '.concat(t,"."));if("number"!=typeof g||!Number.isInteger(g)||g<0)throw new Error('"diff.lag" must be an integer greater than 0 in '.concat(t,"."));l.diff={stdDev:f,scale:y,size:m,targets:v,lag:g}}return l};function $t(t){return $t="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},$t(t)}function Ft(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=$t(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$t(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Gt(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}var Kt="close";function Wt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Yt(t){return Yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(t)}function Qt(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 Xt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=te(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function te(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}}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}function re(t){return re="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},re(t)}function ne(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 oe(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=re(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=re(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==re(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ie(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ae(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function ae(t,e){if(t){if("string"==typeof t)return ue(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)?ue(t,e):void 0}}function ue(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 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 se(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 fe(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?se(Object(r),!0).forEach((function(e){he(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):se(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function he(t,e,r){return(e=function(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+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ye(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)||de(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){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||de(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ve(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=de(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function de(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}}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}var be=function(t,e){return(t-e)/e};function ge(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||Se(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function we(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Se(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Se(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}}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}function _e(t){return _e="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},_e(t)}var je=function(t,e){var r=t.instances,n=t.verticalOhlcv,o=t.nullArray;if(0===e){var i=t.inputParams,a=t.priceBased,u=i.filter((function(t){return"lag"===t.key}));if("object"!==_e(u))return;var l,c=u.map((function(t){return t.params})),s=we(c);try{for(s.s();!(l=s.n()).done;){var f,h=ge(l.value,2),y=h[0],p=h[1],v=we(y);try{for(v.s();!(f=v.n()).done;){var d=f.value;if(a.includes(d))for(var m=1;m<=p;m++)a.push("".concat(d,"_lag_").concat(m))}}catch(t){v.e(t)}finally{v.f()}}}catch(t){s.e(t)}finally{s.f()}r.lag={lagParams:c}}var b,g,w=we(r.lag.lagParams);try{for(w.s();!(b=w.n()).done;){var S,O=ge(b.value,2),_=O[0],j=O[1],P=we(_);try{for(P.s();!(S=P.n()).done;){var A=S.value,E=n[A];if(0===e)for(var k=1;k<=j;k++)n["".concat(A,"_lag_").concat(k)]=function(t){if(Array.isArray(t))return Oe(t)}(g=o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(g)||Se(g)||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.")}();for(var x=1;x<=j;x++){var T="".concat(A,"_lag_").concat(x),I=e-x,M=I<=0||void 0===E[I]?null:E[I];t.pushToMain({index:e,key:T,value:M})}}}catch(t){P.e(t)}finally{P.f()}}}catch(t){w.e(t)}finally{w.f()}return!0};function Pe(t,e){if(t){if("string"==typeof t)return Ae(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)?Ae(t,e):void 0}}function Ae(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 ke(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,xe(n.key),n)}}function xe(t){var e=function(t,e){if("object"!=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 Te=function(t,e){return t>e},Ie=function(t,e){return t<e},Me=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:Te(e,n)?i=this.areHighAndLowUndefined?1:[o,n,this.prevLow,this.prevSlow].every((function(t){return null!==t}))&&Ie(o,n)&&Te(this.prevLow,this.prevSlow)?0:1:Ie(e,n)&&(i=this.areHighAndLowUndefined?0:[r,n,this.prevHigh,this.prevSlow].every((function(t){return null!==t}))&&Te(r,n)&&Ie(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}}])&&ke(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Re=function(t,e){var r=t.nullArray,n=t.verticalOhlcv,o=t.instances,i=t.len;if(0===e){var a=t.inputParams.filter((function(t){return"crossPairs"===t.key}));if("object"!==Ee(a))return;o.crossPairs={crossPairsList:a.flatMap((function(t){return t.params.flat()}))}}var u,l,c=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Pe(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(o.crossPairs.crossPairsList);try{for(c.s();!(u=c.n()).done;){var s=u.value,f=s.fast,h=s.slow;if(null!=f&&null!=h){var y="".concat(f,"_x_").concat(h);if(0===e){if("number"==typeof h&&(n[h]=new Array(i).fill(h)),"price"!==f&&!n.hasOwnProperty(f))throw Error('fast "'.concat(f,' not found in crossPairs"'));if(!n.hasOwnProperty(h))throw Error('slow "'.concat(h,' not found in crossPairs"'));o[y]=new Me,n[y]=function(t){if(Array.isArray(t))return Ae(t)}(l=r)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(l)||Pe(l)||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 p=void 0,v=void 0,d=void 0,m=void 0,b=void 0;"price"===f?(v=n.close[e],d=n.high[e],m=n.low[e],b=n[h][e],o[y].update({fast:v,slow:b,high:d,low:m})):(p=n[f][e],b=n[h][e],o[y].update({fast:p,slow:b})),t.pushToMain({index:e,key:y,value:o[y].getResult()})}}}catch(t){c.e(t)}finally{c.f()}};function Ce(t){return function(t){if(Array.isArray(t))return De(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return De(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?De(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function De(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Be(t){return function(t){if(Array.isArray(t))return Ve(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 Ve(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)?Ve(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 Ve(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 Le=["open","high","low","close"];function Ne(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ue(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function ze(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.includes(r)||{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function He(t){return function(t){if(Array.isArray(t))return qe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ue(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 Ue(t,e){if(t){if("string"==typeof t)return qe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qe(t,e):void 0}}function qe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var $e={dateTime:function(t,e){var r=t.instances,n=t.verticalOhlcv;if(0===e){var o=t.nullArray;if(!t.isValidDate)throw Error('dateTime method found and invalid "date" in input ohlcv');var i=n.date[0].slice(0,10);Object.assign(r,{dateTime:{prevDateStr:i,sessionDailyIndexCount:0,sessionIntradayIndexCount:0,cachedDayInfo:i}}),Object.assign(n,{day_of_the_week:Ce(o),day_of_the_month:Ce(o),week_of_the_month:Ce(o),hour:Ce(o),month:Ce(o),year:Ce(o),session_daily_index:Ce(o),session_intraday_index:Ce(o)})}var a=n.date[e],u=function(t){var e=new Date(t),r=e.getMonth(),n=e.getFullYear(),o=e.getHours(),i=e.getMinutes(),a=e.getDay(),u=e.getDate(),l=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:u,week_of_the_month:Math.ceil((u+l)/7)}}(a),l=u.day_of_the_week,c=u.day_of_the_month,s=u.week_of_the_month,f=u.month,h=u.year,y=u.hour,p=a.slice(0,10);p!==r.dateTime.prevDateStr&&(r.dateTime.prevDateStr=p,r.dateTime.sessionDailyIndexCount++,r.dateTime.sessionIntradayIndexCount=0),t.pushToMain({index:e,key:"session_daily_index",value:r.dateTime.sessionDailyIndexCount}),t.pushToMain({index:e,key:"session_intraday_index",value:r.dateTime.sessionIntradayIndexCount}),t.pushToMain({index:e,key:"day_of_the_week",value:l}),t.pushToMain({index:e,key:"day_of_the_month",value:c}),t.pushToMain({index:e,key:"week_of_the_month",value:s}),t.pushToMain({index:e,key:"month",value:f}),t.pushToMain({index:e,key:"year",value:h}),t.pushToMain({index:e,key:"hour",value:y}),r.dateTime.sessionIntradayIndexCount++},priceVariations:function(t,e){0===e&&(t.priceBased=Be(new Set([].concat(Be(t.priceBased),["mid_price_open_close","mid_price_high_low"]))),Object.assign(t.verticalOhlcv,{mid_price_open_close:Be(t.nullArray),mid_price_high_low:Be(t.nullArray)}));var r=t.verticalOhlcv.open[e],n=t.verticalOhlcv.high[e],o=t.verticalOhlcv.low[e],i=t.verticalOhlcv.close[e];t.pushToMain({index:e,key:"mid_price_open_close",value:(r+i)/2}),t.pushToMain({index:e,key:"mid_price_high_low",value:(n+o)/2})},rsi:function(t,e,r,n){var o=n.scale,i=n.target,a=n.lag,u=t.verticalOhlcv,l=t.instances,c=t.lastIndexReplace,s="close"===i?"":"_".concat(i),f="rsi_".concat(r).concat(s),h="rsi_sma_".concat(r).concat(s);if(0===e){var y=t.crossPairsList,p=t.nullArray;if(!u.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for rsi."));y.push({fast:f,slow:h,isDefault:!0}),Object.assign(l,Dt(Dt({},f,new Et(r)),h,new q(r))),Object.assign(u,Dt(Dt({},f,Rt(p)),h,Rt(p))),a>0&&t.lag([f,h],a)}var v=u[i][e],d=null,m=null;l[f].update(v,c);try{d=l[f].getResult()}catch(t){d=null}null!==d&&"number"==typeof d&&o&&(d=Tt(d,o)),t.pushToMain({index:e,key:f,value:d}),null!==d&&"number"==typeof d&&l[h].update(d,c);try{m=l[h].getResult()}catch(t){m=null}null!==m&&"number"==typeof m&&o&&(m=Tt(m,o)),t.pushToMain({index:e,key:h,value:m})},movingAverages:function(t,e,r,n,o){var i=o.target,a=o.diff,u=t.verticalOhlcv,l=t.instances,c=t.priceBased,s=t.lastIndexReplace,f="string"==typeof i&&u.hasOwnProperty(i)&&"close"!==i?"_".concat(i):"",h="".concat(r,"_").concat(n).concat(f),y="".concat(r,"_").concat(n,"_diff").concat(f);if(0===e){var p=t.nullArray;if(!u.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for ").concat(r,"."));if(l[h]={maInstance:new Ut[r](n)},u[h]=Nt(p),null!==a){l[h].diffInstance=new ot(a.size,a.stdDev);var v,d=[],m=Lt(a.targets);try{for(m.s();!(v=m.n()).done;){var b=v.value;u["".concat(y,"_").concat(b)]=Nt(p),a.lag>0&&d.push("".concat(y,"_").concat(b))}}catch(t){m.e(t)}finally{m.f()}a.lag>0&&t.lag(d,a.lag)}c.push(h)}var g=u[i][e],w=l[h],S=w.maInstance,O=w.diffInstance;S.update(g,s);var _=null;try{_=S.getResult()}catch(t){_=null}if(t.pushToMain({index:e,key:h,value:_}),null!==a){var j,P=Lt(a.targets);try{for(P.s();!(j=P.n()).done;){var A=j.value,E=null;null!==_&&"number"==typeof _&&(E=u[A][e]-_),null!==E&&"number"==typeof E&&O.update(Math.abs(E),s);var k=null;try{k=O.getResult()}catch(t){k=null}var x=Bt(E,k,a.scale);t.pushToMain({index:e,key:"".concat(y,"_").concat(A),value:x})}}catch(t){P.e(t)}finally{P.f()}}return!0},macd:function(t,e,r,n,o,i){var a=i.target,u=t.verticalOhlcv,l=t.instances,c=t.lastIndexReplace,s="".concat(r,"_").concat(n,"_").concat(o).concat(a===Kt?"":"_".concat(a));if(0===e){var f=t.inputParams,h=t.crossPairsList,y=t.nullArray,p=t.priceBased;if(!u.hasOwnProperty(a))throw new Error("Target property ".concat(a," not found in verticalOhlcv for macd."));var v=f.filter((function(t){return"macd"===t.key})).length,d=v>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",m=a===Kt?"".concat(d,"_diff"):"".concat(d,"_diff_").concat(a),b=a===Kt?"".concat(d,"_dea"):"".concat(d,"_dea_").concat(a),g=a===Kt?"".concat(d,"_histogram"):"".concat(d,"_histogram_").concat(a);h.push({fast:m,slow:b,isDefault:!0}),l.hasOwnProperty("macd")||(l.macd={numberOfIndicators:v,settings:{}}),l.macd.settings[s]=new bt(new yt(r),new yt(n),new yt(o)),Object.assign(u,Ft(Ft(Ft({},m,Gt(y)),b,Gt(y)),g,Gt(y))),p.push(m,b,g)}var w=l.macd,S=w.numberOfIndicators,O=w.settings,_=S>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",j=a===Kt?"".concat(_,"_diff"):"".concat(_,"_diff_").concat(a),P=a===Kt?"".concat(_,"_dea"):"".concat(_,"_dea_").concat(a),A=a===Kt?"".concat(_,"_histogram"):"".concat(_,"_histogram_").concat(a),E=O[s],k=u[a][e];E.update(k,c);var x=null;try{x=E.getResult()}catch(t){x=null}return t.pushToMain({index:e,key:j,value:x?x.macd:null}),t.pushToMain({index:e,key:P,value:x?x.signal:null}),t.pushToMain({index:e,key:A,value:x?x.histogram:null}),!0},relativeVolume:function(t,e){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=(arguments.length>3?arguments[3]:void 0).scale,i="relative_volume_".concat(n),a=t.instances,u=t.verticalOhlcv,l=t.lastIndexReplace;if(0===e){var c=t.nullArray;a[i]={instance:new q(n),prevRelativeVolumeSma:null},u[i]=function(t){if(Array.isArray(t))return Wt(t)}(r=c)||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 Wt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Wt(t,e):void 0}}(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 s=u.volume[e],f=a[i].instance;f.update(s,l);var h=null;try{h=f.getResult()}catch(t){h=null}var y=a[i].prevRelativeVolumeSma,p=null;return"number"==typeof h&&"number"==typeof y&&0!==y&&(p=s/y,o&&(p=Tt(p,o))),t.pushToMain({index:e,key:i,value:p}),a[i].prevRelativeVolumeSma=h,!0},donchianChannels:function(t,e,r,n,o){var i=o.height,a=o.range,u=o.scale,l=o.lag,c="".concat(r,"_").concat(n),s=t.verticalOhlcv,f=t.instances,h=t.len;if(0===e){var y=t.inputParams,p=t.priceBased,v=t.nullArray,d=y.filter((function(t){return"donchianChannels"===t.key})).length,m=d>1?"donchian_channel_".concat(c):"donchian_channel",b=["".concat(m,"_upper"),"".concat(m,"_basis"),"".concat(m,"_lower")];i&&b.push("".concat(m,"_height")),f.hasOwnProperty("donchian_channel")||(f.donchian_channel={numberOfIndicators:d,settings:{}});var g,w=Zt(a);try{for(w.s();!(g=w.n()).done;){var S=g.value;if(!(S in s)||!p.includes(S))throw new Error('Invalid range item value "'.concat(S,'" property for donchianChannels. Only price based key names are accepted:\n').concat(JSON.stringify(p)));b.push("".concat(m,"_range_").concat(S))}}catch(t){w.e(t)}finally{w.f()}var O=Object.fromEntries(b.map((function(t){return[t,(e=v,function(t){if(Array.isArray(t))return ee(t)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||te(e)||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 e})));Object.assign(s,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Qt(Object(r),!0).forEach((function(e){Xt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Qt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},O)),l>0&&t.lag(b,l),p.push("".concat(m,"_upper"),"".concat(m,"_basis"),"".concat(m,"_lower")),f.donchian_channel.settings[c]={maxDeque:[],minDeque:[]}}var _=f.donchian_channel.numberOfIndicators>1?"donchian_channel_".concat(c):"donchian_channel",j=f.donchian_channel.settings[c],P=j.maxDeque,A=j.minDeque,E=e-n,k=E+1,x=k-r;if(x<0||k>h){t.pushToMain({index:e,key:"".concat(_,"_upper"),value:null}),t.pushToMain({index:e,key:"".concat(_,"_basis"),value:null}),t.pushToMain({index:e,key:"".concat(_,"_lower"),value:null}),i&&t.pushToMain({index:e,key:"".concat(_,"_height"),value:null});var T,I=Zt(a);try{for(I.s();!(T=I.n()).done;){var M=T.value;t.pushToMain({index:e,key:"".concat(_,"_range_").concat(M),value:null})}}catch(t){I.e(t)}finally{I.f()}return!0}for(var R=s.high,C=s.low;P.length&&P[0]<x;)P.shift();for(;P.length&&R[P[P.length-1]]<=R[E];)P.pop();for(P.push(E);A.length&&A[0]<x;)A.shift();for(;A.length&&C[A[A.length-1]]>=C[E];)A.pop();A.push(E);var D=P.length?R[P[0]]:null,B=A.length?C[A[0]]:null,V="number"==typeof D&&"number"==typeof B?(D+B)/2:null;if(t.pushToMain({index:e,key:"".concat(_,"_upper"),value:D}),t.pushToMain({index:e,key:"".concat(_,"_basis"),value:V}),t.pushToMain({index:e,key:"".concat(_,"_lower"),value:B}),i){var L=null;"number"==typeof D&&"number"==typeof B&&0!==B&&(L=Tt((D-B)/B,.005)),t.pushToMain({index:e,key:"".concat(_,"_height"),value:L})}var N,z=Zt(a);try{for(z.s();!(N=z.n()).done;){var H=N.value,U=null,q=s[H][e];"number"==typeof q&&"number"==typeof D&&"number"==typeof B&&D-B!=0&&(U=(q-B)/(D-B),u&&(U=Tt(U,u))),t.pushToMain({index:e,key:"".concat(_,"_range_").concat(H),value:U})}}catch(t){z.e(t)}finally{z.f()}return!0},bollingerBands:function(t,e,r,n,o){var i,a,u,l,c,s,f,h=o.height,y=o.range,p=void 0===y?[]:y,v=o.zScore,d=void 0===v?[]:v,m=o.target,b=o.scale,g=o.lag,w=t.verticalOhlcv,S=t.instances,O=t.lastIndexReplace,_="close"===m?"":"_".concat(m),j="".concat(r,"_").concat(n).concat(_);if(0===e){var P=t.priceBased,A=t.inputParams,E=t.nullArray,k=t.verticalOhlcv;if(!(m in k))throw new Error('bollingerBands could not find target "'.concat(m,'"'));var x=A.filter((function(t){return"bollingerBands"===t.key})).length;f=x>1?"bollinger_bands_".concat(j):"bollinger_bands".concat(_),S.bollinger_bands||(S.bollinger_bands={numberOfIndicators:x,settings:{}}),S.bollinger_bands.settings[j]=new ot(r,n);var T=["".concat(f,"_upper"),"".concat(f,"_middle"),"".concat(f,"_lower")];h&&T.push("".concat(f,"_height"));var I,M=ie(p);try{for(M.s();!(I=M.n()).done;){var R=I.value;if(!(R in k)||!P.includes(R))throw new Error('Invalid range item value "'.concat(R,'" property for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(P)));T.push("".concat(f,"_range_").concat(R))}}catch(t){M.e(t)}finally{M.f()}var C,D=ie(d);try{for(D.s();!(C=D.n()).done;){var B=C.value;if(!(B in k)||!P.includes(B))throw new Error('Invalid zScore item value "'.concat(B,'" for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(P)));T.push("".concat(f,"_zscore_").concat(B))}}catch(t){D.e(t)}finally{D.f()}var V=Object.fromEntries(T.map((function(t){return[t,(e=E,function(t){if(Array.isArray(t))return ue(t)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||ae(e)||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 e})));Object.assign(k,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ne(Object(r),!0).forEach((function(e){oe(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ne(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},V)),g>0&&t.lag(T,g),P.push("".concat(f,"_upper"),"".concat(f,"_middle"),"".concat(f,"_lower"))}f||(f=S.bollinger_bands.numberOfIndicators>1?"bollinger_bands_".concat(j):"bollinger_bands".concat(_));var L=f,N=S.bollinger_bands.settings[j],z=w[m][e];N.update(z,O);var H=null;try{H=N.getResult()}catch(t){}var U=null!==(i=null===(a=H)||void 0===a?void 0:a.upper)&&void 0!==i?i:null,q=null!==(u=null===(l=H)||void 0===l?void 0:l.middle)&&void 0!==u?u:null,$=null!==(c=null===(s=H)||void 0===s?void 0:s.lower)&&void 0!==c?c:null;if(t.pushToMain({index:e,key:"".concat(L,"_upper"),value:U}),t.pushToMain({index:e,key:"".concat(L,"_middle"),value:q}),t.pushToMain({index:e,key:"".concat(L,"_lower"),value:$}),h){var F=null;"number"==typeof U&&"number"==typeof $&&0!==$&&(F=Tt((U-$)/$,.005)),t.pushToMain({index:e,key:"".concat(L,"_height"),value:F})}var G,J=ie(p);try{for(J.s();!(G=J.n()).done;){var K=G.value,W=null,Y=w[K][e];"number"==typeof Y&&"number"==typeof $&&"number"==typeof U&&U-$!=0&&(W=(Y-$)/(U-$),b&&(W=Tt(W,b))),t.pushToMain({index:e,key:"".concat(L,"_range_").concat(K),value:W})}}catch(t){J.e(t)}finally{J.f()}var Q,X=ie(d);try{for(X.s();!(Q=X.n()).done;){var Z=Q.value,tt=null,et=w[Z][e];"number"==typeof et&&"number"==typeof q&&"number"==typeof U&&"number"==typeof $&&U-$!=0&&(tt=2*n*(et-q)/(U-$),b&&(tt=Tt(tt,b))),t.pushToMain({index:e,key:"".concat(L,"_zscore_").concat(Z),value:tt})}}catch(t){X.e(t)}finally{X.f()}return!0},volumeOscillator:function(t,e,r,n,o){var i,a=o.scale,u=t.verticalOhlcv,l=t.instances,c=t.lastIndexReplace,s=u.volume[e],f="volume_oscillator";if(0===e){var h=t.crossPairsList,y=t.nullArray;Object.assign(l,{volume_oscillator:{fastEMA:new yt(r),slowEMA:new yt(n)}}),u[f]=function(t){if(Array.isArray(t))return le(t)}(i=y)||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 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}}(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.")}(),h.push({fast:f,slow:0,isDefault:!0})}var p=l[f],v=p.fastEMA,d=p.slowEMA;v.update(s,c),d.update(s,c);var m=null,b=null;try{m=v.getResult()}catch(t){m=null}try{b=d.getResult()}catch(t){b=null}var g=null;return"number"==typeof m&&"number"==typeof b&&0!==b&&(g=100*(m-b)/b,a&&(g=Tt(g,a))),t.pushToMain({index:e,key:f,value:g}),!0},candleStudies:function(t,e,r,n){var o=n.stdDev,i=n.patternSize,a=n.lag,u=n.scale,l=t.verticalOhlcv,c=t.instances,s=t.lastIndexReplace,f=function(t,e){return Bt(t,e,u)};if(0===e){for(var h=t.nullArray,y=[["close","open"],["close","high"],["close","low"],["open","high"],["open","low"],["high","low"]],p=[["open","open"],["high","high"],["low","low"],["close","close"]].concat(y),v=[],d={},m=0;m<i;m++){var b,g=ve(p);try{for(g.s();!(b=g.n()).done;){var w=pe(b.value,2),S=w[0],O=w[1];v.push("candle_change_".concat(m+1,"_").concat(S,"_").concat(O)),d["candle_change_".concat(m+1,"_").concat(S,"_").concat(O)]=ye(h)}}catch(t){g.e(t)}finally{g.f()}}for(var _=[],j={},P=0,A=y;P<A.length;P++){var E=pe(A[P],2),k=E[0],x=E[1];_.push("candle_body_".concat(k,"_").concat(x)),j["candle_body_".concat(k,"_").concat(x)]=ye(h)}var T=[].concat(_,v);Object.assign(l,fe(fe({},j),d)),Object.assign(c,{candleStudies:{bodyVectors:y,lookBackVectors:p,keyNames:T,bodyInstance:new ot(r,o)}}),a>0&&t.lag(T,a)}if(0===e)return!0;var I=c.candleStudies,M=I.bodyVectors,R=I.lookBackVectors,C=I.bodyInstance,D=null,B=l.open[e],V=l.close[e],L=be(V,B);C.update(L,s);try{D=C.getResult()}catch(t){}for(var N=0;N<M.length;N++){var z=pe(M[N],2),H=z[0],U=z[1],q=l[H][e],$=l[U][e];t.pushToMain({index:e,key:"candle_body_".concat(H,"_").concat(U),value:f(be(q,$),D)})}for(var F=0;F<i;F++){var G,J=ve(R);try{for(J.s();!(G=J.n()).done;){var K=pe(G.value,2),W=K[0],Y=K[1],Q=l[W][e],X=l[Y][e-(F+1)];t.pushToMain({index:e,key:"candle_change_".concat(F+1,"_").concat(W,"_").concat(Y),value:void 0===X?null:f(be(Q,X),D)})}}catch(t){J.e(t)}finally{J.f()}}return!0}},Fe=function(t,e,r){var n=function(t){return r>1?t*r:t};if("number"===e)return n(t);if("string"===e){var o=It(t);return n(Number(o))}return 0},Ge=function(t,e){return"number"===e?t:"string"===e?Number(It(t)):0},Je=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=e.len,i=e.inputParams,a=e.hasVolume;e.nullArray=new Array(o).fill(null);var u=["open","high","low","close"];a&&u.push("volume");var l=new Set(u);if(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,u=r(e.value.params);try{for(u.s();!(a=u.n()).done;){var l=a.value;if("number"==typeof l&&l>o)throw console.log(l,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){u.e(t)}finally{u.f()}}}catch(t){i.e(t)}finally{i.f()}}(e),u.forEach((function(t){e.verticalOhlcv[t]=He(e.nullArray)}));var c=Object.keys(t[0]).filter((function(t){return!l.has(t)}));c.forEach((function(t){e.verticalOhlcv[t]=He(e.nullArray)})),e.otherKeys=c,function(t,e){for(var r=0,n=Object.keys(e.inputTypes);r<n.length;r++){var o=n[r];if(!(o in t))throw new Error('Property "'.concat(o,'" not found in ohlcv array. ').concat(e.ticker));var i=t[o];if("number"==typeof i&&i>0)e.inputTypes[o]="number";else{if("string"!=typeof i||!/^(\d+(\.\d*)?|\.\d+)$/.test(i))throw new Error('Invalid property "'.concat(o,'" in ohlcv array. ').concat(e.ticker));e.inputTypes[o]="string",i=It(i)}if(0===e.precisionMultiplier&&!0===e.precision){var a=(c=String(i).split("."),s=2,function(t){if(Array.isArray(t))return t}(c)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(c,s)||Ue(c,s)||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.")}())[1],u=void 0===a?"":a,l=Math.max(4,u.length);e.precisionMultiplier=l>1?Math.pow(10,l-1):1}}var c,s}(t[0],e)}else if(!e.otherKeys)throw new Error("otherKeys not found in main. Ensure you run with startIndex=0 first to initialize.");for(var s=function(t){return Array.isArray(t)?t.map((function(t){var e=t.key,r=t.params;return{key:e,fn:$e[e],args:r}})):[]}(i),f=n;f<o;f++){var h=t[f],y=h.open,p=h.high,v=h.low,d=h.close,m=ze(h,Le),b=e.precisionMultiplier,g=Fe(y,e.inputTypes.open,b),w=Fe(p,e.inputTypes.high,b),S=Fe(v,e.inputTypes.low,b),O=Fe(d,e.inputTypes.close,b);if(e.pushToMain({index:f,key:"open",value:g}),e.pushToMain({index:f,key:"high",value:w}),e.pushToMain({index:f,key:"low",value:S}),e.pushToMain({index:f,key:"close",value:O}),a){var _=h.volume,j=Ge(_,e.inputTypes.volume);e.pushToMain({index:f,key:"volume",value:j})}else delete m.volume;var P,A=Ne(e.otherKeys);try{for(A.s();!(P=A.n()).done;){var E=P.value;e.pushToMain({index:f,key:E,value:m[E]})}}catch(t){A.e(t)}finally{A.f()}var k,x=Ne(s);try{for(x.s();!(k=x.n()).done;){var T=k.value,I=T.key,M=T.fn,R=T.args;["crossPairs","lag"].includes(I)||M.apply(void 0,[e,f].concat(He(R)))}}catch(t){x.e(t)}finally{x.f()}je(e,f),Re(e,f),e.lastComputedIndex++}},Ke=function(t,e){for(var r=t.length,n=new q(e),o=new Array(r),i=0,a=0,u=0,l=0;l<r;l++)if(n.update(t[l]),n.isStable){var c=n.getResult();o[l]=c,i+=c,a+=c*c,u++}else o[l]=null;var s=i/u,f=a/u-s*s,h=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/h:null}))},We=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=Ke(t,r),o=Ke(e,r),i=t.length,a=[],u=0,l=0,c=0,s=0,f=0,h=0,y=-1,p=0;p<i;p++){if(null!==n[p]&&null!==o[p]){y=p;break}a.push(0)}if(-1===y)return new Array(i).fill(0);for(var v=y;v<i;v++){var d=n[v],m=o[v];if(null!==d&&null!==m)if(u+=d,l+=m,c+=d*m,s+=d*d,f+=m*m,++h<2)a.push(0);else{var b=h*c-u*l,g=Math.sqrt((h*s-u*u)*(h*f-l*l)),w=0===g?0:b/g;a.push(w)}else u=l=c=s=f=h=0,a.push(0)}return a};function Ye(t){return function(t){if(Array.isArray(t))return tr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ze(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qe(t){return Qe="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},Qe(t)}function Xe(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||Ze(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ze(t,e){if(t){if("string"==typeof t)return tr(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)?tr(t,e):void 0}}function tr(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 er(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,rr(n.key),n)}}function rr(t){var e=function(t,e){if("object"!=Qe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qe(e)?e:e+""}var nr=[.001,.002,.0025,.005,.01,.02,.025,.05,.1,.2,.25,.5,1,2,2.5,5,10],or=function(){return t=function t(e){var r=e.input,n=e.ticker,o=void 0===n?null:n,i=e.precision,a=void 0===i||i,u=e.inputParams,l=void 0===u?null:u;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.hasVolume=!!("number"==typeof r[0].volume&&r[0].volume>0||"string"==typeof r[0].volume&&r[0].volume),this.isComputed=!1,this.lastComputedIndex=0,this.input=r,this.inputTypes=this.hasVolume?{open:"",high:"",low:"",close:"",volume:""}:{open:"",high:"",low:"",close:""},this.priceBased=["open","high","low","close"],this.len=r.length,this.lastIndexReplace=!1,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.studies={},this.utilities={correlation:We},this.invalidValueIndex=-1,this.precision=a,this.precisionMultiplier=!0===this.precision?0:1,this.minMaxRanges={},Array.isArray(l)&&(this.inputParams=l,this.compute()),this.inputParams=[],this},e=[{key:"pushToMain",value:function(t){var e=t.index,r=t.key,n=t.value;if(null==n)for(var o in this.invalidValueIndex=e,this.minMaxRanges)this.minMaxRanges[o]={min:1/0,max:-1/0};if(this.verticalOhlcv[r][e]=n,"number"==typeof n)if(r.includes("_diff_"))this.minMaxRanges.hasOwnProperty(r)&&this.minMaxRanges[r].min!==1/0&&this.minMaxRanges[r].max!==-1/0||(this.minMaxRanges[r]={min:-1,max:1});else if(r.startsWith("candle_"))this.minMaxRanges[r]={min:-1,max:1};else if(r.includes("_range_")&&(r.startsWith("bollinger_bands_")||r.startsWith("donchian_channel_")))this.minMaxRanges[r]={min:0,max:1};else if(!r.includes("_x_")){var i=this.precision&&this.priceBased.includes(r)?n/this.precisionMultiplier:n;this.minMaxRanges.hasOwnProperty(r)||(this.minMaxRanges[r]={min:1/0,max:-1/0}),i<this.minMaxRanges[r].min&&(this.minMaxRanges[r].min=i),i>this.minMaxRanges[r].max&&(this.minMaxRanges[r].max=i)}}},{key:"getDataAsCols",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.compute();for(var e=this.precisionMultiplier,r=this.precision,n=this.invalidValueIndex,o=this.len,i=this.verticalOhlcv,a=this.priceBased,u={},l=n>=0&&t,c=o-(n+1),s=0,f=Object.entries(i);s<f.length;s++){var h=Xe(f[s],2),y=h[0],p=h[1],v=l?p.slice(-c):p;r&&a.includes(y)&&(v=v.map((function(t){return null==t?null:t/e}))),u[y]=v}return u}},{key:"getData",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.compute();var e=this.precisionMultiplier,r=this.priceBased,n=this.precision;return function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,a=Object.keys(t);if(0===a.length)return[];for(var u=e&&i>=0?i+1:0,l=t[a[0]].length,c=new Array(l-u),s=u;s<l;s++){for(var f={},h=0;h<a.length;h++){var y=a[h],p=t[y][s];f[y]=r&&o.includes(y)?p/n:p}c[s-u]=f}return c}(this.verticalOhlcv,t,n,e,r,this.invalidValueIndex)}},{key:"getLastValues",value:function(){this.compute();for(var t=this.precisionMultiplier,e=this.priceBased,r=this.precision,n=this.verticalOhlcv,o=this.len,i={},a=0,u=Object.keys(n);a<u.length;a++){var l=u[a];i[l]=n[l][o-1]}return r?function(t){for(var e=t.row,r=t.precisionMultiplier,n=t.priceBased,o={},i=0,a=Object.entries(e);i<a.length;i++){var u=kt(a[i],2),l=u[0],c=u[1];n.includes(l)&&(c/=r),o[l]=c}return o}({row:i,precisionMultiplier:t,priceBased:e}):i}},{key:"compute",value:function(t){if(!0===this.isComputed&&!t)return this;if(this.isComputed=!1,this.isValidDate=this.input[0].hasOwnProperty("date")&&o(this.input[0].date),this.len>this.lastComputedIndex&&!t&&Je(this.input,this,0),t&&"object"===Qe(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),Je(this.input,this,this.len)):(this.input[n]=t,Je(this.input,this,n))}return this}},{key:"crossPairs",value:function(t){return i(this),this.crossPairsList=[].concat(Ye(this.crossPairsList),Ye(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;if(i(this),!Array.isArray(e))throw new Error('Param "colKeys" must be a valid array of keyNames in lag.');if("number"!=typeof r||!Number.isInteger(r)||r<0)throw new Error('Param "lags" must be a integer greater or equal to 0: '.concat(JSON.stringify(e)));this.inputParams.push({key:"lag",params:[e,r]});for(var n=function(){var r=e[o];t.priceBased.find((function(t){return r===t}))&&t.priceBased.push(r)},o=0;o<e.length;o++)n();return this}},{key:"relativeVolume",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!1===this.hasVolume)throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');i(this);var r=e.scale,n=void 0===r?null:r;if("number"==typeof n&&!nr.includes(n))throw new Error('"scale" value in relativeVolume must be any of the following numbers: '.concat(nr.join(", ")));return this.inputParams.push({key:"relativeVolume",params:[t,{scale:n}]}),this}},{key:"ema",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this);var r=qt("ema",t,e,nr);return this.inputParams.push({key:"movingAverages",params:["ema",t,r]}),this}},{key:"sma",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this);var r=qt("sma",t,e,nr);return this.inputParams.push({key:"movingAverages",params:["sma",t,r]}),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,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};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.');if("object"!==Qe(n))throw new Error('"options" must be an object in macd. eg: {target}');var o=n.target,a=void 0===o?"close":o;return this.inputParams.push({key:"macd",params:[t,e,r,{target:a}]}),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"!==Qe(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,u=void 0!==a&&a,l=r.range,c=void 0===l?[]:l,s=r.zScore,f=void 0===s?[]:s,h=r.scale,y=void 0===h?null:h,p=r.lag,v=void 0===p?0:p;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.');if(!Array.isArray(c))throw new Error('If set, "range" must be a array of column names in bollingerBands.');if(!Array.isArray(f))throw new Error('If set, "zScore" must be a array of column names in bollingerBands.');if("number"!=typeof v)throw new Error('"lag" value in rsi must be a number in bollingerBands.');if("boolean"!=typeof u)throw new Error('"height" must be a boolean in bollingerBands.');if("number"==typeof y&&!nr.includes(y))throw new Error('"scale" value in bollingerBands must be any of the following numbers: '.concat(nr.join(", ")));return this.inputParams.push({key:"bollingerBands",params:[t,e,{target:o,height:u,scale:y,range:c,zScore:f,lag:v}]}),this}},{key:"rsi",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in rsi.');var r=e.scale,n=void 0===r?null:r,o=e.target,a=void 0===o?"close":o,u=e.lag,l=void 0===u?0:u;if("number"==typeof n&&!nr.includes(n))throw new Error('"scale" value in rsi must be any of the following numbers: '.concat(nr.join(", ")));if("number"!=typeof l)throw new Error('"lag" value in rsi must be a number in rsi.');return this.inputParams.push({key:"rsi",params:[t,{scale:n,target:a,lag:l}]}),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 greater than 0 in donchianChannels.');if("number"!=typeof e||e<0)throw new Error('"offset" must be a number greater than or equal to 0 in donchianChannels.');var n=r.height,o=void 0!==n&&n,a=r.range,u=void 0===a?[]:a,l=r.scale,c=void 0===l?null:l,s=r.lag,f=void 0===s?0:s;if(!Array.isArray(u))throw new Error('If set, "range" must be an array of column names in donchianChannels.');if("number"!=typeof f)throw new Error('"lag" value in rsi must be a number in donchianChannels.');if("boolean"!=typeof o)throw new Error('"height" must be a boolean in donchianChannels.');if("number"==typeof c&&!nr.includes(c))throw new Error('"scale" value in donchianChannels must be any of the following numbers: '.concat(nr.join(", ")));return this.inputParams.push({key:"donchianChannels",params:[t,e,{height:o,range:u,scale:c,lag:f}]}),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]:{};if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number greater than 0 in candleStudies.');var r=e.stdDev,n=void 0===r?.5:r,o=e.lag,a=void 0===o?0:o,u=e.scale,l=void 0===u?.05:u,c=e.patternSize,s=void 0===c?1:c;if("number"!=typeof n||n<=0)throw new Error('"stdDev" must be a positive number greater than 0 in candleStudies.');if("number"==typeof l&&!nr.includes(l))throw new Error('"scale" value in candleStudies must be any of the following numbers: '.concat(nr.join(", ")));if("number"!=typeof s||!Number.isInteger(s)||s<1)throw new Error('"patternSize" value in candleStudies must be an integer greater than 0.}');return this.inputParams.push({key:"candleStudies",params:[t,{stdDev:n,patternSize:s,lag:a,scale:l}]}),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,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1===this.hasVolume)throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');if(i(this),"number"!=typeof t||t<=1)throw new Error('fastSize" must be a positive number greater than 1 in volumeOscillator.');if("number"!=typeof e||e<=t)throw new Error('"slowSize" must be a positive number greater than the "fastSize" in volumeOscillator.');var n=r.scale,o=void 0===n?null:n;if("number"==typeof o&&!nr.includes(o))throw new Error('"scale" value in volumeOscillator must be any of the following numbers: '.concat(nr.join(", ")));return this.inputParams.push({key:"volumeOscillator",params:[t,e,{scale:o}]}),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&&er(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,u=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){l=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(l)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:()=>or});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" , "getDataAsCols" or "getData" methods are called.')},a=1e6,u="[big.js] ",l=u+"Invalid ",c=l+"decimal places",s=l+"rounding mode",f=u+"Division by zero",h={},y=void 0,p=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function v(t,e,r,n){var o=t.c;if(r===y&&(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]!==y))),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]!==y||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 m(t){return m="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},m(t)}function b(t){var e="function"==typeof Map?new Map:void 0;return b=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,S(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)},b(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 S(t){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},S(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,u=r.e,l=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=i<0,u!=l)return u>l^e?1:-1;for(a=(u=n.length)<(l=o.length)?u:l,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return u==l?0:u>l^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,u=r.DP;if(u!==~~u||u<0||u>a)throw Error(c);if(!o[0])throw Error(f);if(!n[0])return t.s=i,t.c=[t.e=0],t;var l,s,h,p,d,m=o.slice(),b=l=o.length,g=n.length,w=n.slice(0,l),S=w.length,O=t,j=O.c=[],_=0,P=u+(O.e=e.e-t.e)+1;for(O.s=i,i=P<0?0:P,m.unshift(0);S++<l;)w.push(0);do{for(h=0;h<10;h++){if(l!=(S=w.length))p=l>S?1:-1;else for(d=-1,p=0;++d<l;)if(o[d]!=w[d]){p=o[d]>w[d]?1:-1;break}if(!(p<0))break;for(s=S==l?o:m;S;){if(w[--S]<s[S]){for(d=S;d&&!w[--d];)w[d]=9;--w[d],w[S]+=10}w[S]-=s[S]}for(;!w[0];)w.shift()}j[_++]=p?h:++h,w[0]&&p?w[S]=n[b]||0:w=[n[b]]}while((b++<g||w[0]!==y)&&i--);return j[0]||1==_||(j.shift(),O.e--,P--),_>P&&v(O,P,r.RM,w[0]!==y),O},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,u=i.s,l=(t=new a(t)).s;if(u!=l)return t.s=-l,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=-l:c[0]?t=new a(i):t.s=1,t;if(u=s-h){for((o=u<0)?(u=-u,n=c):(h=s,n=f),n.reverse(),l=u;l--;)n.push(0);n.reverse()}else for(r=((o=c.length<f.length)?c:f).length,u=l=0;l<r;l++)if(c[l]!=f[l]){o=c[l]<f[l];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(l=(r=f.length)-(e=c.length))>0)for(;l--;)c[e++]=0;for(l=e;r>u;){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[--l];)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,u=o.c,l=t.e,c=t.c;if(!u[0]||!c[0])return c[0]||(u[0]?t=new i(o):t.s=o.s),t;if(u=u.slice(),e=a-l){for(e>0?(l=a,n=c):(e=-e,n=u),n.reverse();e--;)n.push(0);n.reverse()}for(u.length-c.length<0&&(n=c,c=u,u=n),e=c.length,r=0;e;u[e]%=10)r=(u[--e]=u[e]+c[e]+r)/10|0;for(r&&(u.unshift(r),++l),e=u.length;0===u[--e];)u.pop();return t.c=u,t.e=l,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(l+"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(l+"precision");return v(new this.constructor(this),t,e)},h.round=function(t,e){if(t===y)t=0;else if(t!==~~t||t<-a||t>a)throw Error(c);return v(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,l=new o("0.5");if(!n.c[0])return new o(n);if(i<0)throw Error(u+"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=l.times(r.plus(n.div(r)))}while(r.c.slice(0,a).join("")!==t.c.slice(0,a).join(""));return v(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,u=i.length,l=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=l+c,a<u&&(e=o,o=i,i=e,c=a,a=u,u=c),e=new Array(c=a+u);c--;)e[c]=0;for(l=u;l--;){for(u=0,c=a+l;c>l;)u=e[c]+i[l]*o[c-l-1]+u,e[c--]=u%10,u=u/10|0;e[c]=u}for(u?++t.e:e.shift(),l=e.length;!e[--l];)e.pop();return t.c=e,t},h.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==y){if(t!==~~t||t<0||t>a)throw Error(c);for(r=v(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!==y){if(t!==~~t||t<0||t>a)throw Error(c);for(t=t+(r=v(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(u+"Imprecise conversion");return t},h.toPrecision=function(t,e){var r=this,n=r.constructor,o=r.c[0];if(t!==y){if(t!==~~t||t<1||t>a)throw Error(l+"precision");for(r=v(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(u+"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===y?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(l+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!p.test(e))throw Error(l+"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 O=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=S(e),function(t,e){if(e&&("object"==m(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||[],S(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}(b(Error));function j(t){return j="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},j(t)}function _(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,A(n.key),n)}}function P(t,e,r){return(e=A(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function A(t){var e=function(t,e){if("object"!=j(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=j(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==j(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),P(this,"previousHighest",void 0),P(this,"highest",void 0),P(this,"previousLowest",void 0),P(this,"lowest",void 0),P(this,"previousResult",void 0),P(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new O;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)}}])&&_(t.prototype,e),r&&_(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}function x(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 T(t,e,r){return e=M(e),function(t,e){if(e&&("object"==k(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,I()?Reflect.construct(e,r||[],M(t).constructor):e.apply(t,r))}function I(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(I=function(){return!!t})()}function M(t){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},M(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}function C(t){var e=function(t,e){if("object"!=k(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==k(e)?e:e+""}var 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=T(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&&R(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)}}])&&x(r.prototype,n),o&&x(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);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 V(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,z(n.key),n)}}function L(t,e,r){return e=H(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,N()?Reflect.construct(e,r||[],H(t).constructor):e.apply(t,r))}function N(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(N=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 z(t){var e=function(t,e){if("object"!=B(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=B(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==B(e)?e:e+""}var q=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),u=0;u<i;u++)a[u]=arguments[u];return r=t=L(this,e,[].concat(a)),o=[],(n=z(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&&V(r.prototype,n),o&&V(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function $(t){return $="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},$(t)}function F(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=J(e),function(t,e){if(e&&("object"==$(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||[],J(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 J(t){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},J(t)}function W(t,e){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},W(t,e)}function Y(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"!=$(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$(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),Y(r=G(this,e),"interval",void 0),Y(r,"indicator",void 0),Y(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new q(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&&W(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&&F(r.prototype,n),o&&F(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 O;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 ut(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,lt()?Reflect.construct(e,r||[],ct(t).constructor):e.apply(t,r))}function lt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(lt=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 yt=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=ut(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 O;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 vt(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,mt(n.key),n)}}function dt(t,e,r){return(e=mt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function mt(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 bt=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 O;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&&vt(t.prototype,e),r&&vt(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,At(n.key),n)}}function St(t,e,r){return e=jt(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,Ot()?Reflect.construct(e,r||[],jt(t).constructor):e.apply(t,r))}function Ot(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ot=function(){return!!t})()}function jt(t){return jt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},jt(t)}function _t(t,e){return _t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_t(t,e)}function Pt(t,e,r){return(e=At(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function At(t){var e=function(t,e){if("object"!=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),Pt(r=St(this,e),"interval",void 0),Pt(r,"previousPrices",[]),Pt(r,"avgGain",void 0),Pt(r,"avgLoss",void 0),Pt(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&&_t(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 kt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||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}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function 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}var Tt=function(t){var e=1/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:.1);return Math.round(t*e)/e},It=function(t){return t.replace(/(?!^-)[^0-9.]/g,"")};function Mt(t){return Mt="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},Mt(t)}function Rt(t){return function(t){if(Array.isArray(t))return Ct(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 Ct(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)?Ct(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 Ct(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 Dt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Mt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Mt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Mt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Bt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.05;if(null==t||null==e)return null;var n=t>=0,o=Math.abs(t),i=e.upper,a=e.middle,u=e.lower;if(o<u)return 0;if(o>i)return n?1:-1;var l=Number.EPSILON*Math.max(o,Math.abs(a));if(Math.abs(o-a)<l)return n?.5:-.5;if(i===u)return null;var c=Tt((o-u)/(i-u),r);return n?Math.min(c,1):Math.max(-c,-1)};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 Lt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ht(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Nt(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)||Ht(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 Ht(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}}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}var zt={ema:yt,sma:q},qt=function(t,e,r,n){if(!r||"object"!==Vt(r))throw new Error('"options" must be an object in '.concat(t,". eg: {target, height, range}"));var o=r.target,i=void 0===o?"close":o,a=r.diff,u=void 0===a?null:a;if("string"!=typeof i)throw new Error('"target" must be a valid keyName '.concat(t,"."));if("number"!=typeof e||e<=0)throw new Error('"size" must be a positive number in '.concat(t,"."));var l={target:i,diff:null};if(null!==u&&("object"===Vt(u)||"boolean"==typeof u&&!0===u)){var c=u=!0===u?{}:u,s=c.stdDev,f=void 0===s?2:s,h=c.scale,y=void 0===h?.05:h,p=c.targets,v=void 0===p?["close"]:p,d=c.size,m=void 0===d?e:d,b=c.lag,g=void 0===b?0:b;if("number"!=typeof f||f<=0)throw new Error('"diff.stdDev" must be a number greater than 0 in '.concat(t,"."));if("number"!=typeof y||!n.includes(y))throw new Error('"diff.scale" must be a number between 0.01 and 1 in '.concat(t,"."));if("number"!=typeof m||!Number.isInteger(m)||m<=0)throw new Error('"diff.size" must be an integer greater than or equal to size in '.concat(t,"."));if(!Array.isArray(v))throw new Error('"diff.targest" must be an array of keyNames with at least 1 item in '.concat(t,"."));if("number"!=typeof g||!Number.isInteger(g)||g<0)throw new Error('"diff.lag" must be an integer greater than 0 in '.concat(t,"."));l.diff={stdDev:f,scale:y,size:m,targets:v,lag:g}}return l};function $t(t){return $t="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},$t(t)}function Ft(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=$t(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=$t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$t(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,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}var Jt="close";function Wt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Yt(t){return Yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(t)}function Qt(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 Xt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=te(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function te(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}}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}function re(t){return re="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},re(t)}function ne(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 oe(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=re(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=re(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==re(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ie(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ae(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function ae(t,e){if(t){if("string"==typeof t)return ue(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)?ue(t,e):void 0}}function ue(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 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 se(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 fe(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?se(Object(r),!0).forEach((function(e){he(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):se(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function he(t,e,r){return(e=function(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+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ye(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)||de(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){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||de(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ve(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=de(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function de(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}}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}var be=function(t,e){return(t-e)/e};function ge(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||Se(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function we(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Se(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Se(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}}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}function je(t){return je="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},je(t)}var _e=function(t,e){var r=t.instances,n=t.verticalOhlcv,o=t.nullArray;if(0===e){var i=t.inputParams,a=t.priceBased,u=i.filter((function(t){return"lag"===t.key}));if("object"!==je(u))return;var l,c=u.map((function(t){return t.params})),s=we(c);try{for(s.s();!(l=s.n()).done;){var f,h=ge(l.value,2),y=h[0],p=h[1],v=we(y);try{for(v.s();!(f=v.n()).done;){var d=f.value;if(a.includes(d))for(var m=1;m<=p;m++)a.push("".concat(d,"_lag_").concat(m))}}catch(t){v.e(t)}finally{v.f()}}}catch(t){s.e(t)}finally{s.f()}r.lag={lagParams:c}}var b,g,w=we(r.lag.lagParams);try{for(w.s();!(b=w.n()).done;){var S,O=ge(b.value,2),j=O[0],_=O[1],P=we(j);try{for(P.s();!(S=P.n()).done;){var A=S.value,E=n[A];if(0===e)for(var k=1;k<=_;k++)n["".concat(A,"_lag_").concat(k)]=function(t){if(Array.isArray(t))return Oe(t)}(g=o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(g)||Se(g)||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.")}();for(var x=1;x<=_;x++){var T="".concat(A,"_lag_").concat(x),I=e-x,M=I<=0||void 0===E[I]?null:E[I];t.pushToMain({index:e,key:T,value:M})}}}catch(t){P.e(t)}finally{P.f()}}}catch(t){w.e(t)}finally{w.f()}return!0};function Pe(t,e){if(t){if("string"==typeof t)return Ae(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)?Ae(t,e):void 0}}function Ae(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 ke(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,xe(n.key),n)}}function xe(t){var e=function(t,e){if("object"!=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 Te=function(t,e){return t>e},Ie=function(t,e){return t<e},Me=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:Te(e,n)?i=this.areHighAndLowUndefined?1:[o,n,this.prevLow,this.prevSlow].every((function(t){return null!==t}))&&Ie(o,n)&&Te(this.prevLow,this.prevSlow)?0:1:Ie(e,n)&&(i=this.areHighAndLowUndefined?0:[r,n,this.prevHigh,this.prevSlow].every((function(t){return null!==t}))&&Te(r,n)&&Ie(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}}])&&ke(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Re=function(t,e){var r=t.nullArray,n=t.verticalOhlcv,o=t.instances,i=t.len;if(0===e){var a=t.inputParams.filter((function(t){return"crossPairs"===t.key}));if("object"!==Ee(a))return;o.crossPairs={crossPairsList:a.flatMap((function(t){return t.params.flat()}))}}var u,l,c=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Pe(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(o.crossPairs.crossPairsList);try{for(c.s();!(u=c.n()).done;){var s=u.value,f=s.fast,h=s.slow;if(null!=f&&null!=h){var y="".concat(f,"_x_").concat(h);if(0===e){if("number"==typeof h&&(n[h]=new Array(i).fill(h)),"price"!==f&&!n.hasOwnProperty(f))throw Error('fast "'.concat(f,' not found in crossPairs"'));if(!n.hasOwnProperty(h))throw Error('slow "'.concat(h,' not found in crossPairs"'));o[y]=new Me,n[y]=function(t){if(Array.isArray(t))return Ae(t)}(l=r)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(l)||Pe(l)||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 p=void 0,v=void 0,d=void 0,m=void 0,b=void 0;"price"===f?(v=n.close[e],d=n.high[e],m=n.low[e],b=n[h][e],o[y].update({fast:v,slow:b,high:d,low:m})):(p=n[f][e],b=n[h][e],o[y].update({fast:p,slow:b})),t.pushToMain({index:e,key:y,value:o[y].getResult()})}}}catch(t){c.e(t)}finally{c.f()}};function Ce(t){return function(t){if(Array.isArray(t))return De(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return De(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?De(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function De(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Be(t){return function(t){if(Array.isArray(t))return Ve(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 Ve(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)?Ve(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 Ve(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 Le=["open","high","low","close"];function Ne(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ze(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,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function He(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.includes(r)||{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function Ue(t){return function(t){if(Array.isArray(t))return qe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ze(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ze(t,e){if(t){if("string"==typeof t)return qe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qe(t,e):void 0}}function qe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var $e={dateTime:function(t,e){var r=t.instances,n=t.verticalOhlcv;if(0===e){var o=t.nullArray;if(!t.isValidDate)throw Error('dateTime method found and invalid "date" in input ohlcv');var i=n.date[0].slice(0,10);Object.assign(r,{dateTime:{prevDateStr:i,sessionDailyIndexCount:0,sessionIntradayIndexCount:0,cachedDayInfo:i}}),Object.assign(n,{day_of_the_week:Ce(o),day_of_the_month:Ce(o),week_of_the_month:Ce(o),hour:Ce(o),month:Ce(o),year:Ce(o),session_daily_index:Ce(o),session_intraday_index:Ce(o)})}var a=n.date[e],u=function(t){var e=new Date(t),r=e.getMonth(),n=e.getFullYear(),o=e.getHours(),i=e.getMinutes(),a=e.getDay(),u=e.getDate(),l=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:u,week_of_the_month:Math.ceil((u+l)/7)}}(a),l=u.day_of_the_week,c=u.day_of_the_month,s=u.week_of_the_month,f=u.month,h=u.year,y=u.hour,p=a.slice(0,10);p!==r.dateTime.prevDateStr&&(r.dateTime.prevDateStr=p,r.dateTime.sessionDailyIndexCount++,r.dateTime.sessionIntradayIndexCount=0),t.pushToMain({index:e,key:"session_daily_index",value:r.dateTime.sessionDailyIndexCount}),t.pushToMain({index:e,key:"session_intraday_index",value:r.dateTime.sessionIntradayIndexCount}),t.pushToMain({index:e,key:"day_of_the_week",value:l}),t.pushToMain({index:e,key:"day_of_the_month",value:c}),t.pushToMain({index:e,key:"week_of_the_month",value:s}),t.pushToMain({index:e,key:"month",value:f}),t.pushToMain({index:e,key:"year",value:h}),t.pushToMain({index:e,key:"hour",value:y}),r.dateTime.sessionIntradayIndexCount++},priceVariations:function(t,e){0===e&&(t.priceBased=Be(new Set([].concat(Be(t.priceBased),["mid_price_open_close","mid_price_high_low"]))),Object.assign(t.verticalOhlcv,{mid_price_open_close:Be(t.nullArray),mid_price_high_low:Be(t.nullArray)}));var r=t.verticalOhlcv.open[e],n=t.verticalOhlcv.high[e],o=t.verticalOhlcv.low[e],i=t.verticalOhlcv.close[e];t.pushToMain({index:e,key:"mid_price_open_close",value:(r+i)/2}),t.pushToMain({index:e,key:"mid_price_high_low",value:(n+o)/2})},rsi:function(t,e,r,n){var o=n.scale,i=n.target,a=n.lag,u=t.verticalOhlcv,l=t.instances,c=t.lastIndexReplace,s="close"===i?"":"_".concat(i),f="rsi_".concat(r).concat(s),h="rsi_sma_".concat(r).concat(s);if(0===e){var y=t.crossPairsList,p=t.nullArray;if(!u.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for rsi."));y.push({fast:f,slow:h,isDefault:!0}),Object.assign(l,Dt(Dt({},f,new Et(r)),h,new q(r))),Object.assign(u,Dt(Dt({},f,Rt(p)),h,Rt(p))),a>0&&t.lag([f,h],a)}var v=u[i][e],d=null,m=null;l[f].update(v,c);try{d=l[f].getResult()}catch(t){d=null}null!==d&&"number"==typeof d&&o&&(d=Tt(d,o)),t.pushToMain({index:e,key:f,value:d}),null!==d&&"number"==typeof d&&l[h].update(d,c);try{m=l[h].getResult()}catch(t){m=null}null!==m&&"number"==typeof m&&o&&(m=Tt(m,o)),t.pushToMain({index:e,key:h,value:m})},movingAverages:function(t,e,r,n,o){var i=o.target,a=o.diff,u=t.verticalOhlcv,l=t.instances,c=t.priceBased,s=t.lastIndexReplace,f="string"==typeof i&&u.hasOwnProperty(i)&&"close"!==i?"_".concat(i):"",h="".concat(r,"_").concat(n).concat(f),y="".concat(r,"_").concat(n,"_diff").concat(f);if(0===e){var p=t.nullArray;if(!u.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for ").concat(r,"."));if(l[h]={maInstance:new zt[r](n)},u[h]=Nt(p),null!==a){l[h].diffInstance=new ot(a.size,a.stdDev);var v,d=[],m=Lt(a.targets);try{for(m.s();!(v=m.n()).done;){var b=v.value;u["".concat(y,"_").concat(b)]=Nt(p),a.lag>0&&d.push("".concat(y,"_").concat(b))}}catch(t){m.e(t)}finally{m.f()}a.lag>0&&t.lag(d,a.lag)}c.push(h)}var g=u[i][e],w=l[h],S=w.maInstance,O=w.diffInstance;S.update(g,s);var j=null;try{j=S.getResult()}catch(t){j=null}if(t.pushToMain({index:e,key:h,value:j}),null!==a){var _,P=Lt(a.targets);try{for(P.s();!(_=P.n()).done;){var A=_.value,E=null;null!==j&&"number"==typeof j&&(E=u[A][e]-j),null!==E&&"number"==typeof E&&O.update(Math.abs(E),s);var k=null;try{k=O.getResult()}catch(t){k=null}var x=Bt(E,k,a.scale);t.pushToMain({index:e,key:"".concat(y,"_").concat(A),value:x})}}catch(t){P.e(t)}finally{P.f()}}return!0},macd:function(t,e,r,n,o,i){var a=i.target,u=t.verticalOhlcv,l=t.instances,c=t.lastIndexReplace,s="".concat(r,"_").concat(n,"_").concat(o).concat(a===Jt?"":"_".concat(a));if(0===e){var f=t.inputParams,h=t.crossPairsList,y=t.nullArray,p=t.priceBased;if(!u.hasOwnProperty(a))throw new Error("Target property ".concat(a," not found in verticalOhlcv for macd."));var v=f.filter((function(t){return"macd"===t.key})).length,d=v>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",m=a===Jt?"".concat(d,"_diff"):"".concat(d,"_diff_").concat(a),b=a===Jt?"".concat(d,"_dea"):"".concat(d,"_dea_").concat(a),g=a===Jt?"".concat(d,"_histogram"):"".concat(d,"_histogram_").concat(a);h.push({fast:m,slow:b,isDefault:!0}),l.hasOwnProperty("macd")||(l.macd={numberOfIndicators:v,settings:{}}),l.macd.settings[s]=new bt(new yt(r),new yt(n),new yt(o)),Object.assign(u,Ft(Ft(Ft({},m,Gt(y)),b,Gt(y)),g,Gt(y))),p.push(m,b,g)}var w=l.macd,S=w.numberOfIndicators,O=w.settings,j=S>1?"macd_".concat(r,"_").concat(n,"_").concat(o):"macd",_=a===Jt?"".concat(j,"_diff"):"".concat(j,"_diff_").concat(a),P=a===Jt?"".concat(j,"_dea"):"".concat(j,"_dea_").concat(a),A=a===Jt?"".concat(j,"_histogram"):"".concat(j,"_histogram_").concat(a),E=O[s],k=u[a][e];E.update(k,c);var x=null;try{x=E.getResult()}catch(t){x=null}return t.pushToMain({index:e,key:_,value:x?x.macd:null}),t.pushToMain({index:e,key:P,value:x?x.signal:null}),t.pushToMain({index:e,key:A,value:x?x.histogram:null}),!0},relativeVolume:function(t,e){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o=(arguments.length>3?arguments[3]:void 0).scale,i="relative_volume_".concat(n),a=t.instances,u=t.verticalOhlcv,l=t.lastIndexReplace;if(0===e){var c=t.nullArray;a[i]={instance:new q(n),prevRelativeVolumeSma:null},u[i]=function(t){if(Array.isArray(t))return Wt(t)}(r=c)||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 Wt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Wt(t,e):void 0}}(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 s=u.volume[e],f=a[i].instance;f.update(s,l);var h=null;try{h=f.getResult()}catch(t){h=null}var y=a[i].prevRelativeVolumeSma,p=null;return"number"==typeof h&&"number"==typeof y&&0!==y&&(p=s/y,o&&(p=Tt(p,o))),t.pushToMain({index:e,key:i,value:p}),a[i].prevRelativeVolumeSma=h,!0},donchianChannels:function(t,e,r,n,o){var i=o.height,a=o.range,u=o.scale,l=o.lag,c="".concat(r,"_").concat(n),s=t.verticalOhlcv,f=t.instances,h=t.len;if(0===e){var y=t.inputParams,p=t.priceBased,v=t.nullArray,d=y.filter((function(t){return"donchianChannels"===t.key})).length,m=d>1?"donchian_channel_".concat(c):"donchian_channel",b=["".concat(m,"_upper"),"".concat(m,"_basis"),"".concat(m,"_lower")];i&&b.push("".concat(m,"_height")),f.hasOwnProperty("donchian_channel")||(f.donchian_channel={numberOfIndicators:d,settings:{}});var g,w=Zt(a);try{for(w.s();!(g=w.n()).done;){var S=g.value;if(!(S in s)||!p.includes(S))throw new Error('Invalid range item value "'.concat(S,'" property for donchianChannels. Only price based key names are accepted:\n').concat(JSON.stringify(p)));b.push("".concat(m,"_range_").concat(S))}}catch(t){w.e(t)}finally{w.f()}var O=Object.fromEntries(b.map((function(t){return[t,(e=v,function(t){if(Array.isArray(t))return ee(t)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||te(e)||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 e})));Object.assign(s,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Qt(Object(r),!0).forEach((function(e){Xt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Qt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},O)),l>0&&t.lag(b,l),p.push("".concat(m,"_upper"),"".concat(m,"_basis"),"".concat(m,"_lower")),f.donchian_channel.settings[c]={maxDeque:[],minDeque:[]}}var j=f.donchian_channel.numberOfIndicators>1?"donchian_channel_".concat(c):"donchian_channel",_=f.donchian_channel.settings[c],P=_.maxDeque,A=_.minDeque,E=e-n,k=E+1,x=k-r;if(x<0||k>h){t.pushToMain({index:e,key:"".concat(j,"_upper"),value:null}),t.pushToMain({index:e,key:"".concat(j,"_basis"),value:null}),t.pushToMain({index:e,key:"".concat(j,"_lower"),value:null}),i&&t.pushToMain({index:e,key:"".concat(j,"_height"),value:null});var T,I=Zt(a);try{for(I.s();!(T=I.n()).done;){var M=T.value;t.pushToMain({index:e,key:"".concat(j,"_range_").concat(M),value:null})}}catch(t){I.e(t)}finally{I.f()}return!0}for(var R=s.high,C=s.low;P.length&&P[0]<x;)P.shift();for(;P.length&&R[P[P.length-1]]<=R[E];)P.pop();for(P.push(E);A.length&&A[0]<x;)A.shift();for(;A.length&&C[A[A.length-1]]>=C[E];)A.pop();A.push(E);var D=P.length?R[P[0]]:null,B=A.length?C[A[0]]:null,V="number"==typeof D&&"number"==typeof B?(D+B)/2:null;if(t.pushToMain({index:e,key:"".concat(j,"_upper"),value:D}),t.pushToMain({index:e,key:"".concat(j,"_basis"),value:V}),t.pushToMain({index:e,key:"".concat(j,"_lower"),value:B}),i){var L=null;"number"==typeof D&&"number"==typeof B&&0!==B&&(L=Tt((D-B)/B,.001)),t.pushToMain({index:e,key:"".concat(j,"_height"),value:L})}var N,H=Zt(a);try{for(H.s();!(N=H.n()).done;){var U=N.value,z=null,q=s[U][e];"number"==typeof q&&"number"==typeof D&&"number"==typeof B&&D-B!=0&&(z=Math.max(Math.min((q-B)/(D-B),1),0),u&&(z=Tt(z,u))),t.pushToMain({index:e,key:"".concat(j,"_range_").concat(U),value:z})}}catch(t){H.e(t)}finally{H.f()}return!0},bollingerBands:function(t,e,r,n,o){var i,a,u,l,c,s,f,h=o.height,y=o.range,p=void 0===y?[]:y,v=o.target,d=o.scale,m=o.lag,b=t.verticalOhlcv,g=t.instances,w=t.lastIndexReplace,S="close"===v?"":"_".concat(v),O="".concat(r,"_").concat(n).concat(S);if(0===e){var j=t.priceBased,_=t.inputParams,P=t.nullArray,A=t.verticalOhlcv;if(!(v in A))throw new Error('bollingerBands could not find target "'.concat(v,'"'));var E=_.filter((function(t){return"bollingerBands"===t.key})).length;f=E>1?"bollinger_bands_".concat(O):"bollinger_bands".concat(S),g.bollinger_bands||(g.bollinger_bands={numberOfIndicators:E,settings:{}}),g.bollinger_bands.settings[O]=new ot(r,n);var k=["".concat(f,"_upper"),"".concat(f,"_middle"),"".concat(f,"_lower")];h&&k.push("".concat(f,"_height"));var x,T=ie(p);try{for(T.s();!(x=T.n()).done;){var I=x.value;if(!(I in A)||!j.includes(I))throw new Error('Invalid range item value "'.concat(I,'" property for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(j)));k.push("".concat(f,"_range_").concat(I))}}catch(t){T.e(t)}finally{T.f()}var M=Object.fromEntries(k.map((function(t){return[t,(e=P,function(t){if(Array.isArray(t))return ue(t)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||ae(e)||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 e})));Object.assign(A,function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ne(Object(r),!0).forEach((function(e){oe(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ne(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},M)),m>0&&t.lag(k,m),j.push("".concat(f,"_upper"),"".concat(f,"_middle"),"".concat(f,"_lower"))}f||(f=g.bollinger_bands.numberOfIndicators>1?"bollinger_bands_".concat(O):"bollinger_bands".concat(S));var R=f,C=g.bollinger_bands.settings[O],D=b[v][e];C.update(D,w);var B=null;try{B=C.getResult()}catch(t){}var V=null!==(i=null===(a=B)||void 0===a?void 0:a.upper)&&void 0!==i?i:null,L=null!==(u=null===(l=B)||void 0===l?void 0:l.middle)&&void 0!==u?u:null,N=null!==(c=null===(s=B)||void 0===s?void 0:s.lower)&&void 0!==c?c:null;if(t.pushToMain({index:e,key:"".concat(R,"_upper"),value:V}),t.pushToMain({index:e,key:"".concat(R,"_middle"),value:L}),t.pushToMain({index:e,key:"".concat(R,"_lower"),value:N}),h){var H=null;"number"==typeof V&&"number"==typeof N&&0!==N&&(H=Tt((V-N)/N,.001)),t.pushToMain({index:e,key:"".concat(R,"_height"),value:H})}var U,z=ie(p);try{for(z.s();!(U=z.n()).done;){var q=U.value,$=null,F=b[q][e];"number"==typeof F&&"number"==typeof N&&"number"==typeof V&&V-N!=0&&($=Math.max(Math.min((F-N)/(V-N),1),0),d&&($=Tt($,d))),t.pushToMain({index:e,key:"".concat(R,"_range_").concat(q),value:$})}}catch(t){z.e(t)}finally{z.f()}return!0},volumeOscillator:function(t,e,r,n,o){var i,a=o.scale,u=t.verticalOhlcv,l=t.instances,c=t.lastIndexReplace,s=u.volume[e],f="volume_oscillator";if(0===e){var h=t.crossPairsList,y=t.nullArray;Object.assign(l,{volume_oscillator:{fastEMA:new yt(r),slowEMA:new yt(n)}}),u[f]=function(t){if(Array.isArray(t))return le(t)}(i=y)||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 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}}(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.")}(),h.push({fast:f,slow:0,isDefault:!0})}var p=l[f],v=p.fastEMA,d=p.slowEMA;v.update(s,c),d.update(s,c);var m=null,b=null;try{m=v.getResult()}catch(t){m=null}try{b=d.getResult()}catch(t){b=null}var g=null;return"number"==typeof m&&"number"==typeof b&&0!==b&&(g=100*(m-b)/b,a&&(g=Tt(g,a))),t.pushToMain({index:e,key:f,value:g}),!0},candleStudies:function(t,e,r,n){var o=n.stdDev,i=n.patternSize,a=n.lag,u=n.scale,l=t.verticalOhlcv,c=t.instances,s=t.lastIndexReplace,f=function(t,e){return Bt(t,e,u)};if(0===e){for(var h=t.nullArray,y=[["close","open"],["close","high"],["close","low"],["open","high"],["open","low"],["high","low"]],p=[["open","open"],["high","high"],["low","low"],["close","close"]].concat(y),v=[],d={},m=0;m<i;m++){var b,g=ve(p);try{for(g.s();!(b=g.n()).done;){var w=pe(b.value,2),S=w[0],O=w[1];v.push("candle_change_".concat(m+1,"_").concat(S,"_").concat(O)),d["candle_change_".concat(m+1,"_").concat(S,"_").concat(O)]=ye(h)}}catch(t){g.e(t)}finally{g.f()}}for(var j=[],_={},P=0,A=y;P<A.length;P++){var E=pe(A[P],2),k=E[0],x=E[1];j.push("candle_body_".concat(k,"_").concat(x)),_["candle_body_".concat(k,"_").concat(x)]=ye(h)}var T=[].concat(j,v);Object.assign(l,fe(fe({},_),d)),Object.assign(c,{candleStudies:{bodyVectors:y,lookBackVectors:p,keyNames:T,bodyInstance:new ot(r,o)}}),a>0&&t.lag(T,a)}if(0===e)return!0;var I=c.candleStudies,M=I.bodyVectors,R=I.lookBackVectors,C=I.bodyInstance,D=null,B=l.open[e],V=l.close[e],L=be(V,B);C.update(L,s);try{D=C.getResult()}catch(t){}for(var N=0;N<M.length;N++){var H=pe(M[N],2),U=H[0],z=H[1],q=l[U][e],$=l[z][e];t.pushToMain({index:e,key:"candle_body_".concat(U,"_").concat(z),value:f(be(q,$),D)})}for(var F=0;F<i;F++){var G,K=ve(R);try{for(K.s();!(G=K.n()).done;){var J=pe(G.value,2),W=J[0],Y=J[1],Q=l[W][e],X=l[Y][e-(F+1)];t.pushToMain({index:e,key:"candle_change_".concat(F+1,"_").concat(W,"_").concat(Y),value:void 0===X?null:f(be(Q,X),D)})}}catch(t){K.e(t)}finally{K.f()}}return!0}},Fe=function(t,e,r){var n=function(t){return r>1?t*r:t};if("number"===e)return n(t);if("string"===e){var o=It(t);return n(Number(o))}return 0},Ge=function(t,e){return"number"===e?t:"string"===e?Number(It(t)):0},Ke=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=e.len,i=e.inputParams,a=e.hasVolume;e.nullArray=new Array(o).fill(null);var u=["open","high","low","close"];a&&u.push("volume");var l=new Set(u);if(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,u=r(e.value.params);try{for(u.s();!(a=u.n()).done;){var l=a.value;if("number"==typeof l&&l>o)throw console.log(l,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){u.e(t)}finally{u.f()}}}catch(t){i.e(t)}finally{i.f()}}(e),u.forEach((function(t){e.verticalOhlcv[t]=Ue(e.nullArray)}));var c=Object.keys(t[0]).filter((function(t){return!l.has(t)}));c.forEach((function(t){e.verticalOhlcv[t]=Ue(e.nullArray)})),e.otherKeys=c,function(t,e){for(var r=0,n=Object.keys(e.inputTypes);r<n.length;r++){var o=n[r];if(!(o in t))throw new Error('Property "'.concat(o,'" not found in ohlcv array. ').concat(e.ticker));var i=t[o];if("number"==typeof i&&i>0)e.inputTypes[o]="number";else{if("string"!=typeof i||!/^(\d+(\.\d*)?|\.\d+)$/.test(i))throw new Error('Invalid property "'.concat(o,'" in ohlcv array. ').concat(e.ticker));e.inputTypes[o]="string",i=It(i)}if(0===e.precisionMultiplier&&!0===e.precision){var a=(c=String(i).split("."),s=2,function(t){if(Array.isArray(t))return t}(c)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(c,s)||ze(c,s)||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.")}())[1],u=void 0===a?"":a,l=Math.max(4,u.length);e.precisionMultiplier=l>1?Math.pow(10,l-1):1}}var c,s}(t[0],e)}else if(!e.otherKeys)throw new Error("otherKeys not found in main. Ensure you run with startIndex=0 first to initialize.");for(var s=function(t){return Array.isArray(t)?t.map((function(t){var e=t.key,r=t.params;return{key:e,fn:$e[e],args:r}})):[]}(i),f=n;f<o;f++){var h=t[f],y=h.open,p=h.high,v=h.low,d=h.close,m=He(h,Le),b=e.precisionMultiplier,g=Fe(y,e.inputTypes.open,b),w=Fe(p,e.inputTypes.high,b),S=Fe(v,e.inputTypes.low,b),O=Fe(d,e.inputTypes.close,b);if(e.pushToMain({index:f,key:"open",value:g}),e.pushToMain({index:f,key:"high",value:w}),e.pushToMain({index:f,key:"low",value:S}),e.pushToMain({index:f,key:"close",value:O}),a){var j=h.volume,_=Ge(j,e.inputTypes.volume);e.pushToMain({index:f,key:"volume",value:_})}else delete m.volume;var P,A=Ne(e.otherKeys);try{for(A.s();!(P=A.n()).done;){var E=P.value;e.pushToMain({index:f,key:E,value:m[E]})}}catch(t){A.e(t)}finally{A.f()}var k,x=Ne(s);try{for(x.s();!(k=x.n()).done;){var T=k.value,I=T.key,M=T.fn,R=T.args;["crossPairs","lag"].includes(I)||M.apply(void 0,[e,f].concat(Ue(R)))}}catch(t){x.e(t)}finally{x.f()}_e(e,f),Re(e,f),e.lastComputedIndex++}},Je=function(t,e){for(var r=t.length,n=new q(e),o=new Array(r),i=0,a=0,u=0,l=0;l<r;l++)if(n.update(t[l]),n.isStable){var c=n.getResult();o[l]=c,i+=c,a+=c*c,u++}else o[l]=null;var s=i/u,f=a/u-s*s,h=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/h:null}))},We=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=Je(t,r),o=Je(e,r),i=t.length,a=[],u=0,l=0,c=0,s=0,f=0,h=0,y=-1,p=0;p<i;p++){if(null!==n[p]&&null!==o[p]){y=p;break}a.push(0)}if(-1===y)return new Array(i).fill(0);for(var v=y;v<i;v++){var d=n[v],m=o[v];if(null!==d&&null!==m)if(u+=d,l+=m,c+=d*m,s+=d*d,f+=m*m,++h<2)a.push(0);else{var b=h*c-u*l,g=Math.sqrt((h*s-u*u)*(h*f-l*l)),w=0===g?0:b/g;a.push(w)}else u=l=c=s=f=h=0,a.push(0)}return a};function Ye(t){return function(t){if(Array.isArray(t))return tr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ze(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qe(t){return Qe="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},Qe(t)}function Xe(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}}(t,e)||Ze(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ze(t,e){if(t){if("string"==typeof t)return tr(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)?tr(t,e):void 0}}function tr(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 er(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,rr(n.key),n)}}function rr(t){var e=function(t,e){if("object"!=Qe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Qe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qe(e)?e:e+""}var nr=[.001,.002,.0025,.005,.01,.02,.025,.05,.1,.2,.25,.5,1,2,2.5,5,10],or=function(){return t=function t(e){var r=e.input,n=e.ticker,o=void 0===n?null:n,i=e.precision,a=void 0===i||i,u=e.inputParams,l=void 0===u?null:u;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.hasVolume=!!("number"==typeof r[0].volume&&r[0].volume>0||"string"==typeof r[0].volume&&r[0].volume),this.isComputed=!1,this.lastComputedIndex=0,this.input=r,this.inputTypes=this.hasVolume?{open:"",high:"",low:"",close:"",volume:""}:{open:"",high:"",low:"",close:""},this.priceBased=["open","high","low","close"],this.len=r.length,this.lastIndexReplace=!1,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.studies={},this.utilities={correlation:We},this.invalidValueIndex=-1,this.precision=a,this.precisionMultiplier=!0===this.precision?0:1,this.minMaxRanges={},Array.isArray(l)&&(this.inputParams=l,this.compute()),this.inputParams=[],this},e=[{key:"pushToMain",value:function(t){var e=t.index,r=t.key,n=t.value;if(null==n)for(var o in this.invalidValueIndex=e,this.minMaxRanges)this.minMaxRanges[o]={min:1/0,max:-1/0};if(this.verticalOhlcv[r][e]=n,"number"==typeof n)if(r.includes("_diff_"))this.minMaxRanges.hasOwnProperty(r)&&this.minMaxRanges[r].min!==1/0&&this.minMaxRanges[r].max!==-1/0||(this.minMaxRanges[r]={min:-1,max:1});else if(r.startsWith("candle_"))this.minMaxRanges[r]={min:-1,max:1};else if(r.includes("_range_")&&(r.startsWith("bollinger_bands_")||r.startsWith("donchian_channel_")))this.minMaxRanges[r]={min:0,max:1};else if(!r.includes("_x_")){var i=this.precision&&this.priceBased.includes(r)?n/this.precisionMultiplier:n;this.minMaxRanges.hasOwnProperty(r)||(this.minMaxRanges[r]={min:1/0,max:-1/0}),i<this.minMaxRanges[r].min&&(this.minMaxRanges[r].min=i),i>this.minMaxRanges[r].max&&(this.minMaxRanges[r].max=i)}}},{key:"getDataAsCols",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.compute();for(var e=this.precisionMultiplier,r=this.precision,n=this.invalidValueIndex,o=this.len,i=this.verticalOhlcv,a=this.priceBased,u={},l=n>=0&&t,c=o-(n+1),s=0,f=Object.entries(i);s<f.length;s++){var h=Xe(f[s],2),y=h[0],p=h[1],v=l?p.slice(-c):p;r&&a.includes(y)&&(v=v.map((function(t){return null==t?null:t/e}))),u[y]=v}return u}},{key:"getData",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.compute();var e=this.precisionMultiplier,r=this.priceBased,n=this.precision;return function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,a=Object.keys(t);if(0===a.length)return[];for(var u=e&&i>=0?i+1:0,l=t[a[0]].length,c=new Array(l-u),s=u;s<l;s++){for(var f={},h=0;h<a.length;h++){var y=a[h],p=t[y][s];f[y]=r&&o.includes(y)?p/n:p}c[s-u]=f}return c}(this.verticalOhlcv,t,n,e,r,this.invalidValueIndex)}},{key:"getLastValues",value:function(){this.compute();for(var t=this.precisionMultiplier,e=this.priceBased,r=this.precision,n=this.verticalOhlcv,o=this.len,i={},a=0,u=Object.keys(n);a<u.length;a++){var l=u[a];i[l]=n[l][o-1]}return r?function(t){for(var e=t.row,r=t.precisionMultiplier,n=t.priceBased,o={},i=0,a=Object.entries(e);i<a.length;i++){var u=kt(a[i],2),l=u[0],c=u[1];n.includes(l)&&(c/=r),o[l]=c}return o}({row:i,precisionMultiplier:t,priceBased:e}):i}},{key:"compute",value:function(t){if(!0===this.isComputed&&!t)return this;if(this.isComputed=!1,this.isValidDate=this.input[0].hasOwnProperty("date")&&o(this.input[0].date),this.len>this.lastComputedIndex&&!t&&Ke(this.input,this,0),t&&"object"===Qe(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),Ke(this.input,this,this.len)):(this.input[n]=t,Ke(this.input,this,n))}return this}},{key:"crossPairs",value:function(t){return i(this),this.crossPairsList=[].concat(Ye(this.crossPairsList),Ye(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;if(i(this),!Array.isArray(e))throw new Error('Param "colKeys" must be a valid array of keyNames in lag.');if("number"!=typeof r||!Number.isInteger(r)||r<0)throw new Error('Param "lags" must be a integer greater or equal to 0: '.concat(JSON.stringify(e)));this.inputParams.push({key:"lag",params:[e,r]});for(var n=function(){var r=e[o];t.priceBased.find((function(t){return r===t}))&&t.priceBased.push(r)},o=0;o<e.length;o++)n();return this}},{key:"relativeVolume",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!1===this.hasVolume)throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');i(this);var r=e.scale,n=void 0===r?null:r;if("number"==typeof n&&!nr.includes(n))throw new Error('"scale" value in relativeVolume must be any of the following numbers: '.concat(nr.join(", ")));return this.inputParams.push({key:"relativeVolume",params:[t,{scale:n}]}),this}},{key:"ema",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this);var r=qt("ema",t,e,nr);return this.inputParams.push({key:"movingAverages",params:["ema",t,r]}),this}},{key:"sma",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this);var r=qt("sma",t,e,nr);return this.inputParams.push({key:"movingAverages",params:["sma",t,r]}),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,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};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.');if("object"!==Qe(n))throw new Error('"options" must be an object in macd. eg: {target}');var o=n.target,a=void 0===o?"close":o;return this.inputParams.push({key:"macd",params:[t,e,r,{target:a}]}),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"!==Qe(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,u=void 0!==a&&a,l=r.range,c=void 0===l?[]:l,s=r.scale,f=void 0===s?null:s,h=r.lag,y=void 0===h?0:h;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.');if(!Array.isArray(c))throw new Error('If set, "range" must be a array of column names in bollingerBands.');if("number"!=typeof y)throw new Error('"lag" value in rsi must be a number in bollingerBands.');if("boolean"!=typeof u)throw new Error('"height" must be a boolean in bollingerBands.');if("number"==typeof f&&!nr.includes(f))throw new Error('"scale" value in bollingerBands must be any of the following numbers: '.concat(nr.join(", ")));return this.inputParams.push({key:"bollingerBands",params:[t,e,{target:o,height:u,scale:f,range:c,lag:y}]}),this}},{key:"rsi",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in rsi.');var r=e.scale,n=void 0===r?null:r,o=e.target,a=void 0===o?"close":o,u=e.lag,l=void 0===u?0:u;if("number"==typeof n&&!nr.includes(n))throw new Error('"scale" value in rsi must be any of the following numbers: '.concat(nr.join(", ")));if("number"!=typeof l)throw new Error('"lag" value in rsi must be a number in rsi.');return this.inputParams.push({key:"rsi",params:[t,{scale:n,target:a,lag:l}]}),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 greater than 0 in donchianChannels.');if("number"!=typeof e||e<0)throw new Error('"offset" must be a number greater than or equal to 0 in donchianChannels.');var n=r.height,o=void 0!==n&&n,a=r.range,u=void 0===a?[]:a,l=r.scale,c=void 0===l?null:l,s=r.lag,f=void 0===s?0:s;if(!Array.isArray(u))throw new Error('If set, "range" must be an array of column names in donchianChannels.');if("number"!=typeof f)throw new Error('"lag" value in rsi must be a number in donchianChannels.');if("boolean"!=typeof o)throw new Error('"height" must be a boolean in donchianChannels.');if("number"==typeof c&&!nr.includes(c))throw new Error('"scale" value in donchianChannels must be any of the following numbers: '.concat(nr.join(", ")));return this.inputParams.push({key:"donchianChannels",params:[t,e,{height:o,range:u,scale:c,lag:f}]}),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]:{};if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number greater than 0 in candleStudies.');var r=e.stdDev,n=void 0===r?.5:r,o=e.lag,a=void 0===o?0:o,u=e.scale,l=void 0===u?.05:u,c=e.patternSize,s=void 0===c?1:c;if("number"!=typeof n||n<=0)throw new Error('"stdDev" must be a positive number greater than 0 in candleStudies.');if("number"==typeof l&&!nr.includes(l))throw new Error('"scale" value in candleStudies must be any of the following numbers: '.concat(nr.join(", ")));if("number"!=typeof s||!Number.isInteger(s)||s<1)throw new Error('"patternSize" value in candleStudies must be an integer greater than 0.}');return this.inputParams.push({key:"candleStudies",params:[t,{stdDev:n,patternSize:s,lag:a,scale:l}]}),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,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1===this.hasVolume)throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');if(i(this),"number"!=typeof t||t<=1)throw new Error('fastSize" must be a positive number greater than 1 in volumeOscillator.');if("number"!=typeof e||e<=t)throw new Error('"slowSize" must be a positive number greater than the "fastSize" in volumeOscillator.');var n=r.scale,o=void 0===n?null:n;if("number"==typeof o&&!nr.includes(o))throw new Error('"scale" value in volumeOscillator must be any of the following numbers: '.concat(nr.join(", ")));return this.inputParams.push({key:"volumeOscillator",params:[t,e,{scale:o}]}),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&&er(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
package/index.js CHANGED
@@ -350,7 +350,7 @@ export default class OHLCV_INDICATORS {
350
350
  throw new Error('"options" must be an object in bollingerBands. eg: {target, height, range}');
351
351
  }
352
352
 
353
- const {target = 'close', height = false, range = [], zScore = [], scale = null, lag = 0} = options
353
+ const {target = 'close', height = false, range = [], scale = null, lag = 0} = options
354
354
 
355
355
  // Validate size and times
356
356
  if (typeof size !== 'number' || size <= 0) {
@@ -362,9 +362,6 @@ export default class OHLCV_INDICATORS {
362
362
  if (!Array.isArray(range)) {
363
363
  throw new Error('If set, "range" must be a array of column names in bollingerBands.');
364
364
  }
365
- if (!Array.isArray(zScore)) {
366
- throw new Error('If set, "zScore" must be a array of column names in bollingerBands.');
367
- }
368
365
  if (typeof lag !== 'number') {
369
366
 
370
367
  throw new Error(`"lag" value in rsi must be a number in bollingerBands.`);
@@ -380,7 +377,7 @@ export default class OHLCV_INDICATORS {
380
377
  }
381
378
  }
382
379
 
383
- this.inputParams.push({key: 'bollingerBands', params: [size, stdDev, {target, height, scale, range, zScore, lag}]});
380
+ this.inputParams.push({key: 'bollingerBands', params: [size, stdDev, {target, height, scale, range, lag}]});
384
381
 
385
382
  return this;
386
383
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohlcv-indicators",
3
- "version": "3.1.8",
3
+ "version": "3.1.9",
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",
@@ -3,7 +3,7 @@ import { calcMagnitude } from '../utilities/numberUtilities.js';
3
3
 
4
4
  const defaultTarget = 'close'
5
5
 
6
- export const bollingerBands = (main, index, size, stdDev, { height, range = [], zScore = [], target, scale, lag }) => {
6
+ export const bollingerBands = (main, index, size, stdDev, { height, range = [], target, scale, lag }) => {
7
7
  const { verticalOhlcv, instances, lastIndexReplace } = main;
8
8
  const suffix = target === defaultTarget ? '' : `_${target}`;
9
9
  const indicatorKey = `${size}_${stdDev}${suffix}`;
@@ -51,14 +51,6 @@ export const bollingerBands = (main, index, size, stdDev, { height, range = [],
51
51
  keyNames.push(`${prefix}_range_${rangeKey}`)
52
52
  }
53
53
 
54
- // Set up additional arrays for each zScore property.
55
- for (const zScoreKey of zScore) {
56
- if (!(zScoreKey in verticalOhlcv) || !priceBased.includes(zScoreKey)) {
57
- throw new Error(`Invalid zScore item value "${zScoreKey}" for bollingerBands. Only price based key names are accepted:\n${JSON.stringify(priceBased)}`);
58
- }
59
- keyNames.push(`${prefix}_zscore_${zScoreKey}`)
60
- }
61
-
62
54
  const verticalOhlcvSetup = Object.fromEntries(keyNames.map(v => [v, [...nullArray]]))
63
55
  Object.assign(verticalOhlcv, {...verticalOhlcvSetup})
64
56
 
@@ -104,7 +96,7 @@ export const bollingerBands = (main, index, size, stdDev, { height, range = [],
104
96
  if (height) {
105
97
  let heightValue = null;
106
98
  if (typeof upper === 'number' && typeof lower === 'number' && lower !== 0) {
107
- heightValue = calcMagnitude( ((upper - lower) / lower), 0.005)
99
+ heightValue = calcMagnitude( ((upper - lower) / lower), 0.001)
108
100
  }
109
101
  main.pushToMain({ index, key: `${subPrefix}_height`, value: heightValue });
110
102
  }
@@ -114,7 +106,7 @@ export const bollingerBands = (main, index, size, stdDev, { height, range = [],
114
106
  let rangeValue = null;
115
107
  const priceValue = verticalOhlcv[rangeKey][index];
116
108
  if (typeof priceValue === 'number' && typeof lower === 'number' && typeof upper === 'number' && (upper - lower) !== 0) {
117
- rangeValue = (priceValue - lower) / (upper - lower);
109
+ rangeValue = Math.max(Math.min((priceValue - lower) / (upper - lower), 1), 0);
118
110
  if (scale) {
119
111
  rangeValue = calcMagnitude(rangeValue, scale);
120
112
  }
@@ -122,24 +114,5 @@ export const bollingerBands = (main, index, size, stdDev, { height, range = [],
122
114
  main.pushToMain({ index, key: `${subPrefix}_range_${rangeKey}`, value: rangeValue });
123
115
  }
124
116
 
125
- // Process each zScore property.
126
- for (const zScoreKey of zScore) {
127
- let zScoreValue = null;
128
- const priceValue = verticalOhlcv[zScoreKey][index];
129
- if (
130
- typeof priceValue === 'number' &&
131
- typeof middle === 'number' &&
132
- typeof upper === 'number' &&
133
- typeof lower === 'number' &&
134
- (upper - lower) !== 0
135
- ) {
136
- zScoreValue = (2 * stdDev * (priceValue - middle)) / (upper - lower);
137
- if (scale) {
138
- zScoreValue = calcMagnitude(zScoreValue, scale);
139
- }
140
- }
141
- main.pushToMain({ index, key: `${subPrefix}_zscore_${zScoreKey}`, value: zScoreValue });
142
- }
143
-
144
117
  return true;
145
118
  }
@@ -110,7 +110,7 @@ export const donchianChannels = (main, index, size, offset, { height, range, sca
110
110
  if (height) {
111
111
  let heightValue = null;
112
112
  if (typeof upper === 'number' && typeof lower === 'number' && lower !== 0) {
113
- heightValue = calcMagnitude( ((upper - lower) / lower), 0.005)
113
+ heightValue = calcMagnitude( ((upper - lower) / lower), 0.001)
114
114
  }
115
115
  main.pushToMain({ index, key: `${subPrefix}_height`, value: heightValue });
116
116
  }
@@ -125,7 +125,7 @@ export const donchianChannels = (main, index, size, offset, { height, range, sca
125
125
  typeof lower === 'number' &&
126
126
  (upper - lower) !== 0
127
127
  ) {
128
- rangeValue = (priceValue - lower) / (upper - lower);
128
+ rangeValue = Math.max(Math.min((priceValue - lower) / (upper - lower), 1), 0);
129
129
  if (scale) {
130
130
  rangeValue = calcMagnitude(rangeValue, scale);
131
131
  }
@@ -46,5 +46,5 @@ export const classifyBoll = (value, bollingerBands, scale = 0.05) => {
46
46
 
47
47
  //magnitude = Math.min(Math.max(magnitude, 0), 1)
48
48
 
49
- return positive ? magnitude : -magnitude
49
+ return positive ? Math.min(magnitude, 1) : Math.max(-magnitude, -1)
50
50
  }