ohlcv-indicators 3.5.48 → 3.5.50
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:()=>Pn});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},y=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},p=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(y(l,{min:-100,max:c,allowDecimals:!1},"min",e),y(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,y=o.slice(),p=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,y.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:y;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[p]||0:d=[n[p]]}while((p++<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,y=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-y){for((o=l<0)?(l=-l,n=c):(y=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(),--y;return c[0]||(t.s=1,c=[y=0]),t.c=c,t.e=y,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=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,Y()?Reflect.construct(r,e||[],U(t).constructor):r.apply(t,e))}function Y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Y=function(){return!!t})()}function U(t){return U=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},U(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 B(t){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(t)}function 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"==B(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"!=B(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=B(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==B(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}(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=pt(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,yt()?Reflect.construct(r,e||[],pt(t).constructor):r.apply(t,e))}function yt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(yt=function(){return!!t})()}function pt(t){return pt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},pt(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&>(e.prototype,n),o&>(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 Yt=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 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 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"!=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 Bt=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 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 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 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 pr(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"!=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+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}var dr={ema:Yt,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 y=l[i][r],p=u[s];p.update(y);var h=NaN;try{h=p.getResult()}catch(t){}return t.pushToMain({index:r,key:s,value:h}),!0};function br(t){return function(t){if(Array.isArray(t))return gr(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 gr(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)?gr(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 gr(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 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 Sr(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=wr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=wr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}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}var Ar="close";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)}var Nr={number:function(t){return t},numberCleanString:function(t){return Number(t)},numberDirtyString:function(t){return Number(t.replace(/(?!^-)[^0-9.]/g,""))}},Pr=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 jr(t)},xr=function(t,r){var e=Math.pow(10,r);return Math.round((t+Number.EPSILON)*e)/e};function _r(t){return function(t){if(Array.isArray(t))return Er(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||kr(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 kr(t,r){if(t){if("string"==typeof t)return Er(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)?Er(t,r):void 0}}function Er(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 Cr(t){return Cr="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},Cr(t)}function Tr(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 Ir(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Cr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Cr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Cr(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Mr(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 Dr(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)?Dr(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 Dr(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 Rr="close";function Lr(t){return Lr="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},Lr(t)}function Fr(t){return Fr="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},Fr(t)}var zr={string:function(t){return t.toISOString()},milliseconds:function(t){return t.getTime()},seconds:function(t){return t.getTime()/1e3},object:function(t){return t}},Yr={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)}},Ur=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(Fr(t),'" date value passed in selectDateFormatter. Supported formats: \n-').concat(r.join("\n- ")))};if("object"===Fr(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 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)}function Vr(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 Gr(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)?Gr(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 Gr(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 Br=new Set(["open","high","low","close"]),Hr=function(t,r){var e={Array,Float64Array,Float32Array,Int32Array,Uint8Array,Int8Array,Int16Array}[t];if(!e||"function"!=typeof e.from)throw new Error("Unsupported array type: ".concat(t));var n="Array"===t?null:NaN;return e.from({length:r},(function(){return n}))},$r=function(t,r){if(!r||"object"!==qr(r))throw new TypeError('Invalid array type: "'.concat(t,'"'));return r.constructor.name};function Xr(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 Kr(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)?Kr(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 Kr(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 function(t){if(Array.isArray(t))return Zr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Wr(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 Wr(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}}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 Qr=function(t,r){var e=new Uint8Array(r);return e[t]=1,e},te=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"))},re=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)||Wr(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},ee=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,Jr(r[s]))}return e},ne=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=Wr(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},oe=function(t){var r=t.trainingCols,e=t.findGroups,n=t.verticalOhlcv,o=t.scaledGroups,i=[].concat(Jr(r),Jr(ee(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},ie=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 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 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 ue(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,ce(n.key),n)}}function ce(t){var r=function(t,r){if("object"!=le(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=le(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==le(r)?r:r+""}var se=function(t,r){return t>r},fe=function(t,r){return t<r},ye=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:se(e,o)?a=this.areHighAndLowUndefined?1:[i,o,this.prevLow,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&fe(i,o)&&se(this.prevLow,this.prevSlow)?0:1:fe(e,o)&&(a=this.areHighAndLowUndefined?0:[n,o,this.prevHigh,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&se(n,o)&&fe(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}}])&&ue(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}();function pe(t){return pe="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},pe(t)}function he(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)||be(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 ve(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 de(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?ve(Object(e),!0).forEach((function(r){me(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):ve(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function me(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=pe(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=pe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pe(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function be(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}function we(t){return function(t){if(Array.isArray(t))return Oe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Se(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 Se(t,r){if(t){if("string"==typeof t)return Oe(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)?Oe(t,r):void 0}}function Oe(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 Ae(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 Ne=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 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}var xe=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 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}}(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 y=l[f][i].length,p=0;p<y;p++)c.push({key:f,bit:p});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 _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}var Ce="pca",Te=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,y=t.scaledGroups,p=t.len,h=t.instances,v=t.ML,d=t.invalidValueIndex+2,m=v.models;if(r===d)h.hasOwnProperty(Ce)||(h[Ce]={}),h[Ce][o]={flatFeaturesColLen:0,featureCols:[],X:[]},f[o]=new Array(p).fill(null);else{if(r<d||r<u)return;if(!1===s(f,r))return;if(r+1===p){if(0===h[Ce][o].featureCols.length){var b=[].concat(_e(l),_e(ee(a,y)));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=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}}}}(h[Ce][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[Ce][o].X.length<i){var O=h[Ce][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[Ce][o];if(0===A.flatFeaturesColLen){if(A.featureCols=oe({trainingCols:l,findGroups:a,verticalOhlcv:f,scaledGroups:y}),!e(t,r,A.featureCols))return;A.flatFeaturesColLen=ne(A.featureCols,f,r)}if(0!==A.flatFeaturesColLen){var j=A.X,N=A.featureCols,P=A.flatFeaturesColLen,x=xe({featureCols:N,flatFeaturesColLen:P,type:Ce,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 Ie(t){return Ie="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},Ie(t)}function Me(t){return function(t){if(Array.isArray(t))return Re(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||De(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function De(t,r){if(t){if("string"==typeof t)return Re(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)?Re(t,r):void 0}}function Re(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,n,o){var i=o.target,a=o.predictions,l=o.retrain,u=o.trainingCols,c=o.findGroups,s=o.type,f=o.modelArgs,y=o.precompute,p=o.filterCallback,h=o.modelConfig,v=o.modelClass,d=y.lookbackAbs,m=y.prefix,b=y.flatX,g=y.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===p(w,r))return;if(r+1===S){if(0===O.regressor[m].featureCols.length){var E=[].concat(Me(u),Me(ee(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=De(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=oe({trainingCols:u,findGroups:c,verticalOhlcv:w,scaledGroups:A}),!e(t,r,D.featureCols))return;D.flatFeaturesColLen=ne(D.featureCols,w,r),te({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,Y=D.featureCols,U=D.shouldRetrain;if(!Y.includes(i))throw new Error('Target property "'.concat(i,'" not found in ').concat(s," features: ").concat(JSON.stringify(Y)));var q=b?w[i][r]:xe({featureCols:Y,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 B=w[i][r+G+1];if(!Number.isFinite(B))break;V.push(B)}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([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(Ie(W)," at index ").concat(r))}else{if(!Array.isArray(W))throw new Error("currTrainY must return an array, got ".concat(Ie(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()),(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 Fe(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=ze(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 ze(t,r){if(t){if("string"==typeof t)return Ye(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)?Ye(t,r):void 0}}function Ye(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 Ue=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},qe=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=Fe(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=[],y=Fe(n.entries());try{for(y.s();!(l=y.n()).done;)for(var p=(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)||ze(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=p[0],v=p[1],d=v.length,m=0;m<o;m++)s.push(v[m%d]),f.push(h)}catch(t){y.e(t)}finally{y.f()}return{X:s,Y:f}};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 Ge(t){return function(t){if(Array.isArray(t))return He(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Be(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Be(t,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}}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}var $e="classifier",Xe=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,y=o.horizon,p=o.precompute,h=o.predictions,v=o.filterCallback,d=o.modelConfig,m=o.modelClass,b=p.lookbackAbs,g=p.prefix,w=p.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($e)||(A[$e]={}),A[$e].hasOwnProperty(g)||(A[$e][g]={});var k=w?h:1;A[$e][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[$e][g].featureCols.length){var T=[].concat(Ge(a),Ge(ee(u,j)));throw new Error("Some of the provided features in ".concat($e,' "').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=Be(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[$e][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[$e][g].X.length<n){var R=A[$e][g].X.length-n;throw new Error('The current "trainingSize" at '.concat($e,' "').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[$e][g];if(0===L.flatFeaturesColLen){if(L.featureCols=oe({trainingCols:a,findGroups:u,verticalOhlcv:S,scaledGroups:j}),!e(t,r,L.featureCols))return;L.flatFeaturesColLen=ne(L.featureCols,S,r),te({featureCols:L.featureCols,flatFeaturesColLen:L.flatFeaturesColLen,type:s,trainingSize:n})}if(0!==L.flatFeaturesColLen){var F=L.uniqueLabels,z=L.expectedLoops,Y=L.featureCols,U=L.flatFeaturesColLen,q=L.shouldRetrain,V=L.X,G=xe({featureCols:Y,flatFeaturesColLen:U,type:s,index:r,lookbackAbs:b,main:t});if(G){var B=i(r,S,y);if(null!==B&&(!Array.isArray(B)||B.length!==h))throw new Error("trainY must be null or an array with ".concat(h,' items, got "').concat(JSON.stringify(B),'" at index ').concat(r," for ").concat(s));for(var H=0;H<z;H++){var $="".concat(g,"_").concat(H+1),X=L.Y[H],K=w?null===B?null:B[H]:B,J=L.isTrained[H];if(x.hasOwnProperty($)&&J&&(!1===q||x[$].length===y)){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&&ie({metrics:P.metrics[$],trueLabel:K,predictedLabel:W})}else{if(!Array.isArray(W)||W.length!==h)throw new Error("Prediction output of ".concat($e,' "').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&&ie({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(Ve(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($e,' "').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(G),V.length>n&&V.shift()),(q||!J)&&V.length===n&&X.length===n){if(!1===J&&(F[H]=Ue(X),F[H]<2))throw new Error("Invalid number or labels in ".concat(g,'. Check the logic of your "yCallback" function.'));var Q=d.train,tt=qe(V,X),rt=Q({modelClass:m,xRows:tt.X,yRows:tt.Y,modelArgs:f,uniqueLabels:F[H]});x[$].push(rt),x[$].length>y&&x[$].shift(),L.isTrained[H]=!0}}}return!0}}};function Ke(t){return function(t){if(Array.isArray(t))return Qe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ze(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Je(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Ze(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 We(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)||Ze(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 Ze(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 tn={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(),y=(new Date).getUTCFullYear();Object.assign(l,{dateTime:{colKeys:[].concat((n=a.colKeys,function(t){if(Array.isArray(t))return ge(t)}(n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||be(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:de(de({},a.colKeySizes),{},me({},"".concat(c,"year"),y-f+1)),startYear:f}});var p,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=be(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();!(p=m.n()).done;)u[p.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?Qr(t,e):t},a=me(me(me(me(me(me({},"".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=he(u[l],2),s=c[0],f=c[1],y=s==="".concat(n,"year")?a[s]-o:a[s];a[s]=i(y,f)}return a}(u.date[r],i,g,c,w),O=0,A=Object.entries(S);O<A.length;O++){var j=he(A[O],2),N=j[0],P=j[1];t.pushToMain({index:r,key:N,value:P})}},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),y="".concat(l,"rsi_").concat(e).concat(f),p="".concat(l,"rsi_sma_").concat(e).concat(f);if(0===r){var h=t.len;if(t.arrayTypes,!c.hasOwnProperty(o))throw new Error("Target property ".concat(o," not found in verticalOhlcv for rsi."));Object.assign(s,fr(fr({},y,new tr(e)),p,new Z(e))),Object.assign(c,fr(fr({},y,new Float64Array(h).fill(NaN)),p,new Float64Array(h).fill(NaN)));var v=[y,p];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[y].update(w);try{S=s[y].getResult()}catch(t){S=NaN}t.pushToMain({index:r,key:y,value:Number.isNaN(S)?NaN:a(S)}),Number.isNaN(S)||s[p].update(S);try{O=s[p].getResult()}catch(t){O=NaN}t.pushToMain({index:r,key:p,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,y=14===e&&3===n&&3===o?"":"".concat(e,"_").concat(n,"_").concat(o),p="".concat(l,"stoch_d").concat(y),h="".concat(l,"stoch_k").concat(y),v="".concat(l).concat(y);if(0===r){var d=t.len;t.arrayTypes,Object.assign(f,vr({},v,new lr(e,n,o))),Object.assign(s,vr(vr({},p,new Float64Array(d).fill(NaN)),h,new Float64Array(d).fill(NaN)));var m=[p,h];u>0&&t.lag(m,u);var b=u>0?m.flatMap((function(t){return[t].concat(pr(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,pr(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:p,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,y=t.verticalOhlcv,p=(t.arrayTypes,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++)y[d[v]]=new Float64Array(p).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=(t.arrayTypes,o.target),c=o.lag,s=o.atrLength,f=void 0===s?200:s,y=o.bandDistance,p=void 0===y?2:y,h=o.liquidityLookback,v=void 0===h?20: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,br(g.liquidity.high)):NaN,E=g.liquidity.low.length===v?Math.min.apply(Math,br(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 Y=NaN;try{Y=g.sma.getResult()}catch(t){}var U=isNaN(I)||isNaN(Y)?NaN:Y+I*p,q=isNaN(I)||isNaN(Y)?NaN:Y-I*p,V=r>0?i[u][r-1]:NaN,G=r>0?i[S.upper][r-1]:NaN,B=r>0?i[S.lower][r-1]:NaN,H=r>0&&V<=G&&O>U,$=r>0&&V>=B&&O<q;H&&(g.isTrendUp=!0),$&&(g.isTrendUp=!1);var X=0;r>0&&(X=g.isTrendUp?_>0?_+1:1:_<0?_-1:-1),H||$?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:U,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:U}),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 y=t.inputParams,p=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 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}}(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(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===Ar?"".concat(m,"_diff"):"".concat(m,"_diff_").concat(a),g=a===Ar?"".concat(m,"_dea"):"".concat(m,"_dea_").concat(a),w=a===Ar?"".concat(m,"_histogram"):"".concat(m,"_histogram_").concat(a);s.hasOwnProperty("macd")||(s.macd={numberOfIndicators:v,settings:{}}),s.macd.settings[f]=new Bt(new Yt(e),new Yt(n),new Yt(o)),Object.assign(c,Sr(Sr(Sr({},b,new Float64Array(p).fill(NaN)),g,new Float64Array(p).fill(NaN)),w,new Float64Array(p).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===Ar?"".concat(N,"_diff"):"".concat(N,"_diff_").concat(a),x=a===Ar?"".concat(N,"_dea"):"".concat(N,"_dea_").concat(a),_=a===Ar?"".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;t.arrayTypes,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 y=a[i].prevRelativeVolumeSma,p=NaN;return Number.isNaN(f)||Number.isNaN(y)||(p=c/y),t.pushToMain({index:r,key:i,value:p}),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,y=o.decimals,p="".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(p):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=kr(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[p]={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(p):"donchian_channel",N=A[p],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(_r(E),_r(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===y?z:xr(z,y)})}for(var Y=D?R-L:NaN,U=0;U<f.length;U++){var q=i[f[U]][r],V=D&&q==q&&Y?(q-L)/Y:NaN;t.pushToMain({index:r,key:C[U],value:null===y?V:xr(V,y)})}return!0},bollingerBands:function(t,r,e,n,o){var i,a,l,u,c,s,f=o.height,y=o.range,p=void 0===y?[]:y,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=Mr(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!==Rr&&(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=Mr(p);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?Tr(Object(e),!0).forEach((function(r){Ir(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Tr(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!==Rr&&(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 Y=NaN;Number.isNaN(z)||Number.isNaN(L)||(Y=(L-z)/z),t.pushToMain({index:r,key:"".concat(w,"_height").concat(I),value:null===d?Y:xr(Y,d)})}var U,q=Mr(p);try{for(q.s();!(U=q.n()).done;){var V=U.value,G=NaN,B=m[V][r];Number.isNaN(B)||Number.isNaN(z)||Number.isNaN(L)||(G=(B-z)/(L-z)),t.pushToMain({index:r,key:"".concat(w,"_range_").concat(V).concat(I),value:null===d?G:xr(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],y="volume_oscillator_".concat(e,"_").concat(n);if(0===r){var p=t.len;t.arrayTypes,Object.assign(s,(i={},a=y,l={fastEMA:new Yt(e),slowEMA:new Yt(n)},(a=function(t){var r=function(t,r){if("object"!=Lr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Lr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lr(r)?r:r+""}(a))in i?Object.defineProperty(i,a,{value:l,enumerable:!0,configurable:!0,writable:!0}):i[a]=l,i)),c[y]=new Float64Array(p).fill(NaN),u>0&&t.lag([y],u)}var h=s[y],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:y,value:g}),!0},mapCols:function(t,r,e,n,o){var i=o.lag,a=t.verticalOhlcv,l=t.len;if(t.arrayTypes,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=Ae(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,y,p=n({index:r,main:t});if(null==p)return!0;for(var h=0,v=Object.entries(p);h<v.length;h++){var d=(f=v[h],y=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,y)||Ae(f,y)||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,y=t.verticalOhlcv,p=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),p.hasOwnProperty("scaler")||(p.scaler={}),p.scaler.hasOwnProperty(h)||(p.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=Se(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(!y.hasOwnProperty(r))throw new Error('Target property "'.concat(r,'" not found in verticalOhlcv'));var e="".concat(h,"_").concat(r);y[e]=new Float64Array(v).fill(NaN);var n=a?s:r;if(p.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,we(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=p.scaler[h].windows,O=!1,A=0;A<n.length;A++){var j=n[A],N=y[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=y[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,p=S[a?s:e];if("minmax"===i){var v=Math.min.apply(Math,we(p)),d=Math.max.apply(Math,we(p));f=re(u,v,d,l)}else{if("zscore"!==i)throw new Error('Unknown scaler type "'.concat(i,'"'));var m=p.reduce((function(t,r){return t+r}),0)/p.length,b=p.reduce((function(t,r){return t+Math.pow(r-m,2)}),0)/p.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.limit,a=n.oneHot,l=t.verticalOhlcv,u=t.verticalOhlcvTempCols,c=t.instances,s=t.len,f=(t.arrayTypes,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 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}}(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 y=o.value,p=y.fast,h=y.slow,v="".concat(p,"_x_").concat(h);if(0===r){if("number"==typeof h){var d=h.toString();u.add(d);var m="Int16Array";0===h||1===h?m="Uint8Array":h>=-125&&h<=125&&(m="Int8Array"),l[d]=Hr(m,s)}c.hasOwnProperty("crossPairs")||(c.crossPairs={}),c.crossPairs[v]={run:new ye,min:1/0,max:-1/0};var b="Int16Array";i<=125&&(b="Int8Array"),l[v]=Hr(b,s),a&&(l["one_hot_".concat(v)]=Hr("Array",s))}else if(r+1===s){if("price"!==p&&!l.hasOwnProperty(p))throw new Error('crossPairs invalid param: fast "'.concat(p,'" 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"!==p&&!l.hasOwnProperty(p))return;if(!l.hasOwnProperty(h))return;var g=c.crossPairs[v].run;if("price"===p){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[p][r],A=l[h][r];g.update(r,{fast:O,slow:A})}var j=g.getResult(),N=Math.max(-i,Math.min(i,j));if(t.pushToMain({index:r,key:v,value:N}),a){var P=N+i,x=2*i+1;t.pushToMain({index:r,key:"one_hot_".concat(v),value:Qr(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=Xr(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=$r(u,o[u]);o[s]=Hr(f,i)}}}catch(t){l.e(t)}finally{l.f()}}var y,p=Xr(e);try{for(p.s();!(y=p.n()).done;)for(var h=y.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){p.e(t)}finally{p.f()}return!0}},rn=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,y=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/y:null}))},en=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=rn(t,e),o=rn(r,e),i=t.length,a=[],l=0,u=0,c=0,s=0,f=0,y=0,p=-1,h=0;h<i;h++){if(null!==n[h]&&null!==o[h]){p=h;break}a.push(0)}if(-1===p)return new Array(i).fill(0);for(var v=p;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,++y<2)a.push(0);else{var b=y*c-l*u,g=Math.sqrt((y*s-l*l)*(y*f-u*u)),w=0===g?0:b/g;a.push(w)}else l=u=c=s=f=y=0,a.push(0)}return a};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=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,y=n.verticalOhlcvKeyNames,p=n.verticalOhlcvTempCols;if(0===y.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 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}}(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(!p.has(S))for(var A=v;A<f;A++)m[A-v][S]="date"===S?zr[u](O[A]):O[A]}return m},an=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 ln(t){return ln="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},ln(t)}function un(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 cn(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?un(Object(e),!0).forEach((function(r){sn(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):un(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function sn(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=ln(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ln(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ln(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function fn(t,r){if(t){if("string"==typeof t)return yn(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)?yn(t,r):void 0}}function yn(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 pn=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)]},hn={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=cn(cn({},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},vn={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=cn(cn({},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=cn(cn({},o),{},{activation:"identity"}));return i.train(e,n),i},unsupervised:!1}};function dn(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 mn(t){return mn="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},mn(t)}function bn(t,r,e){return(r=Nn(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function gn(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=On(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 wn(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)||On(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 Sn(t){return function(t){if(Array.isArray(t))return An(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||On(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 On(t,r){if(t){if("string"==typeof t)return An(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)?An(t,r):void 0}}function An(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 jn(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,Nn(n.key),n)}}function Nn(t){var r=function(t,r){if("object"!=mn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=mn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mn(r)?r:r+""}var Pn=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,p=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);y(p,{min:100,max:5e4,allowDecimals:!1},"chunkProcess","constructor"),c(v,"ML","constructor"),this.chunkProcess=p,this.input=Sn(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=Vr(i[o],2),l=a[0],u=a[1];if("date"===l)e[l]=Ur(u),n[l]="Array";else if("volume"===l)e[l]=Pr(u,!0),n[l]="Int32Array";else if(Br.has(l))e[l]=Pr(u,!0),n[l]="Float64Array";else{var c=Pr(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:en},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(zr),o,"dateFormat","getDataAsCols"),c(t,"options","getDataAsCols");for(var i=this.len,a=this.invalidValueIndex,l=this.verticalOhlcv,u=this.verticalOhlcvTempCols,f={},y=e?a+1:0,p=i-y,h=0,v=Object.entries(l);h<v.length;h++){var d=wn(v[h],2),m=d[0],b=d[1];if(!u.has(m)){var g=$r(m,l[m]);f[m]=Hr(g,p);for(var w=y;w<i;w++)f[m][w]="date"===m?zr[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(zr),o,"dateFormat","getData"),c(t,"options","getData"),on({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(zr),e,"dateFormat","getData"),on({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 y=0,p=Object.keys(c);y<p.length;y++){var h=p[y];l[h]=Hr(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=We(w[g],2),O=S[0],A=S[1],j=b[O];if(Nr.hasOwnProperty(A)){var N=Nr[A](j);r.pushToMain({index:m,key:O,value:N})}else Yr.hasOwnProperty(A)?r.pushToMain({index:m,key:O,value:Yr[A](j)}):r.pushToMain({index:m,key:O,value:j})}var P,x=Je(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&&tn[k].apply(tn,[r,m].concat(Ke(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=Je(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&&Te.apply(void 0,[t,n].concat(Ke(u))),"classifier"===l&&Xe.apply(void 0,[t,n].concat(Ke(u))),"regressor"===l&&Le.apply(void 0,[t,n].concat(Ke(u))))}}catch(t){i.e(t)}finally{i.f()}}}(r),u.push.apply(u,Ke(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?125:n,i=r.oneHot,a=void 0!==i&&i;y(o,{min:2,max:this.len},"options.limit",e),f(a,"options.oneHot",e);var s,p=[],h=gn(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."));p.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=an(p,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),y(r,{min:1,max:this.len,allowDecimals:!1},"lookback",e);var n=an(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),y(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 y(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),y(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,p=r.lower,h=void 0===p?null:p;return y(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),f(a,"options.percentage","atr"),null!==s&&y(s,{min:.001,max:100,allowDecimals:!0},"options.upper","atr"),null!==h&&y(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),y(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),y(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var u=an([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),y(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),y(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",e);var u=an([o],e);return this.inputParams.push({key:e,order:u,params:[e,t,{target:o,lag:a}]}),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),y(t,{min:2,max:this.len,allowDecimals:!1},"size",n),y(r,{min:t,max:this.len,allowDecimals:!1},"smoothing",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,p=e.bandDistance,v=void 0===p?2:p,d=e.liquidityLookback,m=void 0===d?20:d;h(i,"options.target",n),y(u,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),y(v,{min:.01,max:10,allowDecimals:!0},"options.bandDistance",n),y(f,{min:2,max:this.len,allowDecimals:!1},"options.atrLength",n),y(m,{min:1,max:this.len,allowDecimals:!1},"options.liquidityLookback",n);var b=an([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;y(t,{min:1,max:i,allowDecimals:!1},"kPeriod",o),y(r,{min:1,max:i,allowDecimals:!1},"kSlowingPeriod",o),y(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;y(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)?(p(h,"options.minmax",o),a=function(t){return null!==h?re(t,0,100,h):t}):(f(h,"options.minmax",o),h=[0,1],a=function(t){return null!==h?re(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),y(t,{min:1,max:this.len,allowDecimals:!1},"fast",o),y(r,{min:1,max:this.len,allowDecimals:!1},"slow",o),y(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),y(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))},p=an([a],o);return this.inputParams.push({key:o,order:p,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),y(t,{min:1,max:this.len,allowDecimals:!1},"size",n),y(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,p=e.range,v=void 0===p?[]:p,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),y(m,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(s,"options.height",n),null!==g&&y(g,{min:1,max:15,allowDecimals:!1},"decimals",n);var w=an([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),y(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),y(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)?(p(u,"options.minmax",e),s=function(t){return null!==u?re(t,0,100,u):t}):(f(u,"options.minmax",e),u=[0,1],s=function(t){return null!==u?re(t,0,100,u):t}),v="minmax_");var d=an([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),y(t,{min:1,max:this.len,allowDecimals:!1},"size",n),y(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,p=e.lag,h=void 0===p?0:p,v=e.decimals,d=void 0===v?null:v;return u(s,"options.range",n),y(h,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),f(i,"options.height",n),null!==d&&y(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),y(t,{min:1,max:this.len,allowDecimals:!1},"fastsize",n),y(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 y(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;y(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),f(i,"options.oneHot",r);var a=i?"one_hot_":"",u=bn(bn(bn(bn(bn({},"".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),y(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),p(h,"options.range",n),s(["minmax","zscore"],t,"options.type",n);var g={groupKey:"".concat(t,"_").concat(r),groupKeyLen:b.length},w=!1,S=an(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";y(r,{max:this.len,allowDecimals:!1},"trainingSize",n),c(e,"options",n);var o=e.retrain,i=void 0!==o&&o,a=e.trainingCols,p=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"!==mn(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:pn;if("function"!=typeof _)throw new Error('"yCallback" must be a function in the following format:\n\n---\n\nconst yCallback = '.concat(pn.toString(),"\n\n---\n\n"));if(s(Object.keys(hn),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(p,"options.trainingCols",n),y(A,{min:1,max:this.len,allowDecimals:!1},"options.horizon",n),y(m,{max:0,allowDecimals:!1},"options.lookback",n),y(S,{min:1,allowDecimals:!1},"options.predictions",n);var k=Sn(p);if(u(g,"options.findGroups","scaler")&&g.length>0){var E,C=gn(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===p.length)throw new Error('"trainingCols" array is empty in '.concat(n));var F=hn[v],z=F.shortName,Y=F.flatY,U="cla_".concat(z,"_").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 q={lookbackAbs:Math.abs(m)+1,flatY:Y,prefix:U};this.isAlreadyComputed.add(U);var V=an(k,n),G=hn[v],B=this.ML.classes[v];return this.inputParams.push({key:n,order:V,params:[r,{yCallback:_,predictions:S,lookback:m,retrain:i,trainingCols:p,findGroups:g,horizon:A,type:v,modelArgs:N,precompute:q,filterCallback:x,modelConfig:G,modelClass:B}]}),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";y(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,p=r.predictions,v=void 0===p?1:p,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(vn),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),y(v,{min:1,allowDecimals:!1},"predictions",e),y(S,{max:0,allowDecimals:!1},"lookback",e),u(m,"options.trainingCols",e);var _=vn[g],k=_.shortName,E=_.flatX,C=_.flatY,T="reg_".concat(k,"_").concat(t,"_").concat(a,"_prediction"),I=Sn(m);if(u(A,"options.findGroups","scaler")&&A.length>0){var M,D=gn(A);try{for(D.s();!(M=D.n()).done;){var R=M.value,L=R.type,F=void 0===L?"":L,z=R.size,Y=R.groupName,U=void 0===Y?"":Y;if(!F||!z&&!U||z&&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.');I.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(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=an(I,e),G=vn[g],B=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:B}]}),this}},{key:"pca",value:function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="pca";y(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,p=e.lookback,v=void 0===p?0:p,d=e.filterCallback,m=void 0===d?function(){return!0}:d;u(l,"options.trainigCols",n),y(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?dn(Object(e),!0).forEach((function(r){bn(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):dn(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),y(b.nCompNIPALS,{min:1},"options.modelArgs.nCompNIPALS",n);var g=[];if(u(i,"options.findGroups","pca")&&i.length>0){var w,S=gn(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 _=an(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=fn(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 y=(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)||fn(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.")}()),p=(y[0],y[1]),h=p.type,v=p.predictions,d=p.precompute,m=d.flatY,b=d.prefix,g=m?v:1,w=void 0;"regressor"===s?w=vn[h].exportModel:"classifier"===s&&(w=hn[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=Ne),c(e,"options",n);var o=e.lag,i=void 0===o?0:o;u(t,"newCols",n),y(i,{min:0,allowDecimals:!1},"options.lag",n);var a=an(t,n);return this.inputParams.push({key:n,order:a,params:[t,r,{lag:i}]}),this}}],r&&jn(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:()=>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 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"!=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),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 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)}}])&&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 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&>(e.prototype,n),o&>(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 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,zt(n.key),n)}}function It(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=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 C;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}(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 Ir(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Mr(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 Mr(t,r){if(t){if("string"==typeof t)return Ir(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)?Ir(t,r):void 0}}function Ir(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){var e={Array,Float64Array,Float32Array,Int32Array,Uint8Array,Int8Array,Int16Array}[t];if(!e||"function"!=typeof e.from)throw new Error("Unsupported array type: ".concat(t));var n="Array"===t?null:NaN;return e.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 Ie(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Me(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Me(t,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}}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="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=Me(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 M=C.value;if(!w.hasOwnProperty(M))throw new Error('Feature "'.concat(M,'" not found in verticalOhlcv for ').concat(m,"."))}}catch(t){T.e(t)}finally{T.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=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 M,I=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(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[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,M=r>0?l["".concat(s,"_close")][r-1]:NaN,I=!Number.isNaN(M)&&M<=T&&P>A,D=!Number.isNaN(M)&&M>=T&&P<A;I&&(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 M=g.atrBuffer.length===f?g.atrBuffer.reduce((function(t,r){return t+r}),0)/f:NaN,I=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);I=isNaN(g.prevVidya)?O:z*O+(1-z)*g.prevVidya,g.prevVidya=I}g.sma.update(I);var U=NaN;try{U=g.sma.getResult()}catch(t){}var Y=isNaN(M)||isNaN(U)?NaN:U+M*y,q=isNaN(M)||isNaN(U)?NaN:U-M*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=Mr(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,M=i.low,I=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(_)};I(P,T,(function(t,r){return t<=r})),I(x,M,(function(t,r){return t>=r}));var D=P.length&&x.length,R=D?T[P[0]]:NaN,L=D?M[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 M="";b.bollinger_bands.numberOfIndicators>1&&(M+="_".concat(g)),h!==Ur&&(M+="_".concat(h));var I=b.bollinger_bands.settings[g],D=m[h][r];I.update(D);var R={};try{R=I.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(M),value:L}),t.pushToMain({index:r,key:"".concat(w,"_middle").concat(M),value:F}),t.pushToMain({index:r,key:"".concat(w,"_lower").concat(M),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(M),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(M),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.limit,a=n.oneHot,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),l[d]=Jr("Int16Array",s)}c.hasOwnProperty("crossPairs")||(c.crossPairs={}),c.crossPairs[v]={run:new de,min:1/0,max:-1/0},l[v]=Jr("Int16Array",s),a&&(l["one_hot_".concat(v)]=Jr("Array",s))}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 m=c.crossPairs[v].run;if("price"===y){var b=l.close[r],g=l[h][r];m.update(r,{fast:b,slow:g,high:l.high[r],low:l.low[r]})}else{var w=l[y][r],S=l[h][r];m.update(r,{fast:w,slow:S})}var O=m.getResult(),A=O;if(t.pushToMain({index:r,key:v,value:A}),a){var j=Math.max(-i,Math.min(i,O))+i,N=2*i+1;t.pushToMain({index:r,key:"one_hot_".concat(v),value:ne(j,N)})}}}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 M=Object.keys(l);e(r,m,M)||(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?125:n,i=r.oneHot,a=void 0!==i&&i;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,M=T.type,I=void 0===M?"":M,D=T.size,R=T.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){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"),M=Nn(m);if(u(A,"options.findGroups","scaler")&&A.length>0){var I,D=An(A);try{for(D.s();!(I=D.n()).done;){var R=I.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.');M.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(M,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})();
|
package/index.js
CHANGED
|
@@ -355,6 +355,26 @@ export default class OHLCV_INDICATORS {
|
|
|
355
355
|
return this
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
+
heikenAshi(smoothLength = 10, afterSmoothLength = 10, options = {}) {
|
|
359
|
+
const methodName = 'heikenAshi'
|
|
360
|
+
|
|
361
|
+
isAlreadyComputed(this)
|
|
362
|
+
|
|
363
|
+
validateNumber(smoothLength, {min: 1, max: this.len, allowDecimals: false}, 'smoothLength', methodName)
|
|
364
|
+
validateNumber(afterSmoothLength, {min: 1, max: this.len, allowDecimals: false}, 'afterSmoothLength', methodName)
|
|
365
|
+
validateObject(options, 'options', methodName)
|
|
366
|
+
|
|
367
|
+
const {lag = 0} = options
|
|
368
|
+
|
|
369
|
+
validateNumber(lag, {min: 0, max: this.len, allowDecimals: false}, 'options.lag', methodName)
|
|
370
|
+
|
|
371
|
+
const order = 0
|
|
372
|
+
|
|
373
|
+
this.inputParams.push({key: methodName, order, params: [smoothLength, afterSmoothLength, {lag}]})
|
|
374
|
+
|
|
375
|
+
return this
|
|
376
|
+
}
|
|
377
|
+
|
|
358
378
|
vidya(size = 14, momentum = 20, options = {}) {
|
|
359
379
|
|
|
360
380
|
const methodName = 'vidya'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.50",
|
|
4
4
|
"description": "A JavaScript library featuring optimized trading indicators for OHLCV arrays [{open, high, low, close, value}]. This library is optimized for backtesting and trading bot development.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -3,6 +3,7 @@ import { validateInputParams } from "../utilities/validators.js";
|
|
|
3
3
|
import { rsi } from "../oscillators/rsi.js";
|
|
4
4
|
import { stochastic } from "../oscillators/stochastic.js";
|
|
5
5
|
import { movingAverages } from "../moving-averages/movingAverages.js";
|
|
6
|
+
import { heikenAshi } from "../moving-averages/heikenAshi.js";
|
|
6
7
|
import { vidya } from "../moving-averages/vidya.js";
|
|
7
8
|
import { macd } from "../moving-averages/macd.js";
|
|
8
9
|
import { relativeVolume } from "../moving-averages/relativeVolume.js";
|
|
@@ -27,6 +28,7 @@ import { classifier } from "../machine-learning/classifier.js";
|
|
|
27
28
|
// Map indicator keys to their respective functions
|
|
28
29
|
const mainFunctions = {
|
|
29
30
|
dateTime,
|
|
31
|
+
heikenAshi,
|
|
30
32
|
rsi,
|
|
31
33
|
stochastic,
|
|
32
34
|
atr,
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { FasterEMA } from 'trading-signals';
|
|
2
|
+
|
|
3
|
+
export const heikenAshi = (main, index, smoothLength, afterSmoothLength, {lag}) => {
|
|
4
|
+
const { verticalOhlcv, instances, len } = main
|
|
5
|
+
const prefix = `heiken_ashi_${smoothLength}_${afterSmoothLength}`
|
|
6
|
+
const keys = ['open', 'high', 'low', 'close']
|
|
7
|
+
|
|
8
|
+
// ---- INIT ----
|
|
9
|
+
if (index === 0) {
|
|
10
|
+
|
|
11
|
+
// Initialize pre-smoothing EMA instances and buffers
|
|
12
|
+
instances[prefix] = {
|
|
13
|
+
emaPre: Object.fromEntries(keys.map(k => [k, new FasterEMA(smoothLength)])),
|
|
14
|
+
emaPost: Object.fromEntries(keys.map(k => [k, new FasterEMA(afterSmoothLength)])),
|
|
15
|
+
prevHaOpen: NaN,
|
|
16
|
+
prevHaClose: NaN,
|
|
17
|
+
isTrendUp: false,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const keyNames = keys.map(k => `${prefix}_${k}`)
|
|
21
|
+
|
|
22
|
+
const verticalOhlcvSetup = Object.fromEntries([...keyNames, `${prefix}_cross`].map(v => [v, new Float64Array(len).fill(NaN)]))
|
|
23
|
+
|
|
24
|
+
Object.assign(verticalOhlcv, {...verticalOhlcvSetup})
|
|
25
|
+
|
|
26
|
+
if(lag > 0)
|
|
27
|
+
{
|
|
28
|
+
main.lag(keyNames, lag)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ---- FETCH RAW INPUTS ----
|
|
33
|
+
const open = verticalOhlcv.open[index]
|
|
34
|
+
const high = verticalOhlcv.high[index]
|
|
35
|
+
const low = verticalOhlcv.low[index]
|
|
36
|
+
const close = verticalOhlcv.close[index]
|
|
37
|
+
const inst = instances[prefix]
|
|
38
|
+
|
|
39
|
+
// ---- PRE-SMOOTHING (EMA) ----
|
|
40
|
+
inst.emaPre.open.update(open)
|
|
41
|
+
inst.emaPre.high.update(high)
|
|
42
|
+
inst.emaPre.low.update(low)
|
|
43
|
+
inst.emaPre.close.update(close)
|
|
44
|
+
|
|
45
|
+
let sOpen, sHigh, sLow, sClose
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
sOpen = inst.emaPre.open.getResult()
|
|
49
|
+
sHigh = inst.emaPre.high.getResult()
|
|
50
|
+
sLow = inst.emaPre.low.getResult()
|
|
51
|
+
sClose = inst.emaPre.close.getResult()
|
|
52
|
+
} catch {
|
|
53
|
+
return true; // skip if not enough data
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ---- HEIKEN ASHI CORE ----
|
|
57
|
+
const haClose = (sOpen + sHigh + sLow + sClose) / 4
|
|
58
|
+
const haOpen = (Number.isNaN(inst.prevHaOpen) || Number.isNaN(inst.prevHaClose)) ? (sOpen + sClose) / 2 : (inst.prevHaOpen + inst.prevHaClose) / 2
|
|
59
|
+
const haHigh = Math.max(sHigh, haOpen, haClose)
|
|
60
|
+
const haLow = Math.min(sLow, haOpen, haClose)
|
|
61
|
+
|
|
62
|
+
// Store for next round
|
|
63
|
+
inst.prevHaOpen = haOpen
|
|
64
|
+
inst.prevHaClose = haClose
|
|
65
|
+
|
|
66
|
+
// ---- POST-SMOOTHING (EMA) ----
|
|
67
|
+
inst.emaPost.open.update(haOpen)
|
|
68
|
+
inst.emaPost.high.update(haHigh)
|
|
69
|
+
inst.emaPost.low.update(haLow)
|
|
70
|
+
inst.emaPost.close.update(haClose)
|
|
71
|
+
|
|
72
|
+
let smOpen, smHigh, smLow, smClose
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
smOpen = inst.emaPost.open.getResult()
|
|
76
|
+
smHigh = inst.emaPost.high.getResult()
|
|
77
|
+
smLow = inst.emaPost.low.getResult()
|
|
78
|
+
smClose = inst.emaPost.close.getResult()
|
|
79
|
+
} catch {
|
|
80
|
+
return true
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Cumulative cross counter: positive when uptrend, negative when downtrend
|
|
84
|
+
const prevCross = index > 0 ? verticalOhlcv[`${prefix}_cross`][index - 1] : 0
|
|
85
|
+
const prevHaOpen = index > 0 ? verticalOhlcv[`${prefix}_open`][index - 1] : NaN
|
|
86
|
+
const prevHaClose = index > 0 ? verticalOhlcv[`${prefix}_close`][index - 1] : NaN
|
|
87
|
+
const crossUp = !Number.isNaN(prevHaClose) && prevHaClose <= prevHaOpen && smClose > smOpen
|
|
88
|
+
const crossDown = !Number.isNaN(prevHaClose) && prevHaClose >= prevHaOpen && smClose < smOpen
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if (crossUp) inst.isTrendUp = true;
|
|
92
|
+
if (crossDown) inst.isTrendUp = false;
|
|
93
|
+
|
|
94
|
+
let cross = 0
|
|
95
|
+
|
|
96
|
+
if (index > 0) {
|
|
97
|
+
if (inst.isTrendUp) {
|
|
98
|
+
cross = prevCross > 0 ? prevCross + 1 : 1
|
|
99
|
+
} else {
|
|
100
|
+
cross = prevCross < 0 ? prevCross - 1 : -1
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ---- PUSH OUTPUTS ----
|
|
105
|
+
main.pushToMain({ index, key: `${prefix}_open`, value: smOpen })
|
|
106
|
+
main.pushToMain({ index, key: `${prefix}_high`, value: smHigh })
|
|
107
|
+
main.pushToMain({ index, key: `${prefix}_low`, value: smLow })
|
|
108
|
+
main.pushToMain({ index, key: `${prefix}_close`, value: smClose })
|
|
109
|
+
main.pushToMain({ index, key: `${prefix}_cross`, value: cross })
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
return true
|
|
113
|
+
}
|
|
@@ -162,12 +162,7 @@ export const crossPairs = (main, index, crossPairsList, {limit, oneHot}) => {
|
|
|
162
162
|
max: -Infinity
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if(limit <= 125)
|
|
168
|
-
{
|
|
169
|
-
crossArrType = 'Int8Array'
|
|
170
|
-
}
|
|
165
|
+
const crossArrType = 'Int16Array'
|
|
171
166
|
|
|
172
167
|
verticalOhlcv[crossName] = buildArray(crossArrType, len)
|
|
173
168
|
|