ohlcv-indicators 1.9.5 → 1.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ohlcv-indicators.min.js +1 -1
- package/index.js +68 -15
- package/package.json +1 -1
- package/src/moving-averages/macd.js +4 -4
- package/src/oscillators/volumeOscillator.js +3 -3
- package/src/studies/findCrosses.js +3 -6
- package/src/studies/lag.js +2 -0
- package/src/utilities/parsing-utilities.js +8 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{t.r(e),t.d(e,{default:()=>oe});var r=1e6,n="[big.js] ",i=n+"Invalid ",o=i+"decimal places",a=i+"rounding mode",l=n+"Division by zero",u={},s=void 0,c=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(t,e,r,n){var i=t.c;if(r===s&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(a);if(e<1)n=3===r&&(n||!!i[0])||0===e&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(n||i[1]!==s))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=1===r&&i[e]>=5||2===r&&(i[e]>5||5===i[e]&&(n||i[e+1]!==s||1&i[e-1]))||3===r&&(n||!!i[0]),i.length=e,n)for(;++i[--e]>9;)if(i[e]=0,0===e){++t.e,i.unshift(1);break}for(e=i.length;!i[--e];)i.pop()}return t}function h(t,e,r){var n=t.e,i=t.c.join(""),o=i.length;if(e)i=i.charAt(0)+(o>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+="0";else n<o&&(i=i.slice(0,n)+"."+i.slice(n));else o>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}function v(t){return v="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},v(t)}function p(t){var e="function"==typeof Map?new Map:void 0;return p=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(y())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&d(i,r.prototype),i}(t,arguments,b(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,t)},p(t)}function y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(y=function(){return!!t})()}function d(t,e){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},d(t,e)}function b(t){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},b(t)}u.abs=function(){var t=new this.constructor(this);return t.s=1,t},u.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,a=t.s,l=r.e,u=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-a:0;if(o!=a)return o;if(e=o<0,l!=u)return l>u^e?1:-1;for(a=(l=n.length)<(u=i.length)?l:u,o=-1;++o<a;)if(n[o]!=i[o])return n[o]>i[o]^e?1:-1;return l==u?0:l>u^e?1:-1},u.div=function(t){var e=this,n=e.constructor,i=e.c,a=(t=new n(t)).c,u=e.s==t.s?1:-1,c=n.DP;if(c!==~~c||c<0||c>r)throw Error(o);if(!a[0])throw Error(l);if(!i[0])return t.s=u,t.c=[t.e=0],t;var h,v,p,y,d,b=a.slice(),m=h=a.length,g=i.length,w=i.slice(0,h),_=w.length,O=t,S=O.c=[],P=0,j=c+(O.e=e.e-t.e)+1;for(O.s=u,u=j<0?0:j,b.unshift(0);_++<h;)w.push(0);do{for(p=0;p<10;p++){if(h!=(_=w.length))y=h>_?1:-1;else for(d=-1,y=0;++d<h;)if(a[d]!=w[d]){y=a[d]>w[d]?1:-1;break}if(!(y<0))break;for(v=_==h?a:b;_;){if(w[--_]<v[_]){for(d=_;d&&!w[--d];)w[d]=9;--w[d],w[_]+=10}w[_]-=v[_]}for(;!w[0];)w.shift()}S[P++]=y?p:++p,w[0]&&y?w[_]=i[m]||0:w=[i[m]]}while((m++<g||w[0]!==s)&&u--);return S[0]||1==P||(S.shift(),O.e--,j--),P>j&&f(O,j,n.RM,w[0]!==s),O},u.eq=function(t){return 0===this.cmp(t)},u.gt=function(t){return this.cmp(t)>0},u.gte=function(t){return this.cmp(t)>-1},u.lt=function(t){return this.cmp(t)<0},u.lte=function(t){return this.cmp(t)<1},u.minus=u.sub=function(t){var e,r,n,i,o=this,a=o.constructor,l=o.s,u=(t=new a(t)).s;if(l!=u)return t.s=-u,o.plus(t);var s=o.c.slice(),c=o.e,f=t.c,h=t.e;if(!s[0]||!f[0])return f[0]?t.s=-u:s[0]?t=new a(o):t.s=1,t;if(l=c-h){for((i=l<0)?(l=-l,n=s):(h=c,n=f),n.reverse(),u=l;u--;)n.push(0);n.reverse()}else for(r=((i=s.length<f.length)?s:f).length,l=u=0;u<r;u++)if(s[u]!=f[u]){i=s[u]<f[u];break}if(i&&(n=s,s=f,f=n,t.s=-t.s),(u=(r=f.length)-(e=s.length))>0)for(;u--;)s[e++]=0;for(u=e;r>l;){if(s[--r]<f[r]){for(e=r;e&&!s[--e];)s[e]=9;--s[e],s[r]+=10}s[r]-=f[r]}for(;0===s[--u];)s.pop();for(;0===s[0];)s.shift(),--h;return s[0]||(t.s=1,s=[h=0]),t.c=s,t.e=h,t},u.mod=function(t){var e,r=this,n=r.constructor,i=r.s,o=(t=new n(t)).s;if(!t.c[0])throw Error(l);return r.s=t.s=1,e=1==t.cmp(r),r.s=i,t.s=o,e?new n(r):(i=n.DP,o=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=o,this.minus(r.times(t)))},u.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},u.plus=u.add=function(t){var e,r,n,i=this,o=i.constructor;if(t=new o(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var a=i.e,l=i.c,u=t.e,s=t.c;if(!l[0]||!s[0])return s[0]||(l[0]?t=new o(i):t.s=i.s),t;if(l=l.slice(),e=a-u){for(e>0?(u=a,n=s):(e=-e,n=l),n.reverse();e--;)n.push(0);n.reverse()}for(l.length-s.length<0&&(n=s,s=l,l=n),e=s.length,r=0;e;l[e]%=10)r=(l[--e]=l[e]+s[e]+r)/10|0;for(r&&(l.unshift(r),++u),e=l.length;0===l[--e];)l.pop();return t.c=l,t.e=u,t},u.pow=function(t){var e=this,r=new e.constructor("1"),n=r,o=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(i+"exponent");for(o&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return o?r.div(n):n},u.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(i+"precision");return f(new this.constructor(this),t,e)},u.round=function(t,e){if(t===s)t=0;else if(t!==~~t||t<-r||t>r)throw Error(o);return f(new this.constructor(this),t+this.e+1,e)},u.sqrt=function(){var t,e,r,i=this,o=i.constructor,a=i.s,l=i.e,u=new o("0.5");if(!i.c[0])return new o(i);if(a<0)throw Error(n+"No square root");0===(a=Math.sqrt(i+""))||a===1/0?((e=i.c.join("")).length+l&1||(e+="0"),l=((l+1)/2|0)-(l<0||1&l),t=new o(((a=Math.sqrt(e))==1/0?"5e":(a=a.toExponential()).slice(0,a.indexOf("e")+1))+l)):t=new o(a+""),l=t.e+(o.DP+=4);do{r=t,t=u.times(r.plus(i.div(r)))}while(r.c.slice(0,l).join("")!==t.c.slice(0,l).join(""));return f(t,(o.DP-=4)+t.e+1,o.RM)},u.times=u.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,a=i.length,l=o.length,u=r.e,s=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=u+s,a<l&&(e=i,i=o,o=e,s=a,a=l,l=s),e=new Array(s=a+l);s--;)e[s]=0;for(u=l;u--;){for(l=0,s=a+u;s>u;)l=e[s]+o[u]*i[s-u-1]+l,e[s--]=l%10,l=l/10|0;e[s]=l}for(l?++t.e:e.shift(),u=e.length;!e[--u];)e.pop();return t.c=e,t},u.toExponential=function(t,e){var n=this,i=n.c[0];if(t!==s){if(t!==~~t||t<0||t>r)throw Error(o);for(n=f(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return h(n,!0,!!i)},u.toFixed=function(t,e){var n=this,i=n.c[0];if(t!==s){if(t!==~~t||t<0||t>r)throw Error(o);for(t=t+(n=f(new n.constructor(n),t+n.e+1,e)).e+1;n.c.length<t;)n.c.push(0)}return h(n,!1,!!i)},u[Symbol.for("nodejs.util.inspect.custom")]=u.toJSON=u.toString=function(){var t=this,e=t.constructor;return h(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},u.toNumber=function(){var t=Number(h(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},u.toPrecision=function(t,e){var n=this,o=n.constructor,a=n.c[0];if(t!==s){if(t!==~~t||t<1||t>r)throw Error(i+"precision");for(n=f(new o(n),t,e);n.c.length<t;)n.c.push(0)}return h(n,t<=n.e||n.e<=o.NE||n.e>=o.PE,!!a)},u.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return h(t,t.e<=e.NE||t.e>=e.PE,!0)},function t(){function e(r){var n=this;if(!(n instanceof e))return r===s?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(i+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!c.test(e))throw Error(i+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),o=e.length,n=0;n<o&&"0"==e.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==e.charAt(--o););for(t.e=r-n-1,t.c=[],r=0;n<=o;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=u,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();var m=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=b(e),function(t,e){if(e&&("object"==v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,y()?Reflect.construct(e,r||[],b(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(p(Error));function g(t){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g(t)}function w(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,O(n.key),n)}}function _(t,e,r){return(e=O(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function O(t){var e=function(t,e){if("object"!=g(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==g(e)?e:e+""}var S=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),_(this,"previousHighest",void 0),_(this,"highest",void 0),_(this,"previousLowest",void 0),_(this,"lowest",void 0),_(this,"previousResult",void 0),_(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new m;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&w(t.prototype,e),r&&w(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();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 j(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,k(n.key),n)}}function A(t,e,r){return e=I(e),function(t,e){if(e&&("object"==P(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,E()?Reflect.construct(e,r||[],I(t).constructor):e.apply(t,r))}function E(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(E=function(){return!!t})()}function I(t){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},I(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}function k(t){var e=function(t,e){if("object"!=P(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}var M=function(t){function e(t){var r,n,i,o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=A(this,e),o=void 0,(i=k(i="interval"))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&j(r.prototype,n),i&&j(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(S);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 x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,z(n.key),n)}}function D(t,e,r){return e=L(e),function(t,e){if(e&&("object"==T(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,C()?Reflect.construct(e,r||[],L(t).constructor):e.apply(t,r))}function C(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(C=function(){return!!t})()}function L(t){return L=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},L(t)}function B(t,e){return B=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},B(t,e)}function z(t){var e=function(t,e){if("object"!=T(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==T(e)?e:e+""}var H=function(t){function e(){var t,r,n,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return r=t=D(this,e,[].concat(a)),i=[],(n=z(n="prices"))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&B(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}],n&&x(r.prototype,n),i&&x(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(M);function F(t){return F="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},F(t)}function N(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,G(n.key),n)}}function U(t,e,r){return e=q(e),function(t,e){if(e&&("object"==F(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,V()?Reflect.construct(e,r||[],q(t).constructor):e.apply(t,r))}function V(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(V=function(){return!!t})()}function q(t){return q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},q(t)}function K(t,e){return K=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},K(t,e)}function $(t,e,r){return(e=G(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function G(t){var e=function(t,e){if("object"!=F(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=F(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==F(e)?e:e+""}var W=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),$(r=U(this,e),"interval",void 0),$(r,"indicator",void 0),$(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new H(t),r.smoothingFactor=1/r.interval,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&K(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var i=(t-this.result)*this.smoothingFactor;return this.setResult(i+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&N(r.prototype,n),i&&N(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(S);function J(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}function Y(t){return Y="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},Y(t)}function Q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Z(n.key),n)}}function X(t,e,r){return(e=Z(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Z(t){var e=function(t,e){if("object"!=Y(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Y(e)?e:e+""}var tt=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),X(this,"interval",void 0),X(this,"deviationMultiplier",void 0),X(this,"prices",[]),X(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=J(this.prices),r=function(t,e){var r=e||J(t),n=J(t.map((function(t){return t-r})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,e);return this.result={lower:e-r*this.deviationMultiplier,middle:e,upper:e+r*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new m;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&Q(t.prototype,e),r&&Q(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function et(t){return et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},et(t)}function rt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ut(n.key),n)}}function nt(t,e,r){return e=ot(e),function(t,e){if(e&&("object"==et(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,it()?Reflect.construct(e,r||[],ot(t).constructor):e.apply(t,r))}function it(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(it=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,e){return at=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},at(t,e)}function lt(t,e,r){return(e=ut(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ut(t){var e=function(t,e){if("object"!=et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==et(e)?e:e+""}var st=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),lt(r=nt(this,e,[t]),"interval",void 0),lt(r,"pricesCounter",0),lt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&at(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?e&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,e&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),e):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),e)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new m;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&rt(r.prototype,n),i&&rt(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(M);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 ft(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vt(n.key),n)}}function ht(t,e,r){return(e=vt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vt(t){var e=function(t,e){if("object"!=ct(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ct(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ct(e)?e:e+""}var pt=function(){return t=function t(e,r,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),ht(this,"short",void 0),ht(this,"long",void 0),ht(this,"signal",void 0),ht(this,"prices",[]),ht(this,"result",void 0),this.short=e,this.long=r,this.signal=n},e=[{key:"getResult",value:function(){if(void 0===this.result)throw new m;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var i=r-n,o=this.signal.update(i,e);return this.result={histogram:i-o,macd:i,signal:o}}}}],e&&ft(t.prototype,e),r&&ft(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();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 dt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ot(n.key),n)}}function bt(t,e,r){return e=gt(e),function(t,e){if(e&&("object"==yt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,mt()?Reflect.construct(e,r||[],gt(t).constructor):e.apply(t,r))}function mt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(mt=function(){return!!t})()}function gt(t){return gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},gt(t)}function wt(t,e){return wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},wt(t,e)}function _t(t,e,r){return(e=Ot(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ot(t){var e=function(t,e){if("object"!=yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}var St=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:W;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),_t(r=bt(this,e),"interval",void 0),_t(r,"previousPrices",[]),_t(r,"avgGain",void 0),_t(r,"avgLoss",void 0),_t(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&wt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var i=this.avgLoss.getResult();if(0===i)return this.setResult(100,e);var o=this.avgGain.getResult()/i;return this.setResult(this.maxValue-this.maxValue/(o+1),e)}}}}],n&&dt(r.prototype,n),i&&dt(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(S);function Pt(t){return Pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pt(t)}function jt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Pt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function At(t){return At="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},At(t)}function Et(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=At(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=At(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==At(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function It(t){return function(t){if(Array.isArray(t))return Rt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(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 Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var kt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5;if(null===t||null===e||null===r)return null;if(n<2)throw new Error("numLevels must be at least 2");for(var i=4*r/(n-1),o=[],a=0;a<n-1;a++)o.push(e-2*r+a*i);for(var l=o.length-1;l>=0;l--)if(t>o[l])return(l+1)/(n-1);return 0};function Mt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Tt=function(t,e,r){for(var n=0;n<r.length;n++)for(var i=(h=r[n],v=2,function(t){if(Array.isArray(t))return t}(h)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,l=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){s=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw i}}return l}}(h,v)||function(t,e){if(t){if("string"==typeof t)return Mt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mt(t,e):void 0}}(h,v)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=i[0],a=i[1],l=0;l<o.length;l++)for(var u=1;u<=a;u++){var s="".concat(o[l],"_lag_").concat(u);0===e&&(t.verticalOhlcv[s]=new Array(t.len).fill(null));var c=e-u,f=c>=0?t.verticalOhlcv[o[l]][c]:null;t.verticalOhlcv[s][e]=f}var h,v;return!0};function xt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Dt(t){return Dt="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},Dt(t)}function Ct(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lt(n.key),n)}}function Lt(t){var e=function(t,e){if("object"!=Dt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Dt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dt(e)?e:e+""}var Bt=function(t,e){return t>e},zt=function(t,e){return t<e},Ht=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.interval=0,this.prevState=.5,this.prevFast=null,this.prevSlow=null,this.prevHigh=null,this.prevLow=null,this.areHighAndLowUndefined=!1,this.index=0,this.crossIndexes={up:[],down:[]}},(e=[{key:"update",value:function(t){var e=t.fast,r=t.high,n=t.slow,i=t.low,o=this.prevState;this.areHighAndLowUndefined||void 0!==r&&void 0!==i||(this.areHighAndLowUndefined=!0),null===e||null===n||function(t,e){return t===e}(e,n)?o=.5:Bt(e,n)?o=this.areHighAndLowUndefined?1:[i,n,this.prevLow,this.prevSlow].every((function(t){return null!==t}))&&zt(i,n)&&Bt(this.prevLow,this.prevSlow)?0:1:zt(e,n)&&(o=this.areHighAndLowUndefined?0:[r,n,this.prevHigh,this.prevSlow].every((function(t){return null!==t}))&&Bt(r,n)&&zt(this.prevHigh,this.prevSlow)?1:0),.5===o?this.interval=0:1===o?this.prevState<=.5?this.interval=1:this.interval++:0===o&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(this.index),-1===this.interval&&this.crossIndexes.down.push(this.index),this.index++,this.prevState=o,this.prevFast=e,this.prevSlow=n,this.prevHigh=r,this.prevLow=i}},{key:"getResult",value:function(){return this.interval}}])&&Ct(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Ft=function(t,e,r){var n,i=t.len,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return xt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);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 o,a=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw o}}}}(r);try{for(o.s();!(n=o.n()).done;){var a=n.value,l=a.fast,u=a.slow;if(l&&u){var s="".concat(l,"_x_").concat(u);if(0===e){if("number"==typeof u&&(t.verticalOhlcv[u]=new Array(i).fill(u)),"price"!==l&&!t.verticalOhlcv.hasOwnProperty(l))throw Error('fast "'.concat(l,' not found in crossPairs"'));if(!t.verticalOhlcv.hasOwnProperty(u))throw Error('slow "'.concat(u,' not found in crossPairs"'));t.instances[s]=new Ht,t.verticalOhlcv[s]=new Array(i).fill(null)}var c=void 0,f=void 0,h=void 0,v=void 0,p=void 0;"price"===l?(f=t.verticalOhlcv.close[e],h=t.verticalOhlcv.high[e],v=t.verticalOhlcv.low[e],p=t.verticalOhlcv[u][e],t.instances[s].update({fast:f,slow:p,high:h,low:v})):(c=t.verticalOhlcv[l][e],p=t.verticalOhlcv[u][e],t.instances[s].update({fast:c,slow:p})),t.verticalOhlcv[s][e]=t.instances[s].getResult()}}}catch(t){o.e(t)}finally{o.f()}};function Nt(t){return function(t){if(Array.isArray(t))return Ut(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ut(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ut(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Vt(t){return Vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vt(t)}var qt={rsi:function(t,e,r){var n,i,o=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"rsi_".concat(r),slow:"rsi_sma_".concat(r)}),Object.assign(t.instances,jt(jt({},"rsi_".concat(r),new St(r)),"rsi_sma_".concat(r),new H(r))),Object.assign(t.verticalOhlcv,jt(jt({},"rsi_".concat(r),new Array(t.len).fill(null)),"rsi_sma_".concat(r),new Array(t.len).fill(null)))),t.instances["rsi_".concat(r)].update(o);try{n=t.instances["rsi_".concat(r)].getResult()}catch(t){n=null}n&&(t.verticalOhlcv["rsi_".concat(r)][e]=n,t.instances["rsi_sma_".concat(r)].update(n));try{i=t.instances["rsi_sma_".concat(r)].getResult()}catch(t){i=null}return i&&(t.verticalOhlcv["rsi_sma_".concat(r)][e]=i),!0},sma:function(t,e,r){var n,i=t.verticalOhlcv.close[e];0===e&&(t.instances["sma_".concat(r)]=new H(r),t.verticalOhlcv["sma_".concat(r)]=new Array(t.len).fill(null)),t.instances["sma_".concat(r)].update(i);try{n=t.instances["sma_".concat(r)].getResult()}catch(t){}n&&(t.verticalOhlcv["sma_".concat(r)][e]=n)},ema:function(t,e,r){var n,i=t.verticalOhlcv.close[e];0===e&&(t.instances["ema_".concat(r)]=new st(r),t.verticalOhlcv["ema_".concat(r)]=new Array(t.len).fill(null)),t.instances["ema_".concat(r)].update(i);try{n=t.instances["ema_".concat(r)].getResult()}catch(t){n=null}n&&(t.verticalOhlcv["ema_".concat(r)][e]=n)},macd:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:12,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:26,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:9,o=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"macd_diff",slow:"macd_dea"}),t.instances.macd=new pt(new st(r),new st(n),new st(i)),Object.assign(t.verticalOhlcv,{macd_diff:new Array(t.len).fill(null),macd_dea:new Array(t.len).fill(null),macd_histogram:new Array(t.len).fill(null)}));var a,l=t.instances.macd;l.update(o);try{a=l.getResult()}catch(t){}return a&&(t.verticalOhlcv.macd_diff[e]=a.macd,t.verticalOhlcv.macd_dea[e]=a.signal,t.verticalOhlcv.macd_histogram[e]=a.histogram),!0},relativeVolume:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=t.verticalOhlcv.volume[e];0===e&&(t.instances["relative_volume_".concat(r)]=new H(r),Object.assign(t.verticalOhlcv,Et(Et({},"relative_volume_".concat(r),new Array(t.len).fill(null)),"relative_volume_sma_".concat(r),new Array(t.len).fill(null))));var i,o=t.instances["relative_volume_".concat(r)];o.update(n);try{i=o.getResult()}catch(t){}return t.verticalOhlcv["relative_volume_sma_".concat(r)][e]=i,null!==i&&"number"==typeof t.verticalOhlcv["relative_volume_sma_".concat(r)][e-1]?t.verticalOhlcv["relative_volume_".concat(r)][e]=n/t.verticalOhlcv["relative_volume_sma_".concat(r)][e-1]:t.verticalOhlcv["relative_volume_".concat(r)][e]=null,!0},donchianChannels:function(t,e,r,n){var i=t.verticalOhlcv.high,o=t.verticalOhlcv.low;0===e&&(t.instances.donchian_channels={},Object.assign(t.verticalOhlcv,{donchian_channel_upper:new Array(t.len).fill(null),donchian_channel_basis:new Array(t.len).fill(null),donchian_channel_lower:new Array(t.len).fill(null)}));var a=e-n+1,l=a-r;if(l<0||a>t.len)return!0;var u=i.slice(l,a),s=o.slice(l,a),c=Math.max.apply(Math,It(u)),f=Math.min.apply(Math,It(s)),h=(c+f)/2,v=e;return v>=0&&v<t.len&&(t.verticalOhlcv.donchian_channel_upper[v]=c,t.verticalOhlcv.donchian_channel_basis[v]=h,t.verticalOhlcv.donchian_channel_lower[v]=f),!0},bollingerBands:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=t.verticalOhlcv.close[e];0===e&&(Object.assign(t.instances,{bollinger_bands:{instance:new tt(r,n),heightInstance:i?new H(r):null}}),Object.assign(t.verticalOhlcv,{bollinger_bands_upper:new Array(t.len).fill(null),bollinger_bands_middle:new Array(t.len).fill(null),bollinger_bands_lower:new Array(t.len).fill(null)}),i&&Object.assign(t.verticalOhlcv,{bollinger_bands_range:new Array(t.len).fill(null),bollinger_bands_height:new Array(t.len).fill(null)}));var a,l=t.instances.bollinger_bands,u=l.instance,s=l.heightInstance;u.update(o);try{a=u.getResult()}catch(t){}if(!a)return!0;var c,f,h,v=a,p=v.upper,y=v.middle,d=v.lower;if(t.verticalOhlcv.bollinger_bands_upper[e]=p,t.verticalOhlcv.bollinger_bands_middle[e]=y,t.verticalOhlcv.bollinger_bands_lower[e]=d,!i)return!0;c=(o-d)/(p-d),f=p-d,s.update(f);try{h=s.getResult()}catch(t){}return t.verticalOhlcv.bollinger_bands_range[e]=c,h&&(t.verticalOhlcv.bollinger_bands_height[e]=kt(f,h,1.5)),!0},volumeOscillator:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,i=t.verticalOhlcv.volume[e];0===e&&(Object.assign(t.instances,{volume_oscillator:{fastEMA:new st(r),slowEMA:new st(n)}}),t.verticalOhlcv.volume_oscillator=new Array(t.len).fill(null),t.crossPairsList.push({fast:"volume_oscillator",slow:0}));var o=t.instances.volume_oscillator,a=o.fastEMA,l=o.slowEMA;a.update(i),l.update(i);var u=null,s=null;try{u=a.getResult()}catch(t){u=null}try{s=l.getResult()}catch(t){s=null}return t.verticalOhlcv.volume_oscillator[e]="number"==typeof u&&"number"==typeof s&&0!==s?100*(u-s)/s:null,!0},candlesStudies:function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=i.changeLevel,a=void 0===o?7:o,l=i.sizeLevel,u=void 0===l?5:l;0===e&&Object.assign(t.verticalOhlcv,{candle_gap_size:new Array(t.len).fill(null),candle_body_size:new Array(t.len).fill(null),candle_top_size:new Array(t.len).fill(null),candle_bottom_size:new Array(t.len).fill(null),candle_shadow_size:new Array(t.len).fill(null),candle_close_direction:new Array(t.len).fill(null),candle_high_direction:new Array(t.len).fill(null),candle_low_direction:new Array(t.len).fill(null),candle_open_direction:new Array(t.len).fill(null)}),n&&0===e&&Object.assign(t.instances,{candleStudies:{topInstance:new H(r),bottomInstance:new H(r),gapInstance:new H(r),bodySizeInstance:new H(r),shadowSizeInstance:new H(r),closeDirectionInstance:new H(r),highDirectionInstance:new H(r),lowDirectionInstance:new H(r),openDirectionInstance:new H(r)}});var s=t.verticalOhlcv.open[e-1],c=t.verticalOhlcv.high[e-1],f=t.verticalOhlcv.low[e-1],h=t.verticalOhlcv.close[e-1];if([s,c,f,h].some((function(t){return void 0===t})))return!0;var v=t.verticalOhlcv.open[e],p=t.verticalOhlcv.high[e],y=t.verticalOhlcv.low[e],d=t.verticalOhlcv.close[e],b=d>v,m=Math.abs(d-v),g=Math.abs(p-y),w=p-Math.max(v,d),_=Math.min(v,d)-y,O=Math.abs(h-v),S=Math.abs(d-h),P=Math.abs(p-c),j=Math.abs(y-f),A=Math.abs(v-s),E=null,I=null,R=null,k=null,M=null,T=null,x=null,D=null,C=null;if(n){var L=t.instances.candleStudies,B=L.topInstance,z=L.bottomInstance,F=L.gapInstance,N=L.bodySizeInstance,U=L.shadowSizeInstance,V=L.closeDirectionInstance,q=L.highDirectionInstance,K=L.lowDirectionInstance,$=L.openDirectionInstance;B.update(Math.abs(w)),z.update(Math.abs(_)),U.update(Math.abs(g)),F.update(O),N.update(m),V.update(S),q.update(P),K.update(j),$.update(A);try{R=B.getResult(),I=z.getResult(),E=F.getResult(),k=N.getResult(),M=U.getResult(),T=V.getResult(),x=q.getResult(),D=K.getResult(),C=$.getResult()}catch(t){}t.verticalOhlcv.candle_body_size[e]=b?kt(m,k,2,a):-Math.abs(kt(m,k,2,a))||0,t.verticalOhlcv.candle_gap_size[e]=b?kt(O,E,2,a):-Math.abs(kt(O,E,2,a))||0,t.verticalOhlcv.candle_close_direction[e]=b?kt(S,T,2,a):-Math.abs(kt(S,T,2,a))||0,t.verticalOhlcv.candle_high_direction[e]=b?kt(P,x,2,a):-Math.abs(kt(P,x,2,a))||0,t.verticalOhlcv.candle_low_direction[e]=b?kt(j,D,2,a):-Math.abs(kt(j,D,2,a))||0,t.verticalOhlcv.candle_open_direction[e]=b?kt(A,C,2,a):-Math.abs(kt(A,C,2,a))||0,t.verticalOhlcv.candle_top_size[e]=kt(w,R,.5,u),t.verticalOhlcv.candle_bottom_size[e]=kt(_,I,.5,u),t.verticalOhlcv.candle_shadow_size[e]=kt(g,M,.5,u)}else t.verticalOhlcv.candle_body_size[e]=b?m:-m,t.verticalOhlcv.candle_gap_size[e]=b?O:-O,t.verticalOhlcv.candle_close_direction[e]=b?S:-S,t.verticalOhlcv.candle_high_direction[e]=b?P:-P,t.verticalOhlcv.candle_low_direction[e]=b?j:-j,t.verticalOhlcv.candle_open_direction[e]=b?A:-A,t.verticalOhlcv.candle_top_size[e]=w,t.verticalOhlcv.candle_bottom_size[e]=_,t.verticalOhlcv.candle_shadow_size[e]=g;return!0},lag:Tt},Kt={midPriceOpenClose:!0,midPriceHighLow:!0,sessionIndex:!0,sessionIntradayIndex:!0,dayOfTheWeek:!0,dayOfTheMonth:!0,weekOfTheMonth:!0},$t=function(t){var e=new Date(t),r=e.getDay(),n=e.getDate(),i=new Date(e.getFullYear(),e.getMonth(),1).getDay();return{day_of_the_week:r,day_of_the_month:n,week_of_the_month:Math.ceil((n+i)/7)}},Gt=function(t,e){for(var r=t.length,n=new H(e),i=new Array(r),o=0,a=0,l=0,u=0;u<r;u++)if(n.update(t[u]),n.isStable){var s=n.getResult();i[u]=s,o+=s,a+=s*s,l++}else i[u]=null;var c=o/l,f=a/l-c*c,h=Math.sqrt(f);return i.map((function(t){return null!==t?(t-c)/h:null}))},Wt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)throw new Error("Both arrays must have the same length");for(var n=Gt(t,r),i=Gt(e,r),o=t.length,a=[],l=0,u=0,s=0,c=0,f=0,h=0,v=-1,p=0;p<o;p++){if(null!==n[p]&&null!==i[p]){v=p;break}a.push(0)}if(-1===v)return new Array(o).fill(0);for(var y=v;y<o;y++){var d=n[y],b=i[y];if(null!==d&&null!==b)if(l+=d,u+=b,s+=d*b,c+=d*d,f+=b*b,++h<2)a.push(0);else{var m=h*s-l*u,g=Math.sqrt((h*c-l*l)*(h*f-u*u)),w=0===g?0:m/g;a.push(w)}else l=u=s=c=f=h=0,a.push(0)}return a};function Jt(t){return function(t){if(Array.isArray(t))return Xt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Qt(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 Yt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,l=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){s=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw i}}return l}}(t,e)||Qt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qt(t,e){if(t){if("string"==typeof t)return Xt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xt(t,e):void 0}}function Xt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Zt=function(t){for(var e=t.input,r=t.inputParams,n=new(0,t.OHLCV_INDICATORS)({input:e,studyOptions:t.studyOptions}),i=0,o=Object.entries(r);i<o.length;i++){var a=Yt(o[i],2),l=a[0],u=a[1];if(!["crossPairs","lag"].includes(l)&&Array.isArray(u))for(var s=0;s<u.length;s++){var c=u[s];Array.isArray(c)&&(c.length>0?n[l].apply(n,Jt(c)):n[l]())}}for(var f=0,h=Object.entries(r);f<h.length;f++){var v=Yt(h[f],2),p=v[0],y=v[1];if(["crossPairs","lag"].includes(p)&&Array.isArray(y))for(var d=0;d<y.length;d++){var b=y[d];Array.isArray(b)&&(b.length>0?n[p].apply(n,Jt(b)):n[p]())}}return n};function te(t){return te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},te(t)}function ee(t){return function(t){if(Array.isArray(t))return re(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return re(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?re(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function re(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ne(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ie(n.key),n)}}function ie(t){var e=function(t,e){if("object"!=te(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=te(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==te(e)?e:e+""}var oe=function(){return t=function t(e){var r=e.input,n=e.ticker,i=void 0===n?null:n,o=e.studyOptions,a=void 0===o?null:o;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(r))throw Error("input ohlcv must be an array: "+i);if(0===r.length)throw Error("input ohlcv must not be empty: "+i);if(!r[0].hasOwnProperty("close"))throw Error("input ohlcv array objects require at least close property: "+i);return this.input=r,this.priceBased=["open","high","low","close","mid_price_open_close","mid_price_high_low"],this.len=r.length,this.studyOptions=null===a?Kt:a,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.inputParams={crossPairs:null,lag:null,relativeVolume:null,ema:null,sma:null,macd:null,bollingerBands:null,rsi:null,donchianChannels:null,candlesStudies:null,volumeOscillator:null},this.studies={},this.utilities={correlation:Wt},this.setIndicatorsFromInputParams=Zt,this},e=[{key:"getData",value:function(){this.compute();for(var t=this.verticalOhlcv,e=Object.keys(t),r=t[e[0]].length,n=e.length,i=[],o=0;o<r;o++){for(var a={},l=!1,u=0;u<n;u++){var s=e[u],c=t[s][o];if(null==c){l=!0;break}a[s]=c}l||i.push(a)}return i}},{key:"getLastValues",value:function(){return this.getData()[this.getData().length-1]}},{key:"compute",value:function(){return function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=e.len,i=e.studyOptions,o=void 0===i?{}:i,a=e.inputParams;if(o)for(var l=Object.keys(o),u=0;u<l.length;u++){var s=l[u];if(!Kt.hasOwnProperty(s))throw new Error("Key ".concat(s," not found in defaultStudyOptions. Available options: ").concat(Object.keys(Kt).join(", ")))}var c=o.midPriceOpenClose,f=o.midPriceHighLow,h=o.sessionIndex,v=o.sessionIntradayIndex,p=o.dayOfTheWeek,y=o.dayOfTheMonth,d=o.weekOfTheMonth,b=["open","high","low","close","volume"];c&&b.push("mid_price_open_close"),f&&b.push("mid_price_high_low");var m,g=new Set(b),w=e.verticalOhlcv,_=!1;if(0===r){for(var O=0;O<b.length;O++)w[b[O]]=new Array(n);for(var S=Object.keys(t[0]),P=[],j=0;j<S.length;j++){var A=S[j];g.has(A)||(w[A]=new Array(n),P.push(A))}e.otherKeys=P,(_=(m=t)[0].hasOwnProperty("date")&&"string"==typeof m[0].date&&/^\d{4}-\d{2}-\d{2}/.test(m[0].date))?(h&&(w.session_index=new Array(n)),v&&(w.session_intraday_index=new Array(n)),p&&(w.day_of_the_week=new Array(n)),y&&(w.day_of_the_month=new Array(n)),d&&(w.week_of_the_month=new Array(n)),e.prevDateStr=t[0].date.slice(0,10),e.sessionIndexCount=0,e.sessionIntradayIndexCount=0,e.cachedDayInfo=$t(e.prevDateStr)):(e.prevDateStr=null,e.sessionIndexCount=null,e.sessionIntradayIndexCount=null,e.cachedDayInfo=null)}else{if(!e.otherKeys)throw new Error("otherKeys not found in main. Ensure you run with startIndex=0 first to initialize.");if(!e.hasOwnProperty("prevDateStr"))throw new Error("prevDateStr missing in main. Make sure to store state after initial run.");_=null!==e.prevDateStr}var E=[];if(a&&"object"===Vt(a))for(var I in a){var R=a[I];if(Array.isArray(R))for(var k=0;k<R.length;k++){var M=R[k];Array.isArray(M)&&E.push({key:I,fn:qt[I],args:M})}}for(var T=w.open,x=w.high,D=w.low,C=w.close,L=w.volume,B=c?w.mid_price_open_close:null,z=f?w.mid_price_high_low:null,H={},F=0;F<e.otherKeys.length;F++){var N=e.otherKeys[F];H[N]=w[N]}for(var U=e.prevDateStr,V=e.sessionIndexCount,q=e.sessionIntradayIndexCount,K=e.cachedDayInfo,$=r;$<n;$++){var G=t[$];T[$]=G.open,x[$]=G.high,D[$]=G.low,C[$]=G.close,L[$]=G.volume,B&&(B[$]=(G.open+G.close)/2),z&&(z[$]=(G.high+G.low)/2);for(var W=0;W<e.otherKeys.length;W++){var J=e.otherKeys[W];H[J][$]=G[J]}if(_){var Y=G.date.slice(0,10);Y!==U&&(U=Y,V++,q=0,K=$t(Y)),p&&(w.day_of_the_week[$]=K.day_of_the_week),y&&(w.day_of_the_month[$]=K.day_of_the_month),d&&(w.week_of_the_month[$]=K.week_of_the_month),h&&(w.session_index[$]=V),v&&(w.session_intraday_index[$]=q),q++;for(var Q=0;Q<E.length;Q++){var X=E[Q],Z=X.fn,tt=X.args,et=X.key;"crossPairs"!==et&&"lag"!==et&&Z.apply(void 0,[e,$].concat(Nt(tt)))}Tt(e,$,a.lag),Ft(e,$,e.crossPairsList)}}e.prevDateStr=U,e.sessionIndexCount=V,e.sessionIntradayIndexCount=q,e.cachedDayInfo=K}(this.input,this),this}},{key:"crossPairs",value:function(t){var e,r;return this.crossPairsList=[].concat(ee(this.crossPairsList),ee(t)),null!==(r=(e=this.inputParams).crossPairs)&&void 0!==r||(e.crossPairs=[]),this.inputParams.crossPairs.push([this.crossPairsList]),this}},{key:"lag",value:function(){var t,e,r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;null!==(e=(t=this.inputParams).lag)&&void 0!==e||(t.lag=[]),this.inputParams.lag.push([n,i]);for(var o=function(){var t=n[a];r.priceBased.find((function(e){return t.startsWith(e)}))&&r.priceBased.push(t)},a=0;a<n.length;a++)o();return this}},{key:"relativeVolume",value:function(t){var e,r;return null!==(r=(e=this.inputParams).relativeVolume)&&void 0!==r||(e.relativeVolume=[]),this.inputParams.relativeVolume.push([t]),this}},{key:"ema",value:function(t){var e,r;return null!==(r=(e=this.inputParams).ema)&&void 0!==r||(e.ema=[]),this.inputParams.ema.push([t]),this.priceBased.push("ema_".concat(t)),this}},{key:"sma",value:function(t){var e,r;return null!==(r=(e=this.inputParams).sma)&&void 0!==r||(e.sma=[]),this.inputParams.sma.push([t]),this.priceBased.push("sma_".concat(t)),this}},{key:"macd",value:function(t,e,r){var n,i;return null!==(i=(n=this.inputParams).macd)&&void 0!==i||(n.macd=[]),this.inputParams.macd.push([t,e,r]),this}},{key:"bollingerBands",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,i=arguments.length>2?arguments[2]:void 0;if("number"!=typeof r||r<=0)throw new Error('Invalid parameter: "size" must be a positive number in bollingerBands.');if("number"!=typeof n||n<=0)throw new Error('Invalid parameter: "times" must be a positive number in bollingerBands.');return null!==(e=(t=this.inputParams).bollingerBands)&&void 0!==e||(t.bollingerBands=[]),this.inputParams.bollingerBands.push([r,n,i]),this.priceBased.push("bollinger_bands_middle","bollinger_bands_upper","bollinger_bands_lower"),this}},{key:"rsi",value:function(t){var e,r;if("number"!=typeof t||t<=0)throw new Error('Invalid parameter: "size" must be a positive number in rsi.');return null!==(r=(e=this.inputParams).rsi)&&void 0!==r||(e.rsi=[]),this.inputParams.rsi.push([t]),this}},{key:"donchianChannels",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if("number"!=typeof r||r<=0)throw new Error('The "size" must be a positive number or 0 in donchianChannels.');if("number"!=typeof n||n<=0)throw new Error('The "offset" must be a positive number or 0 in donchianChannels.');return null!==(e=(t=this.inputParams).donchianChannels)&&void 0!==e||(t.donchianChannels=[]),this.inputParams.donchianChannels.push([r,n]),this.priceBased.push("donchian_channel_upper","donchian_channel_lower","donchian_channel_basis"),this}},{key:"candlesStudies",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2?arguments[2]:void 0;if("number"!=typeof r||r<=0)throw new Error('The "size" must be a positive number or 0 in candlesStudies.');if("boolean"!=typeof n)throw new Error('The "classify" must be a true or false in candlesStudies.');return null!==(e=(t=this.inputParams).candlesStudies)&&void 0!==e||(t.candlesStudies=[]),this.inputParams.candlesStudies.push([r,n,i]),this}},{key:"volumeOscillator",value:function(t,e){var r,n;return null!==(n=(r=this.inputParams).volumeOscillator)&&void 0!==n||(r.volumeOscillator=[]),this.inputParams.volumeOscillator.push([t,e]),this}}],e&&ne(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
|
|
1
|
+
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{t.r(e),t.d(e,{default:()=>oe});var r=1e6,n="[big.js] ",i=n+"Invalid ",o=i+"decimal places",a=i+"rounding mode",l=n+"Division by zero",u={},s=void 0,c=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(t,e,r,n){var i=t.c;if(r===s&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(a);if(e<1)n=3===r&&(n||!!i[0])||0===e&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(n||i[1]!==s))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=1===r&&i[e]>=5||2===r&&(i[e]>5||5===i[e]&&(n||i[e+1]!==s||1&i[e-1]))||3===r&&(n||!!i[0]),i.length=e,n)for(;++i[--e]>9;)if(i[e]=0,0===e){++t.e,i.unshift(1);break}for(e=i.length;!i[--e];)i.pop()}return t}function h(t,e,r){var n=t.e,i=t.c.join(""),o=i.length;if(e)i=i.charAt(0)+(o>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+="0";else n<o&&(i=i.slice(0,n)+"."+i.slice(n));else o>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}function v(t){return v="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},v(t)}function p(t){var e="function"==typeof Map?new Map:void 0;return p=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(y())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&d(i,r.prototype),i}(t,arguments,b(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,t)},p(t)}function y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(y=function(){return!!t})()}function d(t,e){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},d(t,e)}function b(t){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},b(t)}u.abs=function(){var t=new this.constructor(this);return t.s=1,t},u.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,a=t.s,l=r.e,u=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-a:0;if(o!=a)return o;if(e=o<0,l!=u)return l>u^e?1:-1;for(a=(l=n.length)<(u=i.length)?l:u,o=-1;++o<a;)if(n[o]!=i[o])return n[o]>i[o]^e?1:-1;return l==u?0:l>u^e?1:-1},u.div=function(t){var e=this,n=e.constructor,i=e.c,a=(t=new n(t)).c,u=e.s==t.s?1:-1,c=n.DP;if(c!==~~c||c<0||c>r)throw Error(o);if(!a[0])throw Error(l);if(!i[0])return t.s=u,t.c=[t.e=0],t;var h,v,p,y,d,b=a.slice(),m=h=a.length,g=i.length,w=i.slice(0,h),_=w.length,O=t,S=O.c=[],P=0,j=c+(O.e=e.e-t.e)+1;for(O.s=u,u=j<0?0:j,b.unshift(0);_++<h;)w.push(0);do{for(p=0;p<10;p++){if(h!=(_=w.length))y=h>_?1:-1;else for(d=-1,y=0;++d<h;)if(a[d]!=w[d]){y=a[d]>w[d]?1:-1;break}if(!(y<0))break;for(v=_==h?a:b;_;){if(w[--_]<v[_]){for(d=_;d&&!w[--d];)w[d]=9;--w[d],w[_]+=10}w[_]-=v[_]}for(;!w[0];)w.shift()}S[P++]=y?p:++p,w[0]&&y?w[_]=i[m]||0:w=[i[m]]}while((m++<g||w[0]!==s)&&u--);return S[0]||1==P||(S.shift(),O.e--,j--),P>j&&f(O,j,n.RM,w[0]!==s),O},u.eq=function(t){return 0===this.cmp(t)},u.gt=function(t){return this.cmp(t)>0},u.gte=function(t){return this.cmp(t)>-1},u.lt=function(t){return this.cmp(t)<0},u.lte=function(t){return this.cmp(t)<1},u.minus=u.sub=function(t){var e,r,n,i,o=this,a=o.constructor,l=o.s,u=(t=new a(t)).s;if(l!=u)return t.s=-u,o.plus(t);var s=o.c.slice(),c=o.e,f=t.c,h=t.e;if(!s[0]||!f[0])return f[0]?t.s=-u:s[0]?t=new a(o):t.s=1,t;if(l=c-h){for((i=l<0)?(l=-l,n=s):(h=c,n=f),n.reverse(),u=l;u--;)n.push(0);n.reverse()}else for(r=((i=s.length<f.length)?s:f).length,l=u=0;u<r;u++)if(s[u]!=f[u]){i=s[u]<f[u];break}if(i&&(n=s,s=f,f=n,t.s=-t.s),(u=(r=f.length)-(e=s.length))>0)for(;u--;)s[e++]=0;for(u=e;r>l;){if(s[--r]<f[r]){for(e=r;e&&!s[--e];)s[e]=9;--s[e],s[r]+=10}s[r]-=f[r]}for(;0===s[--u];)s.pop();for(;0===s[0];)s.shift(),--h;return s[0]||(t.s=1,s=[h=0]),t.c=s,t.e=h,t},u.mod=function(t){var e,r=this,n=r.constructor,i=r.s,o=(t=new n(t)).s;if(!t.c[0])throw Error(l);return r.s=t.s=1,e=1==t.cmp(r),r.s=i,t.s=o,e?new n(r):(i=n.DP,o=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=o,this.minus(r.times(t)))},u.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},u.plus=u.add=function(t){var e,r,n,i=this,o=i.constructor;if(t=new o(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var a=i.e,l=i.c,u=t.e,s=t.c;if(!l[0]||!s[0])return s[0]||(l[0]?t=new o(i):t.s=i.s),t;if(l=l.slice(),e=a-u){for(e>0?(u=a,n=s):(e=-e,n=l),n.reverse();e--;)n.push(0);n.reverse()}for(l.length-s.length<0&&(n=s,s=l,l=n),e=s.length,r=0;e;l[e]%=10)r=(l[--e]=l[e]+s[e]+r)/10|0;for(r&&(l.unshift(r),++u),e=l.length;0===l[--e];)l.pop();return t.c=l,t.e=u,t},u.pow=function(t){var e=this,r=new e.constructor("1"),n=r,o=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(i+"exponent");for(o&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return o?r.div(n):n},u.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(i+"precision");return f(new this.constructor(this),t,e)},u.round=function(t,e){if(t===s)t=0;else if(t!==~~t||t<-r||t>r)throw Error(o);return f(new this.constructor(this),t+this.e+1,e)},u.sqrt=function(){var t,e,r,i=this,o=i.constructor,a=i.s,l=i.e,u=new o("0.5");if(!i.c[0])return new o(i);if(a<0)throw Error(n+"No square root");0===(a=Math.sqrt(i+""))||a===1/0?((e=i.c.join("")).length+l&1||(e+="0"),l=((l+1)/2|0)-(l<0||1&l),t=new o(((a=Math.sqrt(e))==1/0?"5e":(a=a.toExponential()).slice(0,a.indexOf("e")+1))+l)):t=new o(a+""),l=t.e+(o.DP+=4);do{r=t,t=u.times(r.plus(i.div(r)))}while(r.c.slice(0,l).join("")!==t.c.slice(0,l).join(""));return f(t,(o.DP-=4)+t.e+1,o.RM)},u.times=u.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,a=i.length,l=o.length,u=r.e,s=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=u+s,a<l&&(e=i,i=o,o=e,s=a,a=l,l=s),e=new Array(s=a+l);s--;)e[s]=0;for(u=l;u--;){for(l=0,s=a+u;s>u;)l=e[s]+o[u]*i[s-u-1]+l,e[s--]=l%10,l=l/10|0;e[s]=l}for(l?++t.e:e.shift(),u=e.length;!e[--u];)e.pop();return t.c=e,t},u.toExponential=function(t,e){var n=this,i=n.c[0];if(t!==s){if(t!==~~t||t<0||t>r)throw Error(o);for(n=f(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return h(n,!0,!!i)},u.toFixed=function(t,e){var n=this,i=n.c[0];if(t!==s){if(t!==~~t||t<0||t>r)throw Error(o);for(t=t+(n=f(new n.constructor(n),t+n.e+1,e)).e+1;n.c.length<t;)n.c.push(0)}return h(n,!1,!!i)},u[Symbol.for("nodejs.util.inspect.custom")]=u.toJSON=u.toString=function(){var t=this,e=t.constructor;return h(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},u.toNumber=function(){var t=Number(h(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},u.toPrecision=function(t,e){var n=this,o=n.constructor,a=n.c[0];if(t!==s){if(t!==~~t||t<1||t>r)throw Error(i+"precision");for(n=f(new o(n),t,e);n.c.length<t;)n.c.push(0)}return h(n,t<=n.e||n.e<=o.NE||n.e>=o.PE,!!a)},u.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return h(t,t.e<=e.NE||t.e>=e.PE,!0)},function t(){function e(r){var n=this;if(!(n instanceof e))return r===s?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(i+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,o;if(!c.test(e))throw Error(i+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),o=e.length,n=0;n<o&&"0"==e.charAt(n);)++n;if(n==o)t.c=[t.e=0];else{for(;o>0&&"0"==e.charAt(--o););for(t.e=r-n-1,t.c=[],r=0;n<=o;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=u,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();var m=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=b(e),function(t,e){if(e&&("object"==v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,y()?Reflect.construct(e,r||[],b(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(p(Error));function g(t){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g(t)}function w(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,O(n.key),n)}}function _(t,e,r){return(e=O(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function O(t){var e=function(t,e){if("object"!=g(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==g(e)?e:e+""}var S=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),_(this,"previousHighest",void 0),_(this,"highest",void 0),_(this,"previousLowest",void 0),_(this,"lowest",void 0),_(this,"previousResult",void 0),_(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new m;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&w(t.prototype,e),r&&w(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();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 j(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,k(n.key),n)}}function A(t,e,r){return e=I(e),function(t,e){if(e&&("object"==P(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,E()?Reflect.construct(e,r||[],I(t).constructor):e.apply(t,r))}function E(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(E=function(){return!!t})()}function I(t){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},I(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}function k(t){var e=function(t,e){if("object"!=P(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}var M=function(t){function e(t){var r,n,i,o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=A(this,e),o=void 0,(i=k(i="interval"))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&j(r.prototype,n),i&&j(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(S);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 x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,B(n.key),n)}}function C(t,e,r){return e=L(e),function(t,e){if(e&&("object"==T(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,D()?Reflect.construct(e,r||[],L(t).constructor):e.apply(t,r))}function D(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(D=function(){return!!t})()}function L(t){return L=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},L(t)}function z(t,e){return z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},z(t,e)}function B(t){var e=function(t,e){if("object"!=T(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=T(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==T(e)?e:e+""}var H=function(t){function e(){var t,r,n,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return r=t=C(this,e,[].concat(a)),i=[],(n=B(n="prices"))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&z(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}],n&&x(r.prototype,n),i&&x(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(M);function F(t){return F="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},F(t)}function N(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,G(n.key),n)}}function U(t,e,r){return e=q(e),function(t,e){if(e&&("object"==F(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,V()?Reflect.construct(e,r||[],q(t).constructor):e.apply(t,r))}function V(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(V=function(){return!!t})()}function q(t){return q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},q(t)}function K(t,e){return K=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},K(t,e)}function $(t,e,r){return(e=G(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function G(t){var e=function(t,e){if("object"!=F(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=F(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==F(e)?e:e+""}var W=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),$(r=U(this,e),"interval",void 0),$(r,"indicator",void 0),$(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new H(t),r.smoothingFactor=1/r.interval,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&K(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var i=(t-this.result)*this.smoothingFactor;return this.setResult(i+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&N(r.prototype,n),i&&N(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(S);function J(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}function Y(t){return Y="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},Y(t)}function Q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Z(n.key),n)}}function X(t,e,r){return(e=Z(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Z(t){var e=function(t,e){if("object"!=Y(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Y(e)?e:e+""}var tt=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),X(this,"interval",void 0),X(this,"deviationMultiplier",void 0),X(this,"prices",[]),X(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=J(this.prices),r=function(t,e){var r=e||J(t),n=J(t.map((function(t){return t-r})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,e);return this.result={lower:e-r*this.deviationMultiplier,middle:e,upper:e+r*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new m;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&Q(t.prototype,e),r&&Q(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function et(t){return et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},et(t)}function rt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ut(n.key),n)}}function nt(t,e,r){return e=ot(e),function(t,e){if(e&&("object"==et(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,it()?Reflect.construct(e,r||[],ot(t).constructor):e.apply(t,r))}function it(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(it=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,e){return at=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},at(t,e)}function lt(t,e,r){return(e=ut(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ut(t){var e=function(t,e){if("object"!=et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==et(e)?e:e+""}var st=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),lt(r=nt(this,e,[t]),"interval",void 0),lt(r,"pricesCounter",0),lt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&at(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?e&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,e&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),e):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),e)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new m;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&rt(r.prototype,n),i&&rt(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(M);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 ft(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vt(n.key),n)}}function ht(t,e,r){return(e=vt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vt(t){var e=function(t,e){if("object"!=ct(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ct(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ct(e)?e:e+""}var pt=function(){return t=function t(e,r,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),ht(this,"short",void 0),ht(this,"long",void 0),ht(this,"signal",void 0),ht(this,"prices",[]),ht(this,"result",void 0),this.short=e,this.long=r,this.signal=n},e=[{key:"getResult",value:function(){if(void 0===this.result)throw new m;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var i=r-n,o=this.signal.update(i,e);return this.result={histogram:i-o,macd:i,signal:o}}}}],e&&ft(t.prototype,e),r&&ft(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();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 dt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ot(n.key),n)}}function bt(t,e,r){return e=gt(e),function(t,e){if(e&&("object"==yt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,mt()?Reflect.construct(e,r||[],gt(t).constructor):e.apply(t,r))}function mt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(mt=function(){return!!t})()}function gt(t){return gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},gt(t)}function wt(t,e){return wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},wt(t,e)}function _t(t,e,r){return(e=Ot(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ot(t){var e=function(t,e){if("object"!=yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}var St=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:W;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),_t(r=bt(this,e),"interval",void 0),_t(r,"previousPrices",[]),_t(r,"avgGain",void 0),_t(r,"avgLoss",void 0),_t(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&wt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var i=this.avgLoss.getResult();if(0===i)return this.setResult(100,e);var o=this.avgGain.getResult()/i;return this.setResult(this.maxValue-this.maxValue/(o+1),e)}}}}],n&&dt(r.prototype,n),i&&dt(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(S);function Pt(t){return Pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pt(t)}function jt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Pt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function At(t){return At="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},At(t)}function Et(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=At(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=At(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==At(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function It(t){return function(t){if(Array.isArray(t))return Rt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(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 Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var kt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5;if(null===t||null===e||null===r)return null;if(n<2)throw new Error("numLevels must be at least 2");for(var i=4*r/(n-1),o=[],a=0;a<n-1;a++)o.push(e-2*r+a*i);for(var l=o.length-1;l>=0;l--)if(t>o[l])return(l+1)/(n-1);return 0};function Mt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Tt=function(t,e,r){if(!r)return!0;for(var n=0;n<r.length;n++)for(var i=(h=r[n],v=2,function(t){if(Array.isArray(t))return t}(h)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,l=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){s=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw i}}return l}}(h,v)||function(t,e){if(t){if("string"==typeof t)return Mt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Mt(t,e):void 0}}(h,v)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=i[0],a=i[1],l=0;l<o.length;l++)for(var u=1;u<=a;u++){var s="".concat(o[l],"_lag_").concat(u);0===e&&(t.verticalOhlcv[s]=new Array(t.len).fill(null));var c=e-u,f=c>=0?t.verticalOhlcv[o[l]][c]:null;t.verticalOhlcv[s][e]=f}var h,v;return!0};function xt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ct(t){return Ct="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ct(t)}function Dt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lt(n.key),n)}}function Lt(t){var e=function(t,e){if("object"!=Ct(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ct(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ct(e)?e:e+""}var zt=function(t,e){return t>e},Bt=function(t,e){return t<e},Ht=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.interval=0,this.prevState=.5,this.prevFast=null,this.prevSlow=null,this.prevHigh=null,this.prevLow=null,this.areHighAndLowUndefined=!1,this.index=0,this.crossIndexes={up:[],down:[]}},(e=[{key:"update",value:function(t){var e=t.fast,r=t.high,n=t.slow,i=t.low,o=this.prevState;this.areHighAndLowUndefined||void 0!==r&&void 0!==i||(this.areHighAndLowUndefined=!0),null===e||null===n||function(t,e){return t===e}(e,n)?o=.5:zt(e,n)?o=this.areHighAndLowUndefined?1:[i,n,this.prevLow,this.prevSlow].every((function(t){return null!==t}))&&Bt(i,n)&&zt(this.prevLow,this.prevSlow)?0:1:Bt(e,n)&&(o=this.areHighAndLowUndefined?0:[r,n,this.prevHigh,this.prevSlow].every((function(t){return null!==t}))&&zt(r,n)&&Bt(this.prevHigh,this.prevSlow)?1:0),.5===o?this.interval=0:1===o?this.prevState<=.5?this.interval=1:this.interval++:0===o&&(this.prevState>=.5?this.interval=-1:this.interval--),1===this.interval&&this.crossIndexes.up.push(this.index),-1===this.interval&&this.crossIndexes.down.push(this.index),this.index++,this.prevState=o,this.prevFast=e,this.prevSlow=n,this.prevHigh=r,this.prevLow=i}},{key:"getResult",value:function(){return this.interval}}])&&Dt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Ft=function(t,e,r){if(r){var n,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return xt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);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 o,a=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw o}}}}(r);try{for(i.s();!(n=i.n()).done;){var o=n.value,a=o.fast,l=o.slow;if(a&&l){var u="".concat(a,"_x_").concat(l);if(0===e){if("number"==typeof l&&(t.verticalOhlcv[l]=new Array(t.len).fill(l)),"price"!==a&&!t.verticalOhlcv.hasOwnProperty(a))throw Error('fast "'.concat(a,' not found in crossPairs"'));if(!t.verticalOhlcv.hasOwnProperty(l))throw Error('slow "'.concat(l,' not found in crossPairs"'));t.instances[u]=new Ht,t.verticalOhlcv[u]=new Array(t.len).fill(null)}var s=void 0,c=void 0,f=void 0,h=void 0,v=void 0;"price"===a?(c=t.verticalOhlcv.close[e],f=t.verticalOhlcv.high[e],h=t.verticalOhlcv.low[e],v=t.verticalOhlcv[l][e],t.instances[u].update({fast:c,slow:v,high:f,low:h})):(s=t.verticalOhlcv[a][e],v=t.verticalOhlcv[l][e],t.instances[u].update({fast:s,slow:v})),t.verticalOhlcv[u][e]=t.instances[u].getResult()}}}catch(t){i.e(t)}finally{i.f()}}};function Nt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function 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)}var Vt={rsi:function(t,e,r){var n,i,o=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"rsi_".concat(r),slow:"rsi_sma_".concat(r)}),Object.assign(t.instances,jt(jt({},"rsi_".concat(r),new St(r)),"rsi_sma_".concat(r),new H(r))),Object.assign(t.verticalOhlcv,jt(jt({},"rsi_".concat(r),new Array(t.len).fill(null)),"rsi_sma_".concat(r),new Array(t.len).fill(null)))),t.instances["rsi_".concat(r)].update(o);try{n=t.instances["rsi_".concat(r)].getResult()}catch(t){n=null}n&&(t.verticalOhlcv["rsi_".concat(r)][e]=n,t.instances["rsi_sma_".concat(r)].update(n));try{i=t.instances["rsi_sma_".concat(r)].getResult()}catch(t){i=null}return i&&(t.verticalOhlcv["rsi_sma_".concat(r)][e]=i),!0},sma:function(t,e,r){var n,i=t.verticalOhlcv.close[e];0===e&&(t.instances["sma_".concat(r)]=new H(r),t.verticalOhlcv["sma_".concat(r)]=new Array(t.len).fill(null)),t.instances["sma_".concat(r)].update(i);try{n=t.instances["sma_".concat(r)].getResult()}catch(t){}n&&(t.verticalOhlcv["sma_".concat(r)][e]=n)},ema:function(t,e,r){var n,i=t.verticalOhlcv.close[e];0===e&&(t.instances["ema_".concat(r)]=new st(r),t.verticalOhlcv["ema_".concat(r)]=new Array(t.len).fill(null)),t.instances["ema_".concat(r)].update(i);try{n=t.instances["ema_".concat(r)].getResult()}catch(t){n=null}n&&(t.verticalOhlcv["ema_".concat(r)][e]=n)},macd:function(t,e,r,n,i){var o=t.verticalOhlcv.close[e];0===e&&(t.crossPairsList.push({fast:"macd_diff",slow:"macd_dea"}),t.instances.macd=new pt(new st(r),new st(n),new st(i)),Object.assign(t.verticalOhlcv,{macd_diff:new Array(t.len).fill(null),macd_dea:new Array(t.len).fill(null),macd_histogram:new Array(t.len).fill(null)}));var a,l=t.instances.macd;l.update(o);try{a=l.getResult()}catch(t){}return a&&(t.verticalOhlcv.macd_diff[e]=a.macd,t.verticalOhlcv.macd_dea[e]=a.signal,t.verticalOhlcv.macd_histogram[e]=a.histogram),!0},relativeVolume:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=t.verticalOhlcv.volume[e];0===e&&(t.instances["relative_volume_".concat(r)]=new H(r),Object.assign(t.verticalOhlcv,Et(Et({},"relative_volume_".concat(r),new Array(t.len).fill(null)),"relative_volume_sma_".concat(r),new Array(t.len).fill(null))));var i,o=t.instances["relative_volume_".concat(r)];o.update(n);try{i=o.getResult()}catch(t){}return t.verticalOhlcv["relative_volume_sma_".concat(r)][e]=i,null!==i&&"number"==typeof t.verticalOhlcv["relative_volume_sma_".concat(r)][e-1]?t.verticalOhlcv["relative_volume_".concat(r)][e]=n/t.verticalOhlcv["relative_volume_sma_".concat(r)][e-1]:t.verticalOhlcv["relative_volume_".concat(r)][e]=null,!0},donchianChannels:function(t,e,r,n){var i=t.verticalOhlcv.high,o=t.verticalOhlcv.low;0===e&&(t.instances.donchian_channels={},Object.assign(t.verticalOhlcv,{donchian_channel_upper:new Array(t.len).fill(null),donchian_channel_basis:new Array(t.len).fill(null),donchian_channel_lower:new Array(t.len).fill(null)}));var a=e-n+1,l=a-r;if(l<0||a>t.len)return!0;var u=i.slice(l,a),s=o.slice(l,a),c=Math.max.apply(Math,It(u)),f=Math.min.apply(Math,It(s)),h=(c+f)/2,v=e;return v>=0&&v<t.len&&(t.verticalOhlcv.donchian_channel_upper[v]=c,t.verticalOhlcv.donchian_channel_basis[v]=h,t.verticalOhlcv.donchian_channel_lower[v]=f),!0},bollingerBands:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=t.verticalOhlcv.close[e];0===e&&(Object.assign(t.instances,{bollinger_bands:{instance:new tt(r,n),heightInstance:i?new H(r):null}}),Object.assign(t.verticalOhlcv,{bollinger_bands_upper:new Array(t.len).fill(null),bollinger_bands_middle:new Array(t.len).fill(null),bollinger_bands_lower:new Array(t.len).fill(null)}),i&&Object.assign(t.verticalOhlcv,{bollinger_bands_range:new Array(t.len).fill(null),bollinger_bands_height:new Array(t.len).fill(null)}));var a,l=t.instances.bollinger_bands,u=l.instance,s=l.heightInstance;u.update(o);try{a=u.getResult()}catch(t){}if(!a)return!0;var c,f,h,v=a,p=v.upper,y=v.middle,d=v.lower;if(t.verticalOhlcv.bollinger_bands_upper[e]=p,t.verticalOhlcv.bollinger_bands_middle[e]=y,t.verticalOhlcv.bollinger_bands_lower[e]=d,!i)return!0;c=(o-d)/(p-d),f=p-d,s.update(f);try{h=s.getResult()}catch(t){}return t.verticalOhlcv.bollinger_bands_range[e]=c,h&&(t.verticalOhlcv.bollinger_bands_height[e]=kt(f,h,1.5)),!0},volumeOscillator:function(t,e,r,n){var i=t.verticalOhlcv.volume[e];0===e&&(Object.assign(t.instances,{volume_oscillator:{fastEMA:new st(r),slowEMA:new st(n)}}),t.verticalOhlcv.volume_oscillator=new Array(t.len).fill(null),t.crossPairsList.push({fast:"volume_oscillator",slow:0}));var o=t.instances.volume_oscillator,a=o.fastEMA,l=o.slowEMA;a.update(i),l.update(i);var u=null,s=null;try{u=a.getResult()}catch(t){u=null}try{s=l.getResult()}catch(t){s=null}return t.verticalOhlcv.volume_oscillator[e]="number"==typeof u&&"number"==typeof s&&0!==s?100*(u-s)/s:null,!0},candlesStudies:function(t,e,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=i.changeLevel,a=void 0===o?7:o,l=i.sizeLevel,u=void 0===l?5:l;0===e&&Object.assign(t.verticalOhlcv,{candle_gap_size:new Array(t.len).fill(null),candle_body_size:new Array(t.len).fill(null),candle_top_size:new Array(t.len).fill(null),candle_bottom_size:new Array(t.len).fill(null),candle_shadow_size:new Array(t.len).fill(null),candle_close_direction:new Array(t.len).fill(null),candle_high_direction:new Array(t.len).fill(null),candle_low_direction:new Array(t.len).fill(null),candle_open_direction:new Array(t.len).fill(null)}),n&&0===e&&Object.assign(t.instances,{candleStudies:{topInstance:new H(r),bottomInstance:new H(r),gapInstance:new H(r),bodySizeInstance:new H(r),shadowSizeInstance:new H(r),closeDirectionInstance:new H(r),highDirectionInstance:new H(r),lowDirectionInstance:new H(r),openDirectionInstance:new H(r)}});var s=t.verticalOhlcv.open[e-1],c=t.verticalOhlcv.high[e-1],f=t.verticalOhlcv.low[e-1],h=t.verticalOhlcv.close[e-1];if([s,c,f,h].some((function(t){return void 0===t})))return!0;var v=t.verticalOhlcv.open[e],p=t.verticalOhlcv.high[e],y=t.verticalOhlcv.low[e],d=t.verticalOhlcv.close[e],b=d>v,m=Math.abs(d-v),g=Math.abs(p-y),w=p-Math.max(v,d),_=Math.min(v,d)-y,O=Math.abs(h-v),S=Math.abs(d-h),P=Math.abs(p-c),j=Math.abs(y-f),A=Math.abs(v-s),E=null,I=null,R=null,k=null,M=null,T=null,x=null,C=null,D=null;if(n){var L=t.instances.candleStudies,z=L.topInstance,B=L.bottomInstance,F=L.gapInstance,N=L.bodySizeInstance,U=L.shadowSizeInstance,V=L.closeDirectionInstance,q=L.highDirectionInstance,K=L.lowDirectionInstance,$=L.openDirectionInstance;z.update(Math.abs(w)),B.update(Math.abs(_)),U.update(Math.abs(g)),F.update(O),N.update(m),V.update(S),q.update(P),K.update(j),$.update(A);try{R=z.getResult(),I=B.getResult(),E=F.getResult(),k=N.getResult(),M=U.getResult(),T=V.getResult(),x=q.getResult(),C=K.getResult(),D=$.getResult()}catch(t){}t.verticalOhlcv.candle_body_size[e]=b?kt(m,k,2,a):-Math.abs(kt(m,k,2,a))||0,t.verticalOhlcv.candle_gap_size[e]=b?kt(O,E,2,a):-Math.abs(kt(O,E,2,a))||0,t.verticalOhlcv.candle_close_direction[e]=b?kt(S,T,2,a):-Math.abs(kt(S,T,2,a))||0,t.verticalOhlcv.candle_high_direction[e]=b?kt(P,x,2,a):-Math.abs(kt(P,x,2,a))||0,t.verticalOhlcv.candle_low_direction[e]=b?kt(j,C,2,a):-Math.abs(kt(j,C,2,a))||0,t.verticalOhlcv.candle_open_direction[e]=b?kt(A,D,2,a):-Math.abs(kt(A,D,2,a))||0,t.verticalOhlcv.candle_top_size[e]=kt(w,R,.5,u),t.verticalOhlcv.candle_bottom_size[e]=kt(_,I,.5,u),t.verticalOhlcv.candle_shadow_size[e]=kt(g,M,.5,u)}else t.verticalOhlcv.candle_body_size[e]=b?m:-m,t.verticalOhlcv.candle_gap_size[e]=b?O:-O,t.verticalOhlcv.candle_close_direction[e]=b?S:-S,t.verticalOhlcv.candle_high_direction[e]=b?P:-P,t.verticalOhlcv.candle_low_direction[e]=b?j:-j,t.verticalOhlcv.candle_open_direction[e]=b?A:-A,t.verticalOhlcv.candle_top_size[e]=w,t.verticalOhlcv.candle_bottom_size[e]=_,t.verticalOhlcv.candle_shadow_size[e]=g;return!0},lag:Tt},qt={midPriceOpenClose:!0,midPriceHighLow:!0,sessionIndex:!0,sessionIntradayIndex:!0,dayOfTheWeek:!0,dayOfTheMonth:!0,weekOfTheMonth:!0},Kt=function(t){var e=new Date(t),r=e.getDay(),n=e.getDate(),i=new Date(e.getFullYear(),e.getMonth(),1).getDay();return{day_of_the_week:r,day_of_the_month:n,week_of_the_month:Math.ceil((n+i)/7)}},$t=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=e.len,i=e.studyOptions,o=void 0===i?{}:i,a=e.inputParams;if(o)for(var l=Object.keys(o),u=0;u<l.length;u++){var s=l[u];if(!qt.hasOwnProperty(s))throw new Error("Key ".concat(s," not found in defaultStudyOptions. Available options: ").concat(Object.keys(qt).join(", ")))}var c=o.midPriceOpenClose,f=o.midPriceHighLow,h=o.sessionIndex,v=o.sessionIntradayIndex,p=o.dayOfTheWeek,y=o.dayOfTheMonth,d=o.weekOfTheMonth,b=["open","high","low","close","volume"];c&&b.push("mid_price_open_close"),f&&b.push("mid_price_high_low");var m,g=new Set(b),w=e.verticalOhlcv,_=!1;if(0===r){for(var O=0;O<b.length;O++)w[b[O]]=new Array(n);for(var S=Object.keys(t[0]),P=[],j=0;j<S.length;j++){var A=S[j];g.has(A)||(w[A]=new Array(n),P.push(A))}e.otherKeys=P,(_=(m=t)[0].hasOwnProperty("date")&&"string"==typeof m[0].date&&/^\d{4}-\d{2}-\d{2}/.test(m[0].date))?(h&&(w.session_index=new Array(n)),v&&(w.session_intraday_index=new Array(n)),p&&(w.day_of_the_week=new Array(n)),y&&(w.day_of_the_month=new Array(n)),d&&(w.week_of_the_month=new Array(n)),e.prevDateStr=t[0].date.slice(0,10),e.sessionIndexCount=0,e.sessionIntradayIndexCount=0,e.cachedDayInfo=Kt(e.prevDateStr)):(e.prevDateStr=null,e.sessionIndexCount=null,e.sessionIntradayIndexCount=null,e.cachedDayInfo=null)}else{if(!e.otherKeys)throw new Error("otherKeys not found in main. Ensure you run with startIndex=0 first to initialize.");if(!e.hasOwnProperty("prevDateStr"))throw new Error("prevDateStr missing in main. Make sure to store state after initial run.");_=null!==e.prevDateStr}var E,I=[];if(a&&"object"===Ut(a))for(var R in a){var k=a[R];if(Array.isArray(k))for(var M=0;M<k.length;M++){var T=k[M];Array.isArray(T)&&I.push({key:R,fn:Vt[R],args:T})}}for(var x=w.open,C=w.high,D=w.low,L=w.close,z=w.volume,B=c?w.mid_price_open_close:null,H=f?w.mid_price_high_low:null,F={},N=0;N<e.otherKeys.length;N++){var U=e.otherKeys[N];F[U]=w[U]}for(var V=e.prevDateStr,q=e.sessionIndexCount,K=e.sessionIntradayIndexCount,$=e.cachedDayInfo,G=r;G<n;G++){var W=t[G];x[G]=W.open,C[G]=W.high,D[G]=W.low,L[G]=W.close,z[G]=W.volume,B&&(B[G]=(W.open+W.close)/2),H&&(H[G]=(W.high+W.low)/2);for(var J=0;J<e.otherKeys.length;J++){var Y=e.otherKeys[J];F[Y][G]=W[Y]}if(_){var Q=W.date.slice(0,10);Q!==V&&(V=Q,q++,K=0,$=Kt(Q)),p&&(w.day_of_the_week[G]=$.day_of_the_week),y&&(w.day_of_the_month[G]=$.day_of_the_month),d&&(w.week_of_the_month[G]=$.week_of_the_month),h&&(w.session_index[G]=q),v&&(w.session_intraday_index[G]=K),K++;for(var X=0;X<I.length;X++){var Z=I[X],tt=Z.fn,et=Z.args,rt=Z.key;"crossPairs"!==rt&&"lag"!==rt&&tt.apply(void 0,[e,G].concat(function(t){if(Array.isArray(t))return Nt(t)}(E=et)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(E)||function(t,e){if(t){if("string"==typeof t)return Nt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nt(t,e):void 0}}(E)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))}Tt(e,G,a.lag),Ft(e,G,e.crossPairsList),e.lastComputedIndex++}}e.prevDateStr=V,e.sessionIndexCount=q,e.sessionIntradayIndexCount=K,e.cachedDayInfo=$},Gt=function(t,e){for(var r=t.length,n=new H(e),i=new Array(r),o=0,a=0,l=0,u=0;u<r;u++)if(n.update(t[u]),n.isStable){var s=n.getResult();i[u]=s,o+=s,a+=s*s,l++}else i[u]=null;var c=o/l,f=a/l-c*c,h=Math.sqrt(f);return i.map((function(t){return null!==t?(t-c)/h:null}))},Wt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)throw new Error("Both arrays must have the same length");for(var n=Gt(t,r),i=Gt(e,r),o=t.length,a=[],l=0,u=0,s=0,c=0,f=0,h=0,v=-1,p=0;p<o;p++){if(null!==n[p]&&null!==i[p]){v=p;break}a.push(0)}if(-1===v)return new Array(o).fill(0);for(var y=v;y<o;y++){var d=n[y],b=i[y];if(null!==d&&null!==b)if(l+=d,u+=b,s+=d*b,c+=d*d,f+=b*b,++h<2)a.push(0);else{var m=h*s-l*u,g=Math.sqrt((h*c-l*l)*(h*f-u*u)),w=0===g?0:m/g;a.push(w)}else l=u=s=c=f=h=0,a.push(0)}return a};function Jt(t){return function(t){if(Array.isArray(t))return Xt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Qt(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 Yt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,l=[],u=!0,s=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(l.push(n.value),l.length!==e);u=!0);}catch(t){s=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw i}}return l}}(t,e)||Qt(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qt(t,e){if(t){if("string"==typeof t)return Xt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Xt(t,e):void 0}}function Xt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Zt=function(t){for(var e=t.input,r=t.inputParams,n=new(0,t.OHLCV_INDICATORS)({input:e,studyOptions:t.studyOptions}),i=0,o=Object.entries(r);i<o.length;i++){var a=Yt(o[i],2),l=a[0],u=a[1];if(!["crossPairs","lag"].includes(l)&&Array.isArray(u))for(var s=0;s<u.length;s++){var c=u[s];Array.isArray(c)&&(c.length>0?n[l].apply(n,Jt(c)):n[l]())}}for(var f=0,h=Object.entries(r);f<h.length;f++){var v=Yt(h[f],2),p=v[0],y=v[1];if(["crossPairs","lag"].includes(p)&&Array.isArray(y))for(var d=0;d<y.length;d++){var b=y[d];Array.isArray(b)&&(b.length>0?n[p].apply(n,Jt(b)):n[p]())}}return n};function te(t){return te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},te(t)}function ee(t){return function(t){if(Array.isArray(t))return re(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return re(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?re(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function re(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ne(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ie(n.key),n)}}function ie(t){var e=function(t,e){if("object"!=te(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=te(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==te(e)?e:e+""}var oe=function(){return t=function t(e){var r=e.input,n=e.ticker,i=void 0===n?null:n,o=e.studyOptions,a=void 0===o?null:o;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(r))throw Error("input ohlcv must be an array: "+i);if(0===r.length)throw Error("input ohlcv must not be empty: "+i);if(!r[0].hasOwnProperty("close"))throw Error("input ohlcv array objects require at least close property: "+i);return this.lastComputedIndex=0,this.input=r,this.priceBased=["open","high","low","close","mid_price_open_close","mid_price_high_low"],this.len=r.length,this.studyOptions=null===a?qt:a,this.instances={},this.crossPairsList=[],this.verticalOhlcv={},this.inputParams={crossPairs:null,lag:null,relativeVolume:null,ema:null,sma:null,macd:null,bollingerBands:null,rsi:null,donchianChannels:null,candlesStudies:null,volumeOscillator:null},this.studies={},this.utilities={correlation:Wt},this.setIndicatorsFromInputParams=Zt,this},e=[{key:"getData",value:function(){this.compute();for(var t=this.verticalOhlcv,e=Object.keys(t),r=t[e[0]].length,n=e.length,i=[],o=0;o<r;o++){for(var a={},l=!1,u=0;u<n;u++){var s=e[u],c=t[s][o];if(null==c){l=!0;break}a[s]=c}l||i.push(a)}return i}},{key:"getLastValues",value:function(){return this.getData()[this.getData().length-1]}},{key:"compute",value:function(t){if(t){var e,r=t.date,n=this.len-1,i=null===(e=this.input[n])||void 0===e?void 0:e.date;0===this.lastComputedIndex&&this.compute(),i!==r?(this.len++,this.input.push(t),$t(this.input,this,this.len)):(this.input[n]=t,$t(this.input,this,n))}return this.len>this.lastComputedIndex&&!t&&$t(this.input,this,0),this}},{key:"crossPairs",value:function(t){var e,r;return this.crossPairsList=[].concat(ee(this.crossPairsList),ee(t)),null!==(r=(e=this.inputParams).crossPairs)&&void 0!==r||(e.crossPairs=[]),this.inputParams.crossPairs.push([this.crossPairsList]),this}},{key:"lag",value:function(){var t,e,r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;null!==(e=(t=this.inputParams).lag)&&void 0!==e||(t.lag=[]),this.inputParams.lag.push([n,i]);for(var o=function(){var t=n[a];r.priceBased.find((function(e){return t.startsWith(e)}))&&r.priceBased.push(t)},a=0;a<n.length;a++)o();return this}},{key:"relativeVolume",value:function(t){var e,r;return null!==(r=(e=this.inputParams).relativeVolume)&&void 0!==r||(e.relativeVolume=[]),this.inputParams.relativeVolume.push([t]),this}},{key:"ema",value:function(t){var e,r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in ema.');return null!==(r=(e=this.inputParams).ema)&&void 0!==r||(e.ema=[]),this.inputParams.ema.push([t]),this.priceBased.push("ema_".concat(t)),this}},{key:"sma",value:function(t){var e,r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in sma.');return null!==(r=(e=this.inputParams).sma)&&void 0!==r||(e.sma=[]),this.inputParams.sma.push([t]),this.priceBased.push("sma_".concat(t)),this}},{key:"macd",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9;if("number"!=typeof r||r<=0)throw new Error('"fast" must be a positive number in macd.');if("number"!=typeof n||n<=r)throw new Error('"slow" must be a positive number greater than "fast" in macd.');if("number"!=typeof i||i<=0)throw new Error('"signal" must be a positive number in macd.');return null!==(e=(t=this.inputParams).macd)&&void 0!==e||(t.macd=[]),this.inputParams.macd.push([r,n,i]),this}},{key:"bollingerBands",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,i=arguments.length>2?arguments[2]:void 0;if("number"!=typeof r||r<=0)throw new Error('Invalid parameter: "size" must be a positive number in bollingerBands.');if("number"!=typeof n||n<=0)throw new Error('Invalid parameter: "times" must be a positive number in bollingerBands.');return null!==(e=(t=this.inputParams).bollingerBands)&&void 0!==e||(t.bollingerBands=[]),this.inputParams.bollingerBands.push([r,n,i]),this.priceBased.push("bollinger_bands_middle","bollinger_bands_upper","bollinger_bands_lower"),this}},{key:"rsi",value:function(t){var e,r;if("number"!=typeof t||t<=0)throw new Error('"size" must be a positive number in rsi.');return null!==(r=(e=this.inputParams).rsi)&&void 0!==r||(e.rsi=[]),this.inputParams.rsi.push([t]),this}},{key:"donchianChannels",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if("number"!=typeof r||r<=0)throw new Error('"size" must be a positive number or 0 in donchianChannels.');if("number"!=typeof n||n<=0)throw new Error('"offset" must be a positive number or 0 in donchianChannels.');return null!==(e=(t=this.inputParams).donchianChannels)&&void 0!==e||(t.donchianChannels=[]),this.inputParams.donchianChannels.push([r,n]),this.priceBased.push("donchian_channel_upper","donchian_channel_lower","donchian_channel_basis"),this}},{key:"candlesStudies",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2?arguments[2]:void 0;if("number"!=typeof r||r<=0)throw new Error('"size" must be a positive number or 0 in candlesStudies.');if("boolean"!=typeof n)throw new Error('"classify" must be a true or false in candlesStudies.');return null!==(e=(t=this.inputParams).candlesStudies)&&void 0!==e||(t.candlesStudies=[]),this.inputParams.candlesStudies.push([r,n,i]),this}},{key:"volumeOscillator",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;if("number"!=typeof r||r<=0)throw new Error('fastSize" must be a positive number in volumeOscillator.');if("number"!=typeof n||n<=r)throw new Error('"slowSize" must be a positive number greater than the "fastSize" in volumeOscillator.');return null!==(e=(t=this.inputParams).volumeOscillator)&&void 0!==e||(t.volumeOscillator=[]),this.inputParams.volumeOscillator.push([r,n]),this}}],e&&ne(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
|
package/index.js
CHANGED
|
@@ -9,6 +9,8 @@ export default class OHLCV_INDICATORS {
|
|
|
9
9
|
if(input.length === 0) throw Error('input ohlcv must not be empty: ' + ticker)
|
|
10
10
|
if(!input[0].hasOwnProperty('close')) throw Error('input ohlcv array objects require at least close property: ' + ticker)
|
|
11
11
|
|
|
12
|
+
this.lastComputedIndex = 0
|
|
13
|
+
|
|
12
14
|
this.input = input
|
|
13
15
|
this.priceBased = ['open', 'high', 'low', 'close', 'mid_price_open_close', 'mid_price_high_low']
|
|
14
16
|
this.len = input.length
|
|
@@ -46,7 +48,7 @@ export default class OHLCV_INDICATORS {
|
|
|
46
48
|
getData() {
|
|
47
49
|
|
|
48
50
|
this.compute()
|
|
49
|
-
|
|
51
|
+
|
|
50
52
|
const {verticalOhlcv} = this
|
|
51
53
|
const keys = Object.keys(verticalOhlcv);
|
|
52
54
|
const len = verticalOhlcv[keys[0]].length;
|
|
@@ -91,14 +93,36 @@ export default class OHLCV_INDICATORS {
|
|
|
91
93
|
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
compute() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
compute(change) {
|
|
97
|
+
if (change) {
|
|
98
|
+
const { date: changeDate } = change;
|
|
99
|
+
const lastIndex = this.len - 1;
|
|
100
|
+
const inputDate = this.input[lastIndex]?.date;
|
|
101
|
+
|
|
102
|
+
if (this.lastComputedIndex === 0) {
|
|
103
|
+
this.compute();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (inputDate !== changeDate) {
|
|
107
|
+
// Add new item
|
|
108
|
+
this.len++;
|
|
109
|
+
this.input.push(change);
|
|
110
|
+
parseOhlcvToVertical(this.input, this, this.len);
|
|
111
|
+
} else {
|
|
112
|
+
// Modify the last item
|
|
113
|
+
this.input[lastIndex] = change;
|
|
114
|
+
parseOhlcvToVertical(this.input, this, lastIndex);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (this.len > this.lastComputedIndex && !change) {
|
|
119
|
+
parseOhlcvToVertical(this.input, this, 0);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return this;
|
|
99
123
|
}
|
|
100
124
|
|
|
101
|
-
|
|
125
|
+
|
|
102
126
|
|
|
103
127
|
crossPairs(arr)
|
|
104
128
|
{
|
|
@@ -138,6 +162,10 @@ export default class OHLCV_INDICATORS {
|
|
|
138
162
|
|
|
139
163
|
ema(size) {
|
|
140
164
|
|
|
165
|
+
if (typeof size !== 'number' || size <= 0) {
|
|
166
|
+
throw new Error('"size" must be a positive number in ema.');
|
|
167
|
+
}
|
|
168
|
+
|
|
141
169
|
this.inputParams.ema ??= []
|
|
142
170
|
this.inputParams.ema.push([size])
|
|
143
171
|
this.priceBased.push(`ema_${size}`)
|
|
@@ -146,16 +174,30 @@ export default class OHLCV_INDICATORS {
|
|
|
146
174
|
}
|
|
147
175
|
sma(size) {
|
|
148
176
|
|
|
177
|
+
if (typeof size !== 'number' || size <= 0) {
|
|
178
|
+
throw new Error('"size" must be a positive number in sma.');
|
|
179
|
+
}
|
|
180
|
+
|
|
149
181
|
this.inputParams.sma ??= []
|
|
150
182
|
this.inputParams.sma.push([size])
|
|
151
183
|
this.priceBased.push(`sma_${size}`)
|
|
152
184
|
|
|
153
185
|
return this
|
|
154
186
|
}
|
|
155
|
-
macd(
|
|
187
|
+
macd(fast = 12, slow = 26, signal = 9) {
|
|
188
|
+
|
|
189
|
+
if (typeof fast !== 'number' || fast <= 0) {
|
|
190
|
+
throw new Error('"fast" must be a positive number in macd.');
|
|
191
|
+
}
|
|
192
|
+
if (typeof slow !== 'number' || slow <= fast) {
|
|
193
|
+
throw new Error('"slow" must be a positive number greater than "fast" in macd.');
|
|
194
|
+
}
|
|
195
|
+
if (typeof signal !== 'number' || signal <= 0) {
|
|
196
|
+
throw new Error('"signal" must be a positive number in macd.');
|
|
197
|
+
}
|
|
156
198
|
|
|
157
199
|
this.inputParams.macd ??= []
|
|
158
|
-
this.inputParams.macd.push([
|
|
200
|
+
this.inputParams.macd.push([fast, slow, signal])
|
|
159
201
|
|
|
160
202
|
return this
|
|
161
203
|
|
|
@@ -180,7 +222,7 @@ export default class OHLCV_INDICATORS {
|
|
|
180
222
|
{
|
|
181
223
|
// Validate size and times
|
|
182
224
|
if (typeof size !== 'number' || size <= 0) {
|
|
183
|
-
throw new Error('
|
|
225
|
+
throw new Error('"size" must be a positive number in rsi.');
|
|
184
226
|
}
|
|
185
227
|
|
|
186
228
|
this.inputParams.rsi ??= []
|
|
@@ -191,11 +233,11 @@ export default class OHLCV_INDICATORS {
|
|
|
191
233
|
donchianChannels(size = 20, offset = 0)
|
|
192
234
|
{
|
|
193
235
|
if (typeof size !== 'number' || size <= 0) {
|
|
194
|
-
throw new Error('
|
|
236
|
+
throw new Error('"size" must be a positive number or 0 in donchianChannels.');
|
|
195
237
|
}
|
|
196
238
|
|
|
197
239
|
if (typeof offset !== 'number' || offset <= 0) {
|
|
198
|
-
throw new Error('
|
|
240
|
+
throw new Error('"offset" must be a positive number or 0 in donchianChannels.');
|
|
199
241
|
}
|
|
200
242
|
|
|
201
243
|
this.inputParams.donchianChannels ??= []
|
|
@@ -208,11 +250,11 @@ export default class OHLCV_INDICATORS {
|
|
|
208
250
|
{
|
|
209
251
|
|
|
210
252
|
if (typeof size !== 'number' || size <= 0) {
|
|
211
|
-
throw new Error('
|
|
253
|
+
throw new Error('"size" must be a positive number or 0 in candlesStudies.');
|
|
212
254
|
}
|
|
213
255
|
|
|
214
256
|
if (typeof classify !== 'boolean') {
|
|
215
|
-
throw new Error('
|
|
257
|
+
throw new Error('"classify" must be a true or false in candlesStudies.');
|
|
216
258
|
}
|
|
217
259
|
|
|
218
260
|
this.inputParams.candlesStudies ??= []
|
|
@@ -220,8 +262,19 @@ export default class OHLCV_INDICATORS {
|
|
|
220
262
|
return this
|
|
221
263
|
}
|
|
222
264
|
|
|
223
|
-
volumeOscillator(fastSize, slowSize)
|
|
265
|
+
volumeOscillator(fastSize = 5, slowSize = 10)
|
|
224
266
|
{
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
if (typeof fastSize !== 'number' || fastSize <= 0) {
|
|
270
|
+
throw new Error('fastSize" must be a positive number in volumeOscillator.');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (typeof slowSize !== 'number' || slowSize <= fastSize) {
|
|
274
|
+
throw new Error('"slowSize" must be a positive number greater than the "fastSize" in volumeOscillator.');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
225
278
|
this.inputParams.volumeOscillator ??= []
|
|
226
279
|
this.inputParams.volumeOscillator.push([fastSize, slowSize])
|
|
227
280
|
return this
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.7",
|
|
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",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {FasterEMA, FasterMACD} from 'trading-signals';
|
|
2
2
|
|
|
3
|
-
export const macd = (main, index,
|
|
3
|
+
export const macd = (main, index, fast, slow, signal) => {
|
|
4
4
|
|
|
5
5
|
const value = main.verticalOhlcv.close[index]
|
|
6
6
|
|
|
@@ -9,9 +9,9 @@ export const macd = (main, index, fastLine = 12, slowLine = 26, signalLine = 9)
|
|
|
9
9
|
main.crossPairsList.push({fast: 'macd_diff', slow: 'macd_dea'});
|
|
10
10
|
|
|
11
11
|
main.instances['macd'] = new FasterMACD(
|
|
12
|
-
new FasterEMA(
|
|
13
|
-
new FasterEMA(
|
|
14
|
-
new FasterEMA(
|
|
12
|
+
new FasterEMA(fast),
|
|
13
|
+
new FasterEMA(slow),
|
|
14
|
+
new FasterEMA(signal)
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
Object.assign(main.verticalOhlcv, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FasterEMA } from 'trading-signals';
|
|
2
2
|
|
|
3
|
-
export const volumeOscillator = (main, index,
|
|
3
|
+
export const volumeOscillator = (main, index, fast, slow) => {
|
|
4
4
|
|
|
5
5
|
const value = main.verticalOhlcv.volume[index]
|
|
6
6
|
|
|
@@ -8,8 +8,8 @@ export const volumeOscillator = (main, index, fastSize = 5, slowSize = 10) => {
|
|
|
8
8
|
|
|
9
9
|
Object.assign(main.instances, {
|
|
10
10
|
volume_oscillator: {
|
|
11
|
-
fastEMA: new FasterEMA(
|
|
12
|
-
slowEMA: new FasterEMA(
|
|
11
|
+
fastEMA: new FasterEMA(fast),
|
|
12
|
+
slowEMA: new FasterEMA(slow)
|
|
13
13
|
}
|
|
14
14
|
})
|
|
15
15
|
|
|
@@ -130,13 +130,10 @@ class CrossInstance {
|
|
|
130
130
|
|
|
131
131
|
export const crossPairs = (main, index, arr) => {
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
if(!arr) return
|
|
134
134
|
|
|
135
135
|
for (const { fast, slow } of arr)
|
|
136
136
|
{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
137
|
if (!fast || !slow) continue
|
|
141
138
|
|
|
142
139
|
let crossName = `${fast}_x_${slow}`
|
|
@@ -145,7 +142,7 @@ export const crossPairs = (main, index, arr) => {
|
|
|
145
142
|
{
|
|
146
143
|
if(typeof slow === 'number')
|
|
147
144
|
{
|
|
148
|
-
main.verticalOhlcv[slow] = new Array(len).fill(slow)
|
|
145
|
+
main.verticalOhlcv[slow] = new Array(main.len).fill(slow)
|
|
149
146
|
}
|
|
150
147
|
|
|
151
148
|
if(fast !== 'price' && !main.verticalOhlcv.hasOwnProperty(fast)) throw Error(`fast "${fast} not found in crossPairs"`)
|
|
@@ -153,7 +150,7 @@ export const crossPairs = (main, index, arr) => {
|
|
|
153
150
|
|
|
154
151
|
|
|
155
152
|
main.instances[crossName] = new CrossInstance()
|
|
156
|
-
main.verticalOhlcv[crossName] = new Array(len).fill(null)
|
|
153
|
+
main.verticalOhlcv[crossName] = new Array(main.len).fill(null)
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
let fastValue
|
package/src/studies/lag.js
CHANGED
|
@@ -23,7 +23,7 @@ const indicatorFunctions = {
|
|
|
23
23
|
lag,
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const validateFirstDate =
|
|
26
|
+
const validateFirstDate = arr => arr[0].hasOwnProperty('date') && typeof arr[0].date === 'string' && /^\d{4}-\d{2}-\d{2}/.test(arr[0].date)
|
|
27
27
|
|
|
28
28
|
export const defaultStudyOptions = {
|
|
29
29
|
midPriceOpenClose: true,
|
|
@@ -53,6 +53,9 @@ const getDateInfo = (dateString) => {
|
|
|
53
53
|
export const parseOhlcvToVertical = (input, main, startIndex = 0) => {
|
|
54
54
|
const { len, studyOptions = {}, inputParams } = main
|
|
55
55
|
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
56
59
|
if (studyOptions) {
|
|
57
60
|
const studyOptionKeys = Object.keys(studyOptions)
|
|
58
61
|
for (let i = 0; i < studyOptionKeys.length; i++) {
|
|
@@ -188,6 +191,9 @@ export const parseOhlcvToVertical = (input, main, startIndex = 0) => {
|
|
|
188
191
|
let sessionIntradayIndexCount = main.sessionIntradayIndexCount
|
|
189
192
|
let cachedDayInfo = main.cachedDayInfo
|
|
190
193
|
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
191
197
|
// Compute indicators and fill data from startIndex to len
|
|
192
198
|
for (let x = startIndex; x < len; x++) {
|
|
193
199
|
const current = input[x]
|
|
@@ -199,8 +205,6 @@ export const parseOhlcvToVertical = (input, main, startIndex = 0) => {
|
|
|
199
205
|
vo_close[x] = current.close
|
|
200
206
|
vo_volume[x] = current.volume
|
|
201
207
|
|
|
202
|
-
|
|
203
|
-
|
|
204
208
|
// Mid-price calculations
|
|
205
209
|
if (vo_mid_oc) {
|
|
206
210
|
vo_mid_oc[x] = (current.open + current.close) / 2
|
|
@@ -257,6 +261,7 @@ export const parseOhlcvToVertical = (input, main, startIndex = 0) => {
|
|
|
257
261
|
|
|
258
262
|
lag(main, x, inputParams.lag)
|
|
259
263
|
crossPairs(main, x, main.crossPairsList)
|
|
264
|
+
main.lastComputedIndex++
|
|
260
265
|
}
|
|
261
266
|
}
|
|
262
267
|
|