ohlcv-indicators 3.5.55 → 3.5.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(r,e)=>{for(var n in e)t.o(e,n)&&!t.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},r={};(()=>{t.r(r),t.d(r,{default:()=>En});var e=function(t,r,e){if(0===e.length)return!1;for(var n=t.verticalOhlcv,o=!0,i=0;i<e.length;i++){var a=e[i];if(!n.hasOwnProperty(a)){o=!1;break}var l=n[a][r];if(null==l||Number.isNaN(l)){o=!1;break}}return o};function n(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=o(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,l=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return l=t.done,t},e:function(t){u=!0,a=t},f:function(){try{l||null==e.return||e.return()}finally{if(u)throw a}}}}function o(t,r){if(t){if("string"==typeof t)return i(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?i(t,r):void 0}}function i(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var a=function(t,r){if(!Array.isArray(t))throw new Error('Property "inputParams" must be an "Array" or "Set".');var e,o=n(t);try{for(o.s();!(e=o.n()).done;){var i,a=n(e.value.params);try{for(a.s();!(i=a.n()).done;){var l=i.value;if("number"==typeof l&&l>r)throw console.log(l,r),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){a.e(t)}finally{a.f()}}}catch(t){o.e(t)}finally{o.f()}},l=function(t){if(!0===t.isComputed)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" , "getDataAsCols" or "getData" methods are called.')},u=function(t,r,e){if(!Array.isArray(t))throw new Error('Param "'.concat(r,'" must be an array in "').concat(e,'".'));return!0},c=function(t,r,e){if(t instanceof Object==0)throw new Error('Param "'.concat(r,'" must be an object in "').concat(e,'".'));return!0},s=function(t,r,e,n){if(u(t,"arrayOptions","".concat(n,".").concat(e,".validateArrayOptions")),!t.includes(r.toString()))throw new Error('Param "'.concat(e,'" must be any of the following values [').concat(t.join(", "),'] in "').concat(n,'".'));return!0},f=function(t,r,e){if("boolean"!=typeof t)throw new Error('Param "'.concat(r,'" must be an boolean in "').concat(e,'".'));return!0},p=function(t,r,e,n){c(r,"options","".concat(n,".").concat(e,".validateNumber"));var o=r.allowDecimals,i=void 0!==o&&o,a=r.min,l=r.max,u=i?"number":"integer";if("number"!=typeof t||!1===i&&!Number.isInteger(t))throw new Error('Param "'.concat(e,'" must be an ').concat(u,' in "').concat(n,'".'));if(void 0!==a&&"number"!=typeof a)throw new Error('Param "min" must be a valid '.concat(u,' (if provided) in "').concat(n,".").concat(e,'.validateNumber".'));if(void 0!==l&&"number"!=typeof l)throw new Error('Param "max" must be a valid '.concat(u,' (if provided) in "').concat(n,".").concat(e,'.validateNumber".'));if(void 0!==a&&void 0!==l&&a>=l)throw new Error('Param "min" must be less than "max" in "'.concat(n,".").concat(e,'.validateNumber".'));if(void 0!==a&&t<a)throw new Error('Param "'.concat(e,'" must be an ').concat(u," ≥ ").concat(a,' in "').concat(n,'".'));if(void 0!==l&&t>l)throw new Error('Param "'.concat(e,'" must be an ').concat(u," ≤ ").concat(l,' in "').concat(n,'".'));return!0},y=function(t,r,e){if(u(t,r,e),2!==t.length)throw new Error('Invalid "'.concat(r,'" array length: expected 2 items, but got ').concat(t.length,' in "').concat(e,".").concat(r,'".'));var n,i,a=(i=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(n,i)||o(n,i)||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=a[0],c=a[1];if(p(l,{min:-100,max:c,allowDecimals:!1},"min",e),p(c,{min:l,max:100,allowDecimals:!1},"max",e),l===c)throw new Error('Invalid "min" can not be equal to "max" property in "'.concat(e,".").concat(r,'".'));return!0},h=function(t,r,e){if("string"!=typeof t||!t.length)throw new Error('Invalid "'.concat(r,'" property in "').concat(e,'". Only strings are accepted.'));return!0},v=1e6,d="[big.js] ",m=d+"Invalid ",b=m+"decimal places",g=m+"rounding mode",w=d+"Division by zero",S={},O=void 0,A=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function j(t,r,e,n){var o=t.c;if(e===O&&(e=t.constructor.RM),0!==e&&1!==e&&2!==e&&3!==e)throw Error(g);if(r<1)n=3===e&&(n||!!o[0])||0===r&&(1===e&&o[0]>=5||2===e&&(o[0]>5||5===o[0]&&(n||o[1]!==O))),o.length=1,n?(t.e=t.e-r+1,o[0]=1):o[0]=t.e=0;else if(r<o.length){if(n=1===e&&o[r]>=5||2===e&&(o[r]>5||5===o[r]&&(n||o[r+1]!==O||1&o[r-1]))||3===e&&(n||!!o[0]),o.length=r,n)for(;++o[--r]>9;)if(o[r]=0,0===r){++t.e,o.unshift(1);break}for(r=o.length;!o[--r];)o.pop()}return t}function N(t,r,e){var n=t.e,o=t.c.join(""),i=o.length;if(r)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&&e?"-"+o:o}function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function x(t){var r="function"==typeof Map?new Map:void 0;return x=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(r){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!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return function(t,r,e){if(_())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,r);var o=new(t.bind.apply(t,n));return e&&k(o,e.prototype),o}(t,arguments,E(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),k(e,t)},x(t)}function _(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_=function(){return!!t})()}function k(t,r){return k=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},k(t,r)}function E(t){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},E(t)}S.abs=function(){var t=new this.constructor(this);return t.s=1,t},S.cmp=function(t){var r,e=this,n=e.c,o=(t=new e.constructor(t)).c,i=e.s,a=t.s,l=e.e,u=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(r=i<0,l!=u)return l>u^r?1:-1;for(a=(l=n.length)<(u=o.length)?l:u,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^r?1:-1;return l==u?0:l>u^r?1:-1},S.div=function(t){var r=this,e=r.constructor,n=r.c,o=(t=new e(t)).c,i=r.s==t.s?1:-1,a=e.DP;if(a!==~~a||a<0||a>v)throw Error(b);if(!o[0])throw Error(w);if(!n[0])return t.s=i,t.c=[t.e=0],t;var l,u,c,s,f,p=o.slice(),y=l=o.length,h=n.length,d=n.slice(0,l),m=d.length,g=t,S=g.c=[],A=0,N=a+(g.e=r.e-t.e)+1;for(g.s=i,i=N<0?0:N,p.unshift(0);m++<l;)d.push(0);do{for(c=0;c<10;c++){if(l!=(m=d.length))s=l>m?1:-1;else for(f=-1,s=0;++f<l;)if(o[f]!=d[f]){s=o[f]>d[f]?1:-1;break}if(!(s<0))break;for(u=m==l?o:p;m;){if(d[--m]<u[m]){for(f=m;f&&!d[--f];)d[f]=9;--d[f],d[m]+=10}d[m]-=u[m]}for(;!d[0];)d.shift()}S[A++]=s?c:++c,d[0]&&s?d[m]=n[y]||0:d=[n[y]]}while((y++<h||d[0]!==O)&&i--);return S[0]||1==A||(S.shift(),g.e--,N--),A>N&&j(g,N,e.RM,d[0]!==O),g},S.eq=function(t){return 0===this.cmp(t)},S.gt=function(t){return this.cmp(t)>0},S.gte=function(t){return this.cmp(t)>-1},S.lt=function(t){return this.cmp(t)<0},S.lte=function(t){return this.cmp(t)<1},S.minus=S.sub=function(t){var r,e,n,o,i=this,a=i.constructor,l=i.s,u=(t=new a(t)).s;if(l!=u)return t.s=-u,i.plus(t);var c=i.c.slice(),s=i.e,f=t.c,p=t.e;if(!c[0]||!f[0])return f[0]?t.s=-u:c[0]?t=new a(i):t.s=1,t;if(l=s-p){for((o=l<0)?(l=-l,n=c):(p=s,n=f),n.reverse(),u=l;u--;)n.push(0);n.reverse()}else for(e=((o=c.length<f.length)?c:f).length,l=u=0;u<e;u++)if(c[u]!=f[u]){o=c[u]<f[u];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(u=(e=f.length)-(r=c.length))>0)for(;u--;)c[r++]=0;for(u=r;e>l;){if(c[--e]<f[e]){for(r=e;r&&!c[--r];)c[r]=9;--c[r],c[e]+=10}c[e]-=f[e]}for(;0===c[--u];)c.pop();for(;0===c[0];)c.shift(),--p;return c[0]||(t.s=1,c=[p=0]),t.c=c,t.e=p,t},S.mod=function(t){var r,e=this,n=e.constructor,o=e.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(w);return e.s=t.s=1,r=1==t.cmp(e),e.s=o,t.s=i,r?new n(e):(o=n.DP,i=n.RM,n.DP=n.RM=0,e=e.div(t),n.DP=o,n.RM=i,this.minus(e.times(t)))},S.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},S.plus=S.add=function(t){var r,e,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var a=o.e,l=o.c,u=t.e,c=t.c;if(!l[0]||!c[0])return c[0]||(l[0]?t=new i(o):t.s=o.s),t;if(l=l.slice(),r=a-u){for(r>0?(u=a,n=c):(r=-r,n=l),n.reverse();r--;)n.push(0);n.reverse()}for(l.length-c.length<0&&(n=c,c=l,l=n),r=c.length,e=0;r;l[r]%=10)e=(l[--r]=l[r]+c[r]+e)/10|0;for(e&&(l.unshift(e),++u),r=l.length;0===l[--r];)l.pop();return t.c=l,t.e=u,t},S.pow=function(t){var r=this,e=new r.constructor("1"),n=e,o=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(m+"exponent");for(o&&(t=-t);1&t&&(n=n.times(r)),t>>=1;)r=r.times(r);return o?e.div(n):n},S.prec=function(t,r){if(t!==~~t||t<1||t>v)throw Error(m+"precision");return j(new this.constructor(this),t,r)},S.round=function(t,r){if(t===O)t=0;else if(t!==~~t||t<-v||t>v)throw Error(b);return j(new this.constructor(this),t+this.e+1,r)},S.sqrt=function(){var t,r,e,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(d+"No square root");0===(i=Math.sqrt(n+""))||i===1/0?((r=n.c.join("")).length+a&1||(r+="0"),a=((a+1)/2|0)-(a<0||1&a),t=new o(((i=Math.sqrt(r))==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):t=new o(i+""),a=t.e+(o.DP+=4);do{e=t,t=l.times(e.plus(n.div(e)))}while(e.c.slice(0,a).join("")!==t.c.slice(0,a).join(""));return j(t,(o.DP-=4)+t.e+1,o.RM)},S.times=S.mul=function(t){var r,e=this,n=e.constructor,o=e.c,i=(t=new n(t)).c,a=o.length,l=i.length,u=e.e,c=t.e;if(t.s=e.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=u+c,a<l&&(r=o,o=i,i=r,c=a,a=l,l=c),r=new Array(c=a+l);c--;)r[c]=0;for(u=l;u--;){for(l=0,c=a+u;c>u;)l=r[c]+i[u]*o[c-u-1]+l,r[c--]=l%10,l=l/10|0;r[c]=l}for(l?++t.e:r.shift(),u=r.length;!r[--u];)r.pop();return t.c=r,t},S.toExponential=function(t,r){var e=this,n=e.c[0];if(t!==O){if(t!==~~t||t<0||t>v)throw Error(b);for(e=j(new e.constructor(e),++t,r);e.c.length<t;)e.c.push(0)}return N(e,!0,!!n)},S.toFixed=function(t,r){var e=this,n=e.c[0];if(t!==O){if(t!==~~t||t<0||t>v)throw Error(b);for(t=t+(e=j(new e.constructor(e),t+e.e+1,r)).e+1;e.c.length<t;)e.c.push(0)}return N(e,!1,!!n)},S[Symbol.for("nodejs.util.inspect.custom")]=S.toJSON=S.toString=function(){var t=this,r=t.constructor;return N(t,t.e<=r.NE||t.e>=r.PE,!!t.c[0])},S.toNumber=function(){var t=Number(N(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(d+"Imprecise conversion");return t},S.toPrecision=function(t,r){var e=this,n=e.constructor,o=e.c[0];if(t!==O){if(t!==~~t||t<1||t>v)throw Error(m+"precision");for(e=j(new n(e),t,r);e.c.length<t;)e.c.push(0)}return N(e,t<=e.e||e.e<=n.NE||e.e>=n.PE,!!o)},S.valueOf=function(){var t=this,r=t.constructor;if(!0===r.strict)throw Error(d+"valueOf disallowed");return N(t,t.e<=r.NE||t.e>=r.PE,!0)},function t(){function r(e){var n=this;if(!(n instanceof r))return e===O?t():new r(e);if(e instanceof r)n.s=e.s,n.e=e.e,n.c=e.c.slice();else{if("string"!=typeof e){if(!0===r.strict&&"bigint"!=typeof e)throw TypeError(m+"value");e=0===e&&1/e<0?"-0":String(e)}!function(t,r){var e,n,o;if(!A.test(r))throw Error(m+"number");for(t.s="-"==r.charAt(0)?(r=r.slice(1),-1):1,(e=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(e<0&&(e=n),e+=+r.slice(n+1),r=r.substring(0,n)):e<0&&(e=r.length),o=r.length,n=0;n<o&&"0"==r.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==r.charAt(--o););for(t.e=e-n-1,t.c=[],e=0;n<=o;)t.c[e++]=+r.charAt(n++)}}(n,e)}n.constructor=r}return r.prototype=S,r.DP=20,r.RM=1,r.NE=-7,r.PE=21,r.strict=!1,r.roundDown=0,r.roundHalfUp=1,r.roundHalfEven=2,r.roundUp=3,r}();var C=function(t){function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),t=function(t,r,e){return r=E(r),function(t,r){if(r&&("object"==P(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_()?Reflect.construct(r,e||[],E(t).constructor):r.apply(t,e))}(this,r,[e]),Object.setPrototypeOf(t,(this instanceof r?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&k(t,r)}(r,t),e=r,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}(x(Error));function T(t){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T(t)}function I(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,D(n.key),n)}}function M(t,r,e){return(r=D(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function D(t){var r=function(t,r){if("object"!=T(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==T(r)?r:r+""}var R=function(){return t=function t(){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),M(this,"previousHighest",void 0),M(this,"highest",void 0),M(this,"previousLowest",void 0),M(this,"lowest",void 0),M(this,"previousResult",void 0),M(this,"result",void 0)},(r=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new C;return this.result}},{key:"setResult",value:function(t,r){return r&&(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)}}])&&I(t.prototype,r),e&&I(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}function F(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,V(n.key),n)}}function z(t,r,e){return r=Y(r),function(t,r){if(r&&("object"==L(r)||"function"==typeof r))return r;if(void 0!==r)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,U()?Reflect.construct(r,e||[],Y(t).constructor):r.apply(t,e))}function U(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(U=function(){return!!t})()}function Y(t){return Y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Y(t)}function q(t,r){return q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},q(t,r)}function V(t){var r=function(t,r){if("object"!=L(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=L(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==L(r)?r:r+""}var G=function(t){function r(t){var e,n,o,i;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),n=e=z(this,r),i=void 0,(o=V(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,e.interval=t,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&q(t,r)}(r,t),e=r,(n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&F(e.prototype,n),o&&F(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function H(t){return H="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},H(t)}function B(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,W(n.key),n)}}function $(t,r,e){return r=K(r),function(t,r){if(r&&("object"==H(r)||"function"==typeof r))return r;if(void 0!==r)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(r,e||[],K(t).constructor):r.apply(t,e))}function X(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(X=function(){return!!t})()}function K(t){return K=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},K(t)}function J(t,r){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},J(t,r)}function W(t){var r=function(t,r){if("object"!=H(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=H(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==H(r)?r:r+""}var Z=function(t){function r(){var t,e,n,o;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);for(var i=arguments.length,a=new Array(i),l=0;l<i;l++)a[l]=arguments[l];return e=t=$(this,r,[].concat(a)),o=[],(n=W(n="prices"))in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&J(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var e=this.prices.reduce((function(t,r){return t+r}),0);return this.setResult(e/this.prices.length,r)}}}],n&&B(e.prototype,n),o&&B(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(G);function Q(t){return Q="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},Q(t)}function tt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,at(n.key),n)}}function rt(t,r,e){return r=nt(r),function(t,r){if(r&&("object"==Q(r)||"function"==typeof r))return r;if(void 0!==r)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,et()?Reflect.construct(r,e||[],nt(t).constructor):r.apply(t,e))}function et(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(et=function(){return!!t})()}function nt(t){return nt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},nt(t)}function ot(t,r){return ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ot(t,r)}function it(t,r,e){return(r=at(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function at(t){var r=function(t,r){if("object"!=Q(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Q(r)?r:r+""}var lt=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),it(e=rt(this,r),"interval",void 0),it(e,"indicator",void 0),it(e,"smoothingFactor",void 0),e.interval=t,e.indicator=new Z(t),e.smoothingFactor=1/e.interval,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ot(t,r)}(r,t),e=r,n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.indicator.update(t);if(r&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,r)}if(!r&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,r)}if(void 0===this.result&&void 0!==e)return this.setResult(e,r)}}],n&&tt(e.prototype,n),o&&tt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function ut(t){return t.length?t.reduce((function(t,r){return t+r}),0)/t.length:0}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 st(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,dt(n.key),n)}}function ft(t,r,e){return r=yt(r),function(t,r){if(r&&("object"==ct(r)||"function"==typeof r))return r;if(void 0!==r)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,pt()?Reflect.construct(r,e||[],yt(t).constructor):r.apply(t,e))}function pt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(pt=function(){return!!t})()}function yt(t){return yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},yt(t)}function ht(t,r){return ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ht(t,r)}function vt(t,r,e){return(r=dt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function dt(t){var r=function(t,r){if("object"!=ct(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var mt=function(t){function r(){var t;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return vt(t=ft(this,r,[].concat(n)),"previousCandle",void 0),vt(t,"twoPreviousCandle",void 0),t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ht(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=t.high,n=t.low,o=e-n;if(this.previousCandle&&r&&(this.previousCandle=this.twoPreviousCandle),this.previousCandle){var i=Math.abs(e-this.previousCandle.close),a=Math.abs(n-this.previousCandle.close);return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(Math.max(o,i,a),r)}return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(o,r)}}],n&&st(e.prototype,n),o&&st(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function gt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Nt(n.key),n)}}function wt(t,r,e){return r=Ot(r),function(t,r){if(r&&("object"==bt(r)||"function"==typeof r))return r;if(void 0!==r)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(r,e||[],Ot(t).constructor):r.apply(t,e))}function St(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(St=function(){return!!t})()}function Ot(t){return Ot=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ot(t)}function At(t,r){return At=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},At(t,r)}function jt(t,r,e){return(r=Nt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Nt(t){var r=function(t,r){if("object"!=bt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var Pt=function(t){function r(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lt;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),jt(e=wt(this,r),"interval",void 0),jt(e,"tr",void 0),jt(e,"smoothing",void 0),e.interval=t,e.tr=new mt,e.smoothing=new n(t),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&At(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.tr.update(t,r);if(this.smoothing.update(e,r),this.smoothing.isStable)return this.setResult(this.smoothing.getResult(),r)}}],n&&gt(e.prototype,n),o&&gt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function xt(t){return xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xt(t)}function _t(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Et(n.key),n)}}function kt(t,r,e){return(r=Et(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Et(t){var r=function(t,r){if("object"!=xt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=xt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xt(r)?r:r+""}var Ct=function(){return t=function t(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),kt(this,"interval",void 0),kt(this,"deviationMultiplier",void 0),kt(this,"prices",[]),kt(this,"result",void 0),this.interval=r,this.deviationMultiplier=e},(r=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var r=ut(this.prices),e=function(t,r){var e=r||ut(t),n=ut(t.map((function(t){return t-e})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,r);return this.result={lower:r-e*this.deviationMultiplier,middle:r,upper:r+e*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new C;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&_t(t.prototype,r),e&&_t(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();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 It(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,zt(n.key),n)}}function Mt(t,r,e){return r=Rt(r),function(t,r){if(r&&("object"==Tt(r)||"function"==typeof r))return r;if(void 0!==r)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,Dt()?Reflect.construct(r,e||[],Rt(t).constructor):r.apply(t,e))}function Dt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Dt=function(){return!!t})()}function Rt(t){return Rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Rt(t)}function Lt(t,r){return Lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Lt(t,r)}function Ft(t,r,e){return(r=zt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function zt(t){var r=function(t,r){if("object"!=Tt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var Ut=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),Ft(e=Mt(this,r,[t]),"interval",void 0),Ft(e,"pricesCounter",0),Ft(e,"weightFactor",void 0),e.interval=t,e.weightFactor=2/(e.interval+1),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Lt(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return r?r&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,r&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),r):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),r)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new C;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&It(e.prototype,n),o&&It(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(G);function Yt(t){return Yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(t)}function qt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Gt(n.key),n)}}function Vt(t,r,e){return(r=Gt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Gt(t){var r=function(t,r){if("object"!=Yt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var Ht=function(){return t=function t(r,e,n){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),Vt(this,"short",void 0),Vt(this,"long",void 0),Vt(this,"signal",void 0),Vt(this,"prices",[]),Vt(this,"result",void 0),this.short=r,this.long=e,this.signal=n},r=[{key:"getResult",value:function(){if(void 0===this.result)throw new C;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t);var e=this.short.update(t,r),n=this.long.update(t,r);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=e-n,i=this.signal.update(o,r);return this.result={histogram:o-i,macd:o,signal:i}}}}],r&&qt(t.prototype,r),e&&qt(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();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 $t(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Qt(n.key),n)}}function Xt(t,r,e){return r=Jt(r),function(t,r){if(r&&("object"==Bt(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Kt()?Reflect.construct(r,e||[],Jt(t).constructor):r.apply(t,e))}function Kt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Kt=function(){return!!t})()}function Jt(t){return Jt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Jt(t)}function Wt(t,r){return Wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Wt(t,r)}function Zt(t,r,e){return(r=Qt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Qt(t){var r=function(t,r){if("object"!=Bt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var tr=function(t){function r(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lt;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),Zt(e=Xt(this,r),"interval",void 0),Zt(e,"previousPrices",[]),Zt(e,"avgGain",void 0),Zt(e,"avgLoss",void 0),Zt(e,"maxValue",100),e.interval=t,e.avgGain=new n(e.interval),e.avgLoss=new n(e.interval),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Wt(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&r?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var e=t,n=this.previousPrices[this.previousPrices.length-2];if(e>n?(this.avgLoss.update(0,r),this.avgGain.update(t-n,r)):(this.avgLoss.update(n-e,r),this.avgGain.update(0,r)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,r);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),r)}}}}],n&&$t(e.prototype,n),o&&$t(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function rr(t){return rr="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},rr(t)}function er(t){return function(t){if(Array.isArray(t))return nr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return nr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?nr(t,r):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 nr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function or(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ar(n.key),n)}}function ir(t,r,e){return(r=ar(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function ar(t){var r=function(t,r){if("object"!=rr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=rr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rr(r)?r:r+""}var lr=function(){return t=function t(r,e,n){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),ir(this,"n",void 0),ir(this,"m",void 0),ir(this,"p",void 0),ir(this,"candles",[]),ir(this,"result",void 0),ir(this,"periodM",void 0),ir(this,"periodP",void 0),this.n=r,this.m=e,this.p=n,this.periodM=new Z(e),this.periodP=new Z(n)},(r=[{key:"getResult",value:function(){if(void 0===this.result)throw new C;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){if(this.candles.push(t),this.candles.length>this.n&&this.candles.shift(),this.candles.length===this.n){var r=Math.max.apply(Math,er(this.candles.map((function(t){return t.high})))),e=Math.min.apply(Math,er(this.candles.map((function(t){return t.low})))),n=r-e,o=100*(t.close-e);o/=0===n?1:n;var i=this.periodM.update(o),a=i&&this.periodP.update(i);if(void 0!==i&&void 0!==a)return this.result={stochD:a,stochK:i}}}}])&&or(t.prototype,r),e&&or(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function ur(t){return ur="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},ur(t)}function cr(t){return function(t){if(Array.isArray(t))return sr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return sr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?sr(t,r):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 sr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function fr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=ur(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ur(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ur(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function pr(t){return pr="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},pr(t)}function yr(t){return function(t){if(Array.isArray(t))return hr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return hr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?hr(t,r):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 hr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function vr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=pr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=pr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var dr={ema:Ut,sma:Z},mr=function(t,r,e,n,o){var i=o.target,a=o.lag,l=t.verticalOhlcv,u=t.instances,c="close"!==i?"_".concat(i):"",s="".concat(e,"_").concat(n).concat(c);if(0===r){var f=t.len;if(!l.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for ").concat(e,"."));u[s]=new dr[e](n),l[s]=new Float64Array(f).fill(NaN),a>0&&t.lag([s],a)}var p=l[i][r],y=u[s];y.update(p);var h=NaN;try{h=y.getResult()}catch(t){}return t.pushToMain({index:r,key:s,value:h}),!0};function br(t){return br="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},br(t)}function gr(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function wr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=br(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=br(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==br(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Sr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Or(t){return function(t){if(Array.isArray(t))return Ar(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return Ar(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ar(t,r):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 Ar(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function jr(t){return jr="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},jr(t)}function Nr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=jr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=jr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Pr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var xr="close";function _r(t){return _r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_r(t)}var kr={number:function(t){return t},numberCleanString:function(t){return Number(t)},numberDirtyString:function(t){return Number(t.replace(/(?!^-)[^0-9.]/g,""))}},Er=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"==typeof t&&!Number.isNaN(t))return"number";if("string"==typeof t){var e=t.trim(),n=/^-?\d+(\.\d+)?$/;if(n.test(e))return"numberCleanString";var o=e.replace(/[^0-9.]/g,"");if(o&&n.test(o))return"numberDirtyString"}if(r)throw new TypeError("Invalid input: expected a number or numeric string");return _r(t)},Cr=function(t,r){var e=Math.pow(10,r);return Math.round((t+Number.EPSILON)*e)/e};function Tr(t){return function(t){if(Array.isArray(t))return Mr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ir(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 Ir(t,r){if(t){if("string"==typeof t)return Mr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Mr(t,r):void 0}}function Mr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Dr(t){return Dr="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},Dr(t)}function Rr(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function Lr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Dr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Dr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Fr(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return zr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?zr(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function zr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ur="close";function Yr(t){return Yr="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},Yr(t)}function qr(t){return qr="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},qr(t)}var Vr={string:function(t){return t.toISOString()},milliseconds:function(t){return t.getTime()},seconds:function(t){return t.getTime()/1e3},object:function(t){return t}},Gr={dateObject:function(t){return t},dateMilliseconds:function(t){return new Date(t)},dateSeconds:function(t){return new Date(1e3*t)},dateIncompleteDayString:function(t){return new Date("".concat(t," 00:00:00"))},dateCompleteDateString:function(t){return new Date(t)}},Hr=function(t){var r=["Date -> object","Milliseconds Timestamp -> integer","Seconds Timestamp -> integer","UTC Time Format (ISO 8601) -> string","Including a Timezone Offset (ISO 8601) -> string","Local Time Format (ISO 8601) -> string","YYYY/MM/DD or YYYY-MM-DD -> string"],e=function(){throw new Error('Invalid "'.concat(qr(t),'" date value passed in selectDateFormatter. Supported formats: \n-').concat(r.join("\n- ")))};if("object"===qr(t)){if(t instanceof Date&&!isNaN(t.valueOf()))return"dateObject";e()}else{if("number"==typeof t)return Math.abs(t)<1e11?"dateSeconds":"dateMillseconds";if("string"==typeof t){if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/i.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?([+-]\d{2}:\d{2})$/.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(t)&&t.length>10||/^\d{4}\/\d{2}\/\d{2}$/.test(t))return"dateCompleteDateString";if(/^\d{4}-\d{2}-\d{2}$/.test(t))return"dateIncompleteDayString";e()}else e()}};function Br(t){return Br="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},Br(t)}function $r(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||function(t,r){if(t){if("string"==typeof t)return Xr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Xr(t,r):void 0}}(t,r)||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 Xr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Kr=new Set(["open","high","low","close"]),Jr=function(t,r,e){var n,o={Array,Float64Array,Float32Array,Int32Array,Uint8Array,Int8Array,Int16Array}[t];if(!o||"function"!=typeof o.from)throw new Error("Unsupported array type: ".concat(t));return n=void 0!==e?e:"Array"===t?null:NaN,o.from({length:r},(function(){return n}))},Wr=function(t,r){if(!r||"object"!==Br(r))throw new TypeError('Invalid array type: "'.concat(t,'"'));return r.constructor.name};function Zr(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Qr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Qr(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function Qr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function te(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)||re(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function re(t,r){if(t){if("string"==typeof t)return ee(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?ee(t,r):void 0}}function ee(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var ne=function(t,r){var e=new Uint8Array(r);return e[t]=1,e},oe=function(t){var r=t.featureCols,e=t.flatFeaturesColLen,n=t.type,o=t.trainingSize,i=r.length!==e?" (including flat one-hot encoded array values) ":"";console.log('---\nInitialized "'.concat(n,'" with ').concat(e," features ").concat(i," and ").concat(o," rows: \n").concat(JSON.stringify(r),"\n\n"))},ie=function(t,r,e,n){var o,i,a=(i=2,function(t){if(Array.isArray(t))return t}(o=n)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(o,i)||re(o,i)||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=a[0],u=a[1];return(Math.min(Math.max(t,r),e)-r)/(e-r)*(u-l)+l},ae=function(t,r){var e=[];if(t.length>0)for(var n=0;n<t.length;n++){var o=t[n],i=o.type,a=o.size,l=void 0===a?null:a,u=o.groupName,c=void 0===u?null:u,s=null!==l?"".concat(i,"_").concat(l):"".concat(i,"_").concat(c);if(!r.hasOwnProperty(s))throw new Error("Scaled group (".concat(s,") not found for regressor.options.findGroups[").concat(n,"]: ").concat(JSON.stringify(o)));e.push.apply(e,te(r[s]))}return e},le=function(t,r,e){var n,o=0,i=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=re(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(t);try{for(i.s();!(n=i.n()).done;){var a=n.value;if(!r.hasOwnProperty(a))throw new Error('Property "'.concat(a,'" not found in "verticalOhlcv".'));var l=r[a][e];if(null==l||Number.isNaN(l))throw new Error('Invalid value of property "'.concat(a,'".'));a.startsWith("one_hot_")||a.startsWith("pca_")?o+=r[a][e].length:o+=1}}catch(t){i.e(t)}finally{i.f()}return o},ue=function(t){var r=t.trainingCols,e=t.findGroups,n=t.verticalOhlcv,o=t.scaledGroups,i=[].concat(te(r),te(ae(e,o)));if(0===i.length)return[];for(var a=!1,l=0;l<i.length;l++){var u=i[l];if(!n.hasOwnProperty(u)){a=!0;break}}return a?[]:i},ce=function(t){var r=t.metrics,e=t.trueLabel,n=t.predictedLabel;r.total=(r.total||0)+1,r.correct=r.correct||0,r.labels=r.labels||{};var o=n.toString();for(var i in r.labels[o]||(r.labels[o]={total:0,correct:0,accuracy:0}),r.labels[o].total++,n===e&&(r.correct++,r.labels[o].correct++),r.accuracy=r.correct/r.total,r.labels){var a=r.labels[i];a.accuracy=a.correct/a.total}};function se(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];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 pe(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ye(n.key),n)}}function ye(t){var r=function(t,r){if("object"!=fe(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var he=function(t,r){return t>r},ve=function(t,r){return t<r},de=function(){return t=function t(){!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,{interval:0,prevState:.5,prevFast:NaN,prevSlow:NaN,prevHigh:NaN,prevLow:NaN,areHighAndLowUndefined:!1,crossIndexes:{up:[],down:[]}})},(r=[{key:"update",value:function(t,r){var e=r.fast,n=r.high,o=r.slow,i=r.low,a=this.prevState;this.areHighAndLowUndefined||void 0!==n&&void 0!==i||(this.areHighAndLowUndefined=!0),Number.isNaN(e)||Number.isNaN(o)||function(t,r){return t===r}(e,o)?a=.5:he(e,o)?a=this.areHighAndLowUndefined?1:[i,o,this.prevLow,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&ve(i,o)&&he(this.prevLow,this.prevSlow)?0:1:ve(e,o)&&(a=this.areHighAndLowUndefined?0:[n,o,this.prevHigh,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&he(n,o)&&ve(this.prevHigh,this.prevSlow)?1:0),.5===a?this.interval=0:1===a?this.prevState<=.5?this.interval=1:this.interval++:0===a&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(t),-1===this.interval&&this.crossIndexes.down.push(t),Object.assign(this,{prevState:a,prevFast:e,prevSlow:o,prevHigh:n,prevLow:i})}},{key:"getResult",value:function(){return this.interval}}])&&pe(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}();function me(t){return me="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},me(t)}function be(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||Oe(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ge(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function we(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?ge(Object(e),!0).forEach((function(r){Se(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):ge(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function Se(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=me(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=me(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==me(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Oe(t,r){if(t){if("string"==typeof t)return Ae(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ae(t,r):void 0}}function Ae(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function je(t){return function(t){if(Array.isArray(t))return Pe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ne(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ne(t,r){if(t){if("string"==typeof t)return Pe(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Pe(t,r):void 0}}function Pe(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function xe(t,r){if(t){if("string"==typeof t)return _e(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?_e(t,r):void 0}}function _e(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var ke=function(t){var r=t.main,e=t.index,n=r.verticalOhlcv,o=n.close[e],i=n.close[e-1];return void 0===i?null:{change:(o-i)/i}};function Ee(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ce=function(t){var r,e=t.featureCols,n=t.flatFeaturesColLen,o=t.type,i=t.index,a=t.lookbackAbs,l=t.main.verticalOhlcv,u=!1,c=[],s=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Ee(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ee(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(e);try{for(s.s();!(r=s.n()).done;){var f=r.value;if(f.startsWith("one_hot_")||f.startsWith("pca_"))for(var p=l[f][i].length,y=0;y<p;y++)c.push({key:f,bit:y});else c.push({key:f})}}catch(t){s.e(t)}finally{s.f()}if(c.length!==n)throw new Error("slots (".concat(c.length,") ≠ flatFeaturesColLen (").concat(n,") in ").concat(o," index ").concat(i));for(var h=new Array(n*a).fill(NaN),v=0;v<a;v++){for(var d=i-v,m=0;m<c.length;m++){var b=c[m],g=b.key,w=b.bit,S=l[g][d],O=null!=w?S[w]:S;if(!Number.isFinite(O)){u=!0;break}h[v*n+m]=O}if(u)break}return u?null:h};function Te(t){return function(t){if(Array.isArray(t))return Me(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ie(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 Ie(t,r){if(t){if("string"==typeof t)return Me(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Me(t,r):void 0}}function Me(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var De="pca",Re=function(t,r,n){var o=n.prefix,i=n.trainingSize,a=n.findGroups,l=n.trainingCols,u=n.lookbackAbs,c=n.modelArgs,s=n.filterCallback,f=t.verticalOhlcv,p=t.scaledGroups,y=t.len,h=t.instances,v=t.ML,d=t.invalidValueIndex+2,m=v.models;if(r===d)h.hasOwnProperty(De)||(h[De]={}),h[De][o]={flatFeaturesColLen:0,featureCols:[],X:[]},f[o]=new Array(y).fill(null);else{if(r<d||r<u)return;if(!1===s(f,r))return;if(r+1===y){if(0===h[De][o].featureCols.length){var b=[].concat(Te(l),Te(ae(a,p)));throw new Error("Some of the provided features in ".concat(o,' features where not found in "verticalOhlcv": ').concat(JSON.stringify(b)))}var g,w=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Ie(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(h[De][o].featureCols);try{for(w.s();!(g=w.n()).done;){var S=g.value;if(!f.hasOwnProperty(S))throw new Error('Feature "'.concat(S,'" not found in verticalOhlcv for pca.'))}}catch(t){w.e(t)}finally{w.f()}if(h[De][o].X.length<i){var O=h[De][o].X.length-i;throw new Error('The current "trainingSize" at "'.concat(o,'" requires at least ').concat(O,' more datapoints. Try adding more input ohlcv rows or reducing the "trainingSize" by ').concat(O,"."))}}}var A=h[De][o];if(0===A.flatFeaturesColLen){if(A.featureCols=ue({trainingCols:l,findGroups:a,verticalOhlcv:f,scaledGroups:p}),!e(t,r,A.featureCols))return;A.flatFeaturesColLen=le(A.featureCols,f,r)}if(0!==A.flatFeaturesColLen){var j=A.X,N=A.featureCols,P=A.flatFeaturesColLen,x=Ce({featureCols:N,flatFeaturesColLen:P,type:De,index:r,lookbackAbs:u,main:t});if(null!=x){if(m.hasOwnProperty(o)){var _=m[o].predict([x]).to2DArray();f[o][r]=_[0]}j.push(x),j.length>i&&j.shift(),j.length===i&&(m[o]=new v.classes.PCA(j,c))}}};function Le(t){return Le="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},Le(t)}function Fe(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)||ze(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ze(t,r){if(t){if("string"==typeof t)return Ue(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ue(t,r):void 0}}function Ue(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ye=function(t,r,n,o){var i=o.target,a=o.predictions,l=o.retrain,u=o.trainingCols,c=o.findGroups,s=o.type,f=o.modelArgs,p=o.precompute,y=o.filterCallback,h=o.modelConfig,v=o.modelClass,d=p.lookbackAbs,m=p.prefix,b=p.flatX,g=p.flatY,w=t.verticalOhlcv,S=t.len,O=t.instances,A=t.scaledGroups,j=t.invalidValueIndex,N=t.ML.models,P=j+1;if(r===P){O.hasOwnProperty("regressor")||(O.regressor={}),O.regressor.hasOwnProperty(m)||(O.regressor[m]={});var x=g?a:1;O.regressor[m]={expectedLoops:x,trainingSize:n,isTrained:new Array(x).fill(!1),shouldRetrain:l,featureCols:[],flatFeaturesColLen:0,X:[],Y:Array.from({length:x},(function(){return[]}))};for(var _=0;_<a;_++){var k="".concat(m,"_").concat(_+1);w[k]=new Float64Array(S).fill(NaN),N.hasOwnProperty(k)||(N[k]=[])}}else{if(r<P||r<d)return;if(!1===y(w,r))return;if(r+1===S){if(0===O.regressor[m].featureCols.length){var E=[].concat(Fe(u),Fe(ae(c,A)));throw new Error("Some of the provided features in ".concat(m,' features where not found in "verticalOhlcv": ').concat(JSON.stringify(E)))}var C,T=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ze(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(O.regressor[m].featureCols);try{for(T.s();!(C=T.n()).done;){var I=C.value;if(!w.hasOwnProperty(I))throw new Error('Feature "'.concat(I,'" not found in verticalOhlcv for ').concat(m,"."))}}catch(t){T.e(t)}finally{T.f()}if(O.regressor[m].X.length<n){var M=O.regressor[m].X.length-n;throw new Error('The current "trainingSize" at "'.concat(m,'" requires at least ').concat(M,' more datapoints. Try adding more input ohlcv rows or reducing the "trainingSize" by ').concat(M,"."))}}}var D=O.regressor[m];if(0===D.flatFeaturesColLen){if(D.featureCols=ue({trainingCols:u,findGroups:c,verticalOhlcv:w,scaledGroups:A}),!e(t,r,D.featureCols))return;D.flatFeaturesColLen=le(D.featureCols,w,r),oe({featureCols:D.featureCols,flatFeaturesColLen:D.flatFeaturesColLen,type:s,trainingSize:n})}if(0!==D.flatFeaturesColLen){if(!w.hasOwnProperty(i))throw new Error('Target property "'.concat(i,'" not found in verticalOhlcv for regressor.'));var R=D.expectedLoops,L=D.X,F=D.Y,z=D.flatFeaturesColLen,U=D.featureCols,Y=D.shouldRetrain;if(!U.includes(i))throw new Error('Target property "'.concat(i,'" not found in ').concat(s," features: ").concat(JSON.stringify(U)));var q=b?w[i][r]:Ce({featureCols:U,flatFeaturesColLen:z,type:s,index:r,lookbackAbs:d,main:t});if(b){if(!Number.isFinite(q))return}else if(null==q)return;for(var V=[],G=0;G<a;G++){var H=w[i][r+G+1];if(!Number.isFinite(H))break;V.push(H)}for(var B=h.train,$=h.unsupervised,X=0;X<R;X++){var K="".concat(m,"_").concat(X+1),J=F[X],W=g?void 0===V[X]?null:V[X]:V,Z=D.isTrained[X];if(N.hasOwnProperty(K)&&Z&&N[K].length===R){var Q=N[K][0],tt=$?Q.predict(a)[0]:Q.predict([q])[0];if(g){if(Number.isNaN(tt))throw new Error("Prediction of ".concat(s," at index ").concat(r," was expecting a number."));t.pushToMain({index:r,key:K,value:tt})}else{if(!Array.isArray(tt)||tt.length!==a)throw new Error('Prediction output of "'.concat(s,'" at index ').concat(r," was expecting an array of values."));for(var rt=0;rt<a;rt++)t.pushToMain({index:r,key:"".concat(m,"_").concat(rt+1),value:tt[rt]})}}if(!(r+a+1>S||V.length<a||null===W)){if(g){if("number"!=typeof W||Number.isNaN(W))throw new Error("currTrainY must return number, got ".concat(Le(W)," at index ").concat(r))}else{if(!Array.isArray(W))throw new Error("currTrainY must return an array, got ".concat(Le(W)," at index ").concat(r));if(W.length!==a)throw new Error("currTrainY length (".concat(W.length,') ≠ "options.predictions" (').concat(a,') for regressor "').concat(s,'"'))}if(J.push(W),J.length>n&&J.shift(),0===X&&(L.push(q),L.length>n&&L.shift()),(Y||!Z)&&L.length===n&&J.length===n){var et=B({modelClass:v,xRows:L,yRows:J,modelArgs:f,uniqueLabels:0});$?N[K]=[et]:(N[K].push(et),N[K].length>a&&N[K].shift()),D.isTrained[X]=!0}}}}};function qe(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Ve(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function Ve(t,r){if(t){if("string"==typeof t)return Ge(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ge(t,r):void 0}}function Ge(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var He=function(t){if(!Array.isArray(t)||0===t.length)return 1;for(var r=Array.isArray(t[0]),e=r?t[0].length:1,n=0,o=0;o<e;o++){for(var i=new Set,a=0;a<t.length;a++){var l=r?t[a][o]:t[a];i.add(l)}n+=i.size}return n},Be=function(t,r){if(!Array.isArray(t)||!Array.isArray(r))throw new TypeError("Both X and Y must be arrays");if(t.length!==r.length)throw new Error("X and Y must have the same length");if(0===r.length)return{X:[],Y:[]};var e,n=r.reduce((function(r,e,n){return r.has(e)||r.set(e,[]),r.get(e).push(t[n]),r}),new Map),o=0,i=qe(n.values());try{for(i.s();!(e=i.n()).done;){var a=e.value;a.length>o&&(o=a.length)}}catch(t){i.e(t)}finally{i.f()}var l,u,c,s=[],f=[],p=qe(n.entries());try{for(p.s();!(l=p.n()).done;)for(var y=(u=l.value,c=2,function(t){if(Array.isArray(t))return t}(u)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(u,c)||Ve(u,c)||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.")}()),h=y[0],v=y[1],d=v.length,m=0;m<o;m++)s.push(v[m%d]),f.push(h)}catch(t){p.e(t)}finally{p.f()}return{X:s,Y:f}};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 Xe(t){return function(t){if(Array.isArray(t))return Je(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ke(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ke(t,r){if(t){if("string"==typeof t)return Je(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Je(t,r):void 0}}function Je(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var We="classifier",Ze=function(t,r,n,o){var i=o.yCallback,a=o.trainingCols,l=o.findGroups,u=void 0===l?[]:l,c=o.retrain,s=o.type,f=o.modelArgs,p=o.horizon,y=o.precompute,h=o.predictions,v=o.filterCallback,d=o.modelConfig,m=o.modelClass,b=y.lookbackAbs,g=y.prefix,w=y.flatY,S=t.verticalOhlcv,O=t.len,A=t.instances,j=t.scaledGroups,N=t.invalidValueIndex,P=t.ML,x=P.models,_=N+1;if(r===_){A.hasOwnProperty(We)||(A[We]={}),A[We].hasOwnProperty(g)||(A[We][g]={});var k=w?h:1;A[We][g]={expectedLoops:k,isTrained:new Array(k).fill(!1),uniqueLabels:new Array(k).fill(0),shouldRetrain:c,featureCols:[],flatFeaturesColLen:0,X:[],Y:Array.from({length:k},(function(){return[]}))};for(var E=0;E<h;E++){var C="".concat(g,"_").concat(E+1);S[C]="KNN"===s?new Array(O).fill(null):new Float32Array(O).fill(NaN),P.metrics[C]={accuracy:{},total:0,correct:0,labels:{}},x.hasOwnProperty(C)||(x[C]=[])}}else{if(r<_||r<b)return;if(!1===v(S,r))return;if(r+1===O){if(0===A[We][g].featureCols.length){var T=[].concat(Xe(a),Xe(ae(u,j)));throw new Error("Some of the provided features in ".concat(We,' "').concat(g,'" features where not found in "verticalOhlcv": ').concat(JSON.stringify(T)))}var I,M=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Ke(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(A[We][g].featureCols);try{for(M.s();!(I=M.n()).done;){var D=I.value;if(!S.hasOwnProperty(D))throw new Error('Feature "'.concat(D,'" not found in verticalOhlcv for ').concat(g,"."))}}catch(t){M.e(t)}finally{M.f()}if(A[We][g].X.length<n){var R=A[We][g].X.length-n;throw new Error('The current "trainingSize" at '.concat(We,' "').concat(g,'" requires at least ').concat(R,' more datapoints. Try adding more input ohlcv rows or reducing the "trainingSize" by ').concat(R,"."))}}}var L=A[We][g];if(0===L.flatFeaturesColLen){if(L.featureCols=ue({trainingCols:a,findGroups:u,verticalOhlcv:S,scaledGroups:j}),!e(t,r,L.featureCols))return;L.flatFeaturesColLen=le(L.featureCols,S,r),oe({featureCols:L.featureCols,flatFeaturesColLen:L.flatFeaturesColLen,type:s,trainingSize:n})}if(0!==L.flatFeaturesColLen){var F=L.uniqueLabels,z=L.expectedLoops,U=L.featureCols,Y=L.flatFeaturesColLen,q=L.shouldRetrain,V=L.X,G=Ce({featureCols:U,flatFeaturesColLen:Y,type:s,index:r,lookbackAbs:b,main:t});if(G){var H=i(r,S,p);if(null!==H&&(!Array.isArray(H)||H.length!==h))throw new Error("trainY must be null or an array with ".concat(h,' items, got "').concat(JSON.stringify(H),'" at index ').concat(r," for ").concat(s));for(var B=0;B<z;B++){var $="".concat(g,"_").concat(B+1),X=L.Y[B],K=w?null===H?null:H[B]:H,J=L.isTrained[B];if(x.hasOwnProperty($)&&J&&(!1===q||x[$].length===p)){var W=x[$][0].predict([G])[0];if(w){if(null==W)throw new Error("Prediction of ".concat(g," at index ").concat(r," was expecting a number."));t.pushToMain({index:r,key:$,value:W}),null!=K&&ce({metrics:P.metrics[$],trueLabel:K,predictedLabel:W})}else{if(!Array.isArray(W)||W.length!==h)throw new Error("Prediction output of ".concat(We,' "').concat(g,'" at index ').concat(r," was expecting an array of values."));for(var Z=0;Z<h;Z++)t.pushToMain({index:r,key:"".concat(g,"_").concat(Z+1),value:W[Z]}),Array.isArray(K)&&K.length===h&&ce({metrics:P.metrics["".concat(g,"_").concat(Z+1)],trueLabel:K[Z],predictedLabel:W[Z]})}}if(!(r+h+1>O)&&null!==K){if(w){if(void 0===K||null==K)throw new Error("currTrainY must return number, string or boolean got ".concat($e(K)," at index ").concat(r))}else if(K.length!==h)throw new Error("The number of label columns returned (".concat(K.length,") doesn’t match the options.predictions (").concat(h,") setting for the ").concat(We,' "').concat(g,'" classifier. ')+"Please update your yCallback function so its output array items align with options.predictions.");if(X.push(K),X.length>n&&X.shift(),0===B&&(V.push(G),V.length>n&&V.shift()),(q||!J)&&V.length===n&&X.length===n){if(!1===J&&(F[B]=He(X),F[B]<2))throw new Error("Invalid number or labels in ".concat(g,'. Check the logic of your "yCallback" function.'));var Q=d.train,tt=Be(V,X),rt=Q({modelClass:m,xRows:tt.X,yRows:tt.Y,modelArgs:f,uniqueLabels:F[B]});x[$].push(rt),x[$].length>p&&x[$].shift(),L.isTrained[B]=!0}}}return!0}}};function Qe(t){return function(t){if(Array.isArray(t))return nn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||en(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 tn(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=en(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function rn(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||en(t,r)||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 en(t,r){if(t){if("string"==typeof t)return nn(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?nn(t,r):void 0}}function nn(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var on={dateTime:function(t,r,e){var n,o=e.lag,i=e.oneHot,a=e.precompute,l=t.instances,u=t.verticalOhlcv,c=a.prefix;if(0===r){var s=t.len;if(!t.dateType)throw Error('dateTime method found and invalid "date" in input ohlcv');var f=u.date[0].getUTCFullYear(),p=(new Date).getUTCFullYear();Object.assign(l,{dateTime:{colKeys:[].concat((n=a.colKeys,function(t){if(Array.isArray(t))return Ae(t)}(n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||Oe(n)||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.")}()),["".concat(c,"year")]),colKeySizes:we(we({},a.colKeySizes),{},Se({},"".concat(c,"year"),p-f+1)),startYear:f}});var y,h=l.dateTime.colKeys,v=i?Array:Int16Array,d=i?null:NaN,m=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Oe(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(h);try{for(m.s();!(y=m.n()).done;)u[y.value]=new v(s).fill(d)}catch(t){m.e(t)}finally{m.f()}o>0&&t.lag(h,o)}for(var b=l.dateTime,g=b.colKeySizes,w=b.startYear,S=function(t,r,e,n,o){for(var i=function(t,e){return r?ne(t,e):t},a=Se(Se(Se(Se(Se(Se({},"".concat(n,"year"),t.getUTCFullYear()),"".concat(n,"month"),t.getUTCMonth()),"".concat(n,"hour"),t.getUTCHours()),"".concat(n,"minute"),t.getUTCMinutes()),"".concat(n,"day_of_the_week"),t.getUTCDay()),"".concat(n,"day_of_the_month"),t.getUTCDate()-1),l=0,u=Object.entries(e);l<u.length;l++){var c=be(u[l],2),s=c[0],f=c[1],p=s==="".concat(n,"year")?a[s]-o:a[s];a[s]=i(p,f)}return a}(u.date[r],i,g,c,w),O=0,A=Object.entries(S);O<A.length;O++){var j=be(A[O],2),N=j[0],P=j[1];t.pushToMain({index:r,key:N,value:P})}},heikenAshi:function(t,r,e,n,o){var i,a=o.lag,l=t.verticalOhlcv,u=t.instances,c=t.len,s="heiken_ashi_".concat(e,"_").concat(n),f=["open","high","low","close"];if(0===r){u[s]={emaPre:Object.fromEntries(f.map((function(t){return[t,new Ut(e)]}))),emaPost:Object.fromEntries(f.map((function(t){return[t,new Ut(n)]}))),prevHaOpen:NaN,prevHaClose:NaN,isTrendUp:!1};var p=f.map((function(t){return"".concat(s,"_").concat(t)})),y=Object.fromEntries([].concat((i=p,function(t){if(Array.isArray(t))return Sr(t)}(i)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,r){if(t){if("string"==typeof t)return Sr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Sr(t,r):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.")}()),["".concat(s,"_cross")]).map((function(t){return[t,new Float64Array(c).fill(NaN)]})));Object.assign(l,function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?gr(Object(e),!0).forEach((function(r){wr(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):gr(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}({},y)),a>0&&t.lag(p,a)}var h,v,d,m,b=l.open[r],g=l.high[r],w=l.low[r],S=l.close[r],O=u[s];O.emaPre.open.update(b),O.emaPre.high.update(g),O.emaPre.low.update(w),O.emaPre.close.update(S);try{h=O.emaPre.open.getResult(),v=O.emaPre.high.getResult(),d=O.emaPre.low.getResult(),m=O.emaPre.close.getResult()}catch(t){return!0}var A,j,N,P,x=(h+v+d+m)/4,_=Number.isNaN(O.prevHaOpen)||Number.isNaN(O.prevHaClose)?(h+m)/2:(O.prevHaOpen+O.prevHaClose)/2,k=Math.max(v,_,x),E=Math.min(d,_,x);O.prevHaOpen=_,O.prevHaClose=x,O.emaPost.open.update(_),O.emaPost.high.update(k),O.emaPost.low.update(E),O.emaPost.close.update(x);try{A=O.emaPost.open.getResult(),j=O.emaPost.high.getResult(),N=O.emaPost.low.getResult(),P=O.emaPost.close.getResult()}catch(t){return!0}var C=r>0?l["".concat(s,"_cross")][r-1]:0,T=r>0?l["".concat(s,"_open")][r-1]:NaN,I=r>0?l["".concat(s,"_close")][r-1]:NaN,M=!Number.isNaN(I)&&I<=T&&P>A,D=!Number.isNaN(I)&&I>=T&&P<A;M&&(O.isTrendUp=!0),D&&(O.isTrendUp=!1);var R=0;return r>0&&(R=O.isTrendUp?C>0?C+1:1:C<0?C-1:-1),t.pushToMain({index:r,key:"".concat(s,"_open"),value:A}),t.pushToMain({index:r,key:"".concat(s,"_high"),value:j}),t.pushToMain({index:r,key:"".concat(s,"_low"),value:N}),t.pushToMain({index:r,key:"".concat(s,"_close"),value:P}),t.pushToMain({index:r,key:"".concat(s,"_cross"),value:R}),!0},rsi:function(t,r,e,n){var o=n.target,i=n.lag,a=n.parser,l=n.prefix,u=n.minmax,c=t.verticalOhlcv,s=t.instances,f="close"===o?"":"_".concat(o),p="".concat(l,"rsi_").concat(e).concat(f),y="".concat(l,"rsi_sma_").concat(e).concat(f);if(0===r){var h=t.len;if(!c.hasOwnProperty(o))throw new Error("Target property ".concat(o," not found in verticalOhlcv for rsi."));Object.assign(s,fr(fr({},p,new tr(e)),y,new Z(e))),Object.assign(c,fr(fr({},p,new Float64Array(h).fill(NaN)),y,new Float64Array(h).fill(NaN)));var v=[p,y];i>0&&t.lag(v,i);var d=i>0?v.flatMap((function(t){return[t].concat(cr(Array.from({length:i},(function(r,e){return"".concat(t,"_lag_").concat(e+1)}))))})):v;if(Array.isArray(u)){var m,b,g=null!==(b=(m=t.scaledGroups).minmax_rsi)&&void 0!==b?b:m.minmax_rsi=[];g.push.apply(g,cr(d))}}var w=c[o][r],S=NaN,O=NaN;s[p].update(w);try{S=s[p].getResult()}catch(t){S=NaN}t.pushToMain({index:r,key:p,value:Number.isNaN(S)?NaN:a(S)}),Number.isNaN(S)||s[y].update(S);try{O=s[y].getResult()}catch(t){O=NaN}t.pushToMain({index:r,key:y,value:Number.isNaN(O)?NaN:a(O)})},stochastic:function(t,r,e,n,o,i){var a=i.minmax,l=i.prefix,u=i.lag,c=i.parser,s=t.verticalOhlcv,f=t.instances,p=14===e&&3===n&&3===o?"":"".concat(e,"_").concat(n,"_").concat(o),y="".concat(l,"stoch_d").concat(p),h="".concat(l,"stoch_k").concat(p),v="".concat(l).concat(p);if(0===r){var d=t.len;Object.assign(f,vr({},v,new lr(e,n,o))),Object.assign(s,vr(vr({},y,new Float64Array(d).fill(NaN)),h,new Float64Array(d).fill(NaN)));var m=[y,h];u>0&&t.lag(m,u);var b=u>0?m.flatMap((function(t){return[t].concat(yr(Array.from({length:u},(function(r,e){return"".concat(t,"_lag_").concat(e+1)}))))})):m;if(Array.isArray(a)){var g,w,S=null!==(w=(g=t.scaledGroups).minmax_rsi)&&void 0!==w?w:g.minmax_rsi=[];S.push.apply(S,yr(b))}}var O=s.close[r],A=s.low[r],j=s.high[r],N=null;f[v].update({close:O,low:A,high:j});try{N=f[v].getResult()}catch(t){N=null}var P=N?c(N.stochK):NaN,x=N?c(N.stochD):NaN;t.pushToMain({index:r,key:h,value:P}),t.pushToMain({index:r,key:y,value:x})},atr:function(t,r,e,n){var o=n.lag,i=n.percentage,a=n.upper,l=n.lower,u=t.verticalOhlcv,c=t.instances,s="atr_".concat(e);if(0===r){var f=t.instances,p=t.verticalOhlcv,y=t.len;f[s]=new Pt(e,lt);var h=[s];i&&h.push("".concat(s,"_percentage")),null!==a&&h.push("".concat(s,"_upper")),null!==l&&h.push("".concat(s,"_lower"));for(var v=0,d=h;v<d.length;v++)p[d[v]]=new Float64Array(y).fill(NaN);o>0&&t.lag(h,o)}var m={high:u.high[r],low:u.low[r],close:u.close[r]},b=c[s];b.update(m);var g=NaN;try{g=b.getResult()}catch(t){}if(i){var w=Number.isNaN(g)?NaN:g/m.close;t.pushToMain({index:r,key:"".concat(s,"_percentage"),value:w})}if(null!==a){var S=Number.isNaN(g)?NaN:m.close+g*a;t.pushToMain({index:r,key:"".concat(s,"_upper"),value:S})}if(null!==l){var O=Number.isNaN(g)?NaN:m.close-g*l;t.pushToMain({index:r,key:"".concat(s,"_lower"),value:O})}return t.pushToMain({index:r,key:s,value:g}),!0},ema:mr,sma:mr,vidya:function(t,r,e,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=t.verticalOhlcv,a=t.instances,l=t.len,u=o.target,c=o.lag,s=o.atrLength,f=void 0===s?200:s,p=o.bandDistance,y=void 0===p?2:p,h=o.liquidityLookback,v=void 0===h?5:h,d="".concat(e,"_").concat(n);if(0===r){if(!(u in i))throw new Error('VIDYA could not find target "'.concat(u,'"'));var m="vidya_".concat(d),b={vidya:"close"===u?m:"".concat(m,"_").concat(u),upper:"".concat(m,"_upper"),lower:"".concat(m,"_lower"),delta_vol:"".concat(m,"_delta_vol"),cross:"".concat(m,"_cross"),liquidity:"".concat(m,"_liquidity")};a.vidya||(a.vidya={settings:{}}),a.vidya.settings[d]={momentumBuffer:[],prevVidya:NaN,sma:new Z(15),atrBuffer:[],isTrendUp:!1,upVol:0,downVol:0,liquidity:{high:[],low:[]}},Object.values(b).forEach((function(t){i[t]=new Float64Array(l).fill(NaN)})),c>0&&t.lag(Object.values(b),c)}var g=a.vidya.settings[d],w="vidya_".concat(d),S={vidya:"close"===u?w:"".concat(w,"_").concat(u),upper:"".concat(w,"_upper"),lower:"".concat(w,"_lower"),delta_vol:"".concat(w,"_delta_vol"),cross:"".concat(w,"_cross"),liquidity:"".concat(w,"_liquidity")},O=i[u][r],A=i.high[r],j=i.low[r],N=i.close[r],P=i.open[r],x=i.volume[r],_=r>0?i[S.cross][r-1]:0,k=g.liquidity.high.length===v?Math.max.apply(Math,Or(g.liquidity.high)):NaN,E=g.liquidity.low.length===v?Math.min.apply(Math,Or(g.liquidity.low)):NaN;if(r>0){var C=i.close[r-1],T=Math.max(A-j,Math.abs(A-C),Math.abs(j-C));g.atrBuffer.push(T),g.atrBuffer.length>f&&g.atrBuffer.shift()}var I=g.atrBuffer.length===f?g.atrBuffer.reduce((function(t,r){return t+r}),0)/f:NaN,M=NaN,D=NaN;if(r>0&&(D=O-i[u][r-1]),g.momentumBuffer.push(D),g.momentumBuffer.length>n&&g.momentumBuffer.shift(),g.momentumBuffer.length===n){var R=0,L=0;g.momentumBuffer.forEach((function(t){return t>=0?R+=t:L+=-t}));var F=R+L,z=2/(e+1)*((0===F?0:100*Math.abs((R-L)/F))/100);M=isNaN(g.prevVidya)?O:z*O+(1-z)*g.prevVidya,g.prevVidya=M}g.sma.update(M);var U=NaN;try{U=g.sma.getResult()}catch(t){}var Y=isNaN(I)||isNaN(U)?NaN:U+I*y,q=isNaN(I)||isNaN(U)?NaN:U-I*y,V=r>0?i[u][r-1]:NaN,G=r>0?i[S.upper][r-1]:NaN,H=r>0?i[S.lower][r-1]:NaN,B=r>0&&V<=G&&O>Y,$=r>0&&V>=H&&O<q;B&&(g.isTrendUp=!0),$&&(g.isTrendUp=!1);var X=0;r>0&&(X=g.isTrendUp?_>0?_+1:1:_<0?_-1:-1),B||$?g.upVol=g.downVol=0:(g.upVol+=N>P?x:0,g.downVol+=N<P?x:0);var K=(g.upVol+g.downVol)/2||1,J=(g.upVol-g.downVol)/K,W=g.isTrendUp?q:Y,Q=NaN;return X>0?Q=E:X<0&&(Q=k),t.pushToMain({index:r,key:S.vidya,value:W}),t.pushToMain({index:r,key:S.upper,value:Y}),t.pushToMain({index:r,key:S.lower,value:q}),t.pushToMain({index:r,key:S.delta_vol,value:J}),t.pushToMain({index:r,key:S.cross,value:X}),t.pushToMain({index:r,key:S.liquidity,value:Q}),g.liquidity.high.push(A),g.liquidity.low.push(j),g.liquidity.high.length>v&&g.liquidity.high.shift(),g.liquidity.low.length>v&&g.liquidity.low.shift(),!0},macd:function(t,r,e,n,o,i){var a=i.target,l=i.lag,u=i.precomputed,c=t.verticalOhlcv,s=t.instances,f=u.instanceKey;if(0===r){var p=t.inputParams,y=t.len;if(!c.hasOwnProperty(a))throw new Error("Target property ".concat(a," not found in verticalOhlcv for macd."));var h,v=0,d=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Pr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Pr(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(p);try{for(d.s();!(h=d.n()).done;)"macd"===h.value.key&&v++}catch(t){d.e(t)}finally{d.f()}var m=v>1?"macd_".concat(e,"_").concat(n,"_").concat(o):"macd",b=a===xr?"".concat(m,"_diff"):"".concat(m,"_diff_").concat(a),g=a===xr?"".concat(m,"_dea"):"".concat(m,"_dea_").concat(a),w=a===xr?"".concat(m,"_histogram"):"".concat(m,"_histogram_").concat(a);s.hasOwnProperty("macd")||(s.macd={numberOfIndicators:v,settings:{}}),s.macd.settings[f]=new Ht(new Ut(e),new Ut(n),new Ut(o)),Object.assign(c,Nr(Nr(Nr({},b,new Float64Array(y).fill(NaN)),g,new Float64Array(y).fill(NaN)),w,new Float64Array(y).fill(NaN)));var S=[b,g,w];l>0&&t.lag(S,l)}var O=s.macd,A=O.numberOfIndicators,j=O.settings,N=A>1?"macd_".concat(e,"_").concat(n,"_").concat(o):"macd",P=a===xr?"".concat(N,"_diff"):"".concat(N,"_diff_").concat(a),x=a===xr?"".concat(N,"_dea"):"".concat(N,"_dea_").concat(a),_=a===xr?"".concat(N,"_histogram"):"".concat(N,"_histogram_").concat(a),k=j[f],E=c[a][r];k.update(E);var C={};try{C=k.getResult()}catch(t){}return t.pushToMain({index:r,key:P,value:C?C.macd:NaN}),t.pushToMain({index:r,key:x,value:C?C.signal:NaN}),t.pushToMain({index:r,key:_,value:C?C.histogram:NaN}),!0},relativeVolume:function(t,r,e,n){var o=n.lag,i="relative_volume_".concat(e),a=t.instances,l=t.verticalOhlcv;if(0===r){var u=t.len;a[i]={instance:new Z(e),prevRelativeVolumeSma:NaN},l[i]=new Float64Array(u).fill(NaN),o>0&&t.lag([i],o)}var c=l.volume[r],s=a[i].instance;s.update(c);var f=NaN;try{f=s.getResult()}catch(t){}var p=a[i].prevRelativeVolumeSma,y=NaN;return Number.isNaN(f)||Number.isNaN(p)||(y=c/p),t.pushToMain({index:r,key:i,value:y}),a[i].prevRelativeVolumeSma=f,!0},donchianChannels:function(t,r,e,n,o){var i=t.verticalOhlcv,a=t.instances,l=t.len,u=t.inputParams,c=t.lag,s=o.height,f=o.range,p=o.decimals,y="".concat(e,"_").concat(n);if(0===r){var h=u.filter((function(t){return"donchianChannels"===t.key})).length,v="donchian_channel",d=h>1?"".concat(v,"_").concat(y):v,m=["upper","basis","lower"].map((function(t){return"".concat(d,"_").concat(t)}));s&&m.push("".concat(d,"_height"));var b,g=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Ir(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(f);try{for(g.s();!(b=g.n()).done;){var w=b.value;if(!(w in i))throw new Error('Invalid range key "'.concat(w,'".'));m.push("".concat(d,"_range_").concat(w))}}catch(t){g.e(t)}finally{g.f()}a.donchian_channel||(a.donchian_channel={numberOfIndicators:h,settings:{}}),a.donchian_channel.numberOfIndicators=h,a.donchian_channel.settings[y]={maxDeque:[],minDeque:[]},Object.assign(i,Object.fromEntries(m.map((function(t){return[t,new Float64Array(l).fill(NaN)]})))),c>0&&t.lag(m,c)}var S=a.donchian_channel,O=S.numberOfIndicators,A=S.settings,j=O>1?"donchian_channel_".concat(y):"donchian_channel",N=A[y],P=N.maxDeque,x=N.minDeque,_=r-n,k=_-e+1,E=["upper","basis","lower"].map((function(t){return"".concat(j,"_").concat(t)}));s&&E.push("".concat(j,"_height"));var C=f.map((function(t){return"".concat(j,"_range_").concat(t)}));if(k<0||_+1>l)return[].concat(Tr(E),Tr(C)).forEach((function(e){return t.pushToMain({index:r,key:e,value:NaN})})),!0;var T=i.high,I=i.low,M=function(t,r,e){for(;t.length&&t[0]<k;)t.shift();for(;t.length&&e(r[t.at(-1)],r[_]);)t.pop();t.push(_)};M(P,T,(function(t,r){return t<=r})),M(x,I,(function(t,r){return t>=r}));var D=P.length&&x.length,R=D?T[P[0]]:NaN,L=D?I[x[0]]:NaN,F=D?(R+L)/2:NaN;if(t.pushToMain({index:r,key:"".concat(j,"_upper"),value:R}),t.pushToMain({index:r,key:"".concat(j,"_basis"),value:F}),t.pushToMain({index:r,key:"".concat(j,"_lower"),value:L}),s){var z=D&&L?(R-L)/L:NaN;t.pushToMain({index:r,key:"".concat(j,"_height"),value:null===p?z:Cr(z,p)})}for(var U=D?R-L:NaN,Y=0;Y<f.length;Y++){var q=i[f[Y]][r],V=D&&q==q&&U?(q-L)/U:NaN;t.pushToMain({index:r,key:C[Y],value:null===p?V:Cr(V,p)})}return!0},bollingerBands:function(t,r,e,n,o){var i,a,l,u,c,s,f=o.height,p=o.range,y=void 0===p?[]:p,h=o.target,v=o.lag,d=o.decimals,m=t.verticalOhlcv,b=t.instances,g="".concat(e,"_").concat(n),w="bollinger_bands";if(0===r){var S=t.inputParams,O=t.verticalOhlcv,A=t.len;if(!(h in O))throw new Error('bollingerBands could not find target "'.concat(h,'"'));var j,N=0,P=Fr(S);try{for(P.s();!(j=P.n()).done;)"bollingerBands"===j.value.key&&N++}catch(t){P.e(t)}finally{P.f()}b.bollinger_bands||(b.bollinger_bands={numberOfIndicators:N,settings:{}}),b.bollinger_bands.settings[g]=new Ct(e,n);var x="";N>1&&(x+="_".concat(g)),h!==Ur&&(x+="_".concat(h));var _=["".concat(w,"_upper"),"".concat(w,"_middle"),"".concat(w,"_lower")].map((function(t){return"".concat(t).concat(x)}));f&&_.push("".concat(w,"_height").concat(x));var k,E=Fr(y);try{for(E.s();!(k=E.n()).done;){var C=k.value;if(!(C in O))throw new Error('Invalid range item value "'.concat(C,'" property for bollingerBands.'));_.push("".concat(w,"_range_").concat(C).concat(x))}}catch(t){E.e(t)}finally{E.f()}var T=Object.fromEntries(_.map((function(t){return[t,new Float64Array(A).fill(NaN)]})));Object.assign(O,function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?Rr(Object(e),!0).forEach((function(r){Lr(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Rr(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}({},T)),v>0&&t.lag(_,v)}var I="";b.bollinger_bands.numberOfIndicators>1&&(I+="_".concat(g)),h!==Ur&&(I+="_".concat(h));var M=b.bollinger_bands.settings[g],D=m[h][r];M.update(D);var R={};try{R=M.getResult()}catch(t){}var L=null!==(i=null===(a=R)||void 0===a?void 0:a.upper)&&void 0!==i?i:NaN,F=null!==(l=null===(u=R)||void 0===u?void 0:u.middle)&&void 0!==l?l:NaN,z=null!==(c=null===(s=R)||void 0===s?void 0:s.lower)&&void 0!==c?c:NaN;if(t.pushToMain({index:r,key:"".concat(w,"_upper").concat(I),value:L}),t.pushToMain({index:r,key:"".concat(w,"_middle").concat(I),value:F}),t.pushToMain({index:r,key:"".concat(w,"_lower").concat(I),value:z}),f){var U=NaN;Number.isNaN(z)||Number.isNaN(L)||(U=(L-z)/z),t.pushToMain({index:r,key:"".concat(w,"_height").concat(I),value:null===d?U:Cr(U,d)})}var Y,q=Fr(y);try{for(q.s();!(Y=q.n()).done;){var V=Y.value,G=NaN,H=m[V][r];Number.isNaN(H)||Number.isNaN(z)||Number.isNaN(L)||(G=(H-z)/(L-z)),t.pushToMain({index:r,key:"".concat(w,"_range_").concat(V).concat(I),value:null===d?G:Cr(G,d)})}}catch(t){q.e(t)}finally{q.f()}return!0},volumeOscillator:function(t,r,e,n,o){var i,a,l,u=o.lag,c=t.verticalOhlcv,s=t.instances,f=c.volume[r],p="volume_oscillator_".concat(e,"_").concat(n);if(0===r){var y=t.len;Object.assign(s,(i={},a=p,l={fastEMA:new Ut(e),slowEMA:new Ut(n)},(a=function(t){var r=function(t,r){if("object"!=Yr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Yr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yr(r)?r:r+""}(a))in i?Object.defineProperty(i,a,{value:l,enumerable:!0,configurable:!0,writable:!0}):i[a]=l,i)),c[p]=new Float64Array(y).fill(NaN),u>0&&t.lag([p],u)}var h=s[p],v=h.fastEMA,d=h.slowEMA;v.update(f),d.update(f);var m=NaN,b=NaN;try{m=v.getResult()}catch(t){}try{b=d.getResult()}catch(t){}var g=NaN;return Number.isNaN(m)||Number.isNaN(b)||(g=100*(m-b)/b),t.pushToMain({index:r,key:p,value:g}),!0},mapCols:function(t,r,e,n,o){var i=o.lag,a=t.verticalOhlcv,l=t.len;if(0===r){var u,c=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=xe(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(e);try{for(c.s();!(u=c.n()).done;){var s=u.value;if(a.hasOwnProperty(s))throw new Error('New property "'.concat(s,'" already exist in "verticalOhlcv" and can not be modified using mapCols.'));a[s]=new Array(l).fill(0)}}catch(t){c.e(t)}finally{c.f()}i>0&&t.lag(e,i)}var f,p,y=n({index:r,main:t});if(null==y)return!0;for(var h=0,v=Object.entries(y);h<v.length;h++){var d=(f=v[h],p=2,function(t){if(Array.isArray(t))return t}(f)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(f,p)||xe(f,p)||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.")}()),m=d[0],b=d[1];t.pushToMain({index:r,key:m,value:b})}},scaler:function(t,r,e,n,o){var i=o.type,a=o.group,l=o.range,u=o.lag,c=o.precomputed,s=(o.secondaryLoop,c.groupKey),f=c.groupKeyLen,p=t.verticalOhlcv,y=t.instances,h=(t.invalidValueIndex,"".concat(i,"_").concat(e));if(0===r){var v=t.len,d=t.isAlreadyComputed;if(d.has(h))throw new Error('In scaler method can not repeat params "size" and "options.type" together between indicators.');d.add(h),y.hasOwnProperty("scaler")||(y.scaler={}),y.scaler.hasOwnProperty(h)||(y.scaler[h]={windows:{}});var m,b=[],g=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Ne(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(n);try{var w=function(){var r=m.value;if(!p.hasOwnProperty(r))throw new Error('Target property "'.concat(r,'" not found in verticalOhlcv'));var e="".concat(h,"_").concat(r);p[e]=new Float64Array(v).fill(NaN);var n=a?s:r;if(y.scaler[h].windows[n]=[],t.scaledGroups[s]||(t.scaledGroups[s]=[]),t.scaledGroups[s].push(e),u>0){var o,i=Array.from({length:u}).map((function(t,r){return"".concat(e,"_lag_").concat(r+1)}));(o=t.scaledGroups[s]).push.apply(o,je(i)),b.push(e)}};for(g.s();!(m=g.n()).done;)w()}catch(t){g.e(t)}finally{g.f()}u>0&&t.lag(b,u)}for(var S=y.scaler[h].windows,O=!1,A=0;A<n.length;A++){var j=n[A],N=p[j];if(void 0===N){O=!0;break}var P=N[r];if(Number.isNaN(P)||null===P){O=!0;break}var x=S[a?s:j];x.push(P),x.length>(a?e*f:e)&&x.shift()}if(!O&&r+1>=e)for(var _=function(){var e=n[k],o=p[e];if(void 0===o)return 0;var u=o[r];if(Number.isNaN(u)||null===u)return 0;var c="".concat(h,"_").concat(e),f=null,y=S[a?s:e];if("minmax"===i){var v=Math.min.apply(Math,je(y)),d=Math.max.apply(Math,je(y));f=ie(u,v,d,l)}else{if("zscore"!==i)throw new Error('Unknown scaler type "'.concat(i,'"'));var m=y.reduce((function(t,r){return t+r}),0)/y.length,b=y.reduce((function(t,r){return t+Math.pow(r-m,2)}),0)/y.length,g=Math.sqrt(b);f=function(t,r,e){return 0===e?0:(t-r)/e}(u,m,g)}t.pushToMain({index:r,key:c,value:f})},k=0;k<n.length&&0!==_();k++);},crossPairs:function(t,r,e,n){var o,i=n.oneHot,a=n.limit,l=t.verticalOhlcv,u=t.verticalOhlcvTempCols,c=t.instances,s=t.len,f=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return se(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?se(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(e);try{for(f.s();!(o=f.n()).done;){var p=o.value,y=p.fast,h=p.slow,v="".concat(y,"_x_").concat(h);if(0===r){if("number"==typeof h){var d=h.toString();u.add(d);var m=h>=-125||h<=125?"Int8Array":"Int16Array";l[d]=Jr(m,s,h)}c.hasOwnProperty("crossPairs")||(c.crossPairs={}),c.crossPairs[v]={run:new de,min:1/0,max:-1/0};var b=null!==a&&a<=125?"Int8Array":"Int16Array";l[v]=Jr(b,s,0),i&&(l["one_hot_".concat(v)]=Jr("Array",s,null))}else if(r+1===s){if("price"!==y&&!l.hasOwnProperty(y))throw new Error('crossPairs invalid param: fast "'.concat(y,'" not found in "verticalOhlcv": ').concat(JSON.stringify(Object.keys(l))));if(!l.hasOwnProperty(h))throw new Error('crossPairs invalid param: slow "'.concat(h,'" not found in "verticalOhlcv": ').concat(JSON.stringify(Object.keys(l))))}if("price"!==y&&!l.hasOwnProperty(y))return;if(!l.hasOwnProperty(h))return;var g=c.crossPairs[v].run;if("price"===y){var w=l.close[r],S=l[h][r];g.update(r,{fast:w,slow:S,high:l.high[r],low:l.low[r]})}else{var O=l[y][r],A=l[h][r];g.update(r,{fast:O,slow:A})}var j=g.getResult(),N=null!==a?Math.min(Math.max(j,-a),a):j;if(t.pushToMain({index:r,key:v,value:N}),i){var P=N+a,x=2*a+1;t.pushToMain({index:r,key:"one_hot_".concat(v),value:ne(P,x)})}}}catch(t){f.e(t)}finally{f.f()}return!0},lag:function(t,r,e,n){var o=t.verticalOhlcv,i=t.len;if(0===r){var a,l=Zr(e);try{for(l.s();!(a=l.n()).done;){var u=a.value;if(!o.hasOwnProperty(u))throw new Error('Lag processing invoked by col "'.concat(u,'" was not found in "verticalOhlcv".'));for(var c=1;c<=n;c++){var s="".concat(u,"_lag_").concat(c),f=Wr(u,o[u]);o[s]=Jr(f,i)}}}catch(t){l.e(t)}finally{l.f()}}var p,y=Zr(e);try{for(y.s();!(p=y.n()).done;)for(var h=p.value,v=o[h],d=1;d<=n;d++){var m="".concat(h,"_lag_").concat(d),b=r-d,g=b<0||void 0===v[b]?null:v[b];t.pushToMain({index:r,key:m,value:g})}}catch(t){y.e(t)}finally{y.f()}return!0}},an=function(t,r){for(var e=t.length,n=new Z(r),o=new Array(e),i=0,a=0,l=0,u=0;u<e;u++)if(n.update(t[u]),n.isStable){var c=n.getResult();o[u]=c,i+=c,a+=c*c,l++}else o[u]=null;var s=i/l,f=a/l-s*s,p=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/p:null}))},ln=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==r.length)throw new Error("Both arrays must have the same length");for(var n=an(t,e),o=an(r,e),i=t.length,a=[],l=0,u=0,c=0,s=0,f=0,p=0,y=-1,h=0;h<i;h++){if(null!==n[h]&&null!==o[h]){y=h;break}a.push(0)}if(-1===y)return new Array(i).fill(0);for(var v=y;v<i;v++){var d=n[v],m=o[v];if(null!==d&&null!==m)if(l+=d,u+=m,c+=d*m,s+=d*d,f+=m*m,++p<2)a.push(0);else{var b=p*c-l*u,g=Math.sqrt((p*s-l*l)*(p*f-u*u)),w=0===g?0:b/g;a.push(w)}else l=u=c=s=f=p=0,a.push(0)}return a};function un(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var cn=function(t){var r,e,n=t.main,o=t.skipNull,i=void 0!==o&&o,a=t.startIndex,l=void 0===a?0:a,u=t.dateFormat,c=n.verticalOhlcv,s=n.invalidValueIndex,f=n.len,p=n.verticalOhlcvKeyNames,y=n.verticalOhlcvTempCols;if(0===p.length)return[];for(var h=i&&s>=0?s+1:0,v=Math.max(h,l),d=f-v,m=Array.from({length:d},(function(){return{}})),b=0,g=Object.entries(c);b<g.length;b++){var w=(r=g[b],e=2,function(t){if(Array.isArray(t))return t}(r)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(r,e)||function(t,r){if(t){if("string"==typeof t)return un(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?un(t,r):void 0}}(r,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.")}()),S=w[0],O=w[1];if(!y.has(S))for(var A=v;A<f;A++)m[A-v][S]="date"===S?Vr[u](O[A]):O[A]}return m},sn=function(t,r){u(t,"arr","getOrderFromArray"),h(r,"methodName","getOrderFromArray");var e=["open","high","low","close","volume","date"],n=["regressor","classifier","pca"].includes(r);if(t.every((function(t){return e.includes(t)}))&&!n)return 0;for(var o=1,i=function(){var r=l[a];t.some((function(t){return t.includes(r)}))&&o++},a=0,l=["_x_","zscore_","minmax_","lag_"];a<l.length;a++)i();if(!n)return o;o=10;for(var c=function(){var r=f[s];t.some((function(t){return t.includes(r)}))&&o++},s=0,f=["prediction_","reg_","cla_","pca_"];s<f.length;s++)c();return o};function fn(t){return fn="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},fn(t)}function pn(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function yn(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?pn(Object(e),!0).forEach((function(r){hn(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):pn(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function hn(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=fn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=fn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fn(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function vn(t,r){if(t){if("string"==typeof t)return dn(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?dn(t,r):void 0}}function dn(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var mn=function(t,r,e){if(2!==e)throw new Error('The default "yCallback" function in this classifier requires that "options.horizon" and "options.predictions" are set to "2".');var n=r.close[t],o=Array.from({length:e},(function(e,n){return r.close[n+1+t]}));if(o.some((function(t){return void 0===t})))return null;var i=o[0],a=o[1];return[Number(i>n),Number(a>i)]},bn={KNN:{shortName:"knn",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},FeedForwardNeuralNetworks:{shortName:"feed_forward",flatY:!1,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=t.modelArgs,i=t.uniqueLabels;o||(o={});var a=new r(o=yn(yn({},o),{},{activation:2===i?"logistic":"identity"}));return a.train(e,n),a},unsupervised:!1},GaussianNB:{shortName:"naive_bayes",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},MultinomialNB:{shortName:"naive_bayes",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},DecisionTreeClassifier:{shortName:"decision_tree",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},RandomForestClassifier:{shortName:"random_forest",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o}},unsupervised:!1},gn={ARIMA:{shortName:"arima",flatX:!0,flatY:!1,exportModel:function(t){return t},train:function(t){var r=t.modelClass,e=t.xRows,n=t.modelArgs;n||(n={});var o=new r(n=yn(yn({},n),{},{p:2,d:1,q:2,P:0,D:0,Q:0,S:0,verbose:!1}));return o.train(e),o},unsupervised:!0},SimpleLinearRegression:{shortName:"linear",flatX:!0,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},PolynomialRegression:{shortName:"polynomial",flatX:!0,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},MultivariateLinearRegression:{shortName:"multivariable",flatX:!1,flatY:!1,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},DecisionTreeRegression:{shortName:"decision_tree",flatX:!1,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},RandomForestRegression:{shortName:"random_forest",flatX:!1,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},FeedForwardNeuralNetworks:{shortName:"feed_forward",flatX:!1,flatY:!1,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=t.modelArgs;o||(o={});var i=new r(o=yn(yn({},o),{},{activation:"identity"}));return i.train(e,n),i},unsupervised:!1}};function wn(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function Sn(t){return Sn="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},Sn(t)}function On(t,r,e){return(r=kn(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function An(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Pn(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function jn(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||Pn(t,r)||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 Nn(t){return function(t){if(Array.isArray(t))return xn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Pn(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 Pn(t,r){if(t){if("string"==typeof t)return xn(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?xn(t,r):void 0}}function xn(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function _n(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,kn(n.key),n)}}function kn(t){var r=function(t,r){if("object"!=Sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Sn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sn(r)?r:r+""}var En=function(){return t=function t(r){var e=this,n=r.input,o=r.ticker,i=void 0===o?null:o,l=r.inputParams,s=void 0===l?null:l,f=r.chunkProcess,y=void 0===f?2e3:f,h=r.ML,v=void 0===h?{}:h;if(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),u(n,"input",null!==i?"contructor ".concat(i):"constuctor"),0===n.length)throw Error("input OHLCV must not be empty: "+i);p(y,{min:100,max:5e4,allowDecimals:!1},"chunkProcess","constructor"),c(v,"ML","constructor"),this.chunkProcess=y,this.input=Nn(n),this.len=this.input.length,this.firstRow=this.input[0];var d=function(t){for(var r=t.firstRow,e={},n={},o=0,i=Object.entries(r);o<i.length;o++){var a=$r(i[o],2),l=a[0],u=a[1];if("date"===l)e[l]=Hr(u),n[l]="Array";else if("volume"===l)e[l]=Er(u,!0),n[l]="Int32Array";else if(Kr.has(l))e[l]=Er(u,!0),n[l]="Float64Array";else{var c=Er(u,!1);e[l]=c,n[l]="number"===c?"Float64Array":"Array"}}return{inputTypes:e,arrayTypes:n}}(this),m=d.inputTypes,b=d.arrayTypes;if(this.inputTypes=m,this.arrayTypes=b,!this.firstRow.hasOwnProperty("close"))throw Error('input OHLCV array objects require at least "close" property: '.concat(i));this.dateType=this.inputTypes.date?this.inputTypes.date:null,this.isComputed=!1,this.instances={},this.verticalOhlcv={},this.verticalOhlcvKeyNames=[],this.verticalOhlcvTempCols=new Set,this.utilities={correlation:ln},this.invalidValueIndex=-1,this.scaledGroups={},this.isAlreadyComputed=new Set;var g=v.classes;return void 0!==g&&c(g,"ML.classes","constructor"),this.ML={models:{},classes:g,metrics:{},featureCols:{}},this.processSecondaryLoop=!1,this.pushToMain=function(t){var r=t.index,n=t.key,o=t.value;return function(t){var r=t.index,e=t.key,n=t.value;return t.main.verticalOhlcv[e][r]=n,!0}({main:e,index:r,key:n,value:o})},null!==s?(a(s,this.len),this.inputParams=s,this.compute()):this.inputParams=[],this},r=[{key:"getDataAsCols",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var r=t.skipNull,e=void 0===r||r,n=t.dateFormat,o=void 0===n?"string":n;s(Object.keys(Vr),o,"dateFormat","getDataAsCols"),c(t,"options","getDataAsCols");for(var i=this.len,a=this.invalidValueIndex,l=this.verticalOhlcv,u=this.verticalOhlcvTempCols,f={},p=e?a+1:0,y=i-p,h=0,v=Object.entries(l);h<v.length;h++){var d=jn(v[h],2),m=d[0],b=d[1];if(!u.has(m)){var g=Wr(m,l[m]);f[m]=Jr(g,y);for(var w=p;w<i;w++)f[m][w]="date"===m?Vr[o](b[w]):b[w]}}return f}},{key:"getData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var r=t.skipNull,e=void 0===r||r,n=t.dateFormat,o=void 0===n?"string":n;return s(Object.keys(Vr),o,"dateFormat","getData"),c(t,"options","getData"),cn({main:this,skipNull:e,startIndex:0,dateFormat:o})}},{key:"getLastValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var r=t.dateFormat,e=void 0===r?"string":r;return s(Object.keys(Vr),e,"dateFormat","getData"),cn({skipNull:!1,main:this,startIndex:this.len-1,dateFormat:e})[0]}},{key:"compute",value:function(){return this.isComputed||(this.isComputed=!1,this.len>0&&(function(t,r){var n=r.len,o=r.inputParams,i=r.arrayTypes,l=r.verticalOhlcv,u=r.verticalOhlcvKeyNames,c=r.inputTypes,s=r.chunkProcess,f=r.processSecondaryLoop;a(o,n);for(var p=0,y=Object.keys(c);p<y.length;p++){var h=y[p];l[h]=Jr(i[h],n)}for(var v=0;v<n;v+=s)for(var d=Math.min(v+s,n),m=v;m<d;m++){for(var b=t[m],g=0,w=Object.entries(c);g<w.length;g++){var S=rn(w[g],2),O=S[0],A=S[1],j=b[O];if(kr.hasOwnProperty(A)){var N=kr[A](j);r.pushToMain({index:m,key:O,value:N})}else Gr.hasOwnProperty(A)?r.pushToMain({index:m,key:O,value:Gr[A](j)}):r.pushToMain({index:m,key:O,value:j})}var P,x=tn(o);try{for(x.s();!(P=x.n()).done;)for(var _=P.value,k=_.key,E=_.params,C=_.order,T=0;T<=9;T++){if("number"!=typeof C)throw new Error("order property of ".concat(k," not found: ").concat(E));T===C&&on[k].apply(on,[r,m].concat(Qe(E)))}}catch(t){x.e(t)}finally{x.f()}t[m]=null;var I=Object.keys(l);e(r,m,I)||(r.invalidValueIndex=m)}(o.some((function(t){var r=t.key;return"regressor"===r||"classifier"===r||"pca"===r}))||f)&&function(t){for(var r=t.inputParams,e=t.len,n=t.invalidValueIndex+1;n<e;n++){var o,i=tn(r);try{for(i.s();!(o=i.n()).done;)for(var a=o.value,l=a.key,u=a.params,c=a.order,s=10;s<=20;s++){if("number"!=typeof c)throw new Error("order property of ".concat(l," not found: ").concat(u));s===c&&("pca"===l&&Re.apply(void 0,[t,n].concat(Qe(u))),"classifier"===l&&Ze.apply(void 0,[t,n].concat(Qe(u))),"regressor"===l&&Ye.apply(void 0,[t,n].concat(Qe(u))))}}catch(t){i.e(t)}finally{i.f()}}}(r),u.push.apply(u,Qe(Object.keys(l)))}(this.input,this),this.isComputed=!0,this.input=[],this.instances={},this.firstRow=[])),this}},{key:"crossPairs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="crossPairs";l(this),u(t,"arr",e),c(r,"options",e);var n=r.limit,o=void 0===n?null:n,i=r.oneHot,a=void 0!==i&&i;null!==o&&p(o,{min:2,max:this.len},"options.limit",e),f(a,"options.oneHot",e);var s,y=[],h=An(t);try{for(h.s();!(s=h.n()).done;){var v=s.value,d=v.fast,m=void 0===d?"":d,b=v.slow,g=void 0===b?"":b;if(""===m||""===g)throw new Error("Invalid crossPairs[".concat(m,"_").concat(g,"]: Object property “fast” must be a non-null column name and “slow” must be a non-null column name or integer."));y.push(m.toString(),g.toString())}}catch(t){h.e(t)}finally{h.f()}if(this.isAlreadyComputed.has(e))throw new Error('You can only call the "'.concat(e,'" method once.'));this.isAlreadyComputed.add(e);var w=sn(y,e);return this.inputParams.push({key:e,order:w,params:[t,{limit:o,oneHot:a}]}),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,e="lag";l(this),u(t,"colKeys",e),p(r,{min:1,max:this.len,allowDecimals:!1},"lookback",e);var n=sn(t,e);return this.inputParams.push({key:e,order:n,params:[t,r]}),this}},{key:"relativeVolume",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="relativeVolume";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.lag,o=void 0===n?0:n;return p(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),this.inputParams.push({key:e,order:0,params:[t,{lag:o}]}),this}},{key:"atr",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="atr";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.lag,o=void 0===n?0:n,i=r.percentage,a=void 0!==i&&i,u=r.upper,s=void 0===u?null:u,y=r.lower,h=void 0===y?null:y;return p(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),f(a,"options.percentage","atr"),null!==s&&p(s,{min:.001,max:100,allowDecimals:!0},"options.upper","atr"),null!==h&&p(h,{min:.001,max:100,allowDecimals:!0},"options.lower","atr"),this.inputParams.push({key:e,order:0,params:[t,{lag:o,percentage:a,upper:s,lower:h}]}),this}},{key:"ema",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="ema";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.target,o=void 0===n?"close":n,i=r.lag,a=void 0===i?0:i;h(o,"options.target",e),p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var u=sn([o],e);return this.inputParams.push({key:e,order:u,params:[e,t,{target:o,lag:a}]}),this}},{key:"sma",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="sma";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.target,o=void 0===n?"close":n,i=r.lag,a=void 0===i?0:i;h(o,"options.target",e),p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var u=sn([o],e);return this.inputParams.push({key:e,order:u,params:[e,t,{target:o,lag:a}]}),this}},{key:"heikenAshi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="heikenAshi";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"smoothLength",n),p(r,{min:1,max:this.len,allowDecimals:!1},"afterSmoothLength",n),c(e,"options",n);var o=e.lag,i=void 0===o?0:o;return p(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),this.inputParams.push({key:n,order:0,params:[t,r,{lag:i}]}),this}},{key:"vidya",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="vidya";l(this),p(t,{min:2,max:this.len,allowDecimals:!1},"size",n),p(r,{min:1,max:this.len,allowDecimals:!1},"momentum",n),c(e,"options",n);var o=e.target,i=void 0===o?"close":o,a=e.lag,u=void 0===a?0:a,s=e.atrLength,f=void 0===s?200:s,y=e.bandDistance,v=void 0===y?2:y,d=e.liquidityLookback,m=void 0===d?20:d;h(i,"options.target",n),p(u,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),p(v,{min:.01,max:10,allowDecimals:!0},"options.bandDistance",n),p(f,{min:2,max:this.len,allowDecimals:!1},"options.atrLength",n),p(m,{min:1,max:this.len,allowDecimals:!1},"options.liquidityLookback",n);var b=sn([i],n);return this.inputParams.push({key:n,order:b,params:[t,r,{target:i,lag:u}]}),this}},{key:"stochastic",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="stochastic",i=this.len;p(t,{min:1,max:i,allowDecimals:!1},"kPeriod",o),p(r,{min:1,max:i,allowDecimals:!1},"kSlowingPeriod",o),p(e,{min:1,max:i,allowDecimals:!1},"dPeriod",o),c(n,"options",o);var a=function(t){return t},l="",u=n.lag,s=void 0===u?0:u;p(s,{min:0,max:i,allowDecimals:!1},"options.lag",o);var h=n.minmax;return(Array.isArray(h)||"boolean"==typeof h&&!0===h)&&(Array.isArray(h)?(y(h,"options.minmax",o),a=function(t){return null!==h?ie(t,0,100,h):t}):(f(h,"options.minmax",o),h=[0,1],a=function(t){return null!==h?ie(t,0,100,h):t}),l="minmax_"),this.inputParams.push({key:o,order:0,params:[t,r,e,{minmax:h,prefix:l,parser:a,lag:s}]}),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="macd";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"fast",o),p(r,{min:1,max:this.len,allowDecimals:!1},"slow",o),p(e,{min:1,max:this.len,allowDecimals:!1},"signal",o),c(n,"options",o);var i=n.target,a=void 0===i?"close":i,u=n.lag,s=void 0===u?0:u;h(a,"options.target",o),p(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",o);var f={instanceKey:"".concat(t,"_").concat(r,"_").concat(e).concat("close"===a?"":"_".concat(a))},y=sn([a],o);return this.inputParams.push({key:o,order:y,params:[t,r,e,{target:a,lag:s,precomputed:f}]}),this}},{key:"bollingerBands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="bollingerBands";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",n),p(r,{min:.01,max:50,allowDecimals:!0},"stdDev",n),c(e,"options",n);var o=e.target,i=void 0===o?"close":o,a=e.height,s=void 0!==a&&a,y=e.range,v=void 0===y?[]:y,d=e.lag,m=void 0===d?0:d,b=e.decimals,g=void 0===b?null:b;h(i,"options.target",n),u(v,"options.range",n),p(m,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(s,"options.height",n),null!==g&&p(g,{min:1,max:15,allowDecimals:!1},"decimals",n);var w=sn([i],n);return this.inputParams.push({key:n,order:w,params:[t,r,{target:i,height:s,range:v,lag:m,decimals:g}]}),this}},{key:"rsi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="rsi";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.target,o=void 0===n?"close":n,i=r.lag,a=void 0===i?0:i,u=r.minmax;h(o,"options.target",e),p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var s=function(t){return t},v="";(Array.isArray(u)||"boolean"==typeof u&&!0===u)&&(Array.isArray(u)?(y(u,"options.minmax",e),s=function(t){return null!==u?ie(t,0,100,u):t}):(f(u,"options.minmax",e),u=[0,1],s=function(t){return null!==u?ie(t,0,100,u):t}),v="minmax_");var d=sn([o],e);return this.inputParams.push({key:e,order:d,params:[t,{target:o,lag:a,parser:s,prefix:v,minmax:u}]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="donchianChannels";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",n),p(r,{min:0,max:this.len,allowDecimals:!1},"offset",n),c(e,"options",n);var o=e.height,i=void 0!==o&&o,a=e.range,s=void 0===a?[]:a,y=e.lag,h=void 0===y?0:y,v=e.decimals,d=void 0===v?null:v;return u(s,"options.range",n),p(h,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(i,"options.height",n),null!==d&&p(d,{min:1,max:15,allowDecimals:!1},"decimals",n),this.inputParams.push({key:n,order:0,params:[t,r,{height:i,range:s,lag:h,decimals:d}]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="volumeOscillator";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"fastsize",n),p(r,{min:t,max:this.len,allowDecimals:!1},"slowsize",n),c(e,"options",n);var o=e.lag,i=void 0===o?0:o;return p(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),this.inputParams.push({key:n,order:0,params:[t,r,{lag:i}]}),this}},{key:"dateTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="dateTime";l(this),c(t,"options",r);var e=t.lag,n=void 0===e?0:e,o=t.oneHot,i=void 0!==o&&o;p(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),f(i,"options.oneHot",r);var a=i?"one_hot_":"",u=On(On(On(On(On({},"".concat(a,"month"),12),"".concat(a,"day_of_the_month"),31),"".concat(a,"day_of_the_week"),7),"".concat(a,"hour"),24),"".concat(a,"minute"),60),s={prefix:a,colKeySizes:u,colKeys:Object.keys(u)};return this.inputParams.push({key:r,order:0,params:[{lag:n,oneHot:i,precompute:s}]}),this}},{key:"scaler",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"zscore",r=arguments.length>1?arguments[1]:void 0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="scaler";l(this),p(r,{min:1,max:this.len,allowDecimals:!1},"size",n),c(e,"options",n);var o=e.group,i=void 0!==o&&o,a=e.range,h=void 0===a?[0,1]:a,v=e.lag,d=void 0===v?0:v,m=e.colKeys,b=void 0===m?[]:m;u(b,"options.colKeys",n),f(i,"options.group",n),y(h,"options.range",n),s(["minmax","zscore"],t,"options.type",n);var g={groupKey:"".concat(t,"_").concat(r),groupKeyLen:b.length},w=!1,S=sn(b,n);return S>=10&&(w=!0),this.inputParams.push({key:n,order:S,params:[r,b,{type:t,group:i,range:h,lag:d,precomputed:g,secondaryLoop:w}]}),this}},{key:"classifier",value:function(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l(this);var n="classifier";p(r,{max:this.len,allowDecimals:!1},"trainingSize",n),c(e,"options",n);var o=e.retrain,i=void 0!==o&&o,a=e.trainingCols,y=void 0===a?[]:a,h=e.type,v=void 0===h?"KNN":h,d=e.lookback,m=void 0===d?0:d,b=e.findGroups,g=void 0===b?[]:b,w=e.predictions,S=void 0===w?2:w,O=e.horizon,A=void 0===O?2:O,j=e.modelArgs,N=void 0===j?void 0:j,P=e.filterCallback,x=void 0===P?function(){return!0}:P;if(void 0!==N&&("object"!==Sn(N)||null===N||Array.isArray(N)))throw new TypeError('"modelArgs" must be either undefined or a plain object in '.concat(v));var _=null!==(t=e.yCallback)&&void 0!==t?t:mn;if("function"!=typeof _)throw new Error('"yCallback" must be a function in the following format:\n\n---\n\nconst yCallback = '.concat(mn.toString(),"\n\n---\n\n"));if(s(Object.keys(bn),v,"options.type",n),!this.ML.classes.hasOwnProperty(v))throw new Error('"'.concat(v,'" isn’t available because its library wasn’t imported into OHLCV_INDICATORS.ML.'));f(i,"options.retrain",n),u(y,"options.trainingCols",n),p(A,{min:1,max:this.len,allowDecimals:!1},"options.horizon",n),p(m,{max:0,allowDecimals:!1},"options.lookback",n),p(S,{min:1,allowDecimals:!1},"options.predictions",n);var k=Nn(y);if(u(g,"options.findGroups","scaler")&&g.length>0){var E,C=An(g);try{for(C.s();!(E=C.n()).done;){var T=E.value,I=T.type,M=void 0===I?"":I,D=T.size,R=T.groupName,L=void 0===R?"":R;if(!M||!D&&!L||D&&L)throw new Error('If "options.findGroups" array is set, each item must be an object that includes the "type" (mandatory) and either "size" or "groupName" (choose 1) used to locate previously scaled (minmax or zscore) groups.');k.push(M.toString(),L.toString())}}catch(t){C.e(t)}finally{C.f()}}else if(0===y.length)throw new Error('"trainingCols" array is empty in '.concat(n));var F=bn[v],z=F.shortName,U=F.flatY,Y="cla_".concat(z,"_").concat(r,"_prediction");if(this.isAlreadyComputed.has(Y))throw new Error("Each classifier must have a unique pair of “type” and trainingSize.\nThis rule ensures that your output columns are labeled unambiguously.\n"+'You provided a duplicate: type="'.concat(v,'" with trainingSize=').concat(r,"."));var q={lookbackAbs:Math.abs(m)+1,flatY:U,prefix:Y};this.isAlreadyComputed.add(Y);var V=sn(k,n),G=bn[v],H=this.ML.classes[v];return this.inputParams.push({key:n,order:V,params:[r,{yCallback:_,predictions:S,lookback:m,retrain:i,trainingCols:y,findGroups:g,horizon:A,type:v,modelArgs:N,precompute:q,filterCallback:x,modelConfig:G,modelClass:H}]}),this}},{key:"regressor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l(this);var e="regressor";p(t,{max:this.len,allowDecimals:!1},"trainingSize",e),c(r,"options",e);var n=r.retrain,o=void 0!==n&&n,i=r.target,a=void 0===i?"close":i,y=r.predictions,v=void 0===y?1:y,d=r.trainingCols,m=void 0===d?[]:d,b=r.type,g=void 0===b?"SimpleLinearRegression":b,w=r.lookback,S=void 0===w?0:w,O=r.findGroups,A=void 0===O?[]:O,j=r.modelArgs,N=void 0===j?void 0:j,P=r.filterCallback,x=void 0===P?function(){return!0}:P;if(s(Object.keys(gn),g,"type",e),!this.ML.classes.hasOwnProperty(g))throw new Error('"'.concat(g,'" isn’t available because its library wasn’t imported into OHLCV_INDICATORS.ML.'));f(o,"options.retrain",e),h(a,"options.target",e),p(v,{min:1,allowDecimals:!1},"predictions",e),p(S,{max:0,allowDecimals:!1},"lookback",e),u(m,"options.trainingCols",e);var _=gn[g],k=_.shortName,E=_.flatX,C=_.flatY,T="reg_".concat(k,"_").concat(t,"_").concat(a,"_prediction"),I=Nn(m);if(u(A,"options.findGroups","scaler")&&A.length>0){var M,D=An(A);try{for(D.s();!(M=D.n()).done;){var R=M.value,L=R.type,F=void 0===L?"":L,z=R.size,U=R.groupName,Y=void 0===U?"":U;if(!F||!z&&!Y||z&&Y)throw new Error('If "options.findGroups" array is set, each item must be an object that includes the "type" (mandatory) and either "size" or "groupName" (choose 1) used to locate previously scaled (minmax or zscore) groups.');I.push(F.toString(),Y.toString())}}catch(t){D.e(t)}finally{D.f()}}else if(0===m.length&&!1===E)throw new Error('"trainingCols" array is empty in '.concat(e," ").concat(g));if(E){if(m.length>0)throw new Error("If regressor type is ".concat(g,' then leave "options.trainingCols" array empty.'));if(S>0)throw new Error("If regressor type is ".concat(g,' then "options.lookback" must be 0.'));if(A.length>0)throw new Error("If regressor type is ".concat(g,' then "options.findGroups" must be null.'));m.push(a)}if(this.isAlreadyComputed.has(T))throw new Error('Each regressor must have a unique "type", "trainingSize" and "target".\nThis rule ensures that your output columns are labeled unambiguously.\n'+'You provided a duplicate: type="'.concat(g,'", trainingSize=').concat(t," target=").concat(a,"."));var q={lookbackAbs:Math.abs(S)+1,flatX:E,flatY:C,prefix:T};this.isAlreadyComputed.add(T);var V=sn(I,e),G=gn[g],H=this.ML.classes[g];return this.inputParams.push({key:e,order:V,params:[t,{target:a,predictions:v,retrain:o,lookback:S,trainingCols:m,findGroups:A,type:g,modelArgs:N,precompute:q,filterCallback:x,modelConfig:G,modelClass:H}]}),this}},{key:"pca",value:function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="pca";p(r,{min:1,max:this.len},"trainingSize",n),h(t,"suffix",n),c(e,"options",n);var o=e.findGroups,i=void 0===o?[]:o,a=e.trainingCols,l=void 0===a?[]:a,y=e.lookback,v=void 0===y?0:y,d=e.filterCallback,m=void 0===d?function(){return!0}:d;u(l,"options.trainigCols",n),p(v,{min:0,max:this.len,allowDecimals:!1},"options.lookback",n),void 0!==e.modelArgs?c(e.modelArgs,"options.modelArgs",n):e.modelArgs={};var b=function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?wn(Object(e),!0).forEach((function(r){On(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):wn(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}({showSource:!1,storeModel:!1,isCovarianceMatrix:!1,method:"NIPALS",center:!0,scale:!1,nCompNIPALS:5,ignoreZeroVariance:!1},e.modelArgs);f(b.showSource,"options.modelArgs.showSource",n),f(b.storeModel,"options.modelArgs.storeModel",n),f(b.isCovarianceMatrix,"options.modelArgs.isCovarianceMatrix",n),f(b.center,"options.modelArgs.center",n),f(b.scale,"options.modelArgs.scale",n),f(b.ignoreZeroVariance,"options.modelArgs.ignoreZeroVariance",n),s(["SVD","NIPALS","covarianceMatrix"],b.method,"options.modelArgs.method",n),p(b.nCompNIPALS,{min:1},"options.modelArgs.nCompNIPALS",n);var g=[];if(u(i,"options.findGroups","pca")&&i.length>0){var w,S=An(i);try{for(S.s();!(w=S.n()).done;){var O=w.value,A=O.type,j=void 0===A?"":A,N=O.size,P=O.groupName,x=void 0===P?"":P;if(!j||!N&&!x||N&&x)throw new Error('If "options.findGroups" array is set, each item must be an object that includes the "type" (mandatory) and either "size" or "groupName" (choose 1) used to locate previously scaled (minmax or zscore) groups.');g.push(j.toString(),x.toString())}}catch(t){S.e(t)}finally{S.f()}}var _=sn(g,n),k="pca_".concat(t,"_").concat(r);if(this.isAlreadyComputed.has(k))throw new Error('Each regressor must have a unique "suffix" param.\nThis rule ensures that your output columns are labeled unambiguously.\n'+'You provided a duplicate: type="'.concat(t,'".'));var E=Math.abs(v)+1;return this.isAlreadyComputed.add(k),this.inputParams.push({key:n,order:_,params:[{prefix:k,trainingSize:r,findGroups:i,trainingCols:l,lookbackAbs:E,modelArgs:b,filterCallback:m}]}),this}},{key:"exportTrainedModels",value:function(){return function(t){var r,e,n,o=t.ML,i=t.inputParams,a=o.models,l={},u=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=vn(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(i);try{for(u.s();!(r=u.n()).done;){var c=r.value,s=c.key,f=c.params;if("classifier"===s||"regressor"===s){var p=(n=2,function(t){if(Array.isArray(t))return t}(e=f)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(e,n)||vn(e,n)||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.")}()),y=(p[0],p[1]),h=y.type,v=y.predictions,d=y.precompute,m=d.flatY,b=d.prefix,g=m?v:1,w=void 0;"regressor"===s?w=gn[h].exportModel:"classifier"===s&&(w=bn[h].exportModel);for(var S=0;S<g;S++){var O="".concat(b,"_").concat(S+1);l[O]=w(a[O])}}}}catch(t){u.e(t)}finally{u.f()}return l}(this)}},{key:"mapCols",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["change"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};l(this);var n="mapCols";null==r&&(r=ke),c(e,"options",n);var o=e.lag,i=void 0===o?0:o;u(t,"newCols",n),p(i,{min:0,allowDecimals:!1},"options.lag",n);var a=sn(t,n);return this.inputParams.push({key:n,order:a,params:[t,r,{lag:i}]}),this}}],r&&_n(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}()})(),OHLCV_INDICATORS=r})();
1
+ var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(r,e)=>{for(var n in e)t.o(e,n)&&!t.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},r={};(()=>{t.r(r),t.d(r,{default:()=>Bn});var e=function(t,r,e){if(0===e.length)return!1;for(var n=t.verticalOhlcv,o=!0,i=0;i<e.length;i++){var a=e[i];if(!n.hasOwnProperty(a)){o=!1;break}var l=n[a][r];if(null==l||Number.isNaN(l)){o=!1;break}}return o};function n(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=o(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,l=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return l=t.done,t},e:function(t){u=!0,a=t},f:function(){try{l||null==e.return||e.return()}finally{if(u)throw a}}}}function o(t,r){if(t){if("string"==typeof t)return i(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?i(t,r):void 0}}function i(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var a=function(t,r){if(!Array.isArray(t))throw new Error('Property "inputParams" must be an "Array" or "Set".');var e,o=n(t);try{for(o.s();!(e=o.n()).done;){var i,a=n(e.value.params);try{for(a.s();!(i=a.n()).done;){var l=i.value;if("number"==typeof l&&l>r)throw console.log(l,r),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){a.e(t)}finally{a.f()}}}catch(t){o.e(t)}finally{o.f()}},l=function(t){if(!0===t.isComputed)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" or "getData" methods are called.')},u=function(t,r,e){if(!Array.isArray(t))throw new Error('Param "'.concat(r,'" must be an array in "').concat(e,'".'));return!0},c=function(t,r,e){if(t instanceof Object==0)throw new Error('Param "'.concat(r,'" must be an object in "').concat(e,'".'));return!0},s=function(t,r,e,n){if(u(t,"arrayOptions","".concat(n,".").concat(e,".validateArrayOptions")),!t.includes(r.toString()))throw new Error('Param "'.concat(e,'" must be any of the following values [').concat(t.join(", "),'] in "').concat(n,'".'));return!0},f=function(t,r,e){if("boolean"!=typeof t)throw new Error('Param "'.concat(r,'" must be an boolean in "').concat(e,'".'));return!0},p=function(t,r,e,n){c(r,"options","".concat(n,".").concat(e,".validateNumber"));var o=r.allowDecimals,i=void 0!==o&&o,a=r.min,l=r.max,u=i?"number":"integer";if("number"!=typeof t||!1===i&&!Number.isInteger(t))throw new Error('Param "'.concat(e,'" must be an ').concat(u,' in "').concat(n,'".'));if(void 0!==a&&"number"!=typeof a)throw new Error('Param "min" must be a valid '.concat(u,' (if provided) in "').concat(n,".").concat(e,'.validateNumber".'));if(void 0!==l&&"number"!=typeof l)throw new Error('Param "max" must be a valid '.concat(u,' (if provided) in "').concat(n,".").concat(e,'.validateNumber".'));if(void 0!==a&&void 0!==l&&a>=l)throw new Error('Param "min" must be less than "max" in "'.concat(n,".").concat(e,'.validateNumber".'));if(void 0!==a&&t<a)throw new Error('Param "'.concat(e,'" must be an ').concat(u," ≥ ").concat(a,' in "').concat(n,'".'));if(void 0!==l&&t>l)throw new Error('Param "'.concat(e,'" must be an ').concat(u," ≤ ").concat(l,' in "').concat(n,'".'));return!0},y=function(t,r,e){if(u(t,r,e),2!==t.length)throw new Error('Invalid "'.concat(r,'" array length: expected 2 items, but got ').concat(t.length,' in "').concat(e,".").concat(r,'".'));var n,i,a=(i=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(n,i)||o(n,i)||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=a[0],c=a[1];if(p(l,{min:-100,max:c,allowDecimals:!1},"min",e),p(c,{min:l,max:100,allowDecimals:!1},"max",e),l===c)throw new Error('Invalid "min" can not be equal to "max" property in "'.concat(e,".").concat(r,'".'));return!0},h=function(t,r,e){if("string"!=typeof t||!t.length)throw new Error('Invalid "'.concat(r,'" property in "').concat(e,'". Only strings are accepted.'));return!0},v=1e6,d="[big.js] ",m=d+"Invalid ",b=m+"decimal places",g=m+"rounding mode",w=d+"Division by zero",S={},O=void 0,A=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function j(t,r,e,n){var o=t.c;if(e===O&&(e=t.constructor.RM),0!==e&&1!==e&&2!==e&&3!==e)throw Error(g);if(r<1)n=3===e&&(n||!!o[0])||0===r&&(1===e&&o[0]>=5||2===e&&(o[0]>5||5===o[0]&&(n||o[1]!==O))),o.length=1,n?(t.e=t.e-r+1,o[0]=1):o[0]=t.e=0;else if(r<o.length){if(n=1===e&&o[r]>=5||2===e&&(o[r]>5||5===o[r]&&(n||o[r+1]!==O||1&o[r-1]))||3===e&&(n||!!o[0]),o.length=r,n)for(;++o[--r]>9;)if(o[r]=0,0===r){++t.e,o.unshift(1);break}for(r=o.length;!o[--r];)o.pop()}return t}function N(t,r,e){var n=t.e,o=t.c.join(""),i=o.length;if(r)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&&e?"-"+o:o}function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function x(t){var r="function"==typeof Map?new Map:void 0;return x=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(r){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!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return function(t,r,e){if(_())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,r);var o=new(t.bind.apply(t,n));return e&&k(o,e.prototype),o}(t,arguments,E(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),k(e,t)},x(t)}function _(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_=function(){return!!t})()}function k(t,r){return k=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},k(t,r)}function E(t){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},E(t)}S.abs=function(){var t=new this.constructor(this);return t.s=1,t},S.cmp=function(t){var r,e=this,n=e.c,o=(t=new e.constructor(t)).c,i=e.s,a=t.s,l=e.e,u=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(r=i<0,l!=u)return l>u^r?1:-1;for(a=(l=n.length)<(u=o.length)?l:u,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^r?1:-1;return l==u?0:l>u^r?1:-1},S.div=function(t){var r=this,e=r.constructor,n=r.c,o=(t=new e(t)).c,i=r.s==t.s?1:-1,a=e.DP;if(a!==~~a||a<0||a>v)throw Error(b);if(!o[0])throw Error(w);if(!n[0])return t.s=i,t.c=[t.e=0],t;var l,u,c,s,f,p=o.slice(),y=l=o.length,h=n.length,d=n.slice(0,l),m=d.length,g=t,S=g.c=[],A=0,N=a+(g.e=r.e-t.e)+1;for(g.s=i,i=N<0?0:N,p.unshift(0);m++<l;)d.push(0);do{for(c=0;c<10;c++){if(l!=(m=d.length))s=l>m?1:-1;else for(f=-1,s=0;++f<l;)if(o[f]!=d[f]){s=o[f]>d[f]?1:-1;break}if(!(s<0))break;for(u=m==l?o:p;m;){if(d[--m]<u[m]){for(f=m;f&&!d[--f];)d[f]=9;--d[f],d[m]+=10}d[m]-=u[m]}for(;!d[0];)d.shift()}S[A++]=s?c:++c,d[0]&&s?d[m]=n[y]||0:d=[n[y]]}while((y++<h||d[0]!==O)&&i--);return S[0]||1==A||(S.shift(),g.e--,N--),A>N&&j(g,N,e.RM,d[0]!==O),g},S.eq=function(t){return 0===this.cmp(t)},S.gt=function(t){return this.cmp(t)>0},S.gte=function(t){return this.cmp(t)>-1},S.lt=function(t){return this.cmp(t)<0},S.lte=function(t){return this.cmp(t)<1},S.minus=S.sub=function(t){var r,e,n,o,i=this,a=i.constructor,l=i.s,u=(t=new a(t)).s;if(l!=u)return t.s=-u,i.plus(t);var c=i.c.slice(),s=i.e,f=t.c,p=t.e;if(!c[0]||!f[0])return f[0]?t.s=-u:c[0]?t=new a(i):t.s=1,t;if(l=s-p){for((o=l<0)?(l=-l,n=c):(p=s,n=f),n.reverse(),u=l;u--;)n.push(0);n.reverse()}else for(e=((o=c.length<f.length)?c:f).length,l=u=0;u<e;u++)if(c[u]!=f[u]){o=c[u]<f[u];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(u=(e=f.length)-(r=c.length))>0)for(;u--;)c[r++]=0;for(u=r;e>l;){if(c[--e]<f[e]){for(r=e;r&&!c[--r];)c[r]=9;--c[r],c[e]+=10}c[e]-=f[e]}for(;0===c[--u];)c.pop();for(;0===c[0];)c.shift(),--p;return c[0]||(t.s=1,c=[p=0]),t.c=c,t.e=p,t},S.mod=function(t){var r,e=this,n=e.constructor,o=e.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(w);return e.s=t.s=1,r=1==t.cmp(e),e.s=o,t.s=i,r?new n(e):(o=n.DP,i=n.RM,n.DP=n.RM=0,e=e.div(t),n.DP=o,n.RM=i,this.minus(e.times(t)))},S.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},S.plus=S.add=function(t){var r,e,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var a=o.e,l=o.c,u=t.e,c=t.c;if(!l[0]||!c[0])return c[0]||(l[0]?t=new i(o):t.s=o.s),t;if(l=l.slice(),r=a-u){for(r>0?(u=a,n=c):(r=-r,n=l),n.reverse();r--;)n.push(0);n.reverse()}for(l.length-c.length<0&&(n=c,c=l,l=n),r=c.length,e=0;r;l[r]%=10)e=(l[--r]=l[r]+c[r]+e)/10|0;for(e&&(l.unshift(e),++u),r=l.length;0===l[--r];)l.pop();return t.c=l,t.e=u,t},S.pow=function(t){var r=this,e=new r.constructor("1"),n=e,o=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(m+"exponent");for(o&&(t=-t);1&t&&(n=n.times(r)),t>>=1;)r=r.times(r);return o?e.div(n):n},S.prec=function(t,r){if(t!==~~t||t<1||t>v)throw Error(m+"precision");return j(new this.constructor(this),t,r)},S.round=function(t,r){if(t===O)t=0;else if(t!==~~t||t<-v||t>v)throw Error(b);return j(new this.constructor(this),t+this.e+1,r)},S.sqrt=function(){var t,r,e,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(d+"No square root");0===(i=Math.sqrt(n+""))||i===1/0?((r=n.c.join("")).length+a&1||(r+="0"),a=((a+1)/2|0)-(a<0||1&a),t=new o(((i=Math.sqrt(r))==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):t=new o(i+""),a=t.e+(o.DP+=4);do{e=t,t=l.times(e.plus(n.div(e)))}while(e.c.slice(0,a).join("")!==t.c.slice(0,a).join(""));return j(t,(o.DP-=4)+t.e+1,o.RM)},S.times=S.mul=function(t){var r,e=this,n=e.constructor,o=e.c,i=(t=new n(t)).c,a=o.length,l=i.length,u=e.e,c=t.e;if(t.s=e.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=u+c,a<l&&(r=o,o=i,i=r,c=a,a=l,l=c),r=new Array(c=a+l);c--;)r[c]=0;for(u=l;u--;){for(l=0,c=a+u;c>u;)l=r[c]+i[u]*o[c-u-1]+l,r[c--]=l%10,l=l/10|0;r[c]=l}for(l?++t.e:r.shift(),u=r.length;!r[--u];)r.pop();return t.c=r,t},S.toExponential=function(t,r){var e=this,n=e.c[0];if(t!==O){if(t!==~~t||t<0||t>v)throw Error(b);for(e=j(new e.constructor(e),++t,r);e.c.length<t;)e.c.push(0)}return N(e,!0,!!n)},S.toFixed=function(t,r){var e=this,n=e.c[0];if(t!==O){if(t!==~~t||t<0||t>v)throw Error(b);for(t=t+(e=j(new e.constructor(e),t+e.e+1,r)).e+1;e.c.length<t;)e.c.push(0)}return N(e,!1,!!n)},S[Symbol.for("nodejs.util.inspect.custom")]=S.toJSON=S.toString=function(){var t=this,r=t.constructor;return N(t,t.e<=r.NE||t.e>=r.PE,!!t.c[0])},S.toNumber=function(){var t=Number(N(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(d+"Imprecise conversion");return t},S.toPrecision=function(t,r){var e=this,n=e.constructor,o=e.c[0];if(t!==O){if(t!==~~t||t<1||t>v)throw Error(m+"precision");for(e=j(new n(e),t,r);e.c.length<t;)e.c.push(0)}return N(e,t<=e.e||e.e<=n.NE||e.e>=n.PE,!!o)},S.valueOf=function(){var t=this,r=t.constructor;if(!0===r.strict)throw Error(d+"valueOf disallowed");return N(t,t.e<=r.NE||t.e>=r.PE,!0)},function t(){function r(e){var n=this;if(!(n instanceof r))return e===O?t():new r(e);if(e instanceof r)n.s=e.s,n.e=e.e,n.c=e.c.slice();else{if("string"!=typeof e){if(!0===r.strict&&"bigint"!=typeof e)throw TypeError(m+"value");e=0===e&&1/e<0?"-0":String(e)}!function(t,r){var e,n,o;if(!A.test(r))throw Error(m+"number");for(t.s="-"==r.charAt(0)?(r=r.slice(1),-1):1,(e=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(e<0&&(e=n),e+=+r.slice(n+1),r=r.substring(0,n)):e<0&&(e=r.length),o=r.length,n=0;n<o&&"0"==r.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==r.charAt(--o););for(t.e=e-n-1,t.c=[],e=0;n<=o;)t.c[e++]=+r.charAt(n++)}}(n,e)}n.constructor=r}return r.prototype=S,r.DP=20,r.RM=1,r.NE=-7,r.PE=21,r.strict=!1,r.roundDown=0,r.roundHalfUp=1,r.roundHalfEven=2,r.roundUp=3,r}();var T=function(t){function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),t=function(t,r,e){return r=E(r),function(t,r){if(r&&("object"==P(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_()?Reflect.construct(r,e||[],E(t).constructor):r.apply(t,e))}(this,r,[e]),Object.setPrototypeOf(t,(this instanceof r?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&k(t,r)}(r,t),e=r,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}(x(Error));function C(t){return C="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},C(t)}function M(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,D(n.key),n)}}function I(t,r,e){return(r=D(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function D(t){var r=function(t,r){if("object"!=C(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=C(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==C(r)?r:r+""}var R=function(){return t=function t(){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),I(this,"previousHighest",void 0),I(this,"highest",void 0),I(this,"previousLowest",void 0),I(this,"lowest",void 0),I(this,"previousResult",void 0),I(this,"result",void 0)},(r=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new T;return this.result}},{key:"setResult",value:function(t,r){return r&&(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)}}])&&M(t.prototype,r),e&&M(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function L(t){return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},L(t)}function F(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,V(n.key),n)}}function B(t,r,e){return r=U(r),function(t,r){if(r&&("object"==L(r)||"function"==typeof r))return r;if(void 0!==r)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,z()?Reflect.construct(r,e||[],U(t).constructor):r.apply(t,e))}function z(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(z=function(){return!!t})()}function U(t){return U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},U(t)}function Y(t,r){return Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Y(t,r)}function V(t){var r=function(t,r){if("object"!=L(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=L(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==L(r)?r:r+""}var q=function(t){function r(t){var e,n,o,i;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),n=e=B(this,r),i=void 0,(o=V(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,e.interval=t,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Y(t,r)}(r,t),e=r,(n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&F(e.prototype,n),o&&F(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function G(t){return G="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},G(t)}function H(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,W(n.key),n)}}function $(t,r,e){return r=K(r),function(t,r){if(r&&("object"==G(r)||"function"==typeof r))return r;if(void 0!==r)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(r,e||[],K(t).constructor):r.apply(t,e))}function X(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(X=function(){return!!t})()}function K(t){return K=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},K(t)}function J(t,r){return J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},J(t,r)}function W(t){var r=function(t,r){if("object"!=G(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=G(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==G(r)?r:r+""}var Z=function(t){function r(){var t,e,n,o;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);for(var i=arguments.length,a=new Array(i),l=0;l<i;l++)a[l]=arguments[l];return e=t=$(this,r,[].concat(a)),o=[],(n=W(n="prices"))in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&J(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var e=this.prices.reduce((function(t,r){return t+r}),0);return this.setResult(e/this.prices.length,r)}}}],n&&H(e.prototype,n),o&&H(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(q);function Q(t){return Q="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},Q(t)}function tt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,at(n.key),n)}}function rt(t,r,e){return r=nt(r),function(t,r){if(r&&("object"==Q(r)||"function"==typeof r))return r;if(void 0!==r)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,et()?Reflect.construct(r,e||[],nt(t).constructor):r.apply(t,e))}function et(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(et=function(){return!!t})()}function nt(t){return nt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},nt(t)}function ot(t,r){return ot=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ot(t,r)}function it(t,r,e){return(r=at(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function at(t){var r=function(t,r){if("object"!=Q(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Q(r)?r:r+""}var lt=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),it(e=rt(this,r),"interval",void 0),it(e,"indicator",void 0),it(e,"smoothingFactor",void 0),e.interval=t,e.indicator=new Z(t),e.smoothingFactor=1/e.interval,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ot(t,r)}(r,t),e=r,n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.indicator.update(t);if(r&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,r)}if(!r&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,r)}if(void 0===this.result&&void 0!==e)return this.setResult(e,r)}}],n&&tt(e.prototype,n),o&&tt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function ut(t){return t.length?t.reduce((function(t,r){return t+r}),0)/t.length:0}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 st(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,dt(n.key),n)}}function ft(t,r,e){return r=yt(r),function(t,r){if(r&&("object"==ct(r)||"function"==typeof r))return r;if(void 0!==r)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,pt()?Reflect.construct(r,e||[],yt(t).constructor):r.apply(t,e))}function pt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(pt=function(){return!!t})()}function yt(t){return yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},yt(t)}function ht(t,r){return ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ht(t,r)}function vt(t,r,e){return(r=dt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function dt(t){var r=function(t,r){if("object"!=ct(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var mt=function(t){function r(){var t;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return vt(t=ft(this,r,[].concat(n)),"previousCandle",void 0),vt(t,"twoPreviousCandle",void 0),t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ht(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=t.high,n=t.low,o=e-n;if(this.previousCandle&&r&&(this.previousCandle=this.twoPreviousCandle),this.previousCandle){var i=Math.abs(e-this.previousCandle.close),a=Math.abs(n-this.previousCandle.close);return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(Math.max(o,i,a),r)}return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(o,r)}}],n&&st(e.prototype,n),o&&st(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function gt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Nt(n.key),n)}}function wt(t,r,e){return r=Ot(r),function(t,r){if(r&&("object"==bt(r)||"function"==typeof r))return r;if(void 0!==r)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(r,e||[],Ot(t).constructor):r.apply(t,e))}function St(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(St=function(){return!!t})()}function Ot(t){return Ot=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ot(t)}function At(t,r){return At=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},At(t,r)}function jt(t,r,e){return(r=Nt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Nt(t){var r=function(t,r){if("object"!=bt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var Pt=function(t){function r(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lt;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),jt(e=wt(this,r),"interval",void 0),jt(e,"tr",void 0),jt(e,"smoothing",void 0),e.interval=t,e.tr=new mt,e.smoothing=new n(t),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&At(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.tr.update(t,r);if(this.smoothing.update(e,r),this.smoothing.isStable)return this.setResult(this.smoothing.getResult(),r)}}],n&&gt(e.prototype,n),o&&gt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function xt(t){return xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xt(t)}function _t(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Et(n.key),n)}}function kt(t,r,e){return(r=Et(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Et(t){var r=function(t,r){if("object"!=xt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=xt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xt(r)?r:r+""}var Tt=function(){return t=function t(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),kt(this,"interval",void 0),kt(this,"deviationMultiplier",void 0),kt(this,"prices",[]),kt(this,"result",void 0),this.interval=r,this.deviationMultiplier=e},(r=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var r=ut(this.prices),e=function(t,r){var e=r||ut(t),n=ut(t.map((function(t){return t-e})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,r);return this.result={lower:r-e*this.deviationMultiplier,middle:r,upper:r+e*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new T;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&_t(t.prototype,r),e&&_t(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();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 Mt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Bt(n.key),n)}}function It(t,r,e){return r=Rt(r),function(t,r){if(r&&("object"==Ct(r)||"function"==typeof r))return r;if(void 0!==r)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,Dt()?Reflect.construct(r,e||[],Rt(t).constructor):r.apply(t,e))}function Dt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Dt=function(){return!!t})()}function Rt(t){return Rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Rt(t)}function Lt(t,r){return Lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Lt(t,r)}function Ft(t,r,e){return(r=Bt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Bt(t){var r=function(t,r){if("object"!=Ct(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var zt=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),Ft(e=It(this,r,[t]),"interval",void 0),Ft(e,"pricesCounter",0),Ft(e,"weightFactor",void 0),e.interval=t,e.weightFactor=2/(e.interval+1),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Lt(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return r?r&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,r&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),r):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),r)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new T;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&Mt(e.prototype,n),o&&Mt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(q);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 Yt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qt(n.key),n)}}function Vt(t,r,e){return(r=qt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function qt(t){var r=function(t,r){if("object"!=Ut(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var Gt=function(){return t=function t(r,e,n){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),Vt(this,"short",void 0),Vt(this,"long",void 0),Vt(this,"signal",void 0),Vt(this,"prices",[]),Vt(this,"result",void 0),this.short=r,this.long=e,this.signal=n},r=[{key:"getResult",value:function(){if(void 0===this.result)throw new T;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t);var e=this.short.update(t,r),n=this.long.update(t,r);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=e-n,i=this.signal.update(o,r);return this.result={histogram:o-i,macd:o,signal:i}}}}],r&&Yt(t.prototype,r),e&&Yt(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function Ht(t){return Ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ht(t)}function $t(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Qt(n.key),n)}}function Xt(t,r,e){return r=Jt(r),function(t,r){if(r&&("object"==Ht(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Kt()?Reflect.construct(r,e||[],Jt(t).constructor):r.apply(t,e))}function Kt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Kt=function(){return!!t})()}function Jt(t){return Jt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Jt(t)}function Wt(t,r){return Wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Wt(t,r)}function Zt(t,r,e){return(r=Qt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Qt(t){var r=function(t,r){if("object"!=Ht(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ht(r)?r:r+""}var tr=function(t){function r(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lt;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),Zt(e=Xt(this,r),"interval",void 0),Zt(e,"previousPrices",[]),Zt(e,"avgGain",void 0),Zt(e,"avgLoss",void 0),Zt(e,"maxValue",100),e.interval=t,e.avgGain=new n(e.interval),e.avgLoss=new n(e.interval),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&Wt(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&r?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var e=t,n=this.previousPrices[this.previousPrices.length-2];if(e>n?(this.avgLoss.update(0,r),this.avgGain.update(t-n,r)):(this.avgLoss.update(n-e,r),this.avgGain.update(0,r)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,r);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),r)}}}}],n&&$t(e.prototype,n),o&&$t(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(R);function rr(t){return rr="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},rr(t)}function er(t){return function(t){if(Array.isArray(t))return nr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return nr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?nr(t,r):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 nr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function or(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ar(n.key),n)}}function ir(t,r,e){return(r=ar(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function ar(t){var r=function(t,r){if("object"!=rr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=rr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rr(r)?r:r+""}var lr=function(){return t=function t(r,e,n){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),ir(this,"n",void 0),ir(this,"m",void 0),ir(this,"p",void 0),ir(this,"candles",[]),ir(this,"result",void 0),ir(this,"periodM",void 0),ir(this,"periodP",void 0),this.n=r,this.m=e,this.p=n,this.periodM=new Z(e),this.periodP=new Z(n)},(r=[{key:"getResult",value:function(){if(void 0===this.result)throw new T;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){if(this.candles.push(t),this.candles.length>this.n&&this.candles.shift(),this.candles.length===this.n){var r=Math.max.apply(Math,er(this.candles.map((function(t){return t.high})))),e=Math.min.apply(Math,er(this.candles.map((function(t){return t.low})))),n=r-e,o=100*(t.close-e);o/=0===n?1:n;var i=this.periodM.update(o),a=i&&this.periodP.update(i);if(void 0!==i&&void 0!==a)return this.result={stochD:a,stochK:i}}}}])&&or(t.prototype,r),e&&or(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function ur(t){return ur="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},ur(t)}function cr(t){return function(t){if(Array.isArray(t))return sr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return sr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?sr(t,r):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 sr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function fr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=ur(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ur(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ur(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function pr(t){return pr="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},pr(t)}function yr(t){return function(t){if(Array.isArray(t))return hr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return hr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?hr(t,r):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 hr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function vr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=pr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=pr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var dr={ema:zt,sma:Z},mr=function(t,r,e,n,o){var i=o.target,a=o.lag,l=t.verticalOhlcv,u=t.instances,c=t.priceBased,s="close"!==i?"_".concat(i):"",f="".concat(e,"_").concat(n).concat(s);if(0===r){var p=t.len;if(!l.hasOwnProperty(i))throw new Error("Target property ".concat(i," not found in verticalOhlcv for ").concat(e,"."));u[f]=new dr[e](n),l[f]=new Float64Array(p).fill(NaN),c.has(i)&&c.add(f),a>0&&t.lag([f],a)}var y=l[i][r],h=u[f];h.update(y);var v=NaN;try{v=h.getResult()}catch(t){}return t.pushToMain({index:r,key:f,value:v}),!0};function br(t){return br="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},br(t)}function gr(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function wr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=br(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=br(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==br(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Sr(t,r){if(t){if("string"==typeof t)return Or(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Or(t,r):void 0}}function Or(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Ar(t){return function(t){if(Array.isArray(t))return jr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){if(t){if("string"==typeof t)return jr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?jr(t,r):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 jr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Nr(t){return Nr="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},Nr(t)}function Pr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Nr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Nr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Nr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function xr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var _r="close";function kr(t){return function(t){if(Array.isArray(t))return Cr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Tr(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 Er(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Tr(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function Tr(t,r){if(t){if("string"==typeof t)return Cr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Cr(t,r):void 0}}function Cr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Mr(t){return Mr="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},Mr(t)}function Ir(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function Dr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Mr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Mr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Mr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Rr(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Lr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Lr(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function Lr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Fr="close";function Br(t){return Br="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},Br(t)}function zr(t){return zr="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},zr(t)}function Ur(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||function(t,r){if(t){if("string"==typeof t)return Yr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Yr(t,r):void 0}}(t,r)||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 Yr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Vr=function(t,r){if("string"!=typeof t)throw new Error("addPrecisionExact expects a string when precision=true");var e="-"===t.charAt(0),n=Ur((e?t.slice(1):t).split("."),2),o=n[0],i=n[1],a=void 0===i?"":i,l=String(r),u=1===r?0:l.length-1,c=a.padEnd(u,"0").slice(0,u),s=parseInt(o+c||"0",10);return e&&(s=-s),s};function qr(t){return qr="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},qr(t)}var Gr={number:function(t){return t},numberCleanString:function(t){return Number(t)},precisionNumberCleanString:function(t,r){return Vr(t,r)}},Hr=function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n="number"==typeof t&&!Number.isNaN(t),o="string"==typeof t&&/^-?\d+(\.\d+)?$/.test(t);if(!0===e){if(o)return"precisionNumberCleanString";if(r)throw new Error("Invalid number forma");return qr(t)}if(n)return"number";if(o)return"numberCleanString";if(r)throw new TypeError("Invalid input: expected a number or numeric string");return qr(t)};function $r(t){return $r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$r(t)}var Xr={string:function(t){return t.toISOString()},milliseconds:function(t){return t.getTime()},seconds:function(t){return t.getTime()/1e3},object:function(t){return t}},Kr={dateObject:function(t){return t},dateMilliseconds:function(t){return new Date(t)},dateSeconds:function(t){return new Date(1e3*t)},dateIncompleteDayString:function(t){return new Date("".concat(t," 00:00:00"))},dateCompleteDateString:function(t){return new Date(t)}},Jr=function(t){var r=["Date -> object","Milliseconds Timestamp -> integer","Seconds Timestamp -> integer","UTC Time Format (ISO 8601) -> string","Including a Timezone Offset (ISO 8601) -> string","Local Time Format (ISO 8601) -> string","YYYY/MM/DD or YYYY-MM-DD -> string"],e=function(){throw new Error('Invalid "'.concat($r(t),'" date value passed in selectDateFormatter. Supported formats: \n-').concat(r.join("\n- ")))};if("object"===$r(t)){if(t instanceof Date&&!isNaN(t.valueOf()))return"dateObject";e()}else{if("number"==typeof t)return Math.abs(t)<1e11?"dateSeconds":"dateMillseconds";if("string"==typeof t){if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/i.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?([+-]\d{2}:\d{2})$/.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(t)&&t.length>10||/^\d{4}\/\d{2}\/\d{2}$/.test(t))return"dateCompleteDateString";if(/^\d{4}-\d{2}-\d{2}$/.test(t))return"dateIncompleteDayString";e()}else e()}};function Wr(t){return Wr="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},Wr(t)}function Zr(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||function(t,r){if(t){if("string"==typeof t)return Qr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Qr(t,r):void 0}}(t,r)||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 Qr(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var te=function(t,r,e){var n,o={Array,Float64Array,Float32Array,Int32Array,Uint8Array,Int8Array,Int16Array}[t];if(!o||"function"!=typeof o.from)throw new Error("Unsupported array type: ".concat(t));return n=void 0!==e?e:"Array"===t?null:NaN,o.from({length:r},(function(){return n}))},re=function(t,r){if(!r||"object"!==Wr(r))throw new TypeError('Invalid array type: "'.concat(t,'"'));return r.constructor.name};function ee(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return ne(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?ne(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function ne(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function oe(t){return function(t){if(Array.isArray(t))return ae(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ie(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 ie(t,r){if(t){if("string"==typeof t)return ae(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?ae(t,r):void 0}}function ae(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var le=function(t,r){var e=new Uint8Array(r);return e[t]=1,e},ue=function(t){var r=t.featureCols,e=t.flatFeaturesColLen,n=t.type,o=t.trainingSize,i=r.length!==e?" (including flat one-hot encoded array values) ":"";console.log('---\nInitialized "'.concat(n,'" with ').concat(e," features ").concat(i," and ").concat(o," rows: \n").concat(JSON.stringify(r),"\n\n"))},ce=function(t,r,e,n){var o,i,a=(i=2,function(t){if(Array.isArray(t))return t}(o=n)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(o,i)||ie(o,i)||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=a[0],u=a[1];return(Math.min(Math.max(t,r),e)-r)/(e-r)*(u-l)+l},se=function(t,r){var e=[];if(t.length>0)for(var n=0;n<t.length;n++){var o=t[n],i=o.type,a=o.size,l=void 0===a?null:a,u=o.groupName,c=void 0===u?null:u,s=null!==l?"".concat(i,"_").concat(l):"".concat(i,"_").concat(c);if(!r.hasOwnProperty(s))throw new Error("Scaled group (".concat(s,") not found for regressor.options.findGroups[").concat(n,"]: ").concat(JSON.stringify(o)));e.push.apply(e,oe(r[s]))}return e},fe=function(t,r,e){var n,o=0,i=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ie(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(t);try{for(i.s();!(n=i.n()).done;){var a=n.value;if(!r.hasOwnProperty(a))throw new Error('Property "'.concat(a,'" not found in "verticalOhlcv".'));var l=r[a][e];if(null==l||Number.isNaN(l))throw new Error('Invalid value of property "'.concat(a,'".'));a.startsWith("one_hot_")||a.startsWith("pca_")?o+=r[a][e].length:o+=1}}catch(t){i.e(t)}finally{i.f()}return o},pe=function(t){var r=t.trainingCols,e=t.findGroups,n=t.verticalOhlcv,o=t.scaledGroups,i=[].concat(oe(r),oe(se(e,o)));if(0===i.length)return[];for(var a=!1,l=0;l<i.length;l++){var u=i[l];if(!n.hasOwnProperty(u)){a=!0;break}}return a?[]:i},ye=function(t){var r=t.metrics,e=t.trueLabel,n=t.predictedLabel;r.total=(r.total||0)+1,r.correct=r.correct||0,r.labels=r.labels||{};var o=n.toString();for(var i in r.labels[o]||(r.labels[o]={total:0,correct:0,accuracy:0}),r.labels[o].total++,n===e&&(r.correct++,r.labels[o].correct++),r.accuracy=r.correct/r.total,r.labels){var a=r.labels[i];a.accuracy=a.correct/a.total}};function he(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function ve(t){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ve(t)}function de(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,me(n.key),n)}}function me(t){var r=function(t,r){if("object"!=ve(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ve(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ve(r)?r:r+""}var be=function(t,r){return t>r},ge=function(t,r){return t<r},we=function(){return t=function t(){!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,{interval:0,prevState:.5,prevFast:NaN,prevSlow:NaN,prevHigh:NaN,prevLow:NaN,areHighAndLowUndefined:!1,crossIndexes:{up:[],down:[]}})},(r=[{key:"update",value:function(t,r){var e=r.fast,n=r.high,o=r.slow,i=r.low,a=this.prevState;this.areHighAndLowUndefined||void 0!==n&&void 0!==i||(this.areHighAndLowUndefined=!0),Number.isNaN(e)||Number.isNaN(o)||function(t,r){return t===r}(e,o)?a=.5:be(e,o)?a=this.areHighAndLowUndefined?1:[i,o,this.prevLow,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&ge(i,o)&&be(this.prevLow,this.prevSlow)?0:1:ge(e,o)&&(a=this.areHighAndLowUndefined?0:[n,o,this.prevHigh,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&be(n,o)&&ge(this.prevHigh,this.prevSlow)?1:0),.5===a?this.interval=0:1===a?this.prevState<=.5?this.interval=1:this.interval++:0===a&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(t),-1===this.interval&&this.crossIndexes.down.push(t),Object.assign(this,{prevState:a,prevFast:e,prevSlow:o,prevHigh:n,prevLow:i})}},{key:"getResult",value:function(){return this.interval}}])&&de(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}();function Se(t){return Se="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},Se(t)}function Oe(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||Pe(t,r)||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 Ae(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function je(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?Ae(Object(e),!0).forEach((function(r){Ne(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ae(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function Ne(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Se(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Se(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Se(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Pe(t,r){if(t){if("string"==typeof t)return xe(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?xe(t,r):void 0}}function xe(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function _e(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)||ke(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ke(t,r){if(t){if("string"==typeof t)return Ee(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ee(t,r):void 0}}function Ee(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Te(t,r){if(t){if("string"==typeof t)return Ce(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ce(t,r):void 0}}function Ce(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Me=function(t){var r=t.main,e=t.index,n=r.verticalOhlcv,o=n.close[e],i=n.open[e-1];return{change:(o-i)/i*100}};function Ie(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var De=function(t){var r,e=t.featureCols,n=t.flatFeaturesColLen,o=t.type,i=t.index,a=t.lookbackAbs,l=t.main.verticalOhlcv,u=!1,c=[],s=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Ie(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ie(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(e);try{for(s.s();!(r=s.n()).done;){var f=r.value;if(f.startsWith("one_hot_")||f.startsWith("pca_"))for(var p=l[f][i].length,y=0;y<p;y++)c.push({key:f,bit:y});else c.push({key:f})}}catch(t){s.e(t)}finally{s.f()}if(c.length!==n)throw new Error("slots (".concat(c.length,") ≠ flatFeaturesColLen (").concat(n,") in ").concat(o," index ").concat(i));for(var h=new Array(n*a).fill(NaN),v=0;v<a;v++){for(var d=i-v,m=0;m<c.length;m++){var b=c[m],g=b.key,w=b.bit,S=l[g][d],O=null!=w?S[w]:S;if(!Number.isFinite(O)){u=!0;break}h[v*n+m]=O}if(u)break}return u?null:h};function Re(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)||Le(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 Le(t,r){if(t){if("string"==typeof t)return Fe(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Fe(t,r):void 0}}function Fe(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Be="pca",ze=function(t,r,n){var o=n.prefix,i=n.trainingSize,a=n.findGroups,l=n.trainingCols,u=n.lookbackAbs,c=n.modelArgs,s=n.filterCallback,f=t.verticalOhlcv,p=t.scaledGroups,y=t.len,h=t.instances,v=t.ML,d=t.invalidValueIndex+2,m=v.models;if(r===d)h.hasOwnProperty(Be)||(h[Be]={}),h[Be][o]={flatFeaturesColLen:0,featureCols:[],X:[]},f[o]=new Array(y).fill(null);else{if(r<d||r<u)return;if(!1===s(f,r))return;if(r+1===y){if(0===h[Be][o].featureCols.length){var b=[].concat(Re(l),Re(se(a,p)));throw new Error("Some of the provided features in ".concat(o,' features where not found in "verticalOhlcv": ').concat(JSON.stringify(b)))}var g,w=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Le(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(h[Be][o].featureCols);try{for(w.s();!(g=w.n()).done;){var S=g.value;if(!f.hasOwnProperty(S))throw new Error('Feature "'.concat(S,'" not found in verticalOhlcv for pca.'))}}catch(t){w.e(t)}finally{w.f()}if(h[Be][o].X.length<i){var O=h[Be][o].X.length-i;throw new Error('The current "trainingSize" at "'.concat(o,'" requires at least ').concat(O,' more datapoints. Try adding more input ohlcv rows or reducing the "trainingSize" by ').concat(O,"."))}}}var A=h[Be][o];if(0===A.flatFeaturesColLen){if(A.featureCols=pe({trainingCols:l,findGroups:a,verticalOhlcv:f,scaledGroups:p}),!e(t,r,A.featureCols))return;A.flatFeaturesColLen=fe(A.featureCols,f,r)}if(0!==A.flatFeaturesColLen){var j=A.X,N=A.featureCols,P=A.flatFeaturesColLen,x=De({featureCols:N,flatFeaturesColLen:P,type:Be,index:r,lookbackAbs:u,main:t});if(null!=x){if(m.hasOwnProperty(o)){var _=m[o].predict([x]).to2DArray();f[o][r]=_[0]}j.push(x),j.length>i&&j.shift(),j.length===i&&(m[o]=new v.classes.PCA(j,c))}}};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)}function Ye(t){return function(t){if(Array.isArray(t))return qe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ve(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ve(t,r){if(t){if("string"==typeof t)return qe(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?qe(t,r):void 0}}function qe(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ge=function(t,r,n,o){var i=o.target,a=o.predictions,l=o.retrain,u=o.trainingCols,c=o.findGroups,s=o.type,f=o.modelArgs,p=o.precompute,y=o.filterCallback,h=o.modelConfig,v=o.modelClass,d=p.lookbackAbs,m=p.prefix,b=p.flatX,g=p.flatY,w=t.verticalOhlcv,S=t.len,O=t.instances,A=t.scaledGroups,j=t.invalidValueIndex,N=t.ML.models,P=j+1;if(r===P){O.hasOwnProperty("regressor")||(O.regressor={}),O.regressor.hasOwnProperty(m)||(O.regressor[m]={});var x=g?a:1;O.regressor[m]={expectedLoops:x,trainingSize:n,isTrained:new Array(x).fill(!1),shouldRetrain:l,featureCols:[],flatFeaturesColLen:0,X:[],Y:Array.from({length:x},(function(){return[]}))};for(var _=0;_<a;_++){var k="".concat(m,"_").concat(_+1);w[k]=new Float64Array(S).fill(NaN),N.hasOwnProperty(k)||(N[k]=[])}}else{if(r<P||r<d)return;if(!1===y(w,r))return;if(r+1===S){if(0===O.regressor[m].featureCols.length){var E=[].concat(Ye(u),Ye(se(c,A)));throw new Error("Some of the provided features in ".concat(m,' features where not found in "verticalOhlcv": ').concat(JSON.stringify(E)))}var T,C=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Ve(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(O.regressor[m].featureCols);try{for(C.s();!(T=C.n()).done;){var M=T.value;if(!w.hasOwnProperty(M))throw new Error('Feature "'.concat(M,'" not found in verticalOhlcv for ').concat(m,"."))}}catch(t){C.e(t)}finally{C.f()}if(O.regressor[m].X.length<n){var I=O.regressor[m].X.length-n;throw new Error('The current "trainingSize" at "'.concat(m,'" requires at least ').concat(I,' more datapoints. Try adding more input ohlcv rows or reducing the "trainingSize" by ').concat(I,"."))}}}var D=O.regressor[m];if(0===D.flatFeaturesColLen){if(D.featureCols=pe({trainingCols:u,findGroups:c,verticalOhlcv:w,scaledGroups:A}),!e(t,r,D.featureCols))return;D.flatFeaturesColLen=fe(D.featureCols,w,r),ue({featureCols:D.featureCols,flatFeaturesColLen:D.flatFeaturesColLen,type:s,trainingSize:n})}if(0!==D.flatFeaturesColLen){if(!w.hasOwnProperty(i))throw new Error('Target property "'.concat(i,'" not found in verticalOhlcv for regressor.'));var R=D.expectedLoops,L=D.X,F=D.Y,B=D.flatFeaturesColLen,z=D.featureCols,U=D.shouldRetrain;if(!z.includes(i))throw new Error('Target property "'.concat(i,'" not found in ').concat(s," features: ").concat(JSON.stringify(z)));var Y=b?w[i][r]:De({featureCols:z,flatFeaturesColLen:B,type:s,index:r,lookbackAbs:d,main:t});if(b){if(!Number.isFinite(Y))return}else if(null==Y)return;for(var V=[],q=0;q<a;q++){var G=w[i][r+q+1];if(!Number.isFinite(G))break;V.push(G)}for(var H=h.train,$=h.unsupervised,X=0;X<R;X++){var K="".concat(m,"_").concat(X+1),J=F[X],W=g?void 0===V[X]?null:V[X]:V,Z=D.isTrained[X];if(N.hasOwnProperty(K)&&Z&&N[K].length===R){var Q=N[K][0],tt=$?Q.predict(a)[0]:Q.predict([Y])[0];if(g){if(Number.isNaN(tt))throw new Error("Prediction of ".concat(s," at index ").concat(r," was expecting a number."));t.pushToMain({index:r,key:K,value:tt})}else{if(!Array.isArray(tt)||tt.length!==a)throw new Error('Prediction output of "'.concat(s,'" at index ').concat(r," was expecting an array of values."));for(var rt=0;rt<a;rt++)t.pushToMain({index:r,key:"".concat(m,"_").concat(rt+1),value:tt[rt]})}}if(!(r+a+1>S||V.length<a||null===W)){if(g){if("number"!=typeof W||Number.isNaN(W))throw new Error("currTrainY must return number, got ".concat(Ue(W)," at index ").concat(r))}else{if(!Array.isArray(W))throw new Error("currTrainY must return an array, got ".concat(Ue(W)," at index ").concat(r));if(W.length!==a)throw new Error("currTrainY length (".concat(W.length,') ≠ "options.predictions" (').concat(a,') for regressor "').concat(s,'"'))}if(J.push(W),J.length>n&&J.shift(),0===X&&(L.push(Y),L.length>n&&L.shift()),(U||!Z)&&L.length===n&&J.length===n){var et=H({modelClass:v,xRows:L,yRows:J,modelArgs:f,uniqueLabels:0});$?N[K]=[et]:(N[K].push(et),N[K].length>a&&N[K].shift()),D.isTrained[X]=!0}}}}};function He(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=$e(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function $e(t,r){if(t){if("string"==typeof t)return Xe(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Xe(t,r):void 0}}function Xe(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ke=function(t){if(!Array.isArray(t)||0===t.length)return 1;for(var r=Array.isArray(t[0]),e=r?t[0].length:1,n=0,o=0;o<e;o++){for(var i=new Set,a=0;a<t.length;a++){var l=r?t[a][o]:t[a];i.add(l)}n+=i.size}return n},Je=function(t,r){if(!Array.isArray(t)||!Array.isArray(r))throw new TypeError("Both X and Y must be arrays");if(t.length!==r.length)throw new Error("X and Y must have the same length");if(0===r.length)return{X:[],Y:[]};var e,n=r.reduce((function(r,e,n){return r.has(e)||r.set(e,[]),r.get(e).push(t[n]),r}),new Map),o=0,i=He(n.values());try{for(i.s();!(e=i.n()).done;){var a=e.value;a.length>o&&(o=a.length)}}catch(t){i.e(t)}finally{i.f()}var l,u,c,s=[],f=[],p=He(n.entries());try{for(p.s();!(l=p.n()).done;)for(var y=(u=l.value,c=2,function(t){if(Array.isArray(t))return t}(u)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(u,c)||$e(u,c)||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.")}()),h=y[0],v=y[1],d=v.length,m=0;m<o;m++)s.push(v[m%d]),f.push(h)}catch(t){p.e(t)}finally{p.f()}return{X:s,Y:f}};function We(t){return We="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},We(t)}function Ze(t){return function(t){if(Array.isArray(t))return en(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||rn(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qe(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function tn(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||rn(t,r)||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 rn(t,r){if(t){if("string"==typeof t)return en(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?en(t,r):void 0}}function en(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function nn(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ln(n.key),n)}}function on(t,r,e){return r&&nn(t.prototype,r),e&&nn(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function an(t,r,e){return(r=ln(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function ln(t){var r=function(t,r){if("object"!=We(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=We(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==We(r)?r:r+""}var un="classifier",cn=on((function t(){var r=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),an(this,"_unwrap",(function(t){return Array.isArray(t)?t[0]:t})),an(this,"_num",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Number(r._unwrap(t));return Number.isFinite(n)?n:e})),an(this,"set",(function(t,e){if("function"==typeof e){var n=e(r._num(r[t],0));return r[t]=n,n}return r[t]=e,e})),an(this,"inc",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return r.set(t,(function(t){return t+e}))})),an(this,"add",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return r.inc(t,e)})),an(this,"getNum",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return r._num(r[t],e)})),an(this,"get",(function(t){return r._unwrap(r[t])})),an(this,"getAll",(function(){for(var t={},e=0,n=Object.entries(r);e<n.length;e++){var o=tn(n[e],2),i=o[0],a=o[1];"function"!=typeof a&&(t[i]=a)}return function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?Qe(Object(e),!0).forEach((function(r){an(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Qe(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}({},t)})),Object.entries(e).forEach((function(t){var e=tn(t,2),n=e[0],o=e[1];r[n]=o}))})),sn=function(t,r,n,o){var i=o.yCallback,a=o.trainingCols,l=o.findGroups,u=void 0===l?[]:l,c=o.retrain,s=o.type,f=o.modelArgs,p=o.horizon,y=o.precompute,h=o.predictions,v=o.filterCallback,d=o.modelConfig,m=o.modelClass,b=y.lookbackAbs,g=y.prefix,w=y.flatY,S=t.verticalOhlcv,O=t.len,A=t.instances,j=t.scaledGroups,N=t.invalidValueIndex,P=t.ML,x=P.models,_=N+1;if(r===_){A.hasOwnProperty(un)||(A[un]={}),A[un].hasOwnProperty(g)||(A[un][g]={});var k=w?h:1;A[un][g]={store:new cn({strategy:null,total:0,win:0,loss:0,strategyGainLoss:0,idx:0,initialBalance:S.close[r]}),expectedLoops:k,isTrained:new Array(k).fill(!1),uniqueLabels:new Array(k).fill(0),shouldRetrain:c,featureCols:[],flatFeaturesColLen:0,X:[],Y:Array.from({length:k},(function(){return[]}))};for(var E=0;E<h;E++){var T="".concat(g,"_").concat(E+1);S[T]="KNN"===s?new Array(O).fill(null):new Float32Array(O).fill(NaN),P.metrics[T]={accuracy:{},total:0,correct:0,labels:{}},x.hasOwnProperty(T)||(x[T]=[])}}else{if(r<_||r<b)return;if(!1===v(S,r,A[un][g].store))return;if(r+1===O){if(0===A[un][g].featureCols.length){var C=[].concat(Ze(a),Ze(se(u,j)));throw new Error("Some of the provided features in ".concat(un,' "').concat(g,'" features where not found in "verticalOhlcv": ').concat(JSON.stringify(C)))}var M,I=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=rn(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(A[un][g].featureCols);try{for(I.s();!(M=I.n()).done;){var D=M.value;if(!S.hasOwnProperty(D))throw new Error('Feature "'.concat(D,'" not found in verticalOhlcv for ').concat(g,"."))}}catch(t){I.e(t)}finally{I.f()}if(A[un][g].X.length<n){var R=A[un][g].X.length-n;throw new Error('The current "trainingSize" at '.concat(un,' "').concat(g,'" requires at least ').concat(R,' more datapoints. Try adding more input ohlcv rows or reducing the "trainingSize" by ').concat(R,"."))}}}var L=A[un][g];if(0===L.flatFeaturesColLen){if(L.featureCols=pe({trainingCols:a,findGroups:u,verticalOhlcv:S,scaledGroups:j}),!e(t,r,L.featureCols))return;L.flatFeaturesColLen=fe(L.featureCols,S,r),ue({featureCols:L.featureCols,flatFeaturesColLen:L.flatFeaturesColLen,type:s,trainingSize:n})}if(0!==L.flatFeaturesColLen){var F=L.uniqueLabels,B=L.expectedLoops,z=L.featureCols,U=L.flatFeaturesColLen,Y=L.shouldRetrain,V=L.X,q=De({featureCols:z,flatFeaturesColLen:U,type:s,index:r,lookbackAbs:b,main:t});if(q){var G=i(r,S,p,A[un][g].store);if(null!==G&&(!Array.isArray(G)||G.length!==h))throw new Error("trainY must be null or an array with ".concat(h,' items, got "').concat(JSON.stringify(G),'" at index ').concat(r," for ").concat(s));for(var H=0;H<B;H++){var $="".concat(g,"_").concat(H+1),X=L.Y[H],K=w?null===G?null:G[H]:G,J=L.isTrained[H];if(x.hasOwnProperty($)&&J&&(!1===Y||x[$].length===p)){var W=x[$][0].predict([q])[0];if(w){if(null==W)throw new Error("Prediction of ".concat(g," at index ").concat(r," was expecting a number."));t.pushToMain({index:r,key:$,value:W}),null!=K&&ye({metrics:P.metrics[$],trueLabel:K,predictedLabel:W})}else{if(!Array.isArray(W)||W.length!==h)throw new Error("Prediction output of ".concat(un,' "').concat(g,'" at index ').concat(r," was expecting an array of values."));for(var Z=0;Z<h;Z++)t.pushToMain({index:r,key:"".concat(g,"_").concat(Z+1),value:W[Z]}),Array.isArray(K)&&K.length===h&&ye({metrics:P.metrics["".concat(g,"_").concat(Z+1)],trueLabel:K[Z],predictedLabel:W[Z]})}}if(!(r+h+1>O)&&null!==K){if(w){if(void 0===K||null==K)throw new Error("currTrainY must return number, string or boolean got ".concat(We(K)," at index ").concat(r))}else if(K.length!==h)throw new Error("The number of label columns returned (".concat(K.length,") doesn’t match the options.predictions (").concat(h,") setting for the ").concat(un,' "').concat(g,'" classifier. ')+"Please update your yCallback function so its output array items align with options.predictions.");if(X.push(K),X.length>n&&X.shift(),0===H&&(V.push(q),V.length>n&&V.shift()),(Y||!J)&&V.length===n&&X.length===n){if(!1===J&&(F[H]=Ke(X),F[H]<1))throw new Error("Invalid number or labels in ".concat(g,'. Check the logic of your "yCallback" function.'));var Q=d.train,tt=Je(V,X),rt=Q({modelClass:m,xRows:tt.X,yRows:tt.Y,modelArgs:f,uniqueLabels:F[H]});x[$].push(rt),x[$].length>p&&x[$].shift(),L.isTrained[H]=!0}}}return!0}}};function fn(t){return function(t){if(Array.isArray(t))return vn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||hn(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 pn(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=hn(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function yn(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(t,r)||hn(t,r)||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 hn(t,r){if(t){if("string"==typeof t)return vn(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?vn(t,r):void 0}}function vn(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var dn={dateTime:function(t,r,e){var n,o=e.lag,i=e.oneHot,a=e.precompute,l=t.instances,u=t.verticalOhlcv,c=a.prefix;if(0===r){var s=t.len;if(!t.dateType)throw Error('dateTime method found and invalid "date" in input ohlcv');var f=u.date[0].getUTCFullYear(),p=(new Date).getUTCFullYear();Object.assign(l,{dateTime:{colKeys:[].concat((n=a.colKeys,function(t){if(Array.isArray(t))return xe(t)}(n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||Pe(n)||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.")}()),["".concat(c,"year")]),colKeySizes:je(je({},a.colKeySizes),{},Ne({},"".concat(c,"year"),p-f+1)),startYear:f}});var y,h=l.dateTime.colKeys,v=i?Array:Int16Array,d=i?null:NaN,m=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Pe(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(h);try{for(m.s();!(y=m.n()).done;)u[y.value]=new v(s).fill(d)}catch(t){m.e(t)}finally{m.f()}o>0&&t.lag(h,o)}for(var b=l.dateTime,g=b.colKeySizes,w=b.startYear,S=function(t,r,e,n,o){for(var i=function(t,e){return r?le(t,e):t},a=Ne(Ne(Ne(Ne(Ne(Ne({},"".concat(n,"year"),t.getUTCFullYear()),"".concat(n,"month"),t.getUTCMonth()),"".concat(n,"hour"),t.getUTCHours()),"".concat(n,"minute"),t.getUTCMinutes()),"".concat(n,"day_of_the_week"),t.getUTCDay()),"".concat(n,"day_of_the_month"),t.getUTCDate()-1),l=0,u=Object.entries(e);l<u.length;l++){var c=Oe(u[l],2),s=c[0],f=c[1],p=s==="".concat(n,"year")?a[s]-o:a[s];a[s]=i(p,f)}return a}(u.date[r],i,g,c,w),O=0,A=Object.entries(S);O<A.length;O++){var j=Oe(A[O],2),N=j[0],P=j[1];t.pushToMain({index:r,key:N,value:P})}},heikenAshi:function(t,r,e,n){var o,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i.lag,l=void 0===a?0:a,u=i.bothNull,c=void 0!==u&&u,s=t.verticalOhlcv,f=t.instances,p=t.len,y=t.priceBased,h=c?"heiken_ashi":"heiken_ashi_".concat(e,"_").concat(n),v=["open","high","low","close"];if(0===r){f[h]={emaPre:c?null:Object.fromEntries(v.map((function(t){return[t,new zt(e)]}))),emaPost:c?null:Object.fromEntries(v.map((function(t){return[t,new zt(n)]}))),prevHaOpen:NaN,prevHaClose:NaN,isTrendUp:!1};var d,m=v.map((function(t){return"".concat(h,"_").concat(t)})),b=Object.fromEntries([].concat((o=m,function(t){if(Array.isArray(t))return Or(t)}(o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||Sr(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.")}()),["".concat(h,"_cross")]).map((function(t){return[t,new Float64Array(p).fill(NaN)]}))),g=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Sr(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(m);try{for(g.s();!(d=g.n()).done;){var w=d.value;y.add(w)}}catch(t){g.e(t)}finally{g.f()}Object.assign(s,function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?gr(Object(e),!0).forEach((function(r){wr(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):gr(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}({},b)),l>0&&t.lag(m,l)}var S,O,A,j,N=s.open[r],P=s.high[r],x=s.low[r],_=s.close[r],k=f[h];if(c)S=N,O=P,A=x,j=_;else{k.emaPre.open.update(N),k.emaPre.high.update(P),k.emaPre.low.update(x),k.emaPre.close.update(_);try{S=k.emaPre.open.getResult(),O=k.emaPre.high.getResult(),A=k.emaPre.low.getResult(),j=k.emaPre.close.getResult()}catch(t){return!0}}var E,T,C,M,I=(S+O+A+j)/4,D=Number.isNaN(k.prevHaOpen)||Number.isNaN(k.prevHaClose)?(S+j)/2:(k.prevHaOpen+k.prevHaClose)/2,R=Math.max(O,D,I),L=Math.min(A,D,I);if(k.prevHaOpen=D,k.prevHaClose=I,c)E=D,T=R,C=L,M=I;else{k.emaPost.open.update(D),k.emaPost.high.update(R),k.emaPost.low.update(L),k.emaPost.close.update(I);try{E=k.emaPost.open.getResult(),T=k.emaPost.high.getResult(),C=k.emaPost.low.getResult(),M=k.emaPost.close.getResult()}catch(t){return!0}}var F=r>0?s["".concat(h,"_cross")][r-1]:0,B=r>0?s["".concat(h,"_open")][r-1]:NaN,z=r>0?s["".concat(h,"_close")][r-1]:NaN,U=!Number.isNaN(z)&&z<=B&&M>E,Y=!Number.isNaN(z)&&z>=B&&M<E;U&&(k.isTrendUp=!0),Y&&(k.isTrendUp=!1);var V=0;return r>0&&(V=k.isTrendUp?F>0?F+1:1:F<0?F-1:-1),t.pushToMain({index:r,key:"".concat(h,"_open"),value:E}),t.pushToMain({index:r,key:"".concat(h,"_high"),value:T}),t.pushToMain({index:r,key:"".concat(h,"_low"),value:C}),t.pushToMain({index:r,key:"".concat(h,"_close"),value:M}),t.pushToMain({index:r,key:"".concat(h,"_cross"),value:V}),!0},rsi:function(t,r,e,n){var o=n.target,i=n.lag,a=n.parser,l=n.prefix,u=n.minmax,c=t.verticalOhlcv,s=t.instances,f="close"===o?"":"_".concat(o),p="".concat(l,"rsi_").concat(e).concat(f),y="".concat(l,"rsi_sma_").concat(e).concat(f);if(0===r){var h=t.len;if(!c.hasOwnProperty(o))throw new Error("Target property ".concat(o," not found in verticalOhlcv for rsi."));Object.assign(s,fr(fr({},p,new tr(e)),y,new Z(e))),Object.assign(c,fr(fr({},p,new Float64Array(h).fill(NaN)),y,new Float64Array(h).fill(NaN)));var v=[p,y];i>0&&t.lag(v,i);var d=i>0?v.flatMap((function(t){return[t].concat(cr(Array.from({length:i},(function(r,e){return"".concat(t,"_lag_").concat(e+1)}))))})):v;if(Array.isArray(u)){var m,b,g=null!==(b=(m=t.scaledGroups).minmax_rsi)&&void 0!==b?b:m.minmax_rsi=[];g.push.apply(g,cr(d))}}var w=c[o][r],S=NaN,O=NaN;s[p].update(w);try{S=s[p].getResult()}catch(t){S=NaN}t.pushToMain({index:r,key:p,value:Number.isNaN(S)?NaN:a(S)}),Number.isNaN(S)||s[y].update(S);try{O=s[y].getResult()}catch(t){O=NaN}t.pushToMain({index:r,key:y,value:Number.isNaN(O)?NaN:a(O)})},stochastic:function(t,r,e,n,o,i){var a=i.minmax,l=i.prefix,u=i.lag,c=i.parser,s=t.verticalOhlcv,f=t.instances,p=14===e&&3===n&&3===o?"":"".concat(e,"_").concat(n,"_").concat(o),y="".concat(l,"stoch_d").concat(p),h="".concat(l,"stoch_k").concat(p),v="".concat(l).concat(p);if(0===r){var d=t.len;Object.assign(f,vr({},v,new lr(e,n,o))),Object.assign(s,vr(vr({},y,new Float64Array(d).fill(NaN)),h,new Float64Array(d).fill(NaN)));var m=[y,h];u>0&&t.lag(m,u);var b=u>0?m.flatMap((function(t){return[t].concat(yr(Array.from({length:u},(function(r,e){return"".concat(t,"_lag_").concat(e+1)}))))})):m;if(Array.isArray(a)){var g,w,S=null!==(w=(g=t.scaledGroups).minmax_rsi)&&void 0!==w?w:g.minmax_rsi=[];S.push.apply(S,yr(b))}}var O=s.close[r],A=s.low[r],j=s.high[r],N=null;f[v].update({close:O,low:A,high:j});try{N=f[v].getResult()}catch(t){N=null}var P=N?c(N.stochK):NaN,x=N?c(N.stochD):NaN;t.pushToMain({index:r,key:h,value:P}),t.pushToMain({index:r,key:y,value:x})},atr:function(t,r,e,n){var o=n.lag,i=n.percentage,a=n.upper,l=n.lower,u=t.verticalOhlcv,c=t.instances,s=t.priceBased,f="atr_".concat(e);if(0===r){var p=t.instances,y=t.verticalOhlcv,h=t.len;p[f]=new Pt(e,lt);var v=[f];i&&v.push("".concat(f,"_percentage")),null!==a&&v.push("".concat(f,"_upper")),null!==l&&v.push("".concat(f,"_lower"));for(var d=0,m=v;d<m.length;d++){var b=m[d];y[b]=new Float64Array(h).fill(NaN),s.add(b)}o>0&&t.lag(v,o)}var g={high:u.high[r],low:u.low[r],close:u.close[r]},w=c[f];w.update(g);var S=NaN;try{S=w.getResult()}catch(t){}if(i){var O=Number.isNaN(S)?NaN:S/g.close;t.pushToMain({index:r,key:"".concat(f,"_percentage"),value:O})}if(null!==a){var A=Number.isNaN(S)?NaN:g.close+S*a;t.pushToMain({index:r,key:"".concat(f,"_upper"),value:A})}if(null!==l){var j=Number.isNaN(S)?NaN:g.close-S*l;t.pushToMain({index:r,key:"".concat(f,"_lower"),value:j})}return t.pushToMain({index:r,key:f,value:S}),!0},ema:mr,sma:mr,vidya:function(t,r,e,n){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=t.verticalOhlcv,a=t.instances,l=t.len,u=t.priceBased,c=o.target,s=o.lag,f=o.atrLength,p=void 0===f?200:f,y=o.bandDistance,h=void 0===y?2:y,v=o.liquidityLookback,d=void 0===v?5:v,m="".concat(e,"_").concat(n);if(0===r){if(!(c in i))throw new Error('VIDYA could not find target "'.concat(c,'"'));for(var b="vidya_".concat(m),g="close"===c?b:"".concat(b,"_").concat(c),w={vidya:g,upper:"".concat(b,"_upper"),lower:"".concat(b,"_lower"),delta_vol:"".concat(b,"_delta_vol"),cross:"".concat(b,"_cross"),liquidity:"".concat(b,"_liquidity")},S=0,O=[g,w.upper,w.lower,w.liquidity];S<O.length;S++){var A=O[S];u.add(A)}a.vidya||(a.vidya={settings:{}}),a.vidya.settings[m]={momentumBuffer:[],prevVidya:NaN,sma:new Z(15),atrBuffer:[],isTrendUp:!1,upVol:0,downVol:0,liquidity:{high:[],low:[]}},Object.values(w).forEach((function(t){i[t]=new Float64Array(l).fill(NaN)})),s>0&&t.lag(Object.values(w),s)}var j=a.vidya.settings[m],N="vidya_".concat(m),P={vidya:"close"===c?N:"".concat(N,"_").concat(c),upper:"".concat(N,"_upper"),lower:"".concat(N,"_lower"),delta_vol:"".concat(N,"_delta_vol"),cross:"".concat(N,"_cross"),liquidity:"".concat(N,"_liquidity")},x=i[c][r],_=i.high[r],k=i.low[r],E=i.close[r],T=i.open[r],C=i.volume[r],M=r>0?i[P.cross][r-1]:0,I=j.liquidity.high.length===d?Math.max.apply(Math,Ar(j.liquidity.high)):NaN,D=j.liquidity.low.length===d?Math.min.apply(Math,Ar(j.liquidity.low)):NaN;if(r>0){var R=i.close[r-1],L=Math.max(_-k,Math.abs(_-R),Math.abs(k-R));j.atrBuffer.push(L),j.atrBuffer.length>p&&j.atrBuffer.shift()}var F=j.atrBuffer.length===p?j.atrBuffer.reduce((function(t,r){return t+r}),0)/p:NaN,B=NaN,z=NaN;if(r>0&&(z=x-i[c][r-1]),j.momentumBuffer.push(z),j.momentumBuffer.length>n&&j.momentumBuffer.shift(),j.momentumBuffer.length===n){var U=0,Y=0;j.momentumBuffer.forEach((function(t){return t>=0?U+=t:Y+=-t}));var V=U+Y,q=2/(e+1)*((0===V?0:100*Math.abs((U-Y)/V))/100);B=isNaN(j.prevVidya)?x:q*x+(1-q)*j.prevVidya,j.prevVidya=B}j.sma.update(B);var G=NaN;try{G=j.sma.getResult()}catch(t){}var H=isNaN(F)||isNaN(G)?NaN:G+F*h,$=isNaN(F)||isNaN(G)?NaN:G-F*h,X=r>0?i[c][r-1]:NaN,K=r>0?i[P.upper][r-1]:NaN,J=r>0?i[P.lower][r-1]:NaN,W=r>0&&X<=K&&x>H,Q=r>0&&X>=J&&x<$;W&&(j.isTrendUp=!0),Q&&(j.isTrendUp=!1);var tt=0;r>0&&(tt=j.isTrendUp?M>0?M+1:1:M<0?M-1:-1),W||Q?j.upVol=j.downVol=0:(j.upVol+=E>T?C:0,j.downVol+=E<T?C:0);var rt=(j.upVol+j.downVol)/2||1,et=(j.upVol-j.downVol)/rt,nt=j.isTrendUp?$:H,ot=NaN;return tt>0?ot=D:tt<0&&(ot=I),t.pushToMain({index:r,key:P.vidya,value:nt}),t.pushToMain({index:r,key:P.upper,value:H}),t.pushToMain({index:r,key:P.lower,value:$}),t.pushToMain({index:r,key:P.delta_vol,value:et}),t.pushToMain({index:r,key:P.cross,value:tt}),t.pushToMain({index:r,key:P.liquidity,value:ot}),j.liquidity.high.push(_),j.liquidity.low.push(k),j.liquidity.high.length>d&&j.liquidity.high.shift(),j.liquidity.low.length>d&&j.liquidity.low.shift(),!0},macd:function(t,r,e,n,o,i){var a=i.target,l=i.lag,u=i.precomputed,c=t.verticalOhlcv,s=t.instances,f=t.priceBased,p=u.instanceKey;if(0===r){var y=t.inputParams,h=t.len;if(!c.hasOwnProperty(a))throw new Error("Target property ".concat(a," not found in verticalOhlcv for macd."));var v,d=0,m=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return xr(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?xr(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(y);try{for(m.s();!(v=m.n()).done;)"macd"===v.value.key&&d++}catch(t){m.e(t)}finally{m.f()}var b=d>1?"macd_".concat(e,"_").concat(n,"_").concat(o):"macd",g=a===_r?"".concat(b,"_diff"):"".concat(b,"_diff_").concat(a),w=a===_r?"".concat(b,"_dea"):"".concat(b,"_dea_").concat(a),S=a===_r?"".concat(b,"_histogram"):"".concat(b,"_histogram_").concat(a);s.hasOwnProperty("macd")||(s.macd={numberOfIndicators:d,settings:{}}),s.macd.settings[p]=new Gt(new zt(e),new zt(n),new zt(o)),Object.assign(c,Pr(Pr(Pr({},g,new Float64Array(h).fill(NaN)),w,new Float64Array(h).fill(NaN)),S,new Float64Array(h).fill(NaN)));for(var O=[g,w,S],A=0,j=O;A<j.length;A++){var N=j[A];f.add(N)}l>0&&t.lag(O,l)}var P=s.macd,x=P.numberOfIndicators,_=P.settings,k=x>1?"macd_".concat(e,"_").concat(n,"_").concat(o):"macd",E=a===_r?"".concat(k,"_diff"):"".concat(k,"_diff_").concat(a),T=a===_r?"".concat(k,"_dea"):"".concat(k,"_dea_").concat(a),C=a===_r?"".concat(k,"_histogram"):"".concat(k,"_histogram_").concat(a),M=_[p],I=c[a][r];M.update(I);var D={};try{D=M.getResult()}catch(t){}return t.pushToMain({index:r,key:E,value:D?D.macd:NaN}),t.pushToMain({index:r,key:T,value:D?D.signal:NaN}),t.pushToMain({index:r,key:C,value:D?D.histogram:NaN}),!0},volumeDelta:function(t,r,e){var n=e.lag,o=void 0===n?0:n,i=t.verticalOhlcv,a=t.instances,l=t.len,u="volume_delta";if(0===r){a[u]||(a[u]={isBuyVolume:!0,cross:0});for(var c=["".concat(u,"_open"),"".concat(u,"_high"),"".concat(u,"_low"),"".concat(u,"_close"),"".concat(u,"_cross")],s=0,f=c;s<f.length;s++)i[f[s]]=new Float64Array(l).fill(NaN);o>0&&t.lag(c,o)}var p=a[u],y=i.volume[r],h=i.open[r],v=i.close[r],d=r>0?i.close[r-1]:NaN,m=p.isBuyVolume;v>h?m=!0:v<h?m=!1:v>d?m=!0:v<d&&(m=!1),p.isBuyVolume=m,r<1?p.cross=m?1:-1:m?p.cross>0?p.cross=p.cross+1:p.cross=1:p.cross>0?p.cross=-1:p.cross=p.cross-1;var b=Number.isFinite(y)?m?y:-y:NaN,g=Number.isNaN(b)?NaN:0,w=b,S=Number.isNaN(b)?NaN:Math.max(b,0),O=Number.isNaN(b)?NaN:Math.min(b,0);return t.pushToMain({index:r,key:"".concat(u,"_open"),value:g}),t.pushToMain({index:r,key:"".concat(u,"_high"),value:S}),t.pushToMain({index:r,key:"".concat(u,"_low"),value:O}),t.pushToMain({index:r,key:"".concat(u,"_close"),value:w}),t.pushToMain({index:r,key:"".concat(u,"_cross"),value:p.cross}),!0},relativeVolume:function(t,r,e,n){var o=n.lag,i="relative_volume_".concat(e),a=t.instances,l=t.verticalOhlcv;if(0===r){var u=t.len;a[i]={instance:new Z(e),prevRelativeVolumeSma:NaN},l[i]=new Float64Array(u).fill(NaN),o>0&&t.lag([i],o)}var c=l.volume[r],s=a[i].instance;s.update(c);var f=NaN;try{f=s.getResult()}catch(t){}var p=a[i].prevRelativeVolumeSma,y=NaN;return Number.isNaN(f)||Number.isNaN(p)||(y=c/p),t.pushToMain({index:r,key:i,value:y}),a[i].prevRelativeVolumeSma=f,!0},donchianChannels:function(t,r,e,n,o){var i=t.verticalOhlcv,a=t.instances,l=t.len,u=t.inputParams,c=t.lag,s=t.priceBased,f=o.height,p=o.range,y="".concat(e,"_").concat(n);if(0===r){var h=u.filter((function(t){return"donchianChannels"===t.key})).length,v="donchian_channel",d=h>1?"".concat(v,"_").concat(y):v,m=["upper","basis","lower"].map((function(t){return"".concat(d,"_").concat(t)}));f&&m.push("".concat(d,"_height"));var b,g=Er(p);try{for(g.s();!(b=g.n()).done;){var w=b.value;if(!(w in i))throw new Error('Invalid range key "'.concat(w,'".'));m.push("".concat(d,"_range_").concat(w))}}catch(t){g.e(t)}finally{g.f()}var S,O=Er(m);try{for(O.s();!(S=O.n()).done;){var A=S.value;s.add(A)}}catch(t){O.e(t)}finally{O.f()}a.donchian_channel||(a.donchian_channel={numberOfIndicators:h,settings:{}}),a.donchian_channel.numberOfIndicators=h,a.donchian_channel.settings[y]={maxDeque:[],minDeque:[]},Object.assign(i,Object.fromEntries(m.map((function(t){return[t,new Float64Array(l).fill(NaN)]})))),c>0&&t.lag(m,c)}var j=a.donchian_channel,N=j.numberOfIndicators,P=j.settings,x=N>1?"donchian_channel_".concat(y):"donchian_channel",_=P[y],k=_.maxDeque,E=_.minDeque,T=r-n,C=T-e+1,M=["upper","basis","lower"].map((function(t){return"".concat(x,"_").concat(t)}));f&&M.push("".concat(x,"_height"));var I=p.map((function(t){return"".concat(x,"_range_").concat(t)}));if(C<0||T+1>l)return[].concat(kr(M),kr(I)).forEach((function(e){return t.pushToMain({index:r,key:e,value:NaN})})),!0;var D=i.high,R=i.low,L=function(t,r,e){for(;t.length&&t[0]<C;)t.shift();for(;t.length&&e(r[t.at(-1)],r[T]);)t.pop();t.push(T)};L(k,D,(function(t,r){return t<=r})),L(E,R,(function(t,r){return t>=r}));var F=k.length&&E.length,B=F?D[k[0]]:NaN,z=F?R[E[0]]:NaN,U=F?(B+z)/2:NaN;if(t.pushToMain({index:r,key:"".concat(x,"_upper"),value:B}),t.pushToMain({index:r,key:"".concat(x,"_basis"),value:U}),t.pushToMain({index:r,key:"".concat(x,"_lower"),value:z}),f){var Y=F&&z?(B-z)/z:NaN;t.pushToMain({index:r,key:"".concat(x,"_height"),value:Y})}for(var V=F?B-z:NaN,q=0;q<p.length;q++){var G=i[p[q]][r],H=F&&G==G&&V?(G-z)/V:NaN;t.pushToMain({index:r,key:I[q],value:H})}return!0},bollingerBands:function(t,r,e,n,o){var i,a,l,u,c,s,f=o.height,p=o.range,y=void 0===p?[]:p,h=o.target,v=o.lag,d=t.verticalOhlcv,m=t.instances,b="".concat(e,"_").concat(n),g="bollinger_bands";if(0===r){var w=t.inputParams,S=t.verticalOhlcv,O=t.len,A=t.priceBased;if(!(h in S))throw new Error('bollingerBands could not find target "'.concat(h,'"'));var j,N=0,P=Rr(w);try{for(P.s();!(j=P.n()).done;)"bollingerBands"===j.value.key&&N++}catch(t){P.e(t)}finally{P.f()}m.bollinger_bands||(m.bollinger_bands={numberOfIndicators:N,settings:{}}),m.bollinger_bands.settings[b]=new Tt(e,n);var x="";N>1&&(x+="_".concat(b)),h!==Fr&&(x+="_".concat(h));var _=["".concat(g,"_upper"),"".concat(g,"_middle"),"".concat(g,"_lower")].map((function(t){return"".concat(t).concat(x)}));f&&_.push("".concat(g,"_height").concat(x));var k,E=Rr(y);try{for(E.s();!(k=E.n()).done;){var T=k.value;if(!(T in S))throw new Error('Invalid range item value "'.concat(T,'" property for bollingerBands.'));_.push("".concat(g,"_range_").concat(T).concat(x))}}catch(t){E.e(t)}finally{E.f()}if(A.has(h)){var C,M=Rr(_);try{for(M.s();!(C=M.n()).done;){var I=C.value;A.add(I)}}catch(t){M.e(t)}finally{M.f()}}var D=Object.fromEntries(_.map((function(t){return[t,new Float64Array(O).fill(NaN)]})));Object.assign(S,function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?Ir(Object(e),!0).forEach((function(r){Dr(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ir(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}({},D)),v>0&&t.lag(_,v)}var R="";m.bollinger_bands.numberOfIndicators>1&&(R+="_".concat(b)),h!==Fr&&(R+="_".concat(h));var L=m.bollinger_bands.settings[b],F=d[h][r];L.update(F);var B={};try{B=L.getResult()}catch(t){}var z=null!==(i=null===(a=B)||void 0===a?void 0:a.upper)&&void 0!==i?i:NaN,U=null!==(l=null===(u=B)||void 0===u?void 0:u.middle)&&void 0!==l?l:NaN,Y=null!==(c=null===(s=B)||void 0===s?void 0:s.lower)&&void 0!==c?c:NaN;if(t.pushToMain({index:r,key:"".concat(g,"_upper").concat(R),value:z}),t.pushToMain({index:r,key:"".concat(g,"_middle").concat(R),value:U}),t.pushToMain({index:r,key:"".concat(g,"_lower").concat(R),value:Y}),f){var V=NaN;Number.isNaN(Y)||Number.isNaN(z)||(V=(z-Y)/Y),t.pushToMain({index:r,key:"".concat(g,"_height").concat(R),value:V})}var q,G=Rr(y);try{for(G.s();!(q=G.n()).done;){var H=q.value,$=NaN,X=d[H][r];Number.isNaN(X)||Number.isNaN(Y)||Number.isNaN(z)||($=(X-Y)/(z-Y)),t.pushToMain({index:r,key:"".concat(g,"_range_").concat(H).concat(R),value:$})}}catch(t){G.e(t)}finally{G.f()}return!0},volumeOscillator:function(t,r,e,n,o){var i,a,l,u=o.lag,c=t.verticalOhlcv,s=t.instances,f=c.volume[r],p="volume_oscillator_".concat(e,"_").concat(n);if(0===r){var y=t.len;Object.assign(s,(i={},a=p,l={fastEMA:new zt(e),slowEMA:new zt(n)},(a=function(t){var r=function(t,r){if("object"!=Br(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Br(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Br(r)?r:r+""}(a))in i?Object.defineProperty(i,a,{value:l,enumerable:!0,configurable:!0,writable:!0}):i[a]=l,i)),c[p]=new Float64Array(y).fill(NaN),u>0&&t.lag([p],u)}var h=s[p],v=h.fastEMA,d=h.slowEMA;v.update(f),d.update(f);var m=NaN,b=NaN;try{m=v.getResult()}catch(t){}try{b=d.getResult()}catch(t){}var g=NaN;return Number.isNaN(m)||Number.isNaN(b)||(g=100*(m-b)/b),t.pushToMain({index:r,key:p,value:g}),!0},mapCols:function(t,r,e,n,o){var i=o.lag,a=o.isPriceBased,l=t.verticalOhlcv,u=t.len,c=t.priceBased,s=t.precision;if(0===r){var f,p=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Te(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(e);try{for(p.s();!(f=p.n()).done;){var y=f.value;if(l.hasOwnProperty(y))throw new Error('New property "'.concat(y,'" already exist in "verticalOhlcv" and can not be modified using mapCols.'));l[y]=new Array(u).fill(0),s&&a&&c.add(y)}}catch(t){p.e(t)}finally{p.f()}i>0&&t.lag(e,i)}var h,v,d=n({index:r,main:t});if(null==d)return!0;for(var m=0,b=Object.entries(d);m<b.length;m++){var g=(h=b[m],v=2,function(t){if(Array.isArray(t))return t}(h)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(h,v)||Te(h,v)||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.")}()),w=g[0],S=g[1];t.pushToMain({index:r,key:w,value:S})}},scaler:function(t,r,e,n,o){var i=o.type,a=o.group,l=o.range,u=o.lag,c=o.precomputed,s=(o.secondaryLoop,c.groupKey),f=c.groupKeyLen,p=t.verticalOhlcv,y=t.instances,h=(t.invalidValueIndex,"".concat(i,"_").concat(e));if(0===r){var v=t.len,d=t.isAlreadyComputed;if(d.has(h))throw new Error('In scaler method can not repeat params "size" and "options.type" together between indicators.');d.add(h),y.hasOwnProperty("scaler")||(y.scaler={}),y.scaler.hasOwnProperty(h)||(y.scaler[h]={windows:{}});var m,b=[],g=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ke(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(n);try{var w=function(){var r=m.value;if(!p.hasOwnProperty(r))throw new Error('Target property "'.concat(r,'" not found in verticalOhlcv'));var e="".concat(h,"_").concat(r);p[e]=new Float64Array(v).fill(NaN);var n=a?s:r;if(y.scaler[h].windows[n]=[],t.scaledGroups[s]||(t.scaledGroups[s]=[]),t.scaledGroups[s].push(e),u>0){var o,i=Array.from({length:u}).map((function(t,r){return"".concat(e,"_lag_").concat(r+1)}));(o=t.scaledGroups[s]).push.apply(o,_e(i)),b.push(e)}};for(g.s();!(m=g.n()).done;)w()}catch(t){g.e(t)}finally{g.f()}u>0&&t.lag(b,u)}for(var S=y.scaler[h].windows,O=!1,A=0;A<n.length;A++){var j=n[A],N=p[j];if(void 0===N){O=!0;break}var P=N[r];if(Number.isNaN(P)||null===P){O=!0;break}var x=S[a?s:j];x.push(P),x.length>(a?e*f:e)&&x.shift()}if(!O&&r+1>=e)for(var _=function(){var e=n[k],o=p[e];if(void 0===o)return 0;var u=o[r];if(Number.isNaN(u)||null===u)return 0;var c="".concat(h,"_").concat(e),f=null,y=S[a?s:e];if("minmax"===i){var v=Math.min.apply(Math,_e(y)),d=Math.max.apply(Math,_e(y));f=ce(u,v,d,l)}else{if("zscore"!==i)throw new Error('Unknown scaler type "'.concat(i,'"'));var m=y.reduce((function(t,r){return t+r}),0)/y.length,b=y.reduce((function(t,r){return t+Math.pow(r-m,2)}),0)/y.length,g=Math.sqrt(b);f=function(t,r,e){return 0===e?0:(t-r)/e}(u,m,g)}t.pushToMain({index:r,key:c,value:f})},k=0;k<n.length&&0!==_();k++);},crossPairs:function(t,r,e,n){var o,i=n.oneHot,a=n.limit,l=t.verticalOhlcv,u=t.verticalOhlcvTempCols,c=t.instances,s=t.len,f=t.precision,p=t.precisionMultiplier,y=t.priceBased,h=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return he(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?he(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(e);try{for(h.s();!(o=h.n()).done;){var v=o.value,d=v.fast,m=v.slow,b="".concat(d,"_x_").concat(m);if(0===r){if("number"==typeof m){var g=m.toString();u.add(g);var w=f&&("price"===d||y.has(d)),S=w?Vr(g,p):m,O=m>=-125&&m<=125&&!1===w?"Int8Array":"Float64Array";l[g]=te(O,s,S)}c.hasOwnProperty("crossPairs")||(c.crossPairs={}),c.crossPairs[b]={run:new we,min:1/0,max:-1/0};var A=null!==a&&a<=125?"Int8Array":"Float64Array";l[b]=te(A,s,0),i&&(l["one_hot_".concat(b)]=te("Array",s,null))}else if(r+1===s){if("price"!==d&&!l.hasOwnProperty(d))throw new Error('crossPairs invalid param: fast "'.concat(d,'" not found in "verticalOhlcv": ').concat(JSON.stringify(Object.keys(l))));if(!l.hasOwnProperty(m))throw new Error('crossPairs invalid param: slow "'.concat(m,'" not found in "verticalOhlcv": ').concat(JSON.stringify(Object.keys(l))))}if("price"!==d&&!l.hasOwnProperty(d))return;if(!l.hasOwnProperty(m))return;var j=c.crossPairs[b].run;if("price"===d){var N=l.close[r],P=l[m][r];j.update(r,{fast:N,slow:P,high:l.high[r],low:l.low[r]})}else{var x=l[d][r],_=l[m][r];j.update(r,{fast:x,slow:_})}var k=j.getResult(),E=null!==a?Math.min(Math.max(k,-a),a):k;if(t.pushToMain({index:r,key:b,value:E}),i){var T=E+a,C=2*a+1;t.pushToMain({index:r,key:"one_hot_".concat(b),value:le(T,C)})}}}catch(t){h.e(t)}finally{h.f()}return!0},lag:function(t,r,e,n){var o=t.verticalOhlcv,i=t.len,a=t.priceBased;if(0===r){var l,u=ee(e);try{for(u.s();!(l=u.n()).done;){var c=l.value;if(!o.hasOwnProperty(c))throw new Error('Lag processing invoked by col "'.concat(c,'" was not found in "verticalOhlcv".'));for(var s=a.has(c),f=1;f<=n;f++){var p="".concat(c,"_lag_").concat(f);s&&a.add(p);var y=re(c,o[c]);o[p]=te(y,i)}}}catch(t){u.e(t)}finally{u.f()}}var h,v=ee(e);try{for(v.s();!(h=v.n()).done;)for(var d=h.value,m=o[d],b=1;b<=n;b++){var g="".concat(d,"_lag_").concat(b),w=r-b,S=w<0||void 0===m[w]?null:m[w];t.pushToMain({index:r,key:g,value:S})}}catch(t){v.e(t)}finally{v.f()}return!0}};function mn(t,r){if(t){if("string"==typeof t)return bn(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?bn(t,r):void 0}}function bn(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var gn=function(t){var r=t.main,e=t.skipNull,n=void 0!==e&&e,o=t.startIndex,i=void 0===o?0:o,a=t.dateFormat,l=r.verticalOhlcv,u=r.invalidValueIndex,c=r.len,s=r.verticalOhlcvKeyNames,f=r.verticalOhlcvTempCols,p=r.priceBased,y=r.precision,h=r.precisionMultiplier;if(0===s.length)return[];var v,d,m,b=n&&u>=0?u+1:0,g=Math.max(b,i),w=c-g,S=Array.from({length:w},(function(){return{}})),O={},A=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=mn(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(s);try{for(A.s();!(v=A.n()).done;){var j=v.value;y&&p.has(j)?O[j]=function(t,r){return function(t,r){if("number"!=typeof t||!Number.isFinite(t))throw new Error("revertPrecisionAsNumber expects a finite number");var e=t<0,n=Math.abs(t);n=Math.trunc(n);var o=1===r?0:String(r).length-1;if(0===o)return e?-n:n;var i=Math.trunc(n/r),a=String(n%r).padStart(o,"0"),l=0===(a=a.replace(/0+$/,"")).length?String(i):"".concat(i,".").concat(a);return Number(e?"-".concat(l):l)}(t,r)}:O[j]=function(t){return t}}}catch(t){A.e(t)}finally{A.f()}for(var N=0,P=Object.entries(l);N<P.length;N++){var x=(d=P[N],m=2,function(t){if(Array.isArray(t))return t}(d)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(d,m)||mn(d,m)||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.")}()),_=x[0],k=x[1];if(!f.has(_))for(var E=g;E<c;E++)S[E-g][_]="date"===_?Xr[a](k[E]):O[_](k[E],h)}return S},wn=function(t,r){u(t,"arr","getOrderFromArray"),h(r,"methodName","getOrderFromArray");var e=["open","high","low","close","volume","date"],n=["regressor","classifier","pca"].includes(r);if(t.every((function(t){return e.includes(t)}))&&!n)return 0;for(var o=1,i=function(){var r=l[a];t.some((function(t){return t.includes(r)}))&&o++},a=0,l=["_x_","zscore_","minmax_","lag_"];a<l.length;a++)i();if(!n)return o;o=10;for(var c=function(){var r=f[s];t.some((function(t){return t.includes(r)}))&&o++},s=0,f=["prediction_","reg_","cla_","pca_"];s<f.length;s++)c();return o};function Sn(t){return Sn="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},Sn(t)}function On(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function An(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?On(Object(e),!0).forEach((function(r){jn(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):On(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function jn(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Sn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sn(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Nn(t,r){if(t){if("string"==typeof t)return Pn(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Pn(t,r):void 0}}function Pn(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var xn=function(t,r,e){if(2!==e)throw new Error('The default "yCallback" function in this classifier requires that "options.horizon" and "options.predictions" are set to "2".');var n=r.close[t],o=Array.from({length:e},(function(e,n){return r.close[n+1+t]}));if(o.some((function(t){return void 0===t})))return null;var i=o[0],a=o[1];return[Number(i>n),Number(a>i)]},_n={KNN:{shortName:"knn",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},FeedForwardNeuralNetworks:{shortName:"feed_forward",flatY:!1,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=t.modelArgs,i=t.uniqueLabels;o||(o={});var a=new r(o=An(An({},o),{},{activation:2===i?"logistic":"identity"}));return a.train(e,n),a},unsupervised:!1},GaussianNB:{shortName:"naive_bayes",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},MultinomialNB:{shortName:"naive_bayes",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},DecisionTreeClassifier:{shortName:"decision_tree",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},RandomForestClassifier:{shortName:"random_forest",flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o}},unsupervised:!1},kn={ARIMA:{shortName:"arima",flatX:!0,flatY:!1,exportModel:function(t){return t},train:function(t){var r=t.modelClass,e=t.xRows,n=t.modelArgs;n||(n={});var o=new r(n=An(An({},n),{},{p:2,d:1,q:2,P:0,D:0,Q:0,S:0,verbose:!1}));return o.train(e),o},unsupervised:!0},SimpleLinearRegression:{shortName:"linear",flatX:!0,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},PolynomialRegression:{shortName:"polynomial",flatX:!0,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},MultivariateLinearRegression:{shortName:"multivariable",flatX:!1,flatY:!1,exportModel:function(t){return t.toJSON()},train:function(t){return new(0,t.modelClass)(t.xRows,t.yRows,t.modelArgs)},unsupervised:!1},DecisionTreeRegression:{shortName:"decision_tree",flatX:!1,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},RandomForestRegression:{shortName:"random_forest",flatX:!1,flatY:!0,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=new r(t.modelArgs);return o.train(e,n),o},unsupervised:!1},FeedForwardNeuralNetworks:{shortName:"feed_forward",flatX:!1,flatY:!1,exportModel:function(t){return t.toJSON()},train:function(t){var r=t.modelClass,e=t.xRows,n=t.yRows,o=t.modelArgs;o||(o={});var i=new r(o=An(An({},o),{},{activation:"identity"}));return i.train(e,n),i},unsupervised:!1}};function En(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function Tn(t){return Tn="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},Tn(t)}function Cn(t,r,e){return(r=Fn(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Mn(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Dn(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}function In(t){return function(t){if(Array.isArray(t))return Rn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Dn(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 Dn(t,r){if(t){if("string"==typeof t)return Rn(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Rn(t,r):void 0}}function Rn(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Ln(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Fn(n.key),n)}}function Fn(t){var r=function(t,r){if("object"!=Tn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Tn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tn(r)?r:r+""}var Bn=function(){return t=function t(r){var e=this,n=r.input,o=r.ticker,i=void 0===o?null:o,l=r.inputParams,s=void 0===l?null:l,y=r.chunkProcess,h=void 0===y?2e3:y,v=r.ML,d=void 0===v?{}:v,m=r.precision,b=void 0!==m&&m;if(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),u(n,"input",null!==i?"contructor ".concat(i):"constuctor"),0===n.length)throw Error("input OHLCV must not be empty: "+i);p(h,{min:100,max:5e4,allowDecimals:!1},"chunkProcess","constructor"),c(d,"ML","constructor"),f(b,"precision","contructor"),this.chunkProcess=h,this.input=In(n),this.len=this.input.length,this.firstRow=this.input[0],this.precision=b;var g=["open","high","low","close"];this.initialPriceBased=new Set(g),this.priceBased=new Set(g),this.precisionMultiplier=function(t){var r=t.precision,e=t.firstRow,n=t.initialPriceBased;if(!1===r)return 1;for(var o=1,i=0,a=Object.entries(e);i<a.length;i++){var l=Ur(a[i],2),u=l[0],c=l[1];if(n.has(u)){if("string"!=typeof c||!/^\d+(\.\d+)?$/.test(c))throw new Error('If "precision" is set to true all the "open", "high", "low" and "close" values must be numeric strings like "123.45" with no commas or currency symbols. Property "'.concat(u,'" had the value "').concat(c,'" type ').concat(zr(c),"."));var s=Ur(c.split("."),2),f=s[0],p=s[1],y=void 0===p?"":p,h=Number(f),v=4;if(0===Math.abs(h)){var d=y.length,m=Math.max(4,d),b=y.search(/[1-9]/);if(-1===b)v=m;else{var g=b+1+5;v=Math.max(m,g)}}var w=Math.pow(10,v);w>o&&(o=w)}}return o}(this);var w=function(t){for(var r=t.firstRow,e=t.precision,n=t.initialPriceBased,o={},i={},a=0,l=Object.entries(r);a<l.length;a++){var u=Zr(l[a],2),c=u[0],s=u[1];if("date"===c)o[c]=Jr(s),i[c]="Array";else if("volume"===c)o[c]=Hr(s,!0),i[c]="Int32Array";else if(n.has(c))o[c]=Hr(s,!0,e),i[c]="Float64Array";else{var f=Hr(s,!1,e);o[c]=f,i[c]="number"===f?"Float64Array":"Array"}}return{inputTypes:o,arrayTypes:i}}(this),S=w.inputTypes,O=w.arrayTypes;if(this.inputTypes=S,this.arrayTypes=O,!this.firstRow.hasOwnProperty("close"))throw Error('input OHLCV array objects require at least "close" property: '.concat(i));this.dateType=this.inputTypes.date?this.inputTypes.date:null,this.isComputed=!1,this.instances={},this.verticalOhlcv={},this.verticalOhlcvKeyNames=[],this.verticalOhlcvTempCols=new Set,this.utilities={},this.invalidValueIndex=-1,this.scaledGroups={},this.isAlreadyComputed=new Set;var A=d.classes;return void 0!==A&&c(A,"ML.classes","constructor"),this.ML={models:{},classes:A,metrics:{},featureCols:{}},this.processSecondaryLoop=!1,this.pushToMain=function(t){var r=t.index,n=t.key,o=t.value;return function(t){var r=t.index,e=t.key,n=t.value;return t.main.verticalOhlcv[e][r]=n,!0}({main:e,index:r,key:n,value:o})},null!==s?(a(s,this.len),this.inputParams=s,this.compute()):this.inputParams=[],this},r=[{key:"getData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var r=t.skipNull,e=void 0===r||r,n=t.dateFormat,o=void 0===n?"string":n;return s(Object.keys(Xr),o,"dateFormat","getData"),c(t,"options","getData"),gn({main:this,skipNull:e,startIndex:0,dateFormat:o})}},{key:"getLastValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var r=t.dateFormat,e=void 0===r?"string":r;return s(Object.keys(Xr),e,"dateFormat","getData"),gn({skipNull:!1,main:this,startIndex:this.len-1,dateFormat:e})[0]}},{key:"compute",value:function(){return this.isComputed||(this.isComputed=!1,this.len>0&&(function(t,r){var n=r.len,o=r.inputParams,i=r.arrayTypes,l=r.verticalOhlcv,u=r.verticalOhlcvKeyNames,c=r.inputTypes,s=r.chunkProcess,f=r.processSecondaryLoop,p=r.precisionMultiplier;a(o,n);for(var y=0,h=Object.keys(c);y<h.length;y++){var v=h[y];l[v]=te(i[v],n)}for(var d=0;d<n;d+=s)for(var m=Math.min(d+s,n),b=d;b<m;b++){for(var g=t[b],w=0,S=Object.entries(c);w<S.length;w++){var O=yn(S[w],2),A=O[0],j=O[1],N=g[A];if(Gr.hasOwnProperty(j)){void 0===N&&console.log({index:b,formaterKey:j,key:A});var P=Gr[j](N,p);r.pushToMain({index:b,key:A,value:P})}else Kr.hasOwnProperty(j)?r.pushToMain({index:b,key:A,value:Kr[j](N)}):r.pushToMain({index:b,key:A,value:N})}var x,_=pn(o);try{for(_.s();!(x=_.n()).done;)for(var k=x.value,E=k.key,T=k.params,C=k.order,M=0;M<=9;M++){if("number"!=typeof C)throw new Error("order property of ".concat(E," not found: ").concat(T));M===C&&dn[E].apply(dn,[r,b].concat(fn(T)))}}catch(t){_.e(t)}finally{_.f()}t[b]=null;var I=Object.keys(l);e(r,b,I)||(r.invalidValueIndex=b)}(o.some((function(t){var r=t.key;return"regressor"===r||"classifier"===r||"pca"===r}))||f)&&function(t){for(var r=t.inputParams,e=t.len,n=t.invalidValueIndex+1;n<e;n++){var o,i=pn(r);try{for(i.s();!(o=i.n()).done;)for(var a=o.value,l=a.key,u=a.params,c=a.order,s=10;s<=20;s++){if("number"!=typeof c)throw new Error("order property of ".concat(l," not found: ").concat(u));s===c&&("pca"===l&&ze.apply(void 0,[t,n].concat(fn(u))),"classifier"===l&&sn.apply(void 0,[t,n].concat(fn(u))),"regressor"===l&&Ge.apply(void 0,[t,n].concat(fn(u))))}}catch(t){i.e(t)}finally{i.f()}}}(r),u.push.apply(u,fn(Object.keys(l)))}(this.input,this),this.isComputed=!0,this.input=[],this.instances={},this.firstRow=[])),this}},{key:"crossPairs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="crossPairs";l(this),u(t,"arr",e),c(r,"options",e);var n=r.limit,o=void 0===n?null:n,i=r.oneHot,a=void 0!==i&&i;null!==o&&p(o,{min:2,max:this.len},"options.limit",e),f(a,"options.oneHot",e);var s,y=[],h=Mn(t);try{for(h.s();!(s=h.n()).done;){var v=s.value,d=v.fast,m=void 0===d?"":d,b=v.slow,g=void 0===b?"":b;if(""===m||""===g)throw new Error("Invalid crossPairs[".concat(m,"_").concat(g,"]: Object property “fast” must be a non-null column name and “slow” must be a non-null column name or integer."));y.push(m.toString(),g.toString())}}catch(t){h.e(t)}finally{h.f()}if(this.isAlreadyComputed.has(e))throw new Error('You can only call the "'.concat(e,'" method once.'));this.isAlreadyComputed.add(e);var w=wn(y,e);return this.inputParams.push({key:e,order:w,params:[t,{limit:o,oneHot:a}]}),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,e="lag";l(this),u(t,"colKeys",e),p(r,{min:1,max:this.len,allowDecimals:!1},"lookback",e);var n=wn(t,e);return this.inputParams.push({key:e,order:n,params:[t,r]}),this}},{key:"relativeVolume",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="relativeVolume";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.lag,o=void 0===n?0:n;return p(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),this.inputParams.push({key:e,order:0,params:[t,{lag:o}]}),this}},{key:"volumeDelta",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="volumeDelta";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeDelta" is called the input ohlcv must contain valid volume properties.');l(this),c(t,"options",r);var e=t.lag,n=void 0===e?0:e;return p(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),this.inputParams.push({key:r,order:0,params:[{lag:n}]}),this}},{key:"atr",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="atr";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.lag,o=void 0===n?0:n,i=r.percentage,a=void 0!==i&&i,u=r.upper,s=void 0===u?null:u,y=r.lower,h=void 0===y?null:y;return p(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),f(a,"options.percentage","atr"),null!==s&&p(s,{min:.001,max:100,allowDecimals:!0},"options.upper","atr"),null!==h&&p(h,{min:.001,max:100,allowDecimals:!0},"options.lower","atr"),this.inputParams.push({key:e,order:0,params:[t,{lag:o,percentage:a,upper:s,lower:h}]}),this}},{key:"ema",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="ema";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.target,o=void 0===n?"close":n,i=r.lag,a=void 0===i?0:i;h(o,"options.target",e),p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var u=wn([o],e);return this.inputParams.push({key:e,order:u,params:[e,t,{target:o,lag:a}]}),this}},{key:"sma",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="sma";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.target,o=void 0===n?"close":n,i=r.lag,a=void 0===i?0:i;h(o,"options.target",e),p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var u=wn([o],e);return this.inputParams.push({key:e,order:u,params:[e,t,{target:o,lag:a}]}),this}},{key:"heikenAshi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="heikenAshi";l(this);var o=null===t&&null===r;!1===o&&(p(t,{min:1,max:this.len,allowDecimals:!1},"smoothLength",n),p(r,{min:1,max:this.len,allowDecimals:!1},"afterSmoothLength",n)),c(e,"options",n);var i=e.lag,a=void 0===i?0:i;return p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),this.inputParams.push({key:n,order:0,params:[t,r,{lag:a,bothNull:o}]}),this}},{key:"vidya",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="vidya";l(this),p(t,{min:2,max:this.len,allowDecimals:!1},"size",n),p(r,{min:1,max:this.len,allowDecimals:!1},"momentum",n),c(e,"options",n);var o=e.target,i=void 0===o?"close":o,a=e.lag,u=void 0===a?0:a,s=e.atrLength,f=void 0===s?200:s,y=e.bandDistance,v=void 0===y?2:y,d=e.liquidityLookback,m=void 0===d?20:d;h(i,"options.target",n),p(u,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),p(v,{min:.01,max:10,allowDecimals:!0},"options.bandDistance",n),p(f,{min:2,max:this.len,allowDecimals:!1},"options.atrLength",n),p(m,{min:1,max:this.len,allowDecimals:!1},"options.liquidityLookback",n);var b=wn([i],n);return this.inputParams.push({key:n,order:b,params:[t,r,{target:i,lag:u}]}),this}},{key:"stochastic",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="stochastic",i=this.len;p(t,{min:1,max:i,allowDecimals:!1},"kPeriod",o),p(r,{min:1,max:i,allowDecimals:!1},"kSlowingPeriod",o),p(e,{min:1,max:i,allowDecimals:!1},"dPeriod",o),c(n,"options",o);var a=function(t){return t},l="",u=n.lag,s=void 0===u?0:u;p(s,{min:0,max:i,allowDecimals:!1},"options.lag",o);var h=n.minmax;return(Array.isArray(h)||"boolean"==typeof h&&!0===h)&&(Array.isArray(h)?(y(h,"options.minmax",o),a=function(t){return null!==h?ce(t,0,100,h):t}):(f(h,"options.minmax",o),h=[0,1],a=function(t){return null!==h?ce(t,0,100,h):t}),l="minmax_"),this.inputParams.push({key:o,order:0,params:[t,r,e,{minmax:h,prefix:l,parser:a,lag:s}]}),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="macd";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"fast",o),p(r,{min:1,max:this.len,allowDecimals:!1},"slow",o),p(e,{min:1,max:this.len,allowDecimals:!1},"signal",o),c(n,"options",o);var i=n.target,a=void 0===i?"close":i,u=n.lag,s=void 0===u?0:u;h(a,"options.target",o),p(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",o);var f={instanceKey:"".concat(t,"_").concat(r,"_").concat(e).concat("close"===a?"":"_".concat(a))},y=wn([a],o);return this.inputParams.push({key:o,order:y,params:[t,r,e,{target:a,lag:s,precomputed:f}]}),this}},{key:"bollingerBands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="bollingerBands";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",n),p(r,{min:.01,max:50,allowDecimals:!0},"stdDev",n),c(e,"options",n);var o=e.target,i=void 0===o?"close":o,a=e.height,s=void 0!==a&&a,y=e.range,v=void 0===y?[]:y,d=e.lag,m=void 0===d?0:d;h(i,"options.target",n),u(v,"options.range",n),p(m,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(s,"options.height",n);var b=wn([i],n);return this.inputParams.push({key:n,order:b,params:[t,r,{target:i,height:s,range:v,lag:m}]}),this}},{key:"rsi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e="rsi";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",e),c(r,"options",e);var n=r.target,o=void 0===n?"close":n,i=r.lag,a=void 0===i?0:i,u=r.minmax;h(o,"options.target",e),p(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var s=function(t){return t},v="";(Array.isArray(u)||"boolean"==typeof u&&!0===u)&&(Array.isArray(u)?(y(u,"options.minmax",e),s=function(t){return null!==u?ce(t,0,100,u):t}):(f(u,"options.minmax",e),u=[0,1],s=function(t){return null!==u?ce(t,0,100,u):t}),v="minmax_");var d=wn([o],e);return this.inputParams.push({key:e,order:d,params:[t,{target:o,lag:a,parser:s,prefix:v,minmax:u}]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="donchianChannels";l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"size",n),p(r,{min:0,max:this.len,allowDecimals:!1},"offset",n),c(e,"options",n);var o=e.height,i=void 0!==o&&o,a=e.range,s=void 0===a?[]:a,y=e.lag,h=void 0===y?0:y;return u(s,"options.range",n),p(h,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(i,"options.height",n),this.inputParams.push({key:n,order:0,params:[t,r,{height:i,range:s,lag:h}]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="volumeOscillator";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');l(this),p(t,{min:1,max:this.len,allowDecimals:!1},"fastsize",n),p(r,{min:t,max:this.len,allowDecimals:!1},"slowsize",n),c(e,"options",n);var o=e.lag,i=void 0===o?0:o;return p(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),this.inputParams.push({key:n,order:0,params:[t,r,{lag:i}]}),this}},{key:"dateTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r="dateTime";l(this),c(t,"options",r);var e=t.lag,n=void 0===e?0:e,o=t.oneHot,i=void 0!==o&&o;p(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),f(i,"options.oneHot",r);var a=i?"one_hot_":"",u=Cn(Cn(Cn(Cn(Cn({},"".concat(a,"month"),12),"".concat(a,"day_of_the_month"),31),"".concat(a,"day_of_the_week"),7),"".concat(a,"hour"),24),"".concat(a,"minute"),60),s={prefix:a,colKeySizes:u,colKeys:Object.keys(u)};return this.inputParams.push({key:r,order:0,params:[{lag:n,oneHot:i,precompute:s}]}),this}},{key:"scaler",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"zscore",r=arguments.length>1?arguments[1]:void 0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="scaler";l(this),p(r,{min:1,max:this.len,allowDecimals:!1},"size",n),c(e,"options",n);var o=e.group,i=void 0!==o&&o,a=e.range,h=void 0===a?[0,1]:a,v=e.lag,d=void 0===v?0:v,m=e.colKeys,b=void 0===m?[]:m;u(b,"options.colKeys",n),f(i,"options.group",n),y(h,"options.range",n),s(["minmax","zscore"],t,"options.type",n);var g={groupKey:"".concat(t,"_").concat(r),groupKeyLen:b.length},w=!1,S=wn(b,n);return S>=10&&(w=!0),this.inputParams.push({key:n,order:S,params:[r,b,{type:t,group:i,range:h,lag:d,precomputed:g,secondaryLoop:w}]}),this}},{key:"classifier",value:function(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l(this);var n="classifier";p(r,{max:this.len,allowDecimals:!1},"trainingSize",n),c(e,"options",n);var o=e.retrain,i=void 0!==o&&o,a=e.trainingCols,y=void 0===a?[]:a,h=e.type,v=void 0===h?"KNN":h,d=e.lookback,m=void 0===d?0:d,b=e.findGroups,g=void 0===b?[]:b,w=e.predictions,S=void 0===w?2:w,O=e.horizon,A=void 0===O?2:O,j=e.modelArgs,N=void 0===j?void 0:j,P=e.filterCallback,x=void 0===P?function(){return!0}:P;if(void 0!==N&&("object"!==Tn(N)||null===N||Array.isArray(N)))throw new TypeError('"modelArgs" must be either undefined or a plain object in '.concat(v));var _=null!==(t=e.yCallback)&&void 0!==t?t:xn;if("function"!=typeof _)throw new Error('"yCallback" must be a function in the following format:\n\n---\n\nconst yCallback = '.concat(xn.toString(),"\n\n---\n\n"));if(s(Object.keys(_n),v,"options.type",n),!this.ML.classes.hasOwnProperty(v))throw new Error('"'.concat(v,'" isn’t available because its library wasn’t imported into OHLCV_INDICATORS.ML.'));f(i,"options.retrain",n),u(y,"options.trainingCols",n),p(A,{min:1,max:this.len,allowDecimals:!1},"options.horizon",n),p(m,{max:0,allowDecimals:!1},"options.lookback",n),p(S,{min:1,allowDecimals:!1},"options.predictions",n);var k=In(y);if(u(g,"options.findGroups","scaler")&&g.length>0){var E,T=Mn(g);try{for(T.s();!(E=T.n()).done;){var C=E.value,M=C.type,I=void 0===M?"":M,D=C.size,R=C.groupName,L=void 0===R?"":R;if(!I||!D&&!L||D&&L)throw new Error('If "options.findGroups" array is set, each item must be an object that includes the "type" (mandatory) and either "size" or "groupName" (choose 1) used to locate previously scaled (minmax or zscore) groups.');k.push(I.toString(),L.toString())}}catch(t){T.e(t)}finally{T.f()}}else if(0===y.length)throw new Error('"trainingCols" array is empty in '.concat(n));var F=_n[v],B=F.shortName,z=F.flatY,U="cla_".concat(B,"_").concat(r,"_prediction");if(this.isAlreadyComputed.has(U))throw new Error("Each classifier must have a unique pair of “type” and trainingSize.\nThis rule ensures that your output columns are labeled unambiguously.\n"+'You provided a duplicate: type="'.concat(v,'" with trainingSize=').concat(r,"."));var Y={lookbackAbs:Math.abs(m)+1,flatY:z,prefix:U};this.isAlreadyComputed.add(U);var V=wn(k,n),q=_n[v],G=this.ML.classes[v];return this.inputParams.push({key:n,order:V,params:[r,{yCallback:_,predictions:S,lookback:m,retrain:i,trainingCols:y,findGroups:g,horizon:A,type:v,modelArgs:N,precompute:Y,filterCallback:x,modelConfig:q,modelClass:G}]}),this}},{key:"regressor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l(this);var e="regressor";p(t,{max:this.len,allowDecimals:!1},"trainingSize",e),c(r,"options",e);var n=r.retrain,o=void 0!==n&&n,i=r.target,a=void 0===i?"close":i,y=r.predictions,v=void 0===y?1:y,d=r.trainingCols,m=void 0===d?[]:d,b=r.type,g=void 0===b?"SimpleLinearRegression":b,w=r.lookback,S=void 0===w?0:w,O=r.findGroups,A=void 0===O?[]:O,j=r.modelArgs,N=void 0===j?void 0:j,P=r.filterCallback,x=void 0===P?function(){return!0}:P;if(s(Object.keys(kn),g,"type",e),!this.ML.classes.hasOwnProperty(g))throw new Error('"'.concat(g,'" isn’t available because its library wasn’t imported into OHLCV_INDICATORS.ML.'));f(o,"options.retrain",e),h(a,"options.target",e),p(v,{min:1,allowDecimals:!1},"predictions",e),p(S,{max:0,allowDecimals:!1},"lookback",e),u(m,"options.trainingCols",e);var _=kn[g],k=_.shortName,E=_.flatX,T=_.flatY,C="reg_".concat(k,"_").concat(t,"_").concat(a,"_prediction"),M=In(m);if(u(A,"options.findGroups","scaler")&&A.length>0){var I,D=Mn(A);try{for(D.s();!(I=D.n()).done;){var R=I.value,L=R.type,F=void 0===L?"":L,B=R.size,z=R.groupName,U=void 0===z?"":z;if(!F||!B&&!U||B&&U)throw new Error('If "options.findGroups" array is set, each item must be an object that includes the "type" (mandatory) and either "size" or "groupName" (choose 1) used to locate previously scaled (minmax or zscore) groups.');M.push(F.toString(),U.toString())}}catch(t){D.e(t)}finally{D.f()}}else if(0===m.length&&!1===E)throw new Error('"trainingCols" array is empty in '.concat(e," ").concat(g));if(E){if(m.length>0)throw new Error("If regressor type is ".concat(g,' then leave "options.trainingCols" array empty.'));if(S>0)throw new Error("If regressor type is ".concat(g,' then "options.lookback" must be 0.'));if(A.length>0)throw new Error("If regressor type is ".concat(g,' then "options.findGroups" must be null.'));m.push(a)}if(this.isAlreadyComputed.has(C))throw new Error('Each regressor must have a unique "type", "trainingSize" and "target".\nThis rule ensures that your output columns are labeled unambiguously.\n'+'You provided a duplicate: type="'.concat(g,'", trainingSize=').concat(t," target=").concat(a,"."));var Y={lookbackAbs:Math.abs(S)+1,flatX:E,flatY:T,prefix:C};this.isAlreadyComputed.add(C);var V=wn(M,e),q=kn[g],G=this.ML.classes[g];return this.inputParams.push({key:e,order:V,params:[t,{target:a,predictions:v,retrain:o,lookback:S,trainingCols:m,findGroups:A,type:g,modelArgs:N,precompute:Y,filterCallback:x,modelConfig:q,modelClass:G}]}),this}},{key:"pca",value:function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="pca";p(r,{min:1,max:this.len},"trainingSize",n),h(t,"suffix",n),c(e,"options",n);var o=e.findGroups,i=void 0===o?[]:o,a=e.trainingCols,l=void 0===a?[]:a,y=e.lookback,v=void 0===y?0:y,d=e.filterCallback,m=void 0===d?function(){return!0}:d;u(l,"options.trainigCols",n),p(v,{min:0,max:this.len,allowDecimals:!1},"options.lookback",n),void 0!==e.modelArgs?c(e.modelArgs,"options.modelArgs",n):e.modelArgs={};var b=function(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?En(Object(e),!0).forEach((function(r){Cn(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):En(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}({showSource:!1,storeModel:!1,isCovarianceMatrix:!1,method:"NIPALS",center:!0,scale:!1,nCompNIPALS:5,ignoreZeroVariance:!1},e.modelArgs);f(b.showSource,"options.modelArgs.showSource",n),f(b.storeModel,"options.modelArgs.storeModel",n),f(b.isCovarianceMatrix,"options.modelArgs.isCovarianceMatrix",n),f(b.center,"options.modelArgs.center",n),f(b.scale,"options.modelArgs.scale",n),f(b.ignoreZeroVariance,"options.modelArgs.ignoreZeroVariance",n),s(["SVD","NIPALS","covarianceMatrix"],b.method,"options.modelArgs.method",n),p(b.nCompNIPALS,{min:1},"options.modelArgs.nCompNIPALS",n);var g=[];if(u(i,"options.findGroups","pca")&&i.length>0){var w,S=Mn(i);try{for(S.s();!(w=S.n()).done;){var O=w.value,A=O.type,j=void 0===A?"":A,N=O.size,P=O.groupName,x=void 0===P?"":P;if(!j||!N&&!x||N&&x)throw new Error('If "options.findGroups" array is set, each item must be an object that includes the "type" (mandatory) and either "size" or "groupName" (choose 1) used to locate previously scaled (minmax or zscore) groups.');g.push(j.toString(),x.toString())}}catch(t){S.e(t)}finally{S.f()}}var _=wn(g,n),k="pca_".concat(t,"_").concat(r);if(this.isAlreadyComputed.has(k))throw new Error('Each regressor must have a unique "suffix" param.\nThis rule ensures that your output columns are labeled unambiguously.\n'+'You provided a duplicate: type="'.concat(t,'".'));var E=Math.abs(v)+1;return this.isAlreadyComputed.add(k),this.inputParams.push({key:n,order:_,params:[{prefix:k,trainingSize:r,findGroups:i,trainingCols:l,lookbackAbs:E,modelArgs:b,filterCallback:m}]}),this}},{key:"exportTrainedModels",value:function(){return function(t){var r,e,n,o=t.ML,i=t.inputParams,a=o.models,l={},u=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Nn(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){l=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(l)throw i}}}}(i);try{for(u.s();!(r=u.n()).done;){var c=r.value,s=c.key,f=c.params;if("classifier"===s||"regressor"===s){var p=(n=2,function(t){if(Array.isArray(t))return t}(e=f)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,a,l=[],u=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;u=!1}else for(;!(u=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw o}}return l}}(e,n)||Nn(e,n)||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.")}()),y=(p[0],p[1]),h=y.type,v=y.predictions,d=y.precompute,m=d.flatY,b=d.prefix,g=m?v:1,w=void 0;"regressor"===s?w=kn[h].exportModel:"classifier"===s&&(w=_n[h].exportModel);for(var S=0;S<g;S++){var O="".concat(b,"_").concat(S+1);l[O]=w(a[O])}}}}catch(t){u.e(t)}finally{u.f()}return l}(this)}},{key:"mapCols",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["change"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};l(this);var n="mapCols";null==r&&(r=Me),c(e,"options",n);var o=e.lag,i=void 0===o?0:o,a=e.isPriceBased,s=void 0!==a&&a;if(u(t,"newCols",n),p(i,{min:0,allowDecimals:!1},"options.lag",n),f(s,"isPriceBased","mapCols"),!1===this.precision&&s)throw new Error('Invalid param: If "mapCols.options.isPriceBased" is true, the "constructor.precision" param must be also true.');var y=wn(t,n);return this.inputParams.push({key:n,order:y,params:[t,r,{lag:i,isPriceBased:s}]}),this}}],r&&Ln(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}()})(),OHLCV_INDICATORS=r})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohlcv-indicators",
3
- "version": "3.5.55",
3
+ "version": "3.5.56",
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",
@@ -8,8 +8,6 @@ const indicatorClasses = {
8
8
 
9
9
  export const movingAverages = (main, index, methodName, size, { target, lag }) => {
10
10
 
11
-
12
-
13
11
  const { verticalOhlcv, instances, priceBased } = main
14
12
  const suffix = (target !== 'close') ? `_${target}` : ''
15
13
  const keyName = `${methodName}_${size}${suffix}`
@@ -2,8 +2,6 @@ import { FasterSMA } from 'trading-signals';
2
2
 
3
3
  export const relativeVolume = (main, index, size, {lag}) => {
4
4
 
5
-
6
-
7
5
  const key = `relative_volume_${size}`;
8
6
  const { instances, verticalOhlcv } = main;
9
7
 
@@ -9,11 +9,11 @@ export const vidya = (main, index, size, momentum, options = {}) => {
9
9
  // Initialization on the first bar
10
10
  if (index === 0) {
11
11
  if (!(target in verticalOhlcv)) {
12
- throw new Error(`VIDYA could not find target "${target}"`);
12
+ throw new Error(`VIDYA could not find target "${target}"`)
13
13
  }
14
14
 
15
- const prefix = `vidya_${indicatorKey}`;
16
- const keyBase = target === 'close' ? prefix : `${prefix}_${target}`;
15
+ const prefix = `vidya_${indicatorKey}`
16
+ const keyBase = target === 'close' ? prefix : `${prefix}_${target}`
17
17
  const keys = {
18
18
  vidya: keyBase,
19
19
  upper: `${prefix}_upper`,
@@ -21,7 +21,7 @@ export const vidya = (main, index, size, momentum, options = {}) => {
21
21
  delta_vol: `${prefix}_delta_vol`,
22
22
  cross: `${prefix}_cross`,
23
23
  liquidity: `${prefix}_liquidity`,
24
- };
24
+ }
25
25
 
26
26
  const priceBasedVidyaKeys = [keyBase, keys.upper, keys.lower, keys.liquidity]
27
27
 
@@ -63,13 +63,13 @@ export const vidya = (main, index, size, momentum, options = {}) => {
63
63
  };
64
64
 
65
65
  // Series inputs
66
- const price = verticalOhlcv[target][index];
67
- const high = verticalOhlcv.high[index];
68
- const low = verticalOhlcv.low[index];
69
- const close = verticalOhlcv.close[index];
70
- const open = verticalOhlcv.open[index];
71
- const vol = verticalOhlcv.volume[index];
72
- const prevCross = index > 0 ? verticalOhlcv[keys.cross][index - 1] : 0;
66
+ const price = verticalOhlcv[target][index]
67
+ const high = verticalOhlcv.high[index]
68
+ const low = verticalOhlcv.low[index]
69
+ const close = verticalOhlcv.close[index]
70
+ const open = verticalOhlcv.open[index]
71
+ const vol = verticalOhlcv.volume[index]
72
+ const prevCross = index > 0 ? verticalOhlcv[keys.cross][index - 1] : 0
73
73
 
74
74
  const highestHigh = (inst.liquidity.high.length === liquidityLookback) ? Math.max(...inst.liquidity.high) : NaN
75
75
  const lowestLow = (inst.liquidity.low.length === liquidityLookback) ? Math.min(...inst.liquidity.low) : NaN
@@ -81,77 +81,77 @@ export const vidya = (main, index, size, momentum, options = {}) => {
81
81
  high - low,
82
82
  Math.abs(high - prevClose),
83
83
  Math.abs(low - prevClose)
84
- );
85
- inst.atrBuffer.push(tr);
86
- if (inst.atrBuffer.length > atrLength) inst.atrBuffer.shift();
84
+ )
85
+ inst.atrBuffer.push(tr)
86
+ if (inst.atrBuffer.length > atrLength) inst.atrBuffer.shift()
87
87
  }
88
88
  const atr = inst.atrBuffer.length === atrLength
89
89
  ? inst.atrBuffer.reduce((a, b) => a + b, 0) / atrLength
90
- : NaN;
90
+ : NaN
91
91
 
92
92
  // Compute raw VIDYA
93
- let rawVidya = NaN;
94
- let mom = NaN;
95
- if (index > 0) mom = price - verticalOhlcv[target][index - 1];
96
- inst.momentumBuffer.push(mom);
97
- if (inst.momentumBuffer.length > momentum) inst.momentumBuffer.shift();
93
+ let rawVidya = NaN
94
+ let mom = NaN
95
+ if (index > 0) mom = price - verticalOhlcv[target][index - 1]
96
+ inst.momentumBuffer.push(mom)
97
+ if (inst.momentumBuffer.length > momentum) inst.momentumBuffer.shift()
98
98
  if (inst.momentumBuffer.length === momentum) {
99
- let sumPos = 0, sumNeg = 0;
99
+ let sumPos = 0, sumNeg = 0
100
100
  inst.momentumBuffer.forEach(m => m >= 0 ? sumPos += m : sumNeg += -m);
101
- const denom = sumPos + sumNeg;
101
+ const denom = sumPos + sumNeg
102
102
  const cmo = denom === 0 ? 0 : Math.abs((sumPos - sumNeg) / denom) * 100;
103
- const alpha = 2 / (size + 1);
104
- const a = alpha * (cmo / 100);
103
+ const alpha = 2 / (size + 1)
104
+ const a = alpha * (cmo / 100)
105
105
  rawVidya = isNaN(inst.prevVidya) ? price : (a * price + (1 - a) * inst.prevVidya);
106
- inst.prevVidya = rawVidya;
106
+ inst.prevVidya = rawVidya
107
107
  }
108
108
 
109
109
  // Smooth VIDYA using fixed 15-bar SMA
110
- inst.sma.update(rawVidya);
111
- let smoothedVidya = NaN;
112
- try { smoothedVidya = inst.sma.getResult(); } catch {}
110
+ inst.sma.update(rawVidya)
111
+ let smoothedVidya = NaN
112
+ try { smoothedVidya = inst.sma.getResult() } catch {}
113
113
 
114
114
  // Bands
115
115
  const upper = (!isNaN(atr) && !isNaN(smoothedVidya))
116
116
  ? smoothedVidya + atr * bandDistance
117
- : NaN;
117
+ : NaN
118
118
  const lower = (!isNaN(atr) && !isNaN(smoothedVidya))
119
119
  ? smoothedVidya - atr * bandDistance
120
- : NaN;
120
+ : NaN
121
121
 
122
122
  // Detect crosses
123
- const prevPrice = index > 0 ? verticalOhlcv[target][index - 1] : NaN;
124
- const prevUpper = index > 0 ? verticalOhlcv[keys.upper][index - 1] : NaN;
125
- const prevLower = index > 0 ? verticalOhlcv[keys.lower][index - 1] : NaN;
126
- const crossUp = index > 0 && prevPrice <= prevUpper && price > upper;
127
- const crossDown = index > 0 && prevPrice >= prevLower && price < lower;
123
+ const prevPrice = index > 0 ? verticalOhlcv[target][index - 1] : NaN
124
+ const prevUpper = index > 0 ? verticalOhlcv[keys.upper][index - 1] : NaN
125
+ const prevLower = index > 0 ? verticalOhlcv[keys.lower][index - 1] : NaN
126
+ const crossUp = index > 0 && prevPrice <= prevUpper && price > upper
127
+ const crossDown = index > 0 && prevPrice >= prevLower && price < lower
128
128
 
129
129
  // Update trend state
130
- if (crossUp) inst.isTrendUp = true;
131
- if (crossDown) inst.isTrendUp = false;
130
+ if (crossUp) inst.isTrendUp = true
131
+ if (crossDown) inst.isTrendUp = false
132
132
 
133
133
  // Cumulative cross counter: positive when uptrend, negative when downtrend
134
134
  let cross = 0;
135
135
  if (index > 0) {
136
136
  if (inst.isTrendUp) {
137
- cross = prevCross > 0 ? prevCross + 1 : 1;
137
+ cross = prevCross > 0 ? prevCross + 1 : 1
138
138
  } else {
139
- cross = prevCross < 0 ? prevCross - 1 : -1;
139
+ cross = prevCross < 0 ? prevCross - 1 : -1
140
140
  }
141
141
  }
142
142
 
143
143
  // Volume accumulation
144
144
  if (crossUp || crossDown) {
145
- inst.upVol = inst.downVol = 0;
145
+ inst.upVol = inst.downVol = 0
146
146
  } else {
147
- inst.upVol += (close > open ? vol : 0);
148
- inst.downVol += (close < open ? vol : 0);
147
+ inst.upVol += (close > open ? vol : 0)
148
+ inst.downVol += (close < open ? vol : 0)
149
149
  }
150
- const avgVol = (inst.upVol + inst.downVol) / 2 || 1;
151
- const deltaPct = (inst.upVol - inst.downVol) / avgVol;
150
+ const avgVol = (inst.upVol + inst.downVol) / 2 || 1
151
+ const deltaPct = (inst.upVol - inst.downVol) / avgVol
152
152
 
153
153
  // Trend-based boundary (reset on crossover)
154
- const trendValue = (inst.isTrendUp) ? lower : upper;
154
+ const trendValue = (inst.isTrendUp) ? lower : upper
155
155
  let liquidity = NaN
156
156
 
157
157
  if(cross > 0)
@@ -164,12 +164,12 @@ export const vidya = (main, index, size, momentum, options = {}) => {
164
164
  }
165
165
 
166
166
  // Push outputs
167
- main.pushToMain({ index, key: keys.vidya, value: trendValue });
168
- main.pushToMain({ index, key: keys.upper, value: upper });
169
- main.pushToMain({ index, key: keys.lower, value: lower });
170
- main.pushToMain({ index, key: keys.delta_vol, value: deltaPct });
171
- main.pushToMain({ index, key: keys.cross, value: cross });
172
- main.pushToMain({ index, key: keys.liquidity, value: liquidity });
167
+ main.pushToMain({ index, key: keys.vidya, value: trendValue })
168
+ main.pushToMain({ index, key: keys.upper, value: upper })
169
+ main.pushToMain({ index, key: keys.lower, value: lower })
170
+ main.pushToMain({ index, key: keys.delta_vol, value: deltaPct })
171
+ main.pushToMain({ index, key: keys.cross, value: cross })
172
+ main.pushToMain({ index, key: keys.liquidity, value: liquidity })
173
173
 
174
174
  inst.liquidity.high.push(high)
175
175
  inst.liquidity.low.push(low)
@@ -177,5 +177,5 @@ export const vidya = (main, index, size, momentum, options = {}) => {
177
177
  if(inst.liquidity.high.length > liquidityLookback) inst.liquidity.high.shift()
178
178
  if(inst.liquidity.low.length > liquidityLookback) inst.liquidity.low.shift()
179
179
 
180
- return true;
181
- };
180
+ return true
181
+ }
@@ -1,39 +1,56 @@
1
1
 
2
- //calcPrecisionMultiplier is calculated once, using the open, high, low and close values of the first row
3
- //the multiplier (min 10000 and max 1000000000) is store in constructor
2
+ //calcPrecisionMultiplier is calculated once in the class constructor, using the open, high, low and close values of the first row
3
+ //the multiplier (min 10000) is store in constructor
4
4
 
5
5
  export const calcPrecisionMultiplier = main => {
6
- const { precision, firstRow, initialPriceBased, priceBased } = main;
6
+ const { precision, firstRow, initialPriceBased } = main
7
7
  if (precision === false) return 1
8
8
 
9
- const multipliers = []
10
-
11
- const err = 'If "precision" is set to true all the "open", "high", "low" and "close" values must be numeric strings like "123.45" with no commas or currency symbols.'
9
+ let maxMultiplier = 1
12
10
 
13
11
  for (const [key, strNum] of Object.entries(firstRow)) {
12
+ if (!initialPriceBased.has(key)) continue
14
13
 
15
- if(!initialPriceBased.has(key)) continue
16
-
17
- if (typeof strNum !== 'string' || !/^-?\d+(\.\d+)?$/.test(strNum)) {
18
- throw new Error(`${err}
19
- Property "${key}" had the value "${strNum}" type ${typeof strNum}.`)
14
+ if (typeof strNum !== 'string' || !/^\d+(\.\d+)?$/.test(strNum)) {
15
+ throw new Error(
16
+ `If "precision" is set to true all the "open", "high", "low" and "close" values must be numeric strings like "123.45" with no commas or currency symbols. Property "${key}" had the value "${strNum}" type ${typeof strNum}.`
17
+ )
20
18
  }
21
19
 
22
- if (!priceBased.has(key)) continue
23
-
24
20
  const [integerStr, decimals = ''] = strNum.split('.')
25
21
  const integer = Number(integerStr)
26
- const decimalPrecision = integer > 0 ? 4 : Math.max(4, decimals.length)
27
- multipliers.push(Math.pow(10, decimalPrecision))
28
- }
29
22
 
30
- if (multipliers.length === 0) return 1
23
+ let decimalPrecision = 4
24
+
25
+ // Treat any non-zero integer (positive or negative) as "normal"
26
+ if (Math.abs(integer) === 0) {
27
+ const decimalsLen = decimals.length
28
+ const countDecimals = Math.max(4, decimalsLen)
29
+
30
+ // index of first non-zero decimal digit, -1 if none
31
+ const firstNonZeroIndex = decimals.search(/[1-9]/)
32
+
33
+ if (firstNonZeroIndex === -1) {
34
+ // 0, 0.0, 0.0000... -> nothing special to preserve
35
+ decimalPrecision = countDecimals
36
+ } else {
37
+ // Give extra headroom after the first non-zero digit
38
+ const extra = 5 // tweak as you like
39
+ const needed = firstNonZeroIndex + 1 + extra
40
+ decimalPrecision = Math.max(countDecimals, needed)
41
+ }
42
+ }
31
43
 
32
- const maxMultiplier = 10 ** 9 //1000000000
44
+ // Optional: cap exponent to keep numbers sane
45
+ const multiplier = 10 ** decimalPrecision
33
46
 
34
- return Math.min(maxMultiplier, Math.max(...multipliers))
47
+ if (multiplier > maxMultiplier) maxMultiplier = multiplier
48
+ }
49
+
50
+ return maxMultiplier
35
51
  }
36
52
 
53
+
37
54
  //this function converts the strNum into a integer * multiplier
38
55
  export const addPrecisionAsNumber = (strNum, multiplier) => {
39
56
  if (typeof strNum !== 'string') throw new Error('addPrecisionExact expects a string when precision=true')