ohlcv-indicators 2.0.9 → 2.1.1
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.
- package/dist/ohlcv-indicators.min.js +1 -1
- package/index.js +47 -11
- package/package.json +1 -1
- package/src/utilities/parsing-utilities.js +1 -1
- package/src/utilities/precision.js +18 -0
|
@@ -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:()=>Ge});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={},p=void 0,y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function v(t,e,r,n){var o=t.c;if(r===p&&(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]!==p))),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]!==p||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function d(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function b(t){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(t)}function m(t){var e="function"==typeof Map?new Map:void 0;return m=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(g())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&w(o,r.prototype),o}(t,arguments,O(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)},m(t)}function g(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(g=function(){return!!t})()}function w(t,e){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},w(t,e)}function O(t){return O=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},O(t)}h.abs=function(){var t=new this.constructor(this);return t.s=1,t},h.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,a=t.s,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,y,d,b=o.slice(),m=l=o.length,g=n.length,w=n.slice(0,l),O=w.length,S=t,_=S.c=[],j=0,A=u+(S.e=e.e-t.e)+1;for(S.s=i,i=A<0?0:A,b.unshift(0);O++<l;)w.push(0);do{for(h=0;h<10;h++){if(l!=(O=w.length))y=l>O?1:-1;else for(d=-1,y=0;++d<l;)if(o[d]!=w[d]){y=o[d]>w[d]?1:-1;break}if(!(y<0))break;for(s=O==l?o:b;O;){if(w[--O]<s[O]){for(d=O;d&&!w[--d];)w[d]=9;--w[d],w[O]+=10}w[O]-=s[O]}for(;!w[0];)w.shift()}_[j++]=y?h:++h,w[0]&&y?w[O]=n[m]||0:w=[n[m]]}while((m++<g||w[0]!==p)&&i--);return _[0]||1==j||(_.shift(),S.e--,A--),j>A&&v(S,A,r.RM,w[0]!==p),S},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===p)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!==p){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!==p){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!==p){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===p?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(!y.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 S=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=O(e),function(t,e){if(e&&("object"==b(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,g()?Reflect.construct(e,r||[],O(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&w(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(m(Error));function _(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,P(n.key),n)}}function A(t,e,r){return(e=P(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(t){var e=function(t,e){if("object"!=_(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 k=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),A(this,"previousHighest",void 0),A(this,"highest",void 0),A(this,"previousLowest",void 0),A(this,"lowest",void 0),A(this,"previousResult",void 0),A(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new S;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 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)}function I(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"==E(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,x()?Reflect.construct(e,r||[],M(t).constructor):e.apply(t,r))}function x(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(x=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"!=E(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=E(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==E(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)}}])&&I(r.prototype,n),o&&I(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(k);function z(t){return z="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},z(t)}function L(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,$(n.key),n)}}function B(t,e,r){return e=H(e),function(t,e){if(e&&("object"==z(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,V()?Reflect.construct(e,r||[],H(t).constructor):e.apply(t,r))}function V(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(V=function(){return!!t})()}function H(t){return H=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},H(t)}function U(t,e){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},U(t,e)}function $(t){var e=function(t,e){if("object"!=z(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=z(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==z(e)?e:e+""}var F=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,a=new Array(i),u=0;u<i;u++)a[u]=arguments[u];return r=t=B(this,e,[].concat(a)),o=[],(n=$(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&U(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}],n&&L(r.prototype,n),o&&L(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Q(n.key),n)}}function G(t,e,r){return e=J(e),function(t,e){if(e&&("object"==N(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,K()?Reflect.construct(e,r||[],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 Y(t,e){return Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Y(t,e)}function W(t,e,r){return(e=Q(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Q(t){var e=function(t,e){if("object"!=N(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=N(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==N(e)?e:e+""}var X=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),W(r=G(this,e),"interval",void 0),W(r,"indicator",void 0),W(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new F(t),r.smoothingFactor=1/r.interval,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Y(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&q(r.prototype,n),o&&q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(k);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 S;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 pt=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 S;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 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 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,bt(n.key),n)}}function dt(t,e,r){return(e=bt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function bt(t){var e=function(t,e){if("object"!=yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}var mt=function(){return 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 S;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,Pt(n.key),n)}}function Ot(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,St()?Reflect.construct(e,r||[],_t(t).constructor):e.apply(t,r))}function St(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(St=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 At(t,e,r){return(e=Pt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pt(t){var e=function(t,e){if("object"!=gt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=gt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gt(e)?e:e+""}var kt=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),At(r=Ot(this,e),"interval",void 0),At(r,"previousPrices",[]),At(r,"avgGain",void 0),At(r,"avgLoss",void 0),At(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&jt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&wt(r.prototype,n),o&&wt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(k);function Et(t){return Et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Et(t)}function It(t){return function(t){if(Array.isArray(t))return Tt(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 Tt(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)?Tt(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 Tt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function xt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Et(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Mt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ct(t){return Ct="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},Ct(t)}function Dt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Ct(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ct(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ct(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){return function(t){if(Array.isArray(t))return Lt(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 Lt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Lt(t,e):void 0}}(t)||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 Lt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Bt(t){return Bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bt(t)}function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ht=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5;if(null===t||null===e||null===r)return null;if(n<2)throw new Error("numLevels must be at least 2");for(var o=4*r/(n-1),i=[],a=0;a<n-1;a++)i.push(e-2*r+a*o);for(var u=i.length-1;u>=0;u--)if(t>i[u])return(u+1)/(n-1);return 0};function Ut(t){return Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ut(t)}function $t(t){return function(t){if(Array.isArray(t))return Ft(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ft(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ft(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Nt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function qt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Nt(Object(r),!0).forEach((function(e){Gt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Nt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Gt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Ut(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ut(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ut(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Kt(t){return Kt="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},Kt(t)}function Jt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Wt(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 Yt(t){return function(t){if(Array.isArray(t))return Qt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Wt(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wt(t,e){if(t){if("string"==typeof t)return Qt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qt(t,e):void 0}}function Qt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Xt(t,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 Zt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Kt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ee(t){return function(t){if(Array.isArray(t))return re(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 re(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)?re(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 re(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 ne(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,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)||ie(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 oe(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ie(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 ie(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 ue(t){return ue="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},ue(t)}var le=function(t,e){if(0===e){var r=t.inputParams.filter((function(t){return"lag"===t.key}));if("object"!==ue(r))return;var n,o=r.map((function(t){return t.params})),i=oe(o);try{for(i.s();!(n=i.n()).done;){var a,u=ne(n.value,2),l=u[0],c=u[1],s=oe(l);try{for(s.s();!(a=s.n()).done;){var f=a.value;if(t.priceBased.includes(f))for(var h=1;h<=c;h++)t.priceBased.push("".concat(f,"_lag_").concat(h))}}catch(t){s.e(t)}finally{s.f()}}}catch(t){i.e(t)}finally{i.f()}t.instances.lag={lagParams:o}}var p,y,v=oe(t.instances.lag.lagParams);try{for(v.s();!(p=v.n()).done;){var d,b=ne(p.value,2),m=b[0],g=b[1],w=oe(m);try{for(w.s();!(d=w.n()).done;){var O=d.value,S=t.verticalOhlcv[O];if(0===e)for(var _=1;_<=g;_++){var j="".concat(O,"_lag_").concat(_);t.verticalOhlcv[j]=function(t){if(Array.isArray(t))return ae(t)}(y=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(y)||ie(y)||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 A=1;A<=g;A++){var P="".concat(O,"_lag_").concat(A),k=e-A;if(k<=0)break;t.pushToMain({index:e,key:P,value:S[k]})}}}catch(t){w.e(t)}finally{w.f()}}}catch(t){v.e(t)}finally{v.f()}return!0};function ce(t,e){if(t){if("string"==typeof t)return se(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?se(t,e):void 0}}function se(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function fe(t){return fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fe(t)}function he(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,pe(n.key),n)}}function pe(t){var e=function(t,e){if("object"!=fe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fe(e)?e:e+""}var ye=function(t,e){return t>e},ve=function(t,e){return t<e},de=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:ye(e,n)?i=this.areHighAndLowUndefined?1:[o,n,this.prevLow,this.prevSlow].every((function(t){return null!==t}))&&ve(o,n)&&ye(this.prevLow,this.prevSlow)?0:1:ve(e,n)&&(i=this.areHighAndLowUndefined?0:[r,n,this.prevHigh,this.prevSlow].every((function(t){return null!==t}))&&ye(r,n)&&ve(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}}])&&he(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),be=function(t,e){if(0===e){var r=t.inputParams.filter((function(t){return"crossPairs"===t.key}));if("object"!==fe(r))return;t.instances.crossPairs={crossPairsList:r.flatMap((function(t){return t.params.flat()}))}}var n,o,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ce(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}}}}(t.instances.crossPairs.crossPairsList);try{for(i.s();!(n=i.n()).done;){var a=n.value,u=a.fast,l=a.slow;if(u&&l){var c="".concat(u,"_x_").concat(l);if(0===e){if("number"==typeof l&&(t.verticalOhlcv[l]=new Array(t.len).fill(l)),"price"!==u&&!t.verticalOhlcv.hasOwnProperty(u))throw Error('fast "'.concat(u,' not found in crossPairs"'));if(!t.verticalOhlcv.hasOwnProperty(l))throw Error('slow "'.concat(l,' not found in crossPairs"'));t.instances[c]=new de,t.verticalOhlcv[c]=function(t){if(Array.isArray(t))return se(t)}(o=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||ce(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var s=void 0,f=void 0,h=void 0,p=void 0,y=void 0;"price"===u?(f=t.verticalOhlcv.close[e],h=t.verticalOhlcv.high[e],p=t.verticalOhlcv.low[e],y=t.verticalOhlcv[l][e],t.instances[c].update({fast:f,slow:y,high:h,low:p})):(s=t.verticalOhlcv[u][e],y=t.verticalOhlcv[l][e],t.instances[c].update({fast:s,slow:y})),t.pushToMain({index:e,key:c,value:t.instances[c].getResult()})}}}catch(t){i.e(t)}finally{i.f()}};function me(t){return function(t){if(Array.isArray(t))return ge(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 ge(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)?ge(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 ge(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 we(t){return function(t){if(Array.isArray(t))return Oe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Oe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Oe(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Oe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Se=["open","high","low","close","volume"];function _e(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Pe(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 je(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 Ae(t){return function(t){if(Array.isArray(t))return ke(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Pe(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){if(t){if("string"==typeof t)return ke(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ke(t,e):void 0}}function ke(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ee=function(t){return t.replace(/(?!^-)[^0-9.]/g,"")},Ie={dateTime:function(t,e){if(0===e){if(!t.isValidDate)throw Error('dateTime method found and invalid "date" in input ohlcv');var r=t.verticalOhlcv.date[0].slice(0,10);Object.assign(t.instances,{dateTime:{prevDateStr:r,sessionDailyIndexCount:0,sessionIntradayIndexCount:0,cachedDayInfo:r}}),Object.assign(t.verticalOhlcv,{day_of_the_week:me(t.nullArray),day_of_the_month:me(t.nullArray),week_of_the_month:me(t.nullArray),hour:me(t.nullArray),month:me(t.nullArray),year:me(t.nullArray),session_daily_index:me(t.nullArray),session_intraday_index:me(t.nullArray)})}var n=t.verticalOhlcv.date[e],o=function(t){var e=new Date(t),r=e.getMonth(),n=e.getFullYear(),o=e.getHours(),i=e.getMinutes(),a=e.getDay(),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)}}(n),i=o.day_of_the_week,a=o.day_of_the_month,u=o.week_of_the_month,l=o.month,c=o.year,s=o.hour,f=n.slice(0,10);f!==t.instances.dateTime.prevDateStr&&(t.instances.dateTime.prevDateStr=f,t.instances.dateTime.sessionDailyIndexCount++,t.instances.dateTime.sessionIntradayIndexCount=0),t.pushToMain({index:e,key:"session_daily_index",value:t.instances.dateTime.sessionDailyIndexCount}),t.pushToMain({index:e,key:"session_intraday_index",value:t.instances.dateTime.sessionIntradayIndexCount}),t.pushToMain({index:e,key:"day_of_the_week",value:i}),t.pushToMain({index:e,key:"day_of_the_month",value:a}),t.pushToMain({index:e,key:"week_of_the_month",value:u}),t.pushToMain({index:e,key:"month",value:l}),t.pushToMain({index:e,key:"year",value:c}),t.pushToMain({index:e,key:"hour",value:s})},priceVariations:function(t,e){0===e&&(t.priceBased=we(new Set([].concat(we(t.priceBased),["mid_price_open_close","mid_price_high_low"]))),Object.assign(t.verticalOhlcv,{mid_price_open_close:we(t.nullArray),mid_price_high_low:we(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){var n,o,i=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"rsi_".concat(r),slow:"rsi_sma_".concat(r),isDefault:!0}),Object.assign(t.instances,xt(xt({},"rsi_".concat(r),new kt(r)),"rsi_sma_".concat(r),new F(r))),Object.assign(t.verticalOhlcv,xt(xt({},"rsi_".concat(r),It(t.nullArray)),"rsi_sma_".concat(r),It(t.nullArray)))),t.instances["rsi_".concat(r)].update(i,t.lastIndexReplace);try{n=t.instances["rsi_".concat(r)].getResult()}catch(t){n=null}n&&(t.pushToMain({index:e,key:"rsi_".concat(r),value:n}),t.instances["rsi_sma_".concat(r)].update(n,t.lastIndexReplace));try{o=t.instances["rsi_sma_".concat(r)].getResult()}catch(t){o=null}return o&&t.pushToMain({index:e,key:"rsi_sma_".concat(r),value:o}),!0},sma:function(t,e,r,n){var o,i,a=t.verticalOhlcv.close[e],u="string"==typeof n&&t.verticalOhlcv.hasOwnProperty(n)&&"close"!==n?"".concat(n,"_"):"",l="".concat(u,"sma_").concat(r);0===e&&(t.instances[l]=new F(r),t.verticalOhlcv[l]=function(t){if(Array.isArray(t))return Mt(t)}(i=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return Mt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mt(t,e):void 0}}(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),t.instances[l].update(a,t.lastIndexReplace);try{o=t.instances[l].getResult()}catch(t){}o&&t.pushToMain({index:e,key:l,value:o})},ema:function(t,e,r,n){var o,i,a=t.verticalOhlcv.close[e],u="string"==typeof n&&t.verticalOhlcv.hasOwnProperty(n)&&"close"!==n?"".concat(n,"_"):"",l="".concat(u,"ema_").concat(r);0===e&&(t.instances[l]=new pt(r),t.verticalOhlcv[l]=function(t){if(Array.isArray(t))return Rt(t)}(i=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),t.instances[l].update(a,t.lastIndexReplace);try{o=t.instances[l].getResult()}catch(t){o=null}o&&t.pushToMain({index:e,key:l,value:o})},macd:function(t,e,r,n,o,i){var a=i.target,u="close"===a?"":"_".concat(a),l="".concat(r,"_").concat(n,"_").concat(o).concat(u);if(0===e){if(!t.verticalOhlcv.hasOwnProperty(a))throw new Error("Target property ".concat(a," not found in verticalOhlcv for macd."));var c=t.inputParams.filter((function(t){return"macd"===t.key})).length,s=c>1?"macd_".concat(l):"macd".concat(u);t.crossPairsList.push({fast:"".concat(s,"_diff"),slow:"".concat(s,"_dea"),isDefault:!0}),t.instances.hasOwnProperty("macd")||(t.instances.macd={numberOfIndicators:c,settings:{}}),t.instances.macd.settings[l]=new mt(new pt(r),new pt(n),new pt(o)),Object.assign(t.verticalOhlcv,Dt(Dt(Dt({},"".concat(s,"_diff"),zt(t.nullArray)),"".concat(s,"_dea"),zt(t.nullArray)),"".concat(s,"_histogram"),zt(t.nullArray)))}var f,h=t.instances.macd.numberOfIndicators>1?"macd_".concat(l):"macd".concat(u),p=t.instances.macd.settings[l],y=t.verticalOhlcv[a][e];p.update(y,t.lastIndexReplace);try{f=p.getResult()}catch(t){}return f&&(t.pushToMain({index:e,key:"".concat(h,"_diff"),value:f.macd}),t.pushToMain({index:e,key:"".concat(h,"_dea"),value:f.signal}),t.pushToMain({index:e,key:"".concat(h,"_histogram"),value:f.histogram})),!0},relativeVolume:function(t,e){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o="relative_volume_".concat(n);0===e&&(t.instances[o]={instance:new F(n),prevRelativeVolumeSma:null},Object.assign(t.verticalOhlcv,function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},o,function(t){if(Array.isArray(t))return Vt(t)}(r=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vt(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())));var i,a=t.verticalOhlcv.volume[e],u=t.instances[o].instance;u.update(a,t.lastIndexReplace);try{i=u.getResult()}catch(t){}var l=t.instances[o].prevRelativeVolumeSma;return t.pushToMain({index:e,key:o,value:null!==i&&null!==l?a/l:null}),t.instances[o].prevRelativeVolumeSma=i,!0},donchianChannels:function(t,e,r,n,o){var i=o.height,a=o.range,u="".concat(r,"_").concat(n);if(0===e){var l=t.inputParams.filter((function(t){return"donchianChannels"===t.key})).length,c=l>1?"donchian_channel_".concat(u):"donchian_channel";Object.assign(t.verticalOhlcv,qt(qt(Gt(Gt(Gt({},"".concat(c,"_upper"),$t(t.nullArray)),"".concat(c,"_basis"),$t(t.nullArray)),"".concat(c,"_lower"),$t(t.nullArray)),i&&Gt({},"".concat(c,"_height"),$t(t.nullArray))),a&&Gt({},"".concat(c,"_range"),$t(t.nullArray)))),t.instances.hasOwnProperty("donchian_channel")||(t.instances.donchian_channel={numberOfIndicators:l,settings:{}}),t.instances.donchian_channel.settings[u]={heightInstance:i?new F("number"==typeof i&&i>0?i:r):null,maxDeque:[],minDeque:[]}}var s=t.instances.donchian_channel.numberOfIndicators>1?"donchian_channel_".concat(u):"donchian_channel",f=t.instances.donchian_channel.settings[u],h=f.heightInstance,p=f.maxDeque,y=f.minDeque,v=e-n,d=v+1,b=d-r;if(b<0||d>t.len)return!0;for(var m=t.verticalOhlcv.high,g=t.verticalOhlcv.low;p.length&&p[0]<b;)p.shift();for(;p.length&&m[p[p.length-1]]<=m[v];)p.pop();for(p.push(v);y.length&&y[0]<b;)y.shift();for(;y.length&&g[y[y.length-1]]>=g[v];)y.pop();y.push(v);var w=m[p[0]],O=g[y[0]],S=(w+O)/2,_=(t.verticalOhlcv.close[e]-O)/(w-O),j=w-O;if(i&&h&&h.update(j,t.lastIndexReplace),t.pushToMain({index:e,key:"".concat(s,"_upper"),value:w}),t.pushToMain({index:e,key:"".concat(s,"_basis"),value:S}),t.pushToMain({index:e,key:"".concat(s,"_lower"),value:O}),a&&t.pushToMain({index:e,key:"".concat(s,"_range"),value:_}),i&&h){var A;try{A=h.getResult()}catch(t){}A&&t.pushToMain({index:e,key:"".concat(s,"_height"),value:Ht(j,A,1.5)})}return!0},bollingerBands:function(t,e,r,n,o){var i,a=o.height,u=o.range,l=void 0===u?[]:u,c=o.zScore,s=void 0===c?[]:c,f=o.target,h="close"===f?"":"_".concat(f),p="".concat(r,"_").concat(n).concat(h);if(0===e){if(!(f in t.verticalOhlcv))throw new Error('bollingerBands could not find target "'.concat(f,'"'));var y=t.inputParams.filter((function(t){return"bollingerBands"===t.key})).length;i=y>1?"bollinger_bands_".concat(p):"bollinger_bands".concat(h),t.instances.bollinger_bands||(t.instances.bollinger_bands={numberOfIndicators:y,settings:{}}),t.instances.bollinger_bands.settings[p]={instance:new ot(r,n),heightInstance:a>=r?new F(a):null};var v,d=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Xt(Object(r),!0).forEach((function(e){Zt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}(Zt(Zt(Zt({},"".concat(i,"_upper"),Yt(t.nullArray)),"".concat(i,"_middle"),Yt(t.nullArray)),"".concat(i,"_lower"),Yt(t.nullArray)),a>=r&&Zt({},"".concat(i,"_height"),Yt(t.nullArray))),b=Jt(l);try{for(b.s();!(v=b.n()).done;){var m=v.value;if(!(m in t.verticalOhlcv)||!t.priceBased.includes(m))throw new Error('Invalid range item value "'.concat(m,'" property for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(t.priceBased)));d["".concat(i,"_range_").concat(m)]=Yt(t.nullArray)}}catch(t){b.e(t)}finally{b.f()}var g,w=Jt(s);try{for(w.s();!(g=w.n()).done;){var O=g.value;if(!(O in t.verticalOhlcv)||!t.priceBased.includes(O))throw new Error('Invalid zScore item value "'.concat(O,'" for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(t.priceBased)));d["".concat(i,"_zscore_").concat(O)]=Yt(t.nullArray)}}catch(t){w.e(t)}finally{w.f()}Object.assign(t.verticalOhlcv,d)}i||(i=t.instances.bollinger_bands.numberOfIndicators>1?"bollinger_bands_".concat(p):"bollinger_bands".concat(h));var S,_=i,j=t.instances.bollinger_bands.settings[p],A=j.instance,P=j.heightInstance,k=t.verticalOhlcv[f][e];A.update(k,t.lastIndexReplace);try{S=A.getResult()}catch(t){}if(!S)return!0;var E=S,I=E.upper,T=E.middle,x=E.lower;if(t.pushToMain({index:e,key:"".concat(_,"_upper"),value:I}),t.pushToMain({index:e,key:"".concat(_,"_middle"),value:T}),t.pushToMain({index:e,key:"".concat(_,"_lower"),value:x}),!a&&!l)return!0;if(P){var M,R=I-x;P.update(R,t.lastIndexReplace);try{M=P.getResult()}catch(t){}M&&t.pushToMain({index:e,key:"".concat(_,"_height"),value:Ht(R,M,.5,7)})}var C,D=Jt(l);try{for(D.s();!(C=D.n()).done;){var z=C.value,L=(t.verticalOhlcv[z][e]-x)/(I-x);t.pushToMain({index:e,key:"".concat(_,"_range_").concat(z),value:L})}}catch(t){D.e(t)}finally{D.f()}var B,V=Jt(s);try{for(V.s();!(B=V.n()).done;){var H=B.value,U=I-x,$=0!==U?2*n*(t.verticalOhlcv[H][e]-T)/U:0;t.pushToMain({index:e,key:"".concat(_,"_zscore_").concat(H),value:$})}}catch(t){V.e(t)}finally{V.f()}return!0},volumeOscillator:function(t,e,r,n){var o,i=t.verticalOhlcv.volume[e],a="volume_oscillator";0===e&&(Object.assign(t.instances,{volume_oscillator:{fastEMA:new pt(r),slowEMA:new pt(n)}}),t.verticalOhlcv[a]=function(t){if(Array.isArray(t))return te(t)}(o=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return te(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?te(t,e):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),t.crossPairsList.push({fast:a,slow:0,isDefault:!0}));var u=t.instances[a],l=u.fastEMA,c=u.slowEMA;l.update(i,t.lastIndexReplace),c.update(i,t.lastIndexReplace);var s=null,f=null;try{s=l.getResult()}catch(t){s=null}try{f=c.getResult()}catch(t){f=null}return"number"==typeof s&&"number"==typeof f&&0!==f?t.pushToMain({index:e,key:a,value:100*(s-f)/f}):t.pushToMain({index:e,key:a,value:null}),!0},candleStudies:function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=o.changeLevel,a=void 0===i?7:i,u=o.sizeLevel,l=void 0===u?5:u;0===e&&Object.assign(t.verticalOhlcv,{candle_gap_size:ee(t.nullArray),candle_body_size:ee(t.nullArray),candle_top_size:ee(t.nullArray),candle_bottom_size:ee(t.nullArray),candle_shadow_size:ee(t.nullArray),candle_close_direction:ee(t.nullArray),candle_high_direction:ee(t.nullArray),candle_low_direction:ee(t.nullArray),candle_open_direction:ee(t.nullArray)}),n&&0===e&&Object.assign(t.instances,{candleStudies:{topInstance:new F(r),bottomInstance:new F(r),gapInstance:new F(r),bodySizeInstance:new F(r),shadowSizeInstance:new F(r),closeDirectionInstance:new F(r),highDirectionInstance:new F(r),lowDirectionInstance:new F(r),openDirectionInstance:new F(r)}});var c=t.verticalOhlcv.open[e-1],s=t.verticalOhlcv.high[e-1],f=t.verticalOhlcv.low[e-1],h=t.verticalOhlcv.close[e-1];if(0===e)return!0;var p=t.verticalOhlcv.open[e],y=t.verticalOhlcv.high[e],v=t.verticalOhlcv.low[e],d=t.verticalOhlcv.close[e],b=d>p,m=Math.abs(d-p),g=Math.abs(y-v),w=y-Math.max(p,d),O=Math.min(p,d)-v,S=Math.abs(h-p),_=Math.abs(d-h),j=Math.abs(y-s),A=Math.abs(v-f),P=Math.abs(p-c),k=null,E=null,I=null,T=null,x=null,M=null,R=null,C=null,D=null;if(n){var z=t.instances.candleStudies,L=z.topInstance,B=z.bottomInstance,V=z.gapInstance,H=z.bodySizeInstance,U=z.shadowSizeInstance,$=z.closeDirectionInstance,N=z.highDirectionInstance,q=z.lowDirectionInstance,G=z.openDirectionInstance;L.update(Math.abs(w),t.lastIndexReplace),B.update(Math.abs(O),t.lastIndexReplace),U.update(Math.abs(g),t.lastIndexReplace),V.update(S,t.lastIndexReplace),H.update(m,t.lastIndexReplace),$.update(_,t.lastIndexReplace),N.update(j,t.lastIndexReplace),q.update(A,t.lastIndexReplace),G.update(P,t.lastIndexReplace);try{I=L.getResult(),E=B.getResult(),k=V.getResult(),T=H.getResult(),x=U.getResult(),M=$.getResult(),R=N.getResult(),C=q.getResult(),D=G.getResult()}catch(t){}t.pushToMain({index:e,key:"candle_body_size",value:b?Ht(m,T,2,a):-Math.abs(Ht(m,T,2,a))||0}),t.pushToMain({index:e,key:"candle_gap_size",value:b?Ht(S,k,2,a):-Math.abs(Ht(S,k,2,a))||0}),t.pushToMain({index:e,key:"candle_close_direction",value:b?Ht(_,M,2,a):-Math.abs(Ht(_,M,2,a))||0}),t.pushToMain({index:e,key:"candle_high_direction",value:b?Ht(j,R,2,a):-Math.abs(Ht(j,R,2,a))||0}),t.pushToMain({index:e,key:"candle_low_direction",value:b?Ht(A,C,2,a):-Math.abs(Ht(A,C,2,a))||0}),t.pushToMain({index:e,key:"candle_open_direction",value:b?Ht(P,D,2,a):-Math.abs(Ht(P,D,2,a))||0}),t.pushToMain({index:e,key:"candle_top_size",value:Ht(w,I,.5,l)}),t.pushToMain({index:e,key:"candle_bottom_size",value:Ht(O,E,.5,l)}),t.pushToMain({index:e,key:"candle_shadow_size",value:Ht(g,x,.5,l)})}else t.pushToMain({index:e,key:"candle_body_size",value:b?m:-m}),t.pushToMain({index:e,key:"candle_gap_size",value:b?S:-S}),t.pushToMain({index:e,key:"candle_close_direction",value:b?_:-_}),t.pushToMain({index:e,key:"candle_high_direction",value:b?j:-j}),t.pushToMain({index:e,key:"candle_low_direction",value:b?A:-A}),t.pushToMain({index:e,key:"candle_open_direction",value:b?P:-P}),t.pushToMain({index:e,key:"candle_top_size",value:w}),t.pushToMain({index:e,key:"candle_bottom_size",value:O}),t.pushToMain({index:e,key:"candle_shadow_size",value:g});return!0}},Te=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=Ee(t);return n(Number(o))}return 0},xe=function(t,e){return"number"===e?t:"string"===e?Number(Ee(t)):0},Me=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=e.len,i=e.inputParams;e.nullArray=new Array(o).fill(null);var a=["open","high","low","close","volume"],u=new Set(a);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),a.forEach((function(t){e.verticalOhlcv[t]=Ae(e.nullArray)}));var l=Object.keys(t[0]).filter((function(t){return!u.has(t)}));l.forEach((function(t){e.verticalOhlcv[t]=Ae(e.nullArray)})),e.otherKeys=l,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=Ee(i)}if(0===e.precisionMultiplier){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)||Pe(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 c=function(t){return Array.isArray(t)?t.map((function(t){var e=t.key,r=t.params;return{key:e,fn:Ie[e],args:r}})):[]}(i),s=n;s<o;s++){var f=t[s],h=f.open,p=(f.high,f.low,f.close,f.volume),y=je(f,Se),v=e.precisionMultiplier,d=Te(h,e.inputTypes.open,v),b=Te(h,e.inputTypes.high,v),m=Te(h,e.inputTypes.low,v),g=Te(h,e.inputTypes.close,v),w=xe(p,e.inputTypes.volume);e.pushToMain({index:s,key:"open",value:d}),e.pushToMain({index:s,key:"high",value:b}),e.pushToMain({index:s,key:"low",value:m}),e.pushToMain({index:s,key:"close",value:g}),e.pushToMain({index:s,key:"volume",value:w});var O,S=_e(e.otherKeys);try{for(S.s();!(O=S.n()).done;){var _=O.value;e.pushToMain({index:s,key:_,value:y[_]})}}catch(t){S.e(t)}finally{S.f()}var j,A=_e(c);try{for(A.s();!(j=A.n()).done;){var P=j.value,k=P.key,E=P.fn,I=P.args;["crossPairs","lag"].includes(k)||E.apply(void 0,[e,s].concat(Ae(I)))}}catch(t){A.e(t)}finally{A.f()}le(e,s),be(e,s),e.lastComputedIndex++}},Re=function(t,e){for(var r=t.length,n=new F(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}))},Ce=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=Re(t,r),o=Re(e,r),i=t.length,a=[],u=0,l=0,c=0,s=0,f=0,h=0,p=-1,y=0;y<i;y++){if(null!==n[y]&&null!==o[y]){p=y;break}a.push(0)}if(-1===p)return new Array(i).fill(0);for(var v=p;v<i;v++){var d=n[v],b=o[v];if(null!==d&&null!==b)if(u+=d,l+=b,c+=d*b,s+=d*d,f+=b*b,++h<2)a.push(0);else{var m=h*c-u*l,g=Math.sqrt((h*s-u*u)*(h*f-l*l)),w=0===g?0:m/g;a.push(w)}else u=l=c=s=f=h=0,a.push(0)}return a};function De(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ze=function(t){for(var e=t.input,r=t.inputParams,n=new(0,t.OHLCV_INDICATORS)({input:e}),o=0;o<r.length;o++){var i=r[o],a=i.key,u=i.params;Array.isArray(u)&&(u.length>0?(Array.isArray(u)&&"crossPairs"===a&&Array.isArray(u[0])&&(u[0]=u[0].filter((function(t){return!t.isDefault}))),n[a].apply(n,function(t){if(Array.isArray(t))return De(t)}(l=u)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(l)||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}}(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.")}())):n[a]())}var l;return n};function Le(t){return function(t){if(Array.isArray(t))return Ue(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||He(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Be(t){return Be="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},Be(t)}function Ve(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)||He(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 He(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 $e(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,e,r){return(e=qe(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ne(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,qe(n.key),n)}}function qe(t){var e=function(t,e){if("object"!=Be(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Be(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Be(e)?e:e+""}var Ge=function(){return t=function t(e){var r=e.input,n=e.ticker,o=void 0===n?null:n;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(r))throw Error("input OHLCV must be an array: "+o);if(0===r.length)throw Error("input OHLCV must not be empty: "+o);if(!r[0].hasOwnProperty("close"))throw Error("input OHLCV array objects require at least close property: "+o);return this.isComputed=!1,this.lastComputedIndex=0,this.input=r,this.inputTypes={open:"",high:"",low:"",close:"",volume:""},this.priceBased=["open","high","low","close"],this.len=r.length,this.lastIndexReplace=!1,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.horizontalOhlcv=new Array(this.len).fill({}),this.inputParams=[],this.studies={},this.utilities={correlation:Ce},this.precisionMultiplier=0,this.setIndicatorsFromInputParams=ze,this},e=[{key:"pushToMain",value:function(t){var e=t.index,r=t.key,n=t.value;this.verticalOhlcv[r][e]=n,this.horizontalOhlcv[e][r]=n}},{key:"getDataAsCols",value:function(){this.compute();for(var t=this.precisionMultiplier,e=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$e(Object(r),!0).forEach((function(e){Fe(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},this.verticalOhlcv),r=0,n=Object.entries(e);r<n.length;r++){var o=Ve(n[r],2),i=o[0],a=o[1];this.priceBased.includes(i)&&(e[i]=a.map((function(e){return e/t})))}return e}},{key:"getData",value:function(){return this.compute(),this.horizontalOhlcv.filter((function(t){return!Object.values(t).some((function(t){return null==t}))}))}},{key:"getLastValues",value:function(){return this.compute(),this.horizontalOhlcv[this.horizontalOhlcv.length-1]}},{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&&Me(this.input,this,0),t&&"object"===Be(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),Me(this.input,this,this.len)):(this.input[n]=t,Me(this.input,this,n))}return this}},{key:"crossPairs",value:function(t){return i(this),this.crossPairsList=[].concat(Le(this.crossPairsList),Le(t)),this.inputParams.push({key:"crossPairs",params:[this.crossPairsList]}),this}},{key:"lag",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;i(this),this.inputParams.push({key:"lag",params:[e,r]});for(var n=function(){var r=e[o];t.priceBased.find((function(t){return r.startsWith(t)}))&&t.priceBased.push(r)},o=0;o<e.length;o++)n();return this}},{key:"relativeVolume",value:function(t){return i(this),this.inputParams.push({key:"relativeVolume",params:[t]}),this}},{key:"ema",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),!e||"object"!==Be(e))throw new Error('"options" must be an object in ema. eg: {target, height, range}');var r=e.target,n=void 0===r?"close":r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in ema.');return this.inputParams.push({key:"ema",params:[t,n]}),this.priceBased.push("ema_".concat(t)),this}},{key:"sma",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),!e||"object"!==Be(e))throw new Error('"options" must be an object in sma. eg: {target, height, range}');var r=e.target,n=void 0===r?"close":r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in sma.');return this.inputParams.push({key:"sma",params:[t,n]}),this.priceBased.push("sma_".concat(t)),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,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"!==Be(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"!==Be(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?0:a,l=r.range,c=void 0===l?[]:l,s=r.zScore,f=void 0===s?[]:s;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 u||"number"==typeof u&&u>0&&u<t)throw new Error('"height" must be a "0" or any number greater than or equal to "size" in bollingerBands.');return this.inputParams.push({key:"bollingerBands",params:[t,e,{target:o,height:u,range:c,zScore:f}]}),this.priceBased.push("bollinger_bands_middle","bollinger_bands_upper","bollinger_bands_lower"),this}},{key:"rsi",value:function(t){if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in rsi.');return this.inputParams.push({key:"rsi",params:[t]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number or 0 in donchianChannels.');if("number"!=typeof e||e<=0)throw new Error('"offset" must be a positive number or 0 in donchianChannels.');var n=r.height,o=void 0!==n&&n,a=r.range,u=void 0!==a&&a;return this.inputParams.push({key:"donchianChannels",params:[t,e,{height:o,range:u}]}),this.priceBased.push("donchian_channel_upper","donchian_channel_lower","donchian_channel_basis"),this}},{key:"candleStudies",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0;if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number or 0 in candleStudies.');if("boolean"!=typeof e)throw new Error('"classify" must be a true or false in candleStudies.');return this.inputParams.push({key:"candleStudies",params:[t,e,r]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;if(i(this),"number"!=typeof t||t<=0)throw new Error('fastSize" must be a positive number in volumeOscillator.');if("number"!=typeof e||e<=t)throw new Error('"slowSize" must be a positive number greater than the "fastSize" in volumeOscillator.');return this.inputParams.push({key:"volumeOscillator",params:[t,e]}),this}},{key:"dateTime",value:function(){return i(this),this.inputParams.push({key:"dateTime",params:[]}),this}},{key:"priceVariations",value:function(){return i(this),this.inputParams.push({key:"priceVariations",params:[]}),this}}],e&&Ne(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:()=>Je});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={},p=void 0,y=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function v(t,e,r,n){var o=t.c;if(r===p&&(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]!==p))),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]!==p||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function d(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function b(t){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(t)}function m(t){var e="function"==typeof Map?new Map:void 0;return m=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(g())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&w(o,r.prototype),o}(t,arguments,O(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,t)},m(t)}function g(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(g=function(){return!!t})()}function w(t,e){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},w(t,e)}function O(t){return O=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},O(t)}h.abs=function(){var t=new this.constructor(this);return t.s=1,t},h.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,a=t.s,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,y,d,b=o.slice(),m=l=o.length,g=n.length,w=n.slice(0,l),O=w.length,S=t,_=S.c=[],j=0,A=u+(S.e=e.e-t.e)+1;for(S.s=i,i=A<0?0:A,b.unshift(0);O++<l;)w.push(0);do{for(h=0;h<10;h++){if(l!=(O=w.length))y=l>O?1:-1;else for(d=-1,y=0;++d<l;)if(o[d]!=w[d]){y=o[d]>w[d]?1:-1;break}if(!(y<0))break;for(s=O==l?o:b;O;){if(w[--O]<s[O]){for(d=O;d&&!w[--d];)w[d]=9;--w[d],w[O]+=10}w[O]-=s[O]}for(;!w[0];)w.shift()}_[j++]=y?h:++h,w[0]&&y?w[O]=n[m]||0:w=[n[m]]}while((m++<g||w[0]!==p)&&i--);return _[0]||1==j||(_.shift(),S.e--,A--),j>A&&v(S,A,r.RM,w[0]!==p),S},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===p)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!==p){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!==p){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!==p){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===p?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(!y.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 S=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=O(e),function(t,e){if(e&&("object"==b(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,g()?Reflect.construct(e,r||[],O(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&w(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(m(Error));function _(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,P(n.key),n)}}function A(t,e,r){return(e=P(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(t){var e=function(t,e){if("object"!=_(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),A(this,"previousHighest",void 0),A(this,"highest",void 0),A(this,"previousLowest",void 0),A(this,"lowest",void 0),A(this,"previousResult",void 0),A(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new S;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 I(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=x(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,M()?Reflect.construct(e,r||[],x(t).constructor):e.apply(t,r))}function M(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(M=function(){return!!t})()}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(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)}}])&&I(r.prototype,n),o&&I(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);function z(t){return z="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},z(t)}function B(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,$(n.key),n)}}function L(t,e,r){return e=H(e),function(t,e){if(e&&("object"==z(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,V()?Reflect.construct(e,r||[],H(t).constructor):e.apply(t,r))}function V(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(V=function(){return!!t})()}function H(t){return H=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},H(t)}function U(t,e){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},U(t,e)}function $(t){var e=function(t,e){if("object"!=z(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=z(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==z(e)?e:e+""}var F=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,a=new Array(i),u=0;u<i;u++)a[u]=arguments[u];return r=t=L(this,e,[].concat(a)),o=[],(n=$(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&U(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}],n&&B(r.prototype,n),o&&B(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(D);function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Q(n.key),n)}}function G(t,e,r){return e=J(e),function(t,e){if(e&&("object"==N(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,K()?Reflect.construct(e,r||[],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 Y(t,e){return Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Y(t,e)}function W(t,e,r){return(e=Q(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Q(t){var e=function(t,e){if("object"!=N(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=N(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==N(e)?e:e+""}var X=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),W(r=G(this,e),"interval",void 0),W(r,"indicator",void 0),W(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new F(t),r.smoothingFactor=1/r.interval,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Y(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&q(r.prototype,n),o&&q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);function Z(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}function tt(t){return tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tt(t)}function et(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,nt(n.key),n)}}function rt(t,e,r){return(e=nt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function nt(t){var e=function(t,e){if("object"!=tt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=tt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==tt(e)?e:e+""}var ot=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),rt(this,"interval",void 0),rt(this,"deviationMultiplier",void 0),rt(this,"prices",[]),rt(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=Z(this.prices),r=function(t,e){var r=e||Z(t),n=Z(t.map((function(t){return t-r})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,e);return this.result={lower:e-r*this.deviationMultiplier,middle:e,upper:e+r*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new S;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 pt=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 S;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 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 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,bt(n.key),n)}}function dt(t,e,r){return(e=bt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function bt(t){var e=function(t,e){if("object"!=yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}var mt=function(){return 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 S;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,Pt(n.key),n)}}function Ot(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,St()?Reflect.construct(e,r||[],_t(t).constructor):e.apply(t,r))}function St(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(St=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 At(t,e,r){return(e=Pt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pt(t){var e=function(t,e){if("object"!=gt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=gt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==gt(e)?e:e+""}var Et=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:X;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),At(r=Ot(this,e),"interval",void 0),At(r,"previousPrices",[]),At(r,"avgGain",void 0),At(r,"avgLoss",void 0),At(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&jt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&wt(r.prototype,n),o&&wt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(E);function kt(t){return kt="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},kt(t)}function It(t){return function(t){if(Array.isArray(t))return Tt(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 Tt(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)?Tt(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 Tt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Mt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=kt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function xt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ct(t){return Ct="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},Ct(t)}function Dt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Ct(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ct(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ct(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){return function(t){if(Array.isArray(t))return Bt(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 Bt(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)?Bt(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 Bt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Lt(t){return Lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lt(t)}function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ht=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5;if(null===t||null===e||null===r)return null;if(n<2)throw new Error("numLevels must be at least 2");for(var o=4*r/(n-1),i=[],a=0;a<n-1;a++)i.push(e-2*r+a*o);for(var u=i.length-1;u>=0;u--)if(t>i[u])return(u+1)/(n-1);return 0};function Ut(t){return Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ut(t)}function $t(t){return function(t){if(Array.isArray(t))return Ft(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ft(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ft(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Nt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function qt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Nt(Object(r),!0).forEach((function(e){Gt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Nt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Gt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Ut(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ut(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ut(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Kt(t){return Kt="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},Kt(t)}function Jt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Wt(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 Yt(t){return function(t){if(Array.isArray(t))return Qt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Wt(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wt(t,e){if(t){if("string"==typeof t)return Qt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qt(t,e):void 0}}function Qt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Xt(t,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 Zt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Kt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ee(t){return function(t){if(Array.isArray(t))return re(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 re(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)?re(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 re(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 ne(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,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)||ie(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 oe(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ie(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 ie(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 ue(t){return ue="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},ue(t)}var le=function(t,e){if(0===e){var r=t.inputParams.filter((function(t){return"lag"===t.key}));if("object"!==ue(r))return;var n,o=r.map((function(t){return t.params})),i=oe(o);try{for(i.s();!(n=i.n()).done;){var a,u=ne(n.value,2),l=u[0],c=u[1],s=oe(l);try{for(s.s();!(a=s.n()).done;){var f=a.value;if(t.priceBased.includes(f))for(var h=1;h<=c;h++)t.priceBased.push("".concat(f,"_lag_").concat(h))}}catch(t){s.e(t)}finally{s.f()}}}catch(t){i.e(t)}finally{i.f()}t.instances.lag={lagParams:o}}var p,y,v=oe(t.instances.lag.lagParams);try{for(v.s();!(p=v.n()).done;){var d,b=ne(p.value,2),m=b[0],g=b[1],w=oe(m);try{for(w.s();!(d=w.n()).done;){var O=d.value,S=t.verticalOhlcv[O];if(0===e)for(var _=1;_<=g;_++){var j="".concat(O,"_lag_").concat(_);t.verticalOhlcv[j]=function(t){if(Array.isArray(t))return ae(t)}(y=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(y)||ie(y)||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 A=1;A<=g;A++){var P="".concat(O,"_lag_").concat(A),E=e-A;if(E<=0)break;t.pushToMain({index:e,key:P,value:S[E]})}}}catch(t){w.e(t)}finally{w.f()}}}catch(t){v.e(t)}finally{v.f()}return!0};function ce(t,e){if(t){if("string"==typeof t)return se(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?se(t,e):void 0}}function se(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function fe(t){return fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fe(t)}function he(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,pe(n.key),n)}}function pe(t){var e=function(t,e){if("object"!=fe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=fe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fe(e)?e:e+""}var ye=function(t,e){return t>e},ve=function(t,e){return t<e},de=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:ye(e,n)?i=this.areHighAndLowUndefined?1:[o,n,this.prevLow,this.prevSlow].every((function(t){return null!==t}))&&ve(o,n)&&ye(this.prevLow,this.prevSlow)?0:1:ve(e,n)&&(i=this.areHighAndLowUndefined?0:[r,n,this.prevHigh,this.prevSlow].every((function(t){return null!==t}))&&ye(r,n)&&ve(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}}])&&he(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),be=function(t,e){if(0===e){var r=t.inputParams.filter((function(t){return"crossPairs"===t.key}));if("object"!==fe(r))return;t.instances.crossPairs={crossPairsList:r.flatMap((function(t){return t.params.flat()}))}}var n,o,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ce(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}}}}(t.instances.crossPairs.crossPairsList);try{for(i.s();!(n=i.n()).done;){var a=n.value,u=a.fast,l=a.slow;if(u&&l){var c="".concat(u,"_x_").concat(l);if(0===e){if("number"==typeof l&&(t.verticalOhlcv[l]=new Array(t.len).fill(l)),"price"!==u&&!t.verticalOhlcv.hasOwnProperty(u))throw Error('fast "'.concat(u,' not found in crossPairs"'));if(!t.verticalOhlcv.hasOwnProperty(l))throw Error('slow "'.concat(l,' not found in crossPairs"'));t.instances[c]=new de,t.verticalOhlcv[c]=function(t){if(Array.isArray(t))return se(t)}(o=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||ce(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var s=void 0,f=void 0,h=void 0,p=void 0,y=void 0;"price"===u?(f=t.verticalOhlcv.close[e],h=t.verticalOhlcv.high[e],p=t.verticalOhlcv.low[e],y=t.verticalOhlcv[l][e],t.instances[c].update({fast:f,slow:y,high:h,low:p})):(s=t.verticalOhlcv[u][e],y=t.verticalOhlcv[l][e],t.instances[c].update({fast:s,slow:y})),t.pushToMain({index:e,key:c,value:t.instances[c].getResult()})}}}catch(t){i.e(t)}finally{i.f()}};function me(t){return function(t){if(Array.isArray(t))return ge(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 ge(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)?ge(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 ge(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 we(t){return function(t){if(Array.isArray(t))return Oe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Oe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Oe(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Oe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Se=["open","high","low","close","volume"];function _e(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Pe(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 je(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 Ae(t){return function(t){if(Array.isArray(t))return Ee(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Pe(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){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}var ke=function(t){return t.replace(/(?!^-)[^0-9.]/g,"")},Ie={dateTime:function(t,e){if(0===e){if(!t.isValidDate)throw Error('dateTime method found and invalid "date" in input ohlcv');var r=t.verticalOhlcv.date[0].slice(0,10);Object.assign(t.instances,{dateTime:{prevDateStr:r,sessionDailyIndexCount:0,sessionIntradayIndexCount:0,cachedDayInfo:r}}),Object.assign(t.verticalOhlcv,{day_of_the_week:me(t.nullArray),day_of_the_month:me(t.nullArray),week_of_the_month:me(t.nullArray),hour:me(t.nullArray),month:me(t.nullArray),year:me(t.nullArray),session_daily_index:me(t.nullArray),session_intraday_index:me(t.nullArray)})}var n=t.verticalOhlcv.date[e],o=function(t){var e=new Date(t),r=e.getMonth(),n=e.getFullYear(),o=e.getHours(),i=e.getMinutes(),a=e.getDay(),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)}}(n),i=o.day_of_the_week,a=o.day_of_the_month,u=o.week_of_the_month,l=o.month,c=o.year,s=o.hour,f=n.slice(0,10);f!==t.instances.dateTime.prevDateStr&&(t.instances.dateTime.prevDateStr=f,t.instances.dateTime.sessionDailyIndexCount++,t.instances.dateTime.sessionIntradayIndexCount=0),t.pushToMain({index:e,key:"session_daily_index",value:t.instances.dateTime.sessionDailyIndexCount}),t.pushToMain({index:e,key:"session_intraday_index",value:t.instances.dateTime.sessionIntradayIndexCount}),t.pushToMain({index:e,key:"day_of_the_week",value:i}),t.pushToMain({index:e,key:"day_of_the_month",value:a}),t.pushToMain({index:e,key:"week_of_the_month",value:u}),t.pushToMain({index:e,key:"month",value:l}),t.pushToMain({index:e,key:"year",value:c}),t.pushToMain({index:e,key:"hour",value:s})},priceVariations:function(t,e){0===e&&(t.priceBased=we(new Set([].concat(we(t.priceBased),["mid_price_open_close","mid_price_high_low"]))),Object.assign(t.verticalOhlcv,{mid_price_open_close:we(t.nullArray),mid_price_high_low:we(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){var n,o,i=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"rsi_".concat(r),slow:"rsi_sma_".concat(r),isDefault:!0}),Object.assign(t.instances,Mt(Mt({},"rsi_".concat(r),new Et(r)),"rsi_sma_".concat(r),new F(r))),Object.assign(t.verticalOhlcv,Mt(Mt({},"rsi_".concat(r),It(t.nullArray)),"rsi_sma_".concat(r),It(t.nullArray)))),t.instances["rsi_".concat(r)].update(i,t.lastIndexReplace);try{n=t.instances["rsi_".concat(r)].getResult()}catch(t){n=null}n&&(t.pushToMain({index:e,key:"rsi_".concat(r),value:n}),t.instances["rsi_sma_".concat(r)].update(n,t.lastIndexReplace));try{o=t.instances["rsi_sma_".concat(r)].getResult()}catch(t){o=null}return o&&t.pushToMain({index:e,key:"rsi_sma_".concat(r),value:o}),!0},sma:function(t,e,r,n){var o,i,a=t.verticalOhlcv.close[e],u="string"==typeof n&&t.verticalOhlcv.hasOwnProperty(n)&&"close"!==n?"".concat(n,"_"):"",l="".concat(u,"sma_").concat(r);0===e&&(t.instances[l]=new F(r),t.verticalOhlcv[l]=function(t){if(Array.isArray(t))return xt(t)}(i=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return xt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xt(t,e):void 0}}(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),t.instances[l].update(a,t.lastIndexReplace);try{o=t.instances[l].getResult()}catch(t){}o&&t.pushToMain({index:e,key:l,value:o})},ema:function(t,e,r,n){var o,i,a=t.verticalOhlcv.close[e],u="string"==typeof n&&t.verticalOhlcv.hasOwnProperty(n)&&"close"!==n?"".concat(n,"_"):"",l="".concat(u,"ema_").concat(r);0===e&&(t.instances[l]=new pt(r),t.verticalOhlcv[l]=function(t){if(Array.isArray(t))return Rt(t)}(i=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(i)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),t.instances[l].update(a,t.lastIndexReplace);try{o=t.instances[l].getResult()}catch(t){o=null}o&&t.pushToMain({index:e,key:l,value:o})},macd:function(t,e,r,n,o,i){var a=i.target,u="close"===a?"":"_".concat(a),l="".concat(r,"_").concat(n,"_").concat(o).concat(u);if(0===e){if(!t.verticalOhlcv.hasOwnProperty(a))throw new Error("Target property ".concat(a," not found in verticalOhlcv for macd."));var c=t.inputParams.filter((function(t){return"macd"===t.key})).length,s=c>1?"macd_".concat(l):"macd".concat(u);t.crossPairsList.push({fast:"".concat(s,"_diff"),slow:"".concat(s,"_dea"),isDefault:!0}),t.instances.hasOwnProperty("macd")||(t.instances.macd={numberOfIndicators:c,settings:{}}),t.instances.macd.settings[l]=new mt(new pt(r),new pt(n),new pt(o)),Object.assign(t.verticalOhlcv,Dt(Dt(Dt({},"".concat(s,"_diff"),zt(t.nullArray)),"".concat(s,"_dea"),zt(t.nullArray)),"".concat(s,"_histogram"),zt(t.nullArray)))}var f,h=t.instances.macd.numberOfIndicators>1?"macd_".concat(l):"macd".concat(u),p=t.instances.macd.settings[l],y=t.verticalOhlcv[a][e];p.update(y,t.lastIndexReplace);try{f=p.getResult()}catch(t){}return f&&(t.pushToMain({index:e,key:"".concat(h,"_diff"),value:f.macd}),t.pushToMain({index:e,key:"".concat(h,"_dea"),value:f.signal}),t.pushToMain({index:e,key:"".concat(h,"_histogram"),value:f.histogram})),!0},relativeVolume:function(t,e){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,o="relative_volume_".concat(n);0===e&&(t.instances[o]={instance:new F(n),prevRelativeVolumeSma:null},Object.assign(t.verticalOhlcv,function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Lt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Lt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},o,function(t){if(Array.isArray(t))return Vt(t)}(r=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vt(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())));var i,a=t.verticalOhlcv.volume[e],u=t.instances[o].instance;u.update(a,t.lastIndexReplace);try{i=u.getResult()}catch(t){}var l=t.instances[o].prevRelativeVolumeSma;return t.pushToMain({index:e,key:o,value:null!==i&&null!==l?a/l:null}),t.instances[o].prevRelativeVolumeSma=i,!0},donchianChannels:function(t,e,r,n,o){var i=o.height,a=o.range,u="".concat(r,"_").concat(n);if(0===e){var l=t.inputParams.filter((function(t){return"donchianChannels"===t.key})).length,c=l>1?"donchian_channel_".concat(u):"donchian_channel";Object.assign(t.verticalOhlcv,qt(qt(Gt(Gt(Gt({},"".concat(c,"_upper"),$t(t.nullArray)),"".concat(c,"_basis"),$t(t.nullArray)),"".concat(c,"_lower"),$t(t.nullArray)),i&&Gt({},"".concat(c,"_height"),$t(t.nullArray))),a&&Gt({},"".concat(c,"_range"),$t(t.nullArray)))),t.instances.hasOwnProperty("donchian_channel")||(t.instances.donchian_channel={numberOfIndicators:l,settings:{}}),t.instances.donchian_channel.settings[u]={heightInstance:i?new F("number"==typeof i&&i>0?i:r):null,maxDeque:[],minDeque:[]}}var s=t.instances.donchian_channel.numberOfIndicators>1?"donchian_channel_".concat(u):"donchian_channel",f=t.instances.donchian_channel.settings[u],h=f.heightInstance,p=f.maxDeque,y=f.minDeque,v=e-n,d=v+1,b=d-r;if(b<0||d>t.len)return!0;for(var m=t.verticalOhlcv.high,g=t.verticalOhlcv.low;p.length&&p[0]<b;)p.shift();for(;p.length&&m[p[p.length-1]]<=m[v];)p.pop();for(p.push(v);y.length&&y[0]<b;)y.shift();for(;y.length&&g[y[y.length-1]]>=g[v];)y.pop();y.push(v);var w=m[p[0]],O=g[y[0]],S=(w+O)/2,_=(t.verticalOhlcv.close[e]-O)/(w-O),j=w-O;if(i&&h&&h.update(j,t.lastIndexReplace),t.pushToMain({index:e,key:"".concat(s,"_upper"),value:w}),t.pushToMain({index:e,key:"".concat(s,"_basis"),value:S}),t.pushToMain({index:e,key:"".concat(s,"_lower"),value:O}),a&&t.pushToMain({index:e,key:"".concat(s,"_range"),value:_}),i&&h){var A;try{A=h.getResult()}catch(t){}A&&t.pushToMain({index:e,key:"".concat(s,"_height"),value:Ht(j,A,1.5)})}return!0},bollingerBands:function(t,e,r,n,o){var i,a=o.height,u=o.range,l=void 0===u?[]:u,c=o.zScore,s=void 0===c?[]:c,f=o.target,h="close"===f?"":"_".concat(f),p="".concat(r,"_").concat(n).concat(h);if(0===e){if(!(f in t.verticalOhlcv))throw new Error('bollingerBands could not find target "'.concat(f,'"'));var y=t.inputParams.filter((function(t){return"bollingerBands"===t.key})).length;i=y>1?"bollinger_bands_".concat(p):"bollinger_bands".concat(h),t.instances.bollinger_bands||(t.instances.bollinger_bands={numberOfIndicators:y,settings:{}}),t.instances.bollinger_bands.settings[p]={instance:new ot(r,n),heightInstance:a>=r?new F(a):null};var v,d=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Xt(Object(r),!0).forEach((function(e){Zt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}(Zt(Zt(Zt({},"".concat(i,"_upper"),Yt(t.nullArray)),"".concat(i,"_middle"),Yt(t.nullArray)),"".concat(i,"_lower"),Yt(t.nullArray)),a>=r&&Zt({},"".concat(i,"_height"),Yt(t.nullArray))),b=Jt(l);try{for(b.s();!(v=b.n()).done;){var m=v.value;if(!(m in t.verticalOhlcv)||!t.priceBased.includes(m))throw new Error('Invalid range item value "'.concat(m,'" property for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(t.priceBased)));d["".concat(i,"_range_").concat(m)]=Yt(t.nullArray)}}catch(t){b.e(t)}finally{b.f()}var g,w=Jt(s);try{for(w.s();!(g=w.n()).done;){var O=g.value;if(!(O in t.verticalOhlcv)||!t.priceBased.includes(O))throw new Error('Invalid zScore item value "'.concat(O,'" for bollingerBands. Only price based key names are accepted:\n').concat(JSON.stringify(t.priceBased)));d["".concat(i,"_zscore_").concat(O)]=Yt(t.nullArray)}}catch(t){w.e(t)}finally{w.f()}Object.assign(t.verticalOhlcv,d)}i||(i=t.instances.bollinger_bands.numberOfIndicators>1?"bollinger_bands_".concat(p):"bollinger_bands".concat(h));var S,_=i,j=t.instances.bollinger_bands.settings[p],A=j.instance,P=j.heightInstance,E=t.verticalOhlcv[f][e];A.update(E,t.lastIndexReplace);try{S=A.getResult()}catch(t){}if(!S)return!0;var k=S,I=k.upper,T=k.middle,M=k.lower;if(t.pushToMain({index:e,key:"".concat(_,"_upper"),value:I}),t.pushToMain({index:e,key:"".concat(_,"_middle"),value:T}),t.pushToMain({index:e,key:"".concat(_,"_lower"),value:M}),!a&&!l)return!0;if(P){var x,R=I-M;P.update(R,t.lastIndexReplace);try{x=P.getResult()}catch(t){}x&&t.pushToMain({index:e,key:"".concat(_,"_height"),value:Ht(R,x,.5,7)})}var C,D=Jt(l);try{for(D.s();!(C=D.n()).done;){var z=C.value,B=(t.verticalOhlcv[z][e]-M)/(I-M);t.pushToMain({index:e,key:"".concat(_,"_range_").concat(z),value:B})}}catch(t){D.e(t)}finally{D.f()}var L,V=Jt(s);try{for(V.s();!(L=V.n()).done;){var H=L.value,U=I-M,$=0!==U?2*n*(t.verticalOhlcv[H][e]-T)/U:0;t.pushToMain({index:e,key:"".concat(_,"_zscore_").concat(H),value:$})}}catch(t){V.e(t)}finally{V.f()}return!0},volumeOscillator:function(t,e,r,n){var o,i=t.verticalOhlcv.volume[e],a="volume_oscillator";0===e&&(Object.assign(t.instances,{volume_oscillator:{fastEMA:new pt(r),slowEMA:new pt(n)}}),t.verticalOhlcv[a]=function(t){if(Array.isArray(t))return te(t)}(o=t.nullArray)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return te(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?te(t,e):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),t.crossPairsList.push({fast:a,slow:0,isDefault:!0}));var u=t.instances[a],l=u.fastEMA,c=u.slowEMA;l.update(i,t.lastIndexReplace),c.update(i,t.lastIndexReplace);var s=null,f=null;try{s=l.getResult()}catch(t){s=null}try{f=c.getResult()}catch(t){f=null}return"number"==typeof s&&"number"==typeof f&&0!==f?t.pushToMain({index:e,key:a,value:100*(s-f)/f}):t.pushToMain({index:e,key:a,value:null}),!0},candleStudies:function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=o.changeLevel,a=void 0===i?7:i,u=o.sizeLevel,l=void 0===u?5:u;0===e&&Object.assign(t.verticalOhlcv,{candle_gap_size:ee(t.nullArray),candle_body_size:ee(t.nullArray),candle_top_size:ee(t.nullArray),candle_bottom_size:ee(t.nullArray),candle_shadow_size:ee(t.nullArray),candle_close_direction:ee(t.nullArray),candle_high_direction:ee(t.nullArray),candle_low_direction:ee(t.nullArray),candle_open_direction:ee(t.nullArray)}),n&&0===e&&Object.assign(t.instances,{candleStudies:{topInstance:new F(r),bottomInstance:new F(r),gapInstance:new F(r),bodySizeInstance:new F(r),shadowSizeInstance:new F(r),closeDirectionInstance:new F(r),highDirectionInstance:new F(r),lowDirectionInstance:new F(r),openDirectionInstance:new F(r)}});var c=t.verticalOhlcv.open[e-1],s=t.verticalOhlcv.high[e-1],f=t.verticalOhlcv.low[e-1],h=t.verticalOhlcv.close[e-1];if(0===e)return!0;var p=t.verticalOhlcv.open[e],y=t.verticalOhlcv.high[e],v=t.verticalOhlcv.low[e],d=t.verticalOhlcv.close[e],b=d>p,m=Math.abs(d-p),g=Math.abs(y-v),w=y-Math.max(p,d),O=Math.min(p,d)-v,S=Math.abs(h-p),_=Math.abs(d-h),j=Math.abs(y-s),A=Math.abs(v-f),P=Math.abs(p-c),E=null,k=null,I=null,T=null,M=null,x=null,R=null,C=null,D=null;if(n){var z=t.instances.candleStudies,B=z.topInstance,L=z.bottomInstance,V=z.gapInstance,H=z.bodySizeInstance,U=z.shadowSizeInstance,$=z.closeDirectionInstance,N=z.highDirectionInstance,q=z.lowDirectionInstance,G=z.openDirectionInstance;B.update(Math.abs(w),t.lastIndexReplace),L.update(Math.abs(O),t.lastIndexReplace),U.update(Math.abs(g),t.lastIndexReplace),V.update(S,t.lastIndexReplace),H.update(m,t.lastIndexReplace),$.update(_,t.lastIndexReplace),N.update(j,t.lastIndexReplace),q.update(A,t.lastIndexReplace),G.update(P,t.lastIndexReplace);try{I=B.getResult(),k=L.getResult(),E=V.getResult(),T=H.getResult(),M=U.getResult(),x=$.getResult(),R=N.getResult(),C=q.getResult(),D=G.getResult()}catch(t){}t.pushToMain({index:e,key:"candle_body_size",value:b?Ht(m,T,2,a):-Math.abs(Ht(m,T,2,a))||0}),t.pushToMain({index:e,key:"candle_gap_size",value:b?Ht(S,E,2,a):-Math.abs(Ht(S,E,2,a))||0}),t.pushToMain({index:e,key:"candle_close_direction",value:b?Ht(_,x,2,a):-Math.abs(Ht(_,x,2,a))||0}),t.pushToMain({index:e,key:"candle_high_direction",value:b?Ht(j,R,2,a):-Math.abs(Ht(j,R,2,a))||0}),t.pushToMain({index:e,key:"candle_low_direction",value:b?Ht(A,C,2,a):-Math.abs(Ht(A,C,2,a))||0}),t.pushToMain({index:e,key:"candle_open_direction",value:b?Ht(P,D,2,a):-Math.abs(Ht(P,D,2,a))||0}),t.pushToMain({index:e,key:"candle_top_size",value:Ht(w,I,.5,l)}),t.pushToMain({index:e,key:"candle_bottom_size",value:Ht(O,k,.5,l)}),t.pushToMain({index:e,key:"candle_shadow_size",value:Ht(g,M,.5,l)})}else t.pushToMain({index:e,key:"candle_body_size",value:b?m:-m}),t.pushToMain({index:e,key:"candle_gap_size",value:b?S:-S}),t.pushToMain({index:e,key:"candle_close_direction",value:b?_:-_}),t.pushToMain({index:e,key:"candle_high_direction",value:b?j:-j}),t.pushToMain({index:e,key:"candle_low_direction",value:b?A:-A}),t.pushToMain({index:e,key:"candle_open_direction",value:b?P:-P}),t.pushToMain({index:e,key:"candle_top_size",value:w}),t.pushToMain({index:e,key:"candle_bottom_size",value:O}),t.pushToMain({index:e,key:"candle_shadow_size",value:g});return!0}},Te=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=ke(t);return n(Number(o))}return 0},Me=function(t,e){return"number"===e?t:"string"===e?Number(ke(t)):0},xe=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=e.len,i=e.inputParams;e.nullArray=new Array(o).fill(null);var a=["open","high","low","close","volume"],u=new Set(a);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),a.forEach((function(t){e.verticalOhlcv[t]=Ae(e.nullArray)}));var l=Object.keys(t[0]).filter((function(t){return!u.has(t)}));l.forEach((function(t){e.verticalOhlcv[t]=Ae(e.nullArray)})),e.otherKeys=l,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=ke(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)||Pe(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 c=function(t){return Array.isArray(t)?t.map((function(t){var e=t.key,r=t.params;return{key:e,fn:Ie[e],args:r}})):[]}(i),s=n;s<o;s++){var f=t[s],h=f.open,p=(f.high,f.low,f.close,f.volume),y=je(f,Se),v=e.precisionMultiplier,d=Te(h,e.inputTypes.open,v),b=Te(h,e.inputTypes.high,v),m=Te(h,e.inputTypes.low,v),g=Te(h,e.inputTypes.close,v),w=Me(p,e.inputTypes.volume);e.pushToMain({index:s,key:"open",value:d}),e.pushToMain({index:s,key:"high",value:b}),e.pushToMain({index:s,key:"low",value:m}),e.pushToMain({index:s,key:"close",value:g}),e.pushToMain({index:s,key:"volume",value:w});var O,S=_e(e.otherKeys);try{for(S.s();!(O=S.n()).done;){var _=O.value;e.pushToMain({index:s,key:_,value:y[_]})}}catch(t){S.e(t)}finally{S.f()}var j,A=_e(c);try{for(A.s();!(j=A.n()).done;){var P=j.value,E=P.key,k=P.fn,I=P.args;["crossPairs","lag"].includes(E)||k.apply(void 0,[e,s].concat(Ae(I)))}}catch(t){A.e(t)}finally{A.f()}le(e,s),be(e,s),e.lastComputedIndex++}},Re=function(t,e){for(var r=t.length,n=new F(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}))},Ce=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=Re(t,r),o=Re(e,r),i=t.length,a=[],u=0,l=0,c=0,s=0,f=0,h=0,p=-1,y=0;y<i;y++){if(null!==n[y]&&null!==o[y]){p=y;break}a.push(0)}if(-1===p)return new Array(i).fill(0);for(var v=p;v<i;v++){var d=n[v],b=o[v];if(null!==d&&null!==b)if(u+=d,l+=b,c+=d*b,s+=d*d,f+=b*b,++h<2)a.push(0);else{var m=h*c-u*l,g=Math.sqrt((h*s-u*u)*(h*f-l*l)),w=0===g?0:m/g;a.push(w)}else u=l=c=s=f=h=0,a.push(0)}return a};function De(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ze=function(t){for(var e=t.input,r=t.inputParams,n=new(0,t.OHLCV_INDICATORS)({input:e}),o=0;o<r.length;o++){var i=r[o],a=i.key,u=i.params;Array.isArray(u)&&(u.length>0?(Array.isArray(u)&&"crossPairs"===a&&Array.isArray(u[0])&&(u[0]=u[0].filter((function(t){return!t.isDefault}))),n[a].apply(n,function(t){if(Array.isArray(t))return De(t)}(l=u)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(l)||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}}(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.")}())):n[a]())}var l;return n};function Be(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Le=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=(s=a[i],f=2,function(t){if(Array.isArray(t))return t}(s)||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}}(s,f)||function(t,e){if(t){if("string"==typeof t)return Be(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Be(t,e):void 0}}(s,f)||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.")}()),l=u[0],c=u[1];n.includes(l)&&(c/=r),o[l]=c}var s,f;return o};function Ve(t){return function(t){if(Array.isArray(t))return Fe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$e(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function He(t){return He="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},He(t)}function Ue(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)||$e(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 $e(t,e){if(t){if("string"==typeof t)return Fe(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)?Fe(t,e):void 0}}function Fe(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 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 qe(t,e,r){return(e=Ke(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ge(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,Ke(n.key),n)}}function Ke(t){var e=function(t,e){if("object"!=He(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=He(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==He(e)?e:e+""}var Je=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;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.isComputed=!1,this.lastComputedIndex=0,this.input=r,this.inputTypes={open:"",high:"",low:"",close:"",volume:""},this.priceBased=["open","high","low","close"],this.len=r.length,this.lastIndexReplace=!1,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.horizontalOhlcv=new Array(this.len).fill({}),this.inputParams=[],this.studies={},this.utilities={correlation:Ce},this.precision=a,this.precisionMultiplier=!0===this.precision?0:1,this.setIndicatorsFromInputParams=ze,this},e=[{key:"pushToMain",value:function(t){var e=t.index,r=t.key,n=t.value;this.verticalOhlcv[r][e]=n,this.horizontalOhlcv[e][r]=n}},{key:"getDataAsCols",value:function(){this.compute();var t=this.precisionMultiplier,e=this.precision,r=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){qe(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}({},this.verticalOhlcv);if(e)for(var n=0,o=Object.entries(r);n<o.length;n++){var i=Ue(o[n],2),a=i[0],u=i[1];this.priceBased.includes(a)&&(this.precision?r[a]=u.map((function(e){return e/t})):r[a]=u)}return r}},{key:"getData",value:function(){this.compute();var t=this.precisionMultiplier,e=this.priceBased;return this.precision?this.horizontalOhlcv.filter((function(t){return!Object.values(t).some((function(t){return null==t}))})).map((function(r){return Le({row:r,precisionMultiplier:t,priceBased:e})})):this.horizontalOhlcv.filter((function(t){return!Object.values(t).some((function(t){return null==t}))}))}},{key:"getLastValues",value:function(){this.compute();var t=this.precisionMultiplier,e=this.priceBased;return this.precision?Le({row:this.horizontalOhlcv[this.horizontalOhlcv.length-1],precisionMultiplier:t,priceBased:e}):this.horizontalOhlcv[this.horizontalOhlcv.length-1]}},{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&&xe(this.input,this,0),t&&"object"===He(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),xe(this.input,this,this.len)):(this.input[n]=t,xe(this.input,this,n))}return this}},{key:"crossPairs",value:function(t){return i(this),this.crossPairsList=[].concat(Ve(this.crossPairsList),Ve(t)),this.inputParams.push({key:"crossPairs",params:[this.crossPairsList]}),this}},{key:"lag",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;i(this),this.inputParams.push({key:"lag",params:[e,r]});for(var n=function(){var r=e[o];t.priceBased.find((function(t){return r.startsWith(t)}))&&t.priceBased.push(r)},o=0;o<e.length;o++)n();return this}},{key:"relativeVolume",value:function(t){return i(this),this.inputParams.push({key:"relativeVolume",params:[t]}),this}},{key:"ema",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),!e||"object"!==He(e))throw new Error('"options" must be an object in ema. eg: {target, height, range}');var r=e.target,n=void 0===r?"close":r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in ema.');return this.inputParams.push({key:"ema",params:[t,n]}),this.priceBased.push("ema_".concat(t)),this}},{key:"sma",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(i(this),!e||"object"!==He(e))throw new Error('"options" must be an object in sma. eg: {target, height, range}');var r=e.target,n=void 0===r?"close":r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in sma.');return this.inputParams.push({key:"sma",params:[t,n]}),this.priceBased.push("sma_".concat(t)),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,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"!==He(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"!==He(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?0:a,l=r.range,c=void 0===l?[]:l,s=r.zScore,f=void 0===s?[]:s;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 u||"number"==typeof u&&u>0&&u<t)throw new Error('"height" must be a "0" or any number greater than or equal to "size" in bollingerBands.');return this.inputParams.push({key:"bollingerBands",params:[t,e,{target:o,height:u,range:c,zScore:f}]}),this.priceBased.push("bollinger_bands_middle","bollinger_bands_upper","bollinger_bands_lower"),this}},{key:"rsi",value:function(t){if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in rsi.');return this.inputParams.push({key:"rsi",params:[t]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number or 0 in donchianChannels.');if("number"!=typeof e||e<=0)throw new Error('"offset" must be a positive number or 0 in donchianChannels.');var n=r.height,o=void 0!==n&&n,a=r.range,u=void 0!==a&&a;return this.inputParams.push({key:"donchianChannels",params:[t,e,{height:o,range:u}]}),this.priceBased.push("donchian_channel_upper","donchian_channel_lower","donchian_channel_basis"),this}},{key:"candleStudies",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0;if(i(this),"number"!=typeof t||t<=0)throw new Error('"size" must be a positive number or 0 in candleStudies.');if("boolean"!=typeof e)throw new Error('"classify" must be a true or false in candleStudies.');return this.inputParams.push({key:"candleStudies",params:[t,e,r]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;if(i(this),"number"!=typeof t||t<=0)throw new Error('fastSize" must be a positive number in volumeOscillator.');if("number"!=typeof e||e<=t)throw new Error('"slowSize" must be a positive number greater than the "fastSize" in volumeOscillator.');return this.inputParams.push({key:"volumeOscillator",params:[t,e]}),this}},{key:"dateTime",value:function(){return i(this),this.inputParams.push({key:"dateTime",params:[]}),this}},{key:"priceVariations",value:function(){return i(this),this.inputParams.push({key:"priceVariations",params:[]}),this}}],e&&Ge(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
|
package/index.js
CHANGED
|
@@ -3,9 +3,10 @@ import { correlation } from './src/studies/correlation.js'
|
|
|
3
3
|
import { setIndicatorsFromInputParams } from './src/utilities/setIndicatorsFromInputParams.js'
|
|
4
4
|
import { validateDate } from './src/utilities/validators.js'
|
|
5
5
|
import { isAlreadyComputed } from './src/utilities/validators.js'
|
|
6
|
+
import { divideByMultiplier } from './src/utilities/precision.js'
|
|
6
7
|
|
|
7
8
|
export default class OHLCV_INDICATORS {
|
|
8
|
-
constructor({input, ticker = null}) {
|
|
9
|
+
constructor({input, ticker = null, precision = true}) {
|
|
9
10
|
|
|
10
11
|
if(!Array.isArray(input)) throw Error('input OHLCV must be an array: ' + ticker)
|
|
11
12
|
if(input.length === 0) throw Error('input OHLCV must not be empty: ' + ticker)
|
|
@@ -30,7 +31,8 @@ export default class OHLCV_INDICATORS {
|
|
|
30
31
|
correlation
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
this.
|
|
34
|
+
this.precision = precision
|
|
35
|
+
this.precisionMultiplier = (this.precision === true) ? 0 : 1
|
|
34
36
|
this.setIndicatorsFromInputParams = setIndicatorsFromInputParams
|
|
35
37
|
|
|
36
38
|
return this
|
|
@@ -46,17 +48,28 @@ export default class OHLCV_INDICATORS {
|
|
|
46
48
|
|
|
47
49
|
this.compute()
|
|
48
50
|
|
|
49
|
-
const {precisionMultiplier} = this
|
|
51
|
+
const {precisionMultiplier, precision} = this
|
|
50
52
|
const verticalClone = {...this.verticalOhlcv}
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
if(precision)
|
|
53
55
|
{
|
|
54
|
-
|
|
56
|
+
for(const [key, arr] of Object.entries(verticalClone))
|
|
55
57
|
{
|
|
56
|
-
|
|
58
|
+
if(this.priceBased.includes(key))
|
|
59
|
+
{
|
|
60
|
+
if(this.precision)
|
|
61
|
+
{
|
|
62
|
+
verticalClone[key] = arr.map(v => v / precisionMultiplier)
|
|
63
|
+
}
|
|
64
|
+
else
|
|
65
|
+
{
|
|
66
|
+
verticalClone[key] = arr
|
|
67
|
+
}
|
|
68
|
+
}
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
71
|
|
|
72
|
+
|
|
60
73
|
return verticalClone
|
|
61
74
|
|
|
62
75
|
}
|
|
@@ -65,9 +78,20 @@ export default class OHLCV_INDICATORS {
|
|
|
65
78
|
|
|
66
79
|
//getData method returns the last object (row) of the new OHLCV with indicators: {open, high, low, close, rsi_14, bollinger_bands_upper}
|
|
67
80
|
this.compute()
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
|
|
82
|
+
const {precisionMultiplier, priceBased, precision} = this
|
|
83
|
+
|
|
84
|
+
if(precision)
|
|
85
|
+
{
|
|
86
|
+
return this.horizontalOhlcv
|
|
87
|
+
.filter(row => !Object.values(row).some(value => value === undefined || value === null))
|
|
88
|
+
.map(row => divideByMultiplier({row, precisionMultiplier, priceBased}))
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
{
|
|
92
|
+
return this.horizontalOhlcv.filter(row => !Object.values(row).some(value => value === undefined || value === null))
|
|
93
|
+
}
|
|
94
|
+
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
|
|
@@ -75,8 +99,20 @@ export default class OHLCV_INDICATORS {
|
|
|
75
99
|
|
|
76
100
|
this.compute()
|
|
77
101
|
|
|
78
|
-
|
|
79
|
-
|
|
102
|
+
const {precisionMultiplier, priceBased, precision} = this
|
|
103
|
+
|
|
104
|
+
if(precision)
|
|
105
|
+
{
|
|
106
|
+
return divideByMultiplier({
|
|
107
|
+
row: this.horizontalOhlcv[this.horizontalOhlcv.length - 1],
|
|
108
|
+
precisionMultiplier,
|
|
109
|
+
priceBased
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
else
|
|
113
|
+
{
|
|
114
|
+
return this.horizontalOhlcv[this.horizontalOhlcv.length - 1]
|
|
115
|
+
}
|
|
80
116
|
}
|
|
81
117
|
|
|
82
118
|
compute(change) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
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",
|
|
@@ -64,7 +64,7 @@ const setInputTypes = (row0, main) => {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// Determine precisionMultiplier if not already set
|
|
67
|
-
if (main.precisionMultiplier === 0) {
|
|
67
|
+
if (main.precisionMultiplier === 0 && main.precision === true) {
|
|
68
68
|
const [, decimals = ''] = String(value).split('.');
|
|
69
69
|
const decimalPrecision = Math.max(4, decimals.length);
|
|
70
70
|
main.precisionMultiplier = decimalPrecision > 1 ? Math.pow(10, decimalPrecision - 1) : 1;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const divideByMultiplier = ({row, precisionMultiplier, priceBased}) => {
|
|
2
|
+
const output = {}
|
|
3
|
+
|
|
4
|
+
for(const [key, value] of Object.entries(row))
|
|
5
|
+
{
|
|
6
|
+
|
|
7
|
+
let newValue = value
|
|
8
|
+
|
|
9
|
+
if(priceBased.includes(key))
|
|
10
|
+
{
|
|
11
|
+
newValue = newValue / precisionMultiplier
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
output[key] = newValue
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return output
|
|
18
|
+
}
|