ohlcv-indicators 1.7.7 → 1.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{t.r(e),t.d(e,{default:()=>te});var r=1e6,n="[big.js] ",o=n+"Invalid ",i=o+"decimal places",u=o+"rounding mode",l=n+"Division by zero",a={},c=void 0,s=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(t,e,r,n){var o=t.c;if(r===c&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(u);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==c))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==c||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function h(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function 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 o=new(t.bind.apply(t,n));return r&&b(o,r.prototype),o}(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(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 b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}a.abs=function(){var t=new this.constructor(this);return t.s=1,t},a.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,u=t.s,l=r.e,a=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-u:0;if(i!=u)return i;if(e=i<0,l!=a)return l>a^e?1:-1;for(u=(l=n.length)<(a=o.length)?l:a,i=-1;++i<u;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return l==a?0:l>a^e?1:-1},a.div=function(t){var e=this,n=e.constructor,o=e.c,u=(t=new n(t)).c,a=e.s==t.s?1:-1,s=n.DP;if(s!==~~s||s<0||s>r)throw Error(i);if(!u[0])throw Error(l);if(!o[0])return t.s=a,t.c=[t.e=0],t;var h,v,p,y,b,d=u.slice(),g=h=u.length,m=o.length,w=o.slice(0,h),O=w.length,_=t,j=_.c=[],S=0,P=s+(_.e=e.e-t.e)+1;for(_.s=a,a=P<0?0:P,d.unshift(0);O++<h;)w.push(0);do{for(p=0;p<10;p++){if(h!=(O=w.length))y=h>O?1:-1;else for(b=-1,y=0;++b<h;)if(u[b]!=w[b]){y=u[b]>w[b]?1:-1;break}if(!(y<0))break;for(v=O==h?u:d;O;){if(w[--O]<v[O]){for(b=O;b&&!w[--b];)w[b]=9;--w[b],w[O]+=10}w[O]-=v[O]}for(;!w[0];)w.shift()}j[S++]=y?p:++p,w[0]&&y?w[O]=o[g]||0:w=[o[g]]}while((g++<m||w[0]!==c)&&a--);return j[0]||1==S||(j.shift(),_.e--,P--),S>P&&f(_,P,n.RM,w[0]!==c),_},a.eq=function(t){return 0===this.cmp(t)},a.gt=function(t){return this.cmp(t)>0},a.gte=function(t){return this.cmp(t)>-1},a.lt=function(t){return this.cmp(t)<0},a.lte=function(t){return this.cmp(t)<1},a.minus=a.sub=function(t){var e,r,n,o,i=this,u=i.constructor,l=i.s,a=(t=new u(t)).s;if(l!=a)return t.s=-a,i.plus(t);var c=i.c.slice(),s=i.e,f=t.c,h=t.e;if(!c[0]||!f[0])return f[0]?t.s=-a:c[0]?t=new u(i):t.s=1,t;if(l=s-h){for((o=l<0)?(l=-l,n=c):(h=s,n=f),n.reverse(),a=l;a--;)n.push(0);n.reverse()}else for(r=((o=c.length<f.length)?c:f).length,l=a=0;a<r;a++)if(c[a]!=f[a]){o=c[a]<f[a];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(a=(r=f.length)-(e=c.length))>0)for(;a--;)c[e++]=0;for(a=e;r>l;){if(c[--r]<f[r]){for(e=r;e&&!c[--e];)c[e]=9;--c[e],c[r]+=10}c[r]-=f[r]}for(;0===c[--a];)c.pop();for(;0===c[0];)c.shift(),--h;return c[0]||(t.s=1,c=[h=0]),t.c=c,t.e=h,t},a.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(l);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},a.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},a.plus=a.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var u=o.e,l=o.c,a=t.e,c=t.c;if(!l[0]||!c[0])return c[0]||(l[0]?t=new i(o):t.s=o.s),t;if(l=l.slice(),e=u-a){for(e>0?(a=u,n=c):(e=-e,n=l),n.reverse();e--;)n.push(0);n.reverse()}for(l.length-c.length<0&&(n=c,c=l,l=n),e=c.length,r=0;e;l[e]%=10)r=(l[--e]=l[e]+c[e]+r)/10|0;for(r&&(l.unshift(r),++a),e=l.length;0===l[--e];)l.pop();return t.c=l,t.e=a,t},a.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(o+"exponent");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},a.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(o+"precision");return f(new this.constructor(this),t,e)},a.round=function(t,e){if(t===c)t=0;else if(t!==~~t||t<-r||t>r)throw Error(i);return f(new this.constructor(this),t+this.e+1,e)},a.sqrt=function(){var t,e,r,o=this,i=o.constructor,u=o.s,l=o.e,a=new i("0.5");if(!o.c[0])return new i(o);if(u<0)throw Error(n+"No square root");0===(u=Math.sqrt(o+""))||u===1/0?((e=o.c.join("")).length+l&1||(e+="0"),l=((l+1)/2|0)-(l<0||1&l),t=new i(((u=Math.sqrt(e))==1/0?"5e":(u=u.toExponential()).slice(0,u.indexOf("e")+1))+l)):t=new i(u+""),l=t.e+(i.DP+=4);do{r=t,t=a.times(r.plus(o.div(r)))}while(r.c.slice(0,l).join("")!==t.c.slice(0,l).join(""));return f(t,(i.DP-=4)+t.e+1,i.RM)},a.times=a.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,u=o.length,l=i.length,a=r.e,c=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=a+c,u<l&&(e=o,o=i,i=e,c=u,u=l,l=c),e=new Array(c=u+l);c--;)e[c]=0;for(a=l;a--;){for(l=0,c=u+a;c>a;)l=e[c]+i[a]*o[c-a-1]+l,e[c--]=l%10,l=l/10|0;e[c]=l}for(l?++t.e:e.shift(),a=e.length;!e[--a];)e.pop();return t.c=e,t},a.toExponential=function(t,e){var n=this,o=n.c[0];if(t!==c){if(t!==~~t||t<0||t>r)throw Error(i);for(n=f(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return h(n,!0,!!o)},a.toFixed=function(t,e){var n=this,o=n.c[0];if(t!==c){if(t!==~~t||t<0||t>r)throw Error(i);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,!!o)},a[Symbol.for("nodejs.util.inspect.custom")]=a.toJSON=a.toString=function(){var t=this,e=t.constructor;return h(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},a.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},a.toPrecision=function(t,e){var n=this,i=n.constructor,u=n.c[0];if(t!==c){if(t!==~~t||t<1||t>r)throw Error(o+"precision");for(n=f(new i(n),t,e);n.c.length<t;)n.c.push(0)}return h(n,t<=n.e||n.e<=i.NE||n.e>=i.PE,!!u)},a.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===c?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(o+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,i;if(!s.test(e))throw Error(o+"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),i=e.length,n=0;n<i&&"0"==e.charAt(n);)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&"0"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=a,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 g=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=d(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||[],d(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&&b(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(p(Error));function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function 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,_(n.key),n)}}function O(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t){var e=function(t,e){if("object"!=m(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=m(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==m(e)?e:e+""}var j=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),O(this,"previousHighest",void 0),O(this,"highest",void 0),O(this,"previousLowest",void 0),O(this,"lowest",void 0),O(this,"previousResult",void 0),O(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 g;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 S(t){return S="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},S(t)}function P(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,T(n.key),n)}}function E(t,e,r){return e=k(e),function(t,e){if(e&&("object"==S(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,A()?Reflect.construct(e,r||[],k(t).constructor):e.apply(t,r))}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function k(t){return k=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},k(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}function T(t){var e=function(t,e){if("object"!=S(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==S(e)?e:e+""}var M=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=E(this,e),i=void 0,(o=T(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&P(r.prototype,n),o&&P(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(j);function x(t){return x="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},x(t)}function C(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,F(n.key),n)}}function D(t,e,r){return e=L(e),function(t,e){if(e&&("object"==x(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,I()?Reflect.construct(e,r||[],L(t).constructor):e.apply(t,r))}function I(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(I=function(){return!!t})()}function 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 F(t){var e=function(t,e){if("object"!=x(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=x(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==x(e)?e:e+""}var N=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,u=new Array(i),l=0;l<i;l++)u[l]=arguments[l];return r=t=D(this,e,[].concat(u)),o=[],(n=F(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&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&&C(r.prototype,n),o&&C(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(M);function H(t){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(t)}function 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,W(n.key),n)}}function G(t,e,r){return e=z(e),function(t,e){if(e&&("object"==H(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||[],z(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 z(t){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},z(t)}function U(t,e){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},U(t,e)}function $(t,e,r){return(e=W(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function W(t){var e=function(t,e){if("object"!=H(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=H(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==H(e)?e:e+""}var J=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=G(this,e),"interval",void 0),$(r,"indicator",void 0),$(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new N(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&&U(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&q(r.prototype,n),o&&q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(j);function K(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=K(this.prices),r=function(t,e){var r=e||K(t),n=K(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 g;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,at(n.key),n)}}function nt(t,e,r){return e=it(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,ot()?Reflect.construct(e,r||[],it(t).constructor):e.apply(t,r))}function ot(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ot=function(){return!!t})()}function it(t){return it=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},it(t)}function ut(t,e){return ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ut(t,e)}function lt(t,e,r){return(e=at(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function at(t){var e=function(t,e){if("object"!=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 ct=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&&ut(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 g;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&rt(r.prototype,n),o&&rt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(M);function st(t){return st="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},st(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"!=st(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=st(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==st(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 g;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=r-n,i=this.signal.update(o,e);return this.result={histogram:o-i,macd:o,signal:i}}}}],e&&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 bt(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,_t(n.key),n)}}function dt(t,e,r){return e=mt(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,gt()?Reflect.construct(e,r||[],mt(t).constructor):e.apply(t,r))}function gt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(gt=function(){return!!t})()}function mt(t){return mt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},mt(t)}function wt(t,e){return wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},wt(t,e)}function Ot(t,e,r){return(e=_t(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _t(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 jt=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ot(r=dt(this,e),"interval",void 0),Ot(r,"previousPrices",[]),Ot(r,"avgGain",void 0),Ot(r,"avgLoss",void 0),Ot(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 o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&bt(r.prototype,n),o&&bt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(j);function St(t){return St="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},St(t)}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)}var Et=function(t,e){if(void 0===t||void 0===e)throw Error("undefined param in getEMA");for(var r=t.length,n=new Array(r).fill(null),o=new ct(e),i=0;i<r;i++){var u=null;if(null!==t[i]){o.update(t[i]);try{u=o.getResult()}catch(t){u=null}}n[i]=u}return n};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)}var kt=function(t,e){if(void 0===t||void 0===e)throw Error("undefined param in getSMA");for(var r=t.length,n=new Array(r).fill(null),o=new N(e),i=0;i<r;i++){var u=null;if(null!==t[i]){o.update(t[i]);try{u=o.getResult()}catch(t){u=null}}n[i]=u}return n};function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Tt=function(t,e){return t>e},Mt=function(t,e){return t<e},xt=function(t){var e=t.fast,r=t.slow,n=e.length;if(n==!r.length)throw Error("fast and slow do not have the same length");for(var o=new Array(n).fill(null),i=0;i<n;i++){var u=e[i],l=r[i],a=void 0;null===u||null===l?a="neutral":u===l?a=Tt(e[i-1],r[i-1])?1:Mt(e[i-1],r[i-1])?0:.5:Tt(u,l)?a=1:Mt(u,l)&&(a=0),o[i]=a}var c=Dt(o);return Ct(c)},Ct=function(t){var e=t.map((function(t){return t.length}));return t.map((function(t,r){var n=e[r];return t.map((function(t,e){var r=n-e;return.5===t&&(r=0),1===t&&(r*=1),0===t&&(r*=-1),r})).reverse()})).flat()},Dt=function(t){return 0===t.length?[]:t.reduce((function(t,e,r,n){if(0===r)t.push([e]);else{var o=n[r-1],i=t[t.length-1];e!==o?t.push([e]):i.push(e)}return t}),[])},It=function(t,e){var r=t.verticalOhlcv;if(!r.hasOwnProperty(e))throw Error("property ".concat(e," not found in verticalOhlcv. Invoked by findDirectionCross."));for(var n=r[e],o=n.length,i=new Array(o).fill(null),u=0;u<o;u++)if(u>0&&null!==n[u]){var l=n[u],a=n[u-1];Tt(l,a)?i[u]=1:Mt(l,a)?i[u]=0:i[u]=.5}return i},Lt=function(t,e){if(!t.verticalOhlcv.hasOwnProperty(e))throw Error("property ".concat(e," not found in verticalOhlcv. Invoked by findDirectionCross."));var r=It(t,e),n=Dt(r);return Ct(n)};function Bt(t){return Bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bt(t)}var Ft={getSMA:kt,getEMA:Et},Nt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"SMA",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:14,o=t.length;if(o<e)return[];for(var i=new Array(o).fill(null),u=new jt(e),l=0;l<o;l++){var a=null;if(null!==t[l]){u.update(t[l]);try{a=u.getResult()}catch(t){a=null}}i[l]=a}var c,s,f,h=(c={},s="rsi_".concat(e),f=i,(s=function(t){var e=function(t,e){if("object"!=Bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bt(e)?e:e+""}(s))in c?Object.defineProperty(c,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[s]=f,c);if("string"==typeof r&&"number"==typeof n&&Ft.hasOwnProperty("get".concat(r))){var v=Ft["get".concat(r)](i,n);h["rsi_".concat(r,"_").concat(n)]=v,h["rsi_".concat(e,"_x_rsi_").concat(r,"_").concat(n)]=xt({fast:i,slow:v})}return h};function Ht(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 qt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(l)throw i}}}}function qt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Gt={midPriceOpenClose:!1,midPriceHighLow:!1,sessionIndex:!1,sessionIntradayIndex:!1,dayOfTheWeek:!1,dayOfTheMonth:!1,weekOfTheMonth:!1},Vt=function(t){var e=new Date(t),r=e.getDay(),n=e.getDate(),o=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+o)/7)}},zt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5;return null===t||null===e||null===r?null:t>=e+2*r?1:t>=e+1.5*r?.875:t>=e+.5*r?.625:t<=e-2*r?0:t<=e-1.5*r?.125:t<=e-.5*r?.375:.5},Ut=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5;return null===t||null===e||null===r?null:t>e+2*r?1:t>e+1*r?.875:t>e-1*r?.625:t>e-1.5*r?.375:.125},$t=function(t,e){for(var r=t.length,n=new N(e),o=new Array(r),i=0,u=0,l=0,a=0;a<r;a++)if(n.update(t[a]),n.isStable){var c=n.getResult();o[a]=c,i+=c,u+=c*c,l++}else o[a]=null;var s=i/l,f=u/l-s*s,h=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/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=$t(t,r),o=$t(e,r),i=t.length,u=[],l=0,a=0,c=0,s=0,f=0,h=0,v=-1,p=0;p<i;p++){if(null!==n[p]&&null!==o[p]){v=p;break}u.push(0)}if(-1===v)return new Array(i).fill(0);for(var y=v;y<i;y++){var b=n[y],d=o[y];if(null!==b&&null!==d)if(l+=b,a+=d,c+=b*d,s+=b*b,f+=d*d,++h<2)u.push(0);else{var g=h*c-l*a,m=Math.sqrt((h*s-l*l)*(h*f-a*a)),w=0===m?0:g/m;u.push(w)}else l=a=c=s=f=h=0,u.push(0)}return u};function Jt(t){return Jt="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},Jt(t)}function Kt(t,e,r){return(e=Zt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}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,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Qt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qt(t,e):void 0}}(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){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Xt(t,e){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,Zt(n.key),n)}}function Zt(t){var e=function(t,e){if("object"!=Jt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Jt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Jt(e)?e:e+""}var te=function(){return t=function t(e){var r=e.input,n=e.ticker,o=void 0===n?null:n,i=e.studyOptions,u=void 0===i?null:i;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(r))throw Error("input ohlcv must be an array: "+o);if(0===r.length)throw Error("input ohlcv must not be empty: "+o);if(!r[0].hasOwnProperty("close"))throw Error("input ohlcv array objects require at least close property: "+o);return this.len=r.length,this.crossPairsArr=[],this.inputOhlcv=r,this.studyOptions=null===u?Gt:u,this.verticalOhlcv=function(t,e,r){if(Boolean(r))for(var n in r)if(!Gt.hasOwnProperty(n))throw new Error("Key ".concat(n," not found in defaultStudyOptions. Available options: ").concat(Object.keys(Gt).join(", ")));var o=r.midPriceOpenClose,i=r.midPriceHighLow,u=r.sessionIndex,l=r.sessionIntradayIndex,a=r.dayOfTheWeek,c=r.dayOfTheMonth,s=r.weekOfTheMonth,f=["open","high","low","close","volume"];o&&f.push("mid_price_open_close"),i&&f.push("mid_price_high_low");for(var h=new Set(f),v={},p=0,y=f;p<y.length;p++)v[y[p]]=new Array(e);for(var b,d=[],g=0,m=Object.keys(t[0]);g<m.length;g++){var w=m[g];h.has(w)||(v[w]=new Array(e),d.push(w))}var O,_=0,j=0,S=(O=t)[0].hasOwnProperty("date")&&"string"==typeof O[0].date&&/^\d{4}-\d{2}-\d{2}/.test(O[0].date);S&&(u&&(v.session_index=new Array(e)),l&&(v.session_intraday_index=new Array(e)),a&&(v.day_of_the_week=new Array(e)),c&&(v.day_of_the_month=new Array(e)),s&&(v.week_of_the_month=new Array(e)),b=t[0].date.slice(0,10));for(var P=0;P<e;P++){var E=t[P];v.open[P]=E.open,v.high[P]=E.high,v.low[P]=E.low,v.close[P]=E.close,v.volume[P]=E.volume,o&&(v.mid_price_open_close[P]=(E.open+E.close)/2),i&&(v.mid_price_high_low[P]=(E.high+E.low)/2);var A,k=Ht(d);try{for(k.s();!(A=k.n()).done;){var R=A.value;v[R][P]=E[R]}}catch(t){k.e(t)}finally{k.f()}if(S){var T=E.date.slice(0,10);T!==b&&(b=T,_++,j=0);var M=Vt(T),x=M.day_of_the_week,C=M.day_of_the_month,D=M.week_of_the_month;a&&(v.day_of_the_week[P]=x),c&&(v.day_of_the_month[P]=C),s&&(v.week_of_the_month[P]=D),u&&(v.session_index[P]=_),l&&(v.session_intraday_index[P]=j),j++}}return v}(r,this.len,this.studyOptions),this.indicators={},this.studies={},this.utilities={correlation:Wt},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,o=[],i=0;i<r;i++){for(var u={},l=!1,a=0;a<n;a++){var c=e[a],s=t[c][i];if(null==s){l=!0;break}u[c]=s}l||o.push(u)}return o}},{key:"getLastValues",value:function(){this.compute();for(var t=this.verticalOhlcv,e=this.len,r={},n=0,o=Object.entries(t);n<o.length;n++){var i=Yt(o[n],2),u=i[0],l=i[1][e-1];r[u]=l}return Object.assign(r,this.studies),r}},{key:"compute",value:function(){for(var t=this.indicators,e=this.addColumn.bind(this),r=0,n=Object.entries(t);r<n.length;r++){var o=Yt(n[r],2),i=o[0],u=o[1];this.verticalOhlcv.hasOwnProperty(i)?delete this.indicators[i]:e(i,u)}return this}},{key:"addColumn",value:function(t,e){var r=this.len;if(t=t.toLowerCase(),e.length>r)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");if(e.length<r){var n=r-e.length;e=new Array(n).fill(null).concat(e)}this.verticalOhlcv[t]=e}},{key:"crossPairs",value:function(t){this.compute();var e=function(t,e){var r,n=t.verticalOhlcv,o=t.len,i={},u={},l={},a=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 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))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(l)throw i}}}}(e);try{var c=function(){var t=r.value,e=t.fast,a=t.slow,c=t.count;if(!e||!a)return 1;"number"!=typeof a||i[a]||(i[a]=Array(o).fill(a));var s="".concat(e,"_x_").concat(a),f="".concat(e,"_c_").concat(a),h=function(t){return void 0!==c?t.slice(-c).filter((function(t){return 1===t||-1===t})).length:0};if(n[s]){var v=n[s];u[s]=v,void 0!==c&&(l[f]=h(v))}else if(n[e]&&n[a]){var p=xt({fast:n[e],slow:n[a]});u[s]=p,void 0!==c&&(l[f]=h(p))}else if(n[e]&&i[a]){var y=xt({fast:n[e],slow:i[a]});u[s]=y,void 0!==c&&(l[f]=h(y))}else console.log("Missing ohlcv properties for ".concat(e," or ").concat(a))};for(a.s();!(r=a.n()).done;)c()}catch(t){a.e(t)}finally{a.f()}return{x:u,c:l}}(this,t),r=e.x,n=e.c;return Object.assign(this.indicators,r),Object.assign(this.studies,n),this.compute(),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.compute();for(var r=this.verticalOhlcv,n=0;n<t.length;n++)for(var o=1;o<=e;o++){var i="".concat(t[n],"_lag_").concat(o),u=r[t[n]].slice(0,-o);Object.assign(this.indicators,Kt({},i,u))}return this.compute(),this}},{key:"relativeVolume",value:function(t){var e=function(t,e){var r=function(t){for(var e=new N(arguments.length>1&&void 0!==arguments[1]?arguments[1]:10),r=new Array(t.length).fill(null),n=new Array(t.length).fill(null),o=0;o<t.length;o++){var i=null;e.update(t[o]);try{i=e.getResult()}catch(t){i=null}r[o]=i,"number"==typeof r[o-1]&&(n[o]=t[o]/r[o-1])}return console.log(n),n}(t.verticalOhlcv.volume,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=St(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=St(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==St(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"relative_volume_".concat(e),r)}(this,t);return Object.assign(this.indicators,e),this}},{key:"ema",value:function(t){var e=function(t,e){var r=t.verticalOhlcv.close,n=Et(r,e);return function(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}({},"ema_".concat(e),n)}(this,t);return Object.assign(this.indicators,e),this}},{key:"sma",value:function(t){var e=function(t,e){var r=t.verticalOhlcv.close,n=kt(r,e);return function(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}({},"sma_".concat(e),n)}(this,t);return Object.assign(this.indicators,e),this}},{key:"macd",value:function(t,e,r){var n=function(t,e,r,n){return function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:26,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:9,o=t.length,i=new Array(o).fill(null),u=new Array(o).fill(null),l=new Array(o).fill(null),a=new pt(new ct(e),new ct(r),new ct(n)),c=0;c<o;c++){var s={};a.update(t[c]);try{s=a.getResult()}catch(t){s={macd:null,signal:null,histogram:null}}i[c]=s.macd,u[c]=s.signal,l[c]=s.histogram}return{macd_diff:i,macd_dea:u,macd_histogram:l,macd_diff_x_macd_dea:xt({fast:i,slow:u})}}(t.verticalOhlcv.close,e,r,n)}(this,t,e,r);return Object.assign(this.indicators,n),this}},{key:"bollingerBands",value:function(t,e){var r=function(t,e,r){return function(t){for(var e,r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,u=t.length,l=Array(u).fill(null),a=Array(u).fill(null),c=Array(u).fill(null),s=Array(u).fill(null),f=Array(u).fill(null),h=null,v=null,p=new tt(o,i),y=0;y<u;y++){var b={};p.update(t[y]);var d=!1;try{b=p.getResult()}catch(t){d=!0,b={upper:null,middle:null,lower:null}}if(l[y]=b.upper,a[y]=b.middle,c[y]=b.lower,d)s[y]=null,f[y]=null;else{var g=(e=t[y],r=b.upper,{range:(e-(n=b.lower))/(r-n)*100,height:(r-n)/n*100});h=g.range,v=g.height}s[y]=h,f[y]=v}return{bollinger_bands_upper:l,bollinger_bands_middle:a,bollinger_bands_lower:c,bollinger_bands_range:s,bollinger_bands_height:f}}(t.verticalOhlcv.close,e,r)}(this,t,e);return Object.assign(this.indicators,r),this}},{key:"rsi",value:function(t,e,r){var n=function(t,e,r,n){var o=t.verticalOhlcv.close;return"number"==typeof e&&void 0===n&&(n=e),Nt(o,e,r,n)}(this,t,e,r);return Object.assign(this.indicators,n),this}},{key:"orb",value:function(){var t=function(t,e){for(var r=new Array(e).fill(0),n=new Array(e).fill(0),o=0,i=null,u=0,l=0,a=0;a<e;a++){var c=t[a];if(0===a&&!c.hasOwnProperty("date"))throw Error("input ohlcv array must have a date property available in candle datapoint");var s=c.date.split(" ")[0];s!==i&&(i=s,u=c.high,l=c.low),r[o]=u,n[o]=l,o++}return{orb_high:r,orb_low:n}}(this.inputOhlcv,this.len);return Object.assign(this.indicators,t),this}},{key:"donchianChannels",value:function(t,e){var r=function(t,e,r){var n=t.verticalOhlcv,o=t.len;return function(t,e,r,n,o){for(var i=new Array(o).fill(null),u=new Array(o).fill(null),l=new Array(o).fill(null),a=[],c=[],s=0;s<o;s++){for(;a.length&&a[0]<=s-r;)a.shift();for(;a.length&&t[a[a.length-1]]<=t[s];)a.pop();for(a.push(s);c.length&&c[0]<=s-r;)c.shift();for(;c.length&&e[c[c.length-1]]>=e[s];)c.pop();if(c.push(s),s>=r-1){var f=t[a[0]],h=e[c[0]],v=(f+h)/2,p=s+n;p>=0&&p<o&&(i[p]=f,u[p]=h,l[p]=v)}}return{donchian_channel_upper:i,donchian_channel_lower:u,donchian_channel_basis:l}}(n.high,n.low,e,r,o)}(this,t,e);return Object.assign(this.indicators,r),this}},{key:"candlesStudies",value:function(t,e){var r=function(t,e,r){return function(t){var e,r,n,o,i,u,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,a=arguments.length>2?arguments[2]:void 0,c=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=new Array(a).fill(null),f=new Array(a).fill(null),h=new Array(a).fill(null),v=new Array(a).fill(null),p=new Array(a).fill(null),y=new Array(a).fill(null);c&&(e=new N(l),r=new N(l),n=new N(l),o=new N(l),i=new N(l),u=new N(l));for(var b=0;b<a;b++){var d=t[b],g=t[b-1];if(void 0!==g){var m=d.open,w=d.high,O=d.low,_=d.close,j=null,S=null,P=null,E=null,A=null,k=null,R=_-m,T=d.high-d.low,M=R>0?w-_:w-m,x=R>0?m-O:_-O,C=d.open-g.close,D=d.close-g.close;if(c){e.update(Math.abs(M)),r.update(Math.abs(x)),i.update(Math.abs(T)),n.update(C),o.update(R),u.update(D);try{P=e.getResult(),S=r.getResult(),j=n.getResult(),E=o.getResult(),A=i.getResult(),k=u.getResult()}catch(t){E=null,j=null,P=null,S=null,A=null,k=null}s[b]=zt(R,E,.5),v[b]=zt(C,j,.5),y[b]=zt(D,k,.5),f[b]=Ut(M,P,.5),h[b]=Ut(x,S,.5),p[b]=Ut(T,A,.5)}else s[b]=R,v[b]=C,y[b]=D,f[b]=M,h[b]=x,p[b]=T}}return{candle_gap_size:v,candle_body_size:s,candle_top_size:f,candle_bottom_size:h,candle_shadow_size:p,candle_position:y}}(t.inputOhlcv,e,t.len,r)}(this,t,e);return Object.assign(this.indicators,r),this}},{key:"findDirectionCross",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close","low"];this.compute();for(var e=0;e<t.length;e++){var r=t[e],n=Lt(this,r);Object.assign(this.indicators,Kt({},"".concat(r,"_direction_cross"),n))}return this.compute(),this}},{key:"findLinearDirection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close","low"];this.compute();for(var e=0;e<t.length;e++){var r=t[e],n=It(this,r);Object.assign(this.indicators,Kt({},"".concat(r,"_linear_direction"),n))}return this.compute(),this}},{key:"change",value:function(t){this.compute();var e=this.verticalOhlcv;if(!e.hasOwnProperty(t)){var r='key "'.concat(t,'" not found in verticalOhlcv. change method');throw Error(r)}return Object.assign(this.indicators,Kt({},"".concat(t,"_change"),function(t){if(!Array.isArray(t))throw Error("data param in arrayGt function must be array");for(var e=Array(t.length).fill(0),r=1;r<e.length;r++)if(null===t[r]||null===t[r-1])e[r];else{var n=t[r],o=t[r-1];e[r]=(n-o)/o*100}return e}(e[t]))),this.compute(),this}},{key:"gt",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"close",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"open";this.compute();var r,n=this.verticalOhlcv;if(!n.hasOwnProperty(t)){var o='key "'.concat(t,'" not found in verticalOhlcv. gt method');throw Error(o)}if("string"==typeof e){if(!n.hasOwnProperty(e)){var i='key "'.concat(e,'" not found in verticalOhlcv. gt method');throw Error(i)}r=n[e]}else"number"==typeof e&&(r=new Array(n[t].length).fill(e));return Object.assign(this.indicators,Kt({},"".concat(t,"_gt_").concat(e),function(t,e){if(!Array.isArray(t)||!Array.isArray(e))throw Error("a and b params in arrayGt function must be arrays");if(t.length!==e.length)throw Error("array a and b must be the same length in arrayGt function");if(t.length<2)throw Error("arrays in arrayGt function must have at least 2 numeric items");for(var r=Array(t.length).fill(.5),n=1;n<r.length;n++)null!==t[n]&&null!==e[n]||(r[n]=null),t[n]>e[n]?r[n]=1:t[n]<e[n]&&(r[n]=0);return r}(n[t],r))),this.compute(),this}}],e&&Xt(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:()=>ne});var r=1e6,n="[big.js] ",o=n+"Invalid ",i=o+"decimal places",u=o+"rounding mode",l=n+"Division by zero",a={},c=void 0,s=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(t,e,r,n){var o=t.c;if(r===c&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(u);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==c))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==c||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function h(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function 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 o=new(t.bind.apply(t,n));return r&&b(o,r.prototype),o}(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(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 b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}a.abs=function(){var t=new this.constructor(this);return t.s=1,t},a.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,u=t.s,l=r.e,a=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-u:0;if(i!=u)return i;if(e=i<0,l!=a)return l>a^e?1:-1;for(u=(l=n.length)<(a=o.length)?l:a,i=-1;++i<u;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return l==a?0:l>a^e?1:-1},a.div=function(t){var e=this,n=e.constructor,o=e.c,u=(t=new n(t)).c,a=e.s==t.s?1:-1,s=n.DP;if(s!==~~s||s<0||s>r)throw Error(i);if(!u[0])throw Error(l);if(!o[0])return t.s=a,t.c=[t.e=0],t;var h,v,p,y,b,d=u.slice(),g=h=u.length,m=o.length,w=o.slice(0,h),O=w.length,_=t,j=_.c=[],S=0,P=s+(_.e=e.e-t.e)+1;for(_.s=a,a=P<0?0:P,d.unshift(0);O++<h;)w.push(0);do{for(p=0;p<10;p++){if(h!=(O=w.length))y=h>O?1:-1;else for(b=-1,y=0;++b<h;)if(u[b]!=w[b]){y=u[b]>w[b]?1:-1;break}if(!(y<0))break;for(v=O==h?u:d;O;){if(w[--O]<v[O]){for(b=O;b&&!w[--b];)w[b]=9;--w[b],w[O]+=10}w[O]-=v[O]}for(;!w[0];)w.shift()}j[S++]=y?p:++p,w[0]&&y?w[O]=o[g]||0:w=[o[g]]}while((g++<m||w[0]!==c)&&a--);return j[0]||1==S||(j.shift(),_.e--,P--),S>P&&f(_,P,n.RM,w[0]!==c),_},a.eq=function(t){return 0===this.cmp(t)},a.gt=function(t){return this.cmp(t)>0},a.gte=function(t){return this.cmp(t)>-1},a.lt=function(t){return this.cmp(t)<0},a.lte=function(t){return this.cmp(t)<1},a.minus=a.sub=function(t){var e,r,n,o,i=this,u=i.constructor,l=i.s,a=(t=new u(t)).s;if(l!=a)return t.s=-a,i.plus(t);var c=i.c.slice(),s=i.e,f=t.c,h=t.e;if(!c[0]||!f[0])return f[0]?t.s=-a:c[0]?t=new u(i):t.s=1,t;if(l=s-h){for((o=l<0)?(l=-l,n=c):(h=s,n=f),n.reverse(),a=l;a--;)n.push(0);n.reverse()}else for(r=((o=c.length<f.length)?c:f).length,l=a=0;a<r;a++)if(c[a]!=f[a]){o=c[a]<f[a];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(a=(r=f.length)-(e=c.length))>0)for(;a--;)c[e++]=0;for(a=e;r>l;){if(c[--r]<f[r]){for(e=r;e&&!c[--e];)c[e]=9;--c[e],c[r]+=10}c[r]-=f[r]}for(;0===c[--a];)c.pop();for(;0===c[0];)c.shift(),--h;return c[0]||(t.s=1,c=[h=0]),t.c=c,t.e=h,t},a.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(l);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},a.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},a.plus=a.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var u=o.e,l=o.c,a=t.e,c=t.c;if(!l[0]||!c[0])return c[0]||(l[0]?t=new i(o):t.s=o.s),t;if(l=l.slice(),e=u-a){for(e>0?(a=u,n=c):(e=-e,n=l),n.reverse();e--;)n.push(0);n.reverse()}for(l.length-c.length<0&&(n=c,c=l,l=n),e=c.length,r=0;e;l[e]%=10)r=(l[--e]=l[e]+c[e]+r)/10|0;for(r&&(l.unshift(r),++a),e=l.length;0===l[--e];)l.pop();return t.c=l,t.e=a,t},a.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(o+"exponent");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},a.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(o+"precision");return f(new this.constructor(this),t,e)},a.round=function(t,e){if(t===c)t=0;else if(t!==~~t||t<-r||t>r)throw Error(i);return f(new this.constructor(this),t+this.e+1,e)},a.sqrt=function(){var t,e,r,o=this,i=o.constructor,u=o.s,l=o.e,a=new i("0.5");if(!o.c[0])return new i(o);if(u<0)throw Error(n+"No square root");0===(u=Math.sqrt(o+""))||u===1/0?((e=o.c.join("")).length+l&1||(e+="0"),l=((l+1)/2|0)-(l<0||1&l),t=new i(((u=Math.sqrt(e))==1/0?"5e":(u=u.toExponential()).slice(0,u.indexOf("e")+1))+l)):t=new i(u+""),l=t.e+(i.DP+=4);do{r=t,t=a.times(r.plus(o.div(r)))}while(r.c.slice(0,l).join("")!==t.c.slice(0,l).join(""));return f(t,(i.DP-=4)+t.e+1,i.RM)},a.times=a.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,u=o.length,l=i.length,a=r.e,c=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=a+c,u<l&&(e=o,o=i,i=e,c=u,u=l,l=c),e=new Array(c=u+l);c--;)e[c]=0;for(a=l;a--;){for(l=0,c=u+a;c>a;)l=e[c]+i[a]*o[c-a-1]+l,e[c--]=l%10,l=l/10|0;e[c]=l}for(l?++t.e:e.shift(),a=e.length;!e[--a];)e.pop();return t.c=e,t},a.toExponential=function(t,e){var n=this,o=n.c[0];if(t!==c){if(t!==~~t||t<0||t>r)throw Error(i);for(n=f(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return h(n,!0,!!o)},a.toFixed=function(t,e){var n=this,o=n.c[0];if(t!==c){if(t!==~~t||t<0||t>r)throw Error(i);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,!!o)},a[Symbol.for("nodejs.util.inspect.custom")]=a.toJSON=a.toString=function(){var t=this,e=t.constructor;return h(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},a.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},a.toPrecision=function(t,e){var n=this,i=n.constructor,u=n.c[0];if(t!==c){if(t!==~~t||t<1||t>r)throw Error(o+"precision");for(n=f(new i(n),t,e);n.c.length<t;)n.c.push(0)}return h(n,t<=n.e||n.e<=i.NE||n.e>=i.PE,!!u)},a.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===c?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(o+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,i;if(!s.test(e))throw Error(o+"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),i=e.length,n=0;n<i&&"0"==e.charAt(n);)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&"0"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=a,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 g=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=d(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||[],d(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&&b(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(p(Error));function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function 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,_(n.key),n)}}function O(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t){var e=function(t,e){if("object"!=m(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=m(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==m(e)?e:e+""}var j=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),O(this,"previousHighest",void 0),O(this,"highest",void 0),O(this,"previousLowest",void 0),O(this,"lowest",void 0),O(this,"previousResult",void 0),O(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 g;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 S(t){return S="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},S(t)}function P(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,T(n.key),n)}}function E(t,e,r){return e=k(e),function(t,e){if(e&&("object"==S(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,A()?Reflect.construct(e,r||[],k(t).constructor):e.apply(t,r))}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function k(t){return k=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},k(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}function T(t){var e=function(t,e){if("object"!=S(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==S(e)?e:e+""}var M=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=E(this,e),i=void 0,(o=T(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&P(r.prototype,n),o&&P(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(j);function x(t){return x="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},x(t)}function C(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,F(n.key),n)}}function D(t,e,r){return e=L(e),function(t,e){if(e&&("object"==x(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,I()?Reflect.construct(e,r||[],L(t).constructor):e.apply(t,r))}function I(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(I=function(){return!!t})()}function 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 F(t){var e=function(t,e){if("object"!=x(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=x(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==x(e)?e:e+""}var N=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,u=new Array(i),l=0;l<i;l++)u[l]=arguments[l];return r=t=D(this,e,[].concat(u)),o=[],(n=F(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&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&&C(r.prototype,n),o&&C(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(M);function H(t){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(t)}function 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,W(n.key),n)}}function G(t,e,r){return e=z(e),function(t,e){if(e&&("object"==H(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||[],z(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 z(t){return z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},z(t)}function U(t,e){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},U(t,e)}function $(t,e,r){return(e=W(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function W(t){var e=function(t,e){if("object"!=H(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=H(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==H(e)?e:e+""}var J=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=G(this,e),"interval",void 0),$(r,"indicator",void 0),$(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new N(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&&U(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&q(r.prototype,n),o&&q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(j);function K(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=K(this.prices),r=function(t,e){var r=e||K(t),n=K(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 g;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,at(n.key),n)}}function nt(t,e,r){return e=it(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,ot()?Reflect.construct(e,r||[],it(t).constructor):e.apply(t,r))}function ot(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ot=function(){return!!t})()}function it(t){return it=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},it(t)}function ut(t,e){return ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ut(t,e)}function lt(t,e,r){return(e=at(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function at(t){var e=function(t,e){if("object"!=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 ct=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&&ut(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 g;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&rt(r.prototype,n),o&&rt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(M);function st(t){return st="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},st(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"!=st(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=st(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==st(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 g;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=r-n,i=this.signal.update(o,e);return this.result={histogram:o-i,macd:o,signal:i}}}}],e&&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 bt(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,_t(n.key),n)}}function dt(t,e,r){return e=mt(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,gt()?Reflect.construct(e,r||[],mt(t).constructor):e.apply(t,r))}function gt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(gt=function(){return!!t})()}function mt(t){return mt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},mt(t)}function wt(t,e){return wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},wt(t,e)}function Ot(t,e,r){return(e=_t(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _t(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 jt=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ot(r=dt(this,e),"interval",void 0),Ot(r,"previousPrices",[]),Ot(r,"avgGain",void 0),Ot(r,"avgLoss",void 0),Ot(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 o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&bt(r.prototype,n),o&&bt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(j);function St(t){return St="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},St(t)}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)}var Et=function(t,e){if(void 0===t||void 0===e)throw Error("undefined param in getEMA");for(var r=t.length,n=new Array(r).fill(null),o=new ct(e),i=0;i<r;i++){var u=null;if(null!==t[i]){o.update(t[i]);try{u=o.getResult()}catch(t){u=null}}n[i]=u}return n};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)}var kt=function(t,e){if(void 0===t||void 0===e)throw Error("undefined param in getSMA");for(var r=t.length,n=new Array(r).fill(null),o=new N(e),i=0;i<r;i++){var u=null;if(null!==t[i]){o.update(t[i]);try{u=o.getResult()}catch(t){u=null}}n[i]=u}return n};function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Tt=function(t,e){return t===e},Mt=function(t,e){return t>e},xt=function(t,e){return t<e},Ct=function(t){var e=t.fast,r=t.high,n=t.low,o=t.slow,i=e.length;if(i==!o.length)throw Error("fast and slow do not have the same length");for(var u=new Array(i).fill(.5),l=0;l<i;l++){var a=(null==u?void 0:u[l-1])||.5,c=e[l],s=o[l],f=null==r?void 0:r[l],h=null==n?void 0:n[l];if(!r&&!n||void 0!==f&&void 0!==h){var v=o[l-1],p=null==r?void 0:r[l-1],y=null==n?void 0:n[l-1];if(!r&&!n||void 0!==p&&void 0!==y&&void 0!==v){var b=void 0;null===c||null===s?b=.5:Tt(c,s)?b=a:Mt(c,s)?b=xt(h,s)&&Mt(y,v)?0:1:xt(c,s)&&(b=Mt(f,s)&&xt(p,v)?1:0),u[l]=b}}}var d=It(u);return Dt(d)},Dt=function(t){var e=t.map((function(t){return t.length}));return t.map((function(t,r){var n=e[r];return t.map((function(t,e){var r=n-e;return.5===t&&(r=0),1===t&&(r*=1),0===t&&(r*=-1),r})).reverse()})).flat()},It=function(t){return 0===t.length?[]:t.reduce((function(t,e,r,n){if(0===r)t.push([e]);else{var o=n[r-1],i=t[t.length-1];e!==o?t.push([e]):i.push(e)}return t}),[])},Lt=function(t,e){var r=t.verticalOhlcv;if(!r.hasOwnProperty(e))throw Error("property ".concat(e," not found in verticalOhlcv. Invoked by findDirectionCross."));for(var n=r[e],o=n.length,i=new Array(o).fill(null),u=0;u<o;u++)if(u>0&&null!==n[u]){var l=n[u],a=n[u-1];Mt(l,a)?i[u]=1:xt(l,a)?i[u]=0:i[u]=.5}return i},Bt=function(t,e){if(!t.verticalOhlcv.hasOwnProperty(e))throw Error("property ".concat(e," not found in verticalOhlcv. Invoked by findDirectionCross."));var r=Lt(t,e),n=It(r);return Dt(n)},Ft=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5;return null===t||null===e||null===r?null:t>e+2*r?1:t>e+1*r?.875:t>e-1*r?.625:t>e-1.5*r?.375:.125},Nt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5;return null===t||null===e||null===r?null:t>=e+2*r?1:t>=e+1.5*r?.875:t>=e+.5*r?.625:t<=e-2*r?0:t<=e-1.5*r?.125:t<=e-.5*r?.375:.5};function Ht(t){return Ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ht(t)}var qt={getSMA:kt,getEMA:Et},Gt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"SMA",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:14,o=t.length;if(o<e)return[];for(var i=new Array(o).fill(null),u=new jt(e),l=0;l<o;l++){var a=null;if(null!==t[l]){u.update(t[l]);try{a=u.getResult()}catch(t){a=null}}i[l]=a}var c,s,f,h=(c={},s="rsi_".concat(e),f=i,(s=function(t){var e=function(t,e){if("object"!=Ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ht(e)?e:e+""}(s))in c?Object.defineProperty(c,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[s]=f,c);if("string"==typeof r&&"number"==typeof n&&qt.hasOwnProperty("get".concat(r))){var v=qt["get".concat(r)](i,n);h["rsi_".concat(r,"_").concat(n)]=v,h["rsi_".concat(e,"_x_rsi_").concat(r,"_").concat(n)]=Ct({fast:i,slow:v})}return h};function Vt(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 zt(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)?zt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(l)throw i}}}}function zt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ut={midPriceOpenClose:!1,midPriceHighLow:!1,sessionIndex:!1,sessionIntradayIndex:!1,dayOfTheWeek:!1,dayOfTheMonth:!1,weekOfTheMonth:!1},$t=function(t){var e=new Date(t),r=e.getDay(),n=e.getDate(),o=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+o)/7)}},Wt=function(t,e){for(var r=t.length,n=new N(e),o=new Array(r),i=0,u=0,l=0,a=0;a<r;a++)if(n.update(t[a]),n.isStable){var c=n.getResult();o[a]=c,i+=c,u+=c*c,l++}else o[a]=null;var s=i/l,f=u/l-s*s,h=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/h:null}))},Jt=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=Wt(t,r),o=Wt(e,r),i=t.length,u=[],l=0,a=0,c=0,s=0,f=0,h=0,v=-1,p=0;p<i;p++){if(null!==n[p]&&null!==o[p]){v=p;break}u.push(0)}if(-1===v)return new Array(i).fill(0);for(var y=v;y<i;y++){var b=n[y],d=o[y];if(null!==b&&null!==d)if(l+=b,a+=d,c+=b*d,s+=b*b,f+=d*d,++h<2)u.push(0);else{var g=h*c-l*a,m=Math.sqrt((h*s-l*l)*(h*f-a*a)),w=0===m?0:g/m;u.push(w)}else l=a=c=s=f=h=0,u.push(0)}return u};function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Yt(t){return function(t){if(Array.isArray(t))return te(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Zt(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qt(t,e,r){return(e=re(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(t,e)||Zt(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 Zt(t,e){if(t){if("string"==typeof t)return te(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?te(t,e):void 0}}function te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ee(t,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,re(n.key),n)}}function re(t){var e=function(t,e){if("object"!=Kt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kt(e)?e:e+""}var ne=function(){return t=function t(e){var r=e.input,n=e.ticker,o=void 0===n?null:n,i=e.studyOptions,u=void 0===i?null:i;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(r))throw Error("input ohlcv must be an array: "+o);if(0===r.length)throw Error("input ohlcv must not be empty: "+o);if(!r[0].hasOwnProperty("close"))throw Error("input ohlcv array objects require at least close property: "+o);return this.priceBased=new Set(["open","high","low","close","mid_price_open_close","mid_price_high_low"]),this.len=r.length,this.crossPairsArr=[],this.inputOhlcv=r,this.studyOptions=null===u?Ut:u,this.verticalOhlcv=function(t,e,r){if(Boolean(r))for(var n in r)if(!Ut.hasOwnProperty(n))throw new Error("Key ".concat(n," not found in defaultStudyOptions. Available options: ").concat(Object.keys(Ut).join(", ")));var o=r.midPriceOpenClose,i=r.midPriceHighLow,u=r.sessionIndex,l=r.sessionIntradayIndex,a=r.dayOfTheWeek,c=r.dayOfTheMonth,s=r.weekOfTheMonth,f=["open","high","low","close","volume"];o&&f.push("mid_price_open_close"),i&&f.push("mid_price_high_low");for(var h=new Set(f),v={},p=0,y=f;p<y.length;p++)v[y[p]]=new Array(e);for(var b,d=[],g=0,m=Object.keys(t[0]);g<m.length;g++){var w=m[g];h.has(w)||(v[w]=new Array(e),d.push(w))}var O,_=0,j=0,S=(O=t)[0].hasOwnProperty("date")&&"string"==typeof O[0].date&&/^\d{4}-\d{2}-\d{2}/.test(O[0].date);S&&(u&&(v.session_index=new Array(e)),l&&(v.session_intraday_index=new Array(e)),a&&(v.day_of_the_week=new Array(e)),c&&(v.day_of_the_month=new Array(e)),s&&(v.week_of_the_month=new Array(e)),b=t[0].date.slice(0,10));for(var P=0;P<e;P++){var E=t[P];v.open[P]=E.open,v.high[P]=E.high,v.low[P]=E.low,v.close[P]=E.close,v.volume[P]=E.volume,o&&(v.mid_price_open_close[P]=(E.open+E.close)/2),i&&(v.mid_price_high_low[P]=(E.high+E.low)/2);var A,k=Vt(d);try{for(k.s();!(A=k.n()).done;){var R=A.value;v[R][P]=E[R]}}catch(t){k.e(t)}finally{k.f()}if(S){var T=E.date.slice(0,10);T!==b&&(b=T,_++,j=0);var M=$t(T),x=M.day_of_the_week,C=M.day_of_the_month,D=M.week_of_the_month;a&&(v.day_of_the_week[P]=x),c&&(v.day_of_the_month[P]=C),s&&(v.week_of_the_month[P]=D),u&&(v.session_index[P]=_),l&&(v.session_intraday_index[P]=j),j++}}return v}(r,this.len,this.studyOptions),this.indicators={},this.studies={},this.utilities={correlation:Jt},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,o=[],i=0;i<r;i++){for(var u={},l=!1,a=0;a<n;a++){var c=e[a],s=t[c][i];if(null==s){l=!0;break}u[c]=s}l||o.push(u)}return o}},{key:"getLastValues",value:function(){return this.getData()[this.getData().length-1]}},{key:"compute",value:function(){for(var t=this.indicators,e=this.addColumn.bind(this),r=0,n=Object.entries(t);r<n.length;r++){var o=Xt(n[r],2),i=o[0],u=o[1];this.verticalOhlcv.hasOwnProperty(i)?delete this.indicators[i]:e(i,u)}return this}},{key:"addColumn",value:function(t,e){var r=this.len;if(t=t.toLowerCase(),e.length>r)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");if(e.length<r){var n=r-e.length;e=new Array(n).fill(null).concat(e)}this.verticalOhlcv[t]=e}},{key:"crossPairs",value:function(t){this.compute();var e=function(t,e){var r,n=t.verticalOhlcv,o=t.len,i={},u={},l={},a=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 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))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(l)throw i}}}}(e);try{var c=function(){var t=r.value,e=t.fast,a=t.slow,c=t.count;if(!e||!a)return 1;"number"!=typeof a||i[a]||(i[a]=Array(o).fill(a));var s="".concat(e,"_x_").concat(a),f="".concat(e,"_c_").concat(a),h=function(t){return void 0!==c?t.slice(-c).filter((function(t){return 1===t||-1===t})).length:0};if(n[s]){var v=n[s];u[s]=v,void 0!==c&&(l[f]=h(v))}else if((n[e]||"price"===e)&&n[a]){var p=Ct("price"===e?{fast:n.close,high:n.high,low:n.low,slow:n[a]}:{fast:n[e],slow:n[a]});u[s]=p,void 0!==c&&(l[f]=h(p))}else if(n[e]&&i[a]){var y=Ct({fast:n[e],slow:i[a]});u[s]=y,void 0!==c&&(l[f]=h(y))}else console.log("Missing ohlcv properties for ".concat(e," or ").concat(a))};for(a.s();!(r=a.n()).done;)c()}catch(t){a.e(t)}finally{a.f()}return{x:u,c:l}}(this,t),r=e.x,n=e.c;return Object.assign(this.indicators,r),Object.assign(this.studies,n),this.compute(),this}},{key:"lag",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.compute();for(var n=this.verticalOhlcv,o=this.priceBased,i=0;i<e.length;i++)for(var u=function(){var r="".concat(e[i],"_lag_").concat(l),u=n[e[i]].slice(0,-l);Object.assign(t.indicators,Qt({},r,u)),Yt(o).find((function(t){return r.startsWith(t)}))&&t.priceBased.add(r)},l=1;l<=r;l++)u();return this.compute(),this}},{key:"relativeVolume",value:function(t){var e=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=function(t,e){for(var r=new N(e),n=new Array(t.length).fill(null),o=new Array(t.length).fill(null),i=0;i<t.length;i++){var u=null;r.update(t[i]);try{u=r.getResult()}catch(t){u=null}n[i]=u,"number"==typeof n[i-1]&&(o[i]=t[i]/n[i-1])}return o}(t.verticalOhlcv.volume,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=St(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=St(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==St(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"relative_volume_".concat(e),r)}(this,t);return Object.assign(this.indicators,e),this}},{key:"ema",value:function(t){var e=function(t,e){var r=t.verticalOhlcv.close,n=Et(r,e);return function(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}({},"ema_".concat(e),n)}(this,t);return Object.assign(this.indicators,e),this.priceBased.add("ema_".concat(t)),this}},{key:"sma",value:function(t){var e=function(t,e){var r=t.verticalOhlcv.close,n=kt(r,e);return function(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}({},"sma_".concat(e),n)}(this,t);return Object.assign(this.indicators,e),this.priceBased.add("sma_".concat(t)),this}},{key:"macd",value:function(t,e,r){var n=function(t,e,r,n){return function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:26,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:9,o=t.length,i=new Array(o).fill(null),u=new Array(o).fill(null),l=new Array(o).fill(null),a=new pt(new ct(e),new ct(r),new ct(n)),c=0;c<o;c++){var s={};a.update(t[c]);try{s=a.getResult()}catch(t){s={macd:null,signal:null,histogram:null}}i[c]=s.macd,u[c]=s.signal,l[c]=s.histogram}return{macd_diff:i,macd_dea:u,macd_histogram:l,macd_diff_x_macd_dea:Ct({fast:i,slow:u})}}(t.verticalOhlcv.close,e,r,n)}(this,t,e,r);return Object.assign(this.indicators,n),this}},{key:"bollingerBands",value:function(t,e){var r=function(t,e,r){return function(t){for(var e,r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,u=t.length,l=Array(u).fill(null),a=Array(u).fill(null),c=Array(u).fill(null),s=Array(u).fill(null),f=Array(u).fill(null),h=new N(o),v=null,p=null,y=new tt(o,i),b=0;b<u;b++){var d={};y.update(t[b]);var g=!1,m=void 0;try{d=y.getResult()}catch(t){g=!0,d={upper:null,middle:null,lower:null}}if(l[b]=d.upper,a[b]=d.middle,c[b]=d.lower,g)s[b]=null,f[b]=null;else{var w=(e=t[b],r=d.upper,{range:(e-(n=d.lower))/(r-n),height:r-n});v=w.range,p=w.height,h.update(p);try{m=h.getResult()}catch(t){m=null}}s[b]=v,f[b]=Ft(p,m,1.5)}return{bollinger_bands_upper:l,bollinger_bands_middle:a,bollinger_bands_lower:c,bollinger_bands_range:s,bollinger_bands_height:f}}(t.verticalOhlcv.close,e,r)}(this,t,e);return Object.assign(this.indicators,r),this.priceBased.add("bollinger_bands_middle"),this.priceBased.add("bollinger_bands_upper"),this.priceBased.add("bollinger_bands_lower"),this}},{key:"rsi",value:function(t,e,r){var n=function(t,e,r,n){var o=t.verticalOhlcv.close;return"number"==typeof e&&void 0===n&&(n=e),Gt(o,e,r,n)}(this,t,e,r);return Object.assign(this.indicators,n),this}},{key:"orb",value:function(){var t=function(t,e){for(var r=new Array(e).fill(0),n=new Array(e).fill(0),o=0,i=null,u=0,l=0,a=0;a<e;a++){var c=t[a];if(0===a&&!c.hasOwnProperty("date"))throw Error("input ohlcv array must have a date property available in candle datapoint");var s=c.date.split(" ")[0];s!==i&&(i=s,u=c.high,l=c.low),r[o]=u,n[o]=l,o++}return{orb_high:r,orb_low:n}}(this.inputOhlcv,this.len);return Object.assign(this.indicators,t),this.priceBased.add("orb_high"),this.priceBased.add("orb_low"),this}},{key:"donchianChannels",value:function(t,e){var r=function(t,e,r){var n=t.verticalOhlcv,o=t.len;return function(t,e,r,n,o){for(var i=new Array(o).fill(null),u=new Array(o).fill(null),l=new Array(o).fill(null),a=[],c=[],s=0;s<o;s++){for(;a.length&&a[0]<=s-r;)a.shift();for(;a.length&&t[a[a.length-1]]<=t[s];)a.pop();for(a.push(s);c.length&&c[0]<=s-r;)c.shift();for(;c.length&&e[c[c.length-1]]>=e[s];)c.pop();if(c.push(s),s>=r-1){var f=t[a[0]],h=e[c[0]],v=(f+h)/2,p=s+n;p>=0&&p<o&&(i[p]=f,u[p]=h,l[p]=v)}}return{donchian_channel_upper:i,donchian_channel_lower:u,donchian_channel_basis:l}}(n.high,n.low,e,r,o)}(this,t,e);return Object.assign(this.indicators,r),this.priceBased.add("donchian_channel_upper"),this.priceBased.add("donchian_channel_lower"),this.priceBased.add("donchian_channel_basis"),this}},{key:"candlesStudies",value:function(t,e){var r=function(t,e,r){return function(t){var e,r,n,o,i,u,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,a=arguments.length>2?arguments[2]:void 0,c=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=new Array(a).fill(null),f=new Array(a).fill(null),h=new Array(a).fill(null),v=new Array(a).fill(null),p=new Array(a).fill(null),y=new Array(a).fill(null);c&&(e=new N(l),r=new N(l),n=new N(l),o=new N(l),i=new N(l),u=new N(l));for(var b=0;b<a;b++){var d=t[b],g=t[b-1];if(void 0!==g){var m=d.open,w=d.high,O=d.low,_=d.close,j=null,S=null,P=null,E=null,A=null,k=null,R=_-m,T=d.high-d.low,M=R>0?w-_:w-m,x=R>0?m-O:_-O,C=d.open-g.close,D=d.close-g.close;if(c){e.update(Math.abs(M)),r.update(Math.abs(x)),i.update(Math.abs(T)),n.update(C),o.update(R),u.update(D);try{P=e.getResult(),S=r.getResult(),j=n.getResult(),E=o.getResult(),A=i.getResult(),k=u.getResult()}catch(t){E=null,j=null,P=null,S=null,A=null,k=null}s[b]=Nt(R,E,.5),v[b]=Nt(C,j,.5),y[b]=Nt(D,k,.5),f[b]=Ft(M,P,.5),h[b]=Ft(x,S,.5),p[b]=Ft(T,A,.5)}else s[b]=R,v[b]=C,y[b]=D,f[b]=M,h[b]=x,p[b]=T}}return{candle_gap_size:v,candle_body_size:s,candle_top_size:f,candle_bottom_size:h,candle_shadow_size:p,candle_position:y}}(t.inputOhlcv,e,t.len,r)}(this,t,e);return Object.assign(this.indicators,r),this}},{key:"findDirectionCross",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close","low"];this.compute();for(var e=0;e<t.length;e++){var r=t[e],n=Bt(this,r);Object.assign(this.indicators,Qt({},"".concat(r,"_direction_cross"),n))}return this.compute(),this}},{key:"findLinearDirection",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close","low"];this.compute();for(var e=0;e<t.length;e++){var r=t[e],n=Lt(this,r);Object.assign(this.indicators,Qt({},"".concat(r,"_linear_direction"),n))}return this.compute(),this}},{key:"change",value:function(t){this.compute();var e=this.verticalOhlcv;if(!e.hasOwnProperty(t)){var r='key "'.concat(t,'" not found in verticalOhlcv. change method');throw Error(r)}return Object.assign(this.indicators,Qt({},"".concat(t,"_change"),function(t){if(!Array.isArray(t))throw Error("data param in arrayGt function must be array");for(var e=Array(t.length).fill(0),r=1;r<e.length;r++)if(null===t[r]||null===t[r-1])e[r];else{var n=t[r],o=t[r-1];e[r]=(n-o)/o*100}return e}(e[t]))),this.compute(),this}},{key:"gt",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"close",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"open";this.compute();var r,n=this.verticalOhlcv;if(!n.hasOwnProperty(t)){var o='key "'.concat(t,'" not found in verticalOhlcv. gt method');throw Error(o)}if("string"==typeof e){if(!n.hasOwnProperty(e)){var i='key "'.concat(e,'" not found in verticalOhlcv. gt method');throw Error(i)}r=n[e]}else"number"==typeof e&&(r=new Array(n[t].length).fill(e));return Object.assign(this.indicators,Qt({},"".concat(t,"_gt_").concat(e),function(t,e){if(!Array.isArray(t)||!Array.isArray(e))throw Error("a and b params in arrayGt function must be arrays");if(t.length!==e.length)throw Error("array a and b must be the same length in arrayGt function");if(t.length<2)throw Error("arrays in arrayGt function must have at least 2 numeric items");for(var r=Array(t.length).fill(.5),n=1;n<r.length;n++)null!==t[n]&&null!==e[n]||(r[n]=null),t[n]>e[n]?r[n]=1:t[n]<e[n]&&(r[n]=0);return r}(n[t],r))),this.compute(),this}}],e&&ee(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
package/index.js CHANGED
@@ -19,6 +19,7 @@ export default class OHLCV_INDICATORS {
19
19
  if(input.length === 0) throw Error('input ohlcv must not be empty: ' + ticker)
20
20
  if(!input[0].hasOwnProperty('close')) throw Error('input ohlcv array objects require at least close property: ' + ticker)
21
21
 
22
+ this.priceBased = new Set(['open', 'high', 'low', 'close', 'mid_price_open_close', 'mid_price_high_low'])
22
23
  this.len = input.length
23
24
  this.crossPairsArr = []
24
25
  this.inputOhlcv = input
@@ -50,6 +51,7 @@ export default class OHLCV_INDICATORS {
50
51
  // Loop over keys to fill row data
51
52
  for (let x = 0; x < keysLength; x++) {
52
53
  const header = keys[x];
54
+
53
55
  const value = verticalOhlcv[header][i];
54
56
 
55
57
  // If value is null, mark the row to be skipped and break
@@ -58,7 +60,7 @@ export default class OHLCV_INDICATORS {
58
60
  break;
59
61
  }
60
62
 
61
- row[header] = value
63
+ row[header] = value
62
64
  }
63
65
 
64
66
  // If no null values were found, add row to result
@@ -72,21 +74,7 @@ export default class OHLCV_INDICATORS {
72
74
 
73
75
 
74
76
  getLastValues(){
75
-
76
- this.compute()
77
- const {verticalOhlcv, len} = this
78
- const output = {}
79
-
80
- for (const [k, arr] of Object.entries(verticalOhlcv)) {
81
- let value = arr[len - 1]
82
-
83
- output[k] = value
84
-
85
- }
86
-
87
- Object.assign(output, this.studies)
88
-
89
- return output
77
+ return this.getData()[this.getData().length -1]
90
78
  }
91
79
 
92
80
  compute() {
@@ -142,7 +130,7 @@ export default class OHLCV_INDICATORS {
142
130
 
143
131
  lag(colKeys = ['close'], lags = 1) {
144
132
  this.compute();
145
- const {verticalOhlcv} = this;
133
+ const {verticalOhlcv, priceBased} = this;
146
134
 
147
135
  for (let x = 0; x < colKeys.length; x++) {
148
136
  for (let lag = 1; lag <= lags; lag++) {
@@ -151,8 +139,14 @@ export default class OHLCV_INDICATORS {
151
139
  const values = verticalOhlcv[colKeys[x]].slice(0, -(lag));
152
140
 
153
141
  Object.assign(this.indicators, {[key]: values})
142
+
143
+ if([...priceBased].find(v => key.startsWith(v)))
144
+ {
145
+ this.priceBased.add(key)
146
+ }
154
147
  }
155
148
  }
149
+
156
150
 
157
151
  this.compute();
158
152
  return this;
@@ -160,9 +154,9 @@ export default class OHLCV_INDICATORS {
160
154
 
161
155
  relativeVolume(size) {
162
156
 
163
-
164
157
  const result = relativeVolume(this, size)
165
158
  Object.assign(this.indicators, result)
159
+
166
160
 
167
161
  return this
168
162
  }
@@ -173,6 +167,8 @@ export default class OHLCV_INDICATORS {
173
167
  const result = ema(this, size)
174
168
  Object.assign(this.indicators, result)
175
169
 
170
+ this.priceBased.add(`ema_${size}`)
171
+
176
172
  return this
177
173
  }
178
174
  sma(size) {
@@ -180,6 +176,8 @@ export default class OHLCV_INDICATORS {
180
176
  const result = sma(this, size)
181
177
  Object.assign(this.indicators, result)
182
178
 
179
+ this.priceBased.add(`sma_${size}`)
180
+
183
181
  return this
184
182
  }
185
183
  macd(fastLine, slowLine, signalLine) {
@@ -196,6 +194,10 @@ export default class OHLCV_INDICATORS {
196
194
  const result = bollingerBands(this, size, times)
197
195
  Object.assign(this.indicators, result)
198
196
 
197
+ this.priceBased.add('bollinger_bands_middle')
198
+ this.priceBased.add('bollinger_bands_upper')
199
+ this.priceBased.add('bollinger_bands_lower')
200
+
199
201
  return this
200
202
  }
201
203
  rsi(period, movingAverage, movingAveragePeriod)
@@ -211,6 +213,9 @@ export default class OHLCV_INDICATORS {
211
213
  const result = orb(this)
212
214
  Object.assign(this.indicators, result)
213
215
 
216
+ this.priceBased.add('orb_high')
217
+ this.priceBased.add('orb_low')
218
+
214
219
  return this
215
220
  }
216
221
  donchianChannels(period, offset)
@@ -218,6 +223,11 @@ export default class OHLCV_INDICATORS {
218
223
  const result = donchianChannels(this, period, offset)
219
224
  Object.assign(this.indicators, result)
220
225
 
226
+
227
+ this.priceBased.add('donchian_channel_upper')
228
+ this.priceBased.add('donchian_channel_lower')
229
+ this.priceBased.add('donchian_channel_basis')
230
+
221
231
  return this
222
232
  }
223
233
  candlesStudies(period, classify)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohlcv-indicators",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "A JavaScript library featuring optimized trading indicators for OHLCV arrays [{open, high, low, close, value}]. This library is optimized for backtesting and trading bot development.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -13,7 +13,6 @@
13
13
  "author": "https://jaimelias.com/",
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
- "ml-knn": "^3.0.0",
17
16
  "trading-signals": "^5.0.4"
18
17
  },
19
18
  "devDependencies": {
@@ -1,5 +1,6 @@
1
1
 
2
- import {BollingerBands, FasterBollingerBands, Big} from 'trading-signals';
2
+ import {FasterBollingerBands, FasterSMA} from 'trading-signals';
3
+ import { classifySize } from '../utilities/classification.js';
3
4
 
4
5
  export const bollingerBands = (main, size, times) => {
5
6
 
@@ -18,13 +19,18 @@ export const getBollingerBands = (data, size = 20, times = 2) => {
18
19
  const bollinger_bands_lower = Array(dataLength).fill(null)
19
20
  const bollinger_bands_range = Array(dataLength).fill(null)
20
21
  const bollinger_bands_height = Array(dataLength).fill(null)
22
+
23
+
24
+ const heightInstance = new FasterSMA(size)
25
+
21
26
  let range = null
22
27
  let height = null
23
28
 
24
29
  let getRange = (value, upper, lower) => ({
25
- range: ((value - lower) / (upper - lower)) * 100,
26
- height: ((upper-lower)/lower) * 100
30
+ range: ((value - lower) / (upper - lower)),
31
+ height: upper-lower
27
32
  })
33
+
28
34
  let instance = new FasterBollingerBands(size, times)
29
35
 
30
36
 
@@ -32,6 +38,8 @@ export const getBollingerBands = (data, size = 20, times = 2) => {
32
38
  let obj = {};
33
39
  instance.update(data[x])
34
40
  let hasNull = false
41
+ let heightMean
42
+
35
43
 
36
44
  try {
37
45
  obj = instance.getResult()
@@ -54,11 +62,23 @@ export const getBollingerBands = (data, size = 20, times = 2) => {
54
62
  const extraProps = getRange(data[x], obj.upper, obj.lower)
55
63
  range = extraProps.range
56
64
  height = extraProps.height
65
+
66
+ heightInstance.update(height)
67
+
68
+ try{
69
+ heightMean = heightInstance.getResult()
70
+ }
71
+ catch(err)
72
+ {
73
+ heightMean = null
74
+ }
75
+
57
76
  }
58
77
 
59
78
  bollinger_bands_range[x] = range
60
- bollinger_bands_height[x] = height
79
+ bollinger_bands_height[x] = classifySize(height, heightMean, 1.5)
61
80
  }
62
81
 
63
82
  return { bollinger_bands_upper, bollinger_bands_middle, bollinger_bands_lower, bollinger_bands_range, bollinger_bands_height }
64
- }
83
+ }
84
+
@@ -1,6 +1,6 @@
1
1
  import {FasterSMA} from 'trading-signals'
2
2
 
3
- export const relativeVolume = (main, size) => {
3
+ export const relativeVolume = (main, size = 10) => {
4
4
  const {verticalOhlcv} = main
5
5
  const {volume} = verticalOhlcv
6
6
  const col = getRelativeVolume(volume, size)
@@ -10,7 +10,7 @@ export const relativeVolume = (main, size) => {
10
10
  }
11
11
  }
12
12
 
13
- export const getRelativeVolume = (volume, size = 10) => {
13
+ export const getRelativeVolume = (volume, size) => {
14
14
 
15
15
  const instance = new FasterSMA(size)
16
16
  const sma = new Array(volume.length).fill(null)
@@ -38,8 +38,6 @@ export const getRelativeVolume = (volume, size = 10) => {
38
38
  output[x] = volume[x] / sma[x-1]
39
39
  }
40
40
  }
41
-
42
- console.log(output)
43
-
41
+
44
42
  return output
45
43
  }
@@ -1,4 +1,5 @@
1
- import {FasterSMA} from 'trading-signals';
1
+ import {FasterSMA} from 'trading-signals'
2
+ import { classifyChange, classifySize } from '../utilities/classification.js'
2
3
 
3
4
  export const candlesStudies = (main, period, classify) => {
4
5
 
@@ -65,7 +66,7 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true) => {
65
66
  //sizes
66
67
  const topSize = (candleBodySize > 0) ? high - close : high - open
67
68
  const bottomSize = (candleBodySize > 0) ? open - low : close - low
68
- const gapSize = curr.open - prev.close
69
+ const gapSize = prev.close - curr.open
69
70
  const position = curr.close - prev.close
70
71
 
71
72
  if(classify)
@@ -131,54 +132,4 @@ const getCandlesStudies = (inputOhlcv, period = 20, len, classify = true) => {
131
132
  candle_shadow_size,
132
133
  candle_position
133
134
  }
134
- }
135
-
136
- const classifyChange = (value, mean, standardDeviation = 0.5) => {
137
- if (value === null || mean === null || standardDeviation === null) return null;
138
-
139
- const largePositiveThreshold = mean + (2 * standardDeviation); // Large positive
140
- const mediumPositiveThreshold = mean + (1.5 * standardDeviation); // Medium positive (1.5σ)
141
- const smallPositiveThreshold = mean + (0.5 * standardDeviation); // Small positive (0.5σ)
142
- const smallNegativeThreshold = mean - (0.5 * standardDeviation); // Small negative (-0.5σ)
143
- const mediumNegativeThreshold = mean - (1.5 * standardDeviation); // Medium negative (-1.5σ)
144
- const largeNegativeThreshold = mean - (2 * standardDeviation); // Large negative
145
-
146
- if (value >= largePositiveThreshold) {
147
- return 1; // Large positive
148
- } else if (value >= mediumPositiveThreshold) {
149
- return 0.875; // Medium positive
150
- } else if (value >= smallPositiveThreshold) {
151
- return 0.625; // Small positive
152
- } else if (value <= largeNegativeThreshold) {
153
- return 0; // Large negative
154
- } else if (value <= mediumNegativeThreshold) {
155
- return 0.125; // Medium negative
156
- } else if (value <= smallNegativeThreshold) {
157
- return 0.375; // Small negative
158
- } else {
159
- return 0.5; // No significant change
160
- }
161
- };
162
-
163
-
164
-
165
- const classifySize = (value, mean, standardDeviation = 1.5) => {
166
- if (value === null || mean === null || standardDeviation === null) return null;
167
-
168
- const largeThreshold = mean + (2 * standardDeviation); // Large (2σ above mean)
169
- const mediumThreshold = mean + (1 * standardDeviation); // Medium (1σ above mean)
170
- const smallThreshold = mean - (1 * standardDeviation); // Small (1σ below mean)
171
- const verySmallThreshold = mean - (1.5 * standardDeviation); // Very small (1.5σ below mean)
172
-
173
- if (value > largeThreshold) {
174
- return 1; // Large
175
- } else if (value > mediumThreshold) {
176
- return 0.875; // Medium
177
- } else if (value > smallThreshold) {
178
- return 0.625; // Small
179
- } else if (value > verySmallThreshold) {
180
- return 0.375; // Very small
181
- } else {
182
- return 0.125; // Insignificant
183
- }
184
- };
135
+ }
@@ -1,10 +1,10 @@
1
- const eq = (a, b) => a === b
2
- const gt = (a, b) => a > b
3
- const lt = (a, b) => a < b
1
+ const eq = (f, s) => f === s
2
+ const gt = (f, s) => f > s
3
+ const lt = (f, s) => f < s
4
4
 
5
5
 
6
6
  // Function to find crosses between two arrays: fast and slow
7
- export const findCrosses = ({fast, slow}) => {
7
+ export const findCrosses = ({fast, high, low, slow}) => {
8
8
  // Map states based on comparison of fast and slow arrays
9
9
 
10
10
  const dataLength = fast.length
@@ -14,32 +14,60 @@ export const findCrosses = ({fast, slow}) => {
14
14
  throw Error('fast and slow do not have the same length')
15
15
  }
16
16
 
17
- const state = new Array(dataLength).fill(null)
17
+ const state = new Array(dataLength).fill(0.5)
18
18
 
19
19
  for(let x = 0; x < dataLength; x++)
20
20
  {
21
+ const prevState = state?.[x-1] || 0.5
21
22
  const f = fast[x]
22
23
  const s = slow[x]
24
+ const hi = high?.[x]
25
+ const lo = low?.[x]
26
+
27
+ if(high || low)
28
+ {
29
+ if(typeof hi === 'undefined' || typeof lo === 'undefined') continue
30
+ }
31
+
32
+ const prevS = slow[x - 1]
33
+ const prevHi = high?.[x-1]
34
+ const prevLo = low?.[x-1]
35
+
36
+ if(high || low)
37
+ {
38
+ if(typeof prevHi === 'undefined' || typeof prevLo === 'undefined' || typeof prevS === 'undefined') continue
39
+ }
40
+
23
41
  let value
24
42
 
25
- if(f === null || s === null) value = 'neutral'
26
- else if(eq(f, s)){
27
- if(gt(fast[x-1], slow[x-1]))
43
+ if(f === null || s === null) value = 0.5
44
+
45
+ else if(eq(f, s)) {
46
+ value = prevState
47
+ }
48
+ else if(gt(f, s)) {
49
+
50
+ if(lt(lo, s) && gt(prevLo, prevS))
28
51
  {
29
- value = 1 //up
52
+ value = 0
30
53
  }
31
- else if(lt(fast[x-1], slow[x-1]))
54
+ else
55
+ {
56
+ value = 1
57
+ }
58
+ }
59
+ else if(lt(f, s)) {
60
+
61
+ if(gt(hi, s) && lt(prevHi, prevS))
32
62
  {
33
- value = 0 //down
63
+ value = 1
34
64
  }
35
65
  else
36
66
  {
37
- value = 0.5 //neutral
67
+ value = 0
38
68
  }
39
69
  }
40
- else if(gt(f, s)) value = 1
41
- else if(lt(f, s)) value = 0
42
-
70
+
43
71
  state[x] = value
44
72
  }
45
73
 
@@ -110,6 +138,8 @@ export const groupConsecutiveValues = arr => {
110
138
 
111
139
  export const crossPairs = (main, arr) => {
112
140
 
141
+
142
+
113
143
  const {verticalOhlcv, len} = main
114
144
  const slowNumArrCache = {};
115
145
  const x = {}
@@ -143,9 +173,17 @@ export const crossPairs = (main, arr) => {
143
173
 
144
174
  }
145
175
  //cross created from 2 columns
146
- else if (verticalOhlcv[fast] && verticalOhlcv[slow]) {
176
+ else if ((verticalOhlcv[fast] || fast === 'price') && verticalOhlcv[slow]) {
177
+
178
+ const cross = (fast === 'price')
179
+ ? findCrosses({
180
+ fast: verticalOhlcv.close,
181
+ high: verticalOhlcv.high,
182
+ low: verticalOhlcv.low,
183
+ slow: verticalOhlcv[slow]}
184
+ )
185
+ : findCrosses({fast: verticalOhlcv[fast], slow: verticalOhlcv[slow]})
147
186
 
148
- const cross = findCrosses({fast: verticalOhlcv[fast], slow: verticalOhlcv[slow]});
149
187
  x[crossName] = cross
150
188
 
151
189
  if(typeof count !== 'undefined')
@@ -0,0 +1,49 @@
1
+
2
+ export const classifySize = (value, mean, standardDeviation = 1.5) => {
3
+ if (value === null || mean === null || standardDeviation === null) return null;
4
+
5
+ const largeThreshold = mean + (2 * standardDeviation); // Large (2σ above mean)
6
+ const mediumThreshold = mean + (1 * standardDeviation); // Medium (1σ above mean)
7
+ const smallThreshold = mean - (1 * standardDeviation); // Small (1σ below mean)
8
+ const verySmallThreshold = mean - (1.5 * standardDeviation); // Very small (1.5σ below mean)
9
+
10
+ if (value > largeThreshold) {
11
+ return 1; // Large
12
+ } else if (value > mediumThreshold) {
13
+ return 0.75; // Medium
14
+ } else if (value > smallThreshold) {
15
+ return 0.5; // Small
16
+ } else if (value > verySmallThreshold) {
17
+ return 0.25; // Very small
18
+ } else {
19
+ return 0; // Insignificant
20
+ }
21
+ };
22
+
23
+
24
+ export const classifyChange = (value, mean, standardDeviation = 0.5) => {
25
+ if (value === null || mean === null || standardDeviation === null) return null;
26
+
27
+ const largePositiveThreshold = mean + (2 * standardDeviation); // Large positive
28
+ const mediumPositiveThreshold = mean + (1.5 * standardDeviation); // Medium positive (1.5σ)
29
+ const smallPositiveThreshold = mean + (0.5 * standardDeviation); // Small positive (0.5σ)
30
+ const smallNegativeThreshold = mean - (0.5 * standardDeviation); // Small negative (-0.5σ)
31
+ const mediumNegativeThreshold = mean - (1.5 * standardDeviation); // Medium negative (-1.5σ)
32
+ const largeNegativeThreshold = mean - (2 * standardDeviation); // Large negative
33
+
34
+ if (value >= largePositiveThreshold) {
35
+ return 1; // Large positive
36
+ } else if (value >= mediumPositiveThreshold) {
37
+ return 0.5; // Medium positive
38
+ } else if (value >= smallPositiveThreshold) {
39
+ return 0.25; // Small positive
40
+ } else if (value <= largeNegativeThreshold) {
41
+ return -1; // Large negative
42
+ } else if (value <= mediumNegativeThreshold) {
43
+ return -0.5; // Medium negative
44
+ } else if (value <= smallNegativeThreshold) {
45
+ return -0.25; // Small negative
46
+ } else {
47
+ return 0; // No significant change
48
+ }
49
+ };
@@ -1,6 +1,12 @@
1
+
2
+
3
+
1
4
  //true if first row date starts with yyyy-mm-dd date
2
5
  const validateFirstDate = arr => arr[0].hasOwnProperty('date') && typeof arr[0].date === 'string' && /^\d{4}-\d{2}-\d{2}/.test(arr[0].date)
3
6
 
7
+
8
+
9
+
4
10
  export const defaultStudyOptions = {
5
11
  midPriceOpenClose: false,
6
12
  midPriceHighLow: false,
@@ -35,6 +41,12 @@ export const parseOhlcvToVertical = (input, len, studyOptions) => {
35
41
  weekOfTheMonth
36
42
  } = studyOptions
37
43
 
44
+ let highMax
45
+ let lowMin
46
+ let volMax
47
+ let volMin
48
+
49
+
38
50
  const numberColsKeys = ['open', 'high', 'low', 'close', 'volume']
39
51
 
40
52
  if(midPriceOpenClose)
@@ -105,6 +117,7 @@ export const parseOhlcvToVertical = (input, len, studyOptions) => {
105
117
  for (let x = 0; x < len; x++) {
106
118
  const current = input[x]
107
119
 
120
+
108
121
  verticalOhlcv.open[x] = current.open
109
122
  verticalOhlcv.high[x] = current.high
110
123
  verticalOhlcv.low[x] = current.low
@@ -194,4 +207,13 @@ const getDateInfo = dateString => {
194
207
  day_of_the_month,
195
208
  week_of_the_month
196
209
  };
210
+ }
211
+
212
+
213
+ const normalizeArray = (array, min, max, range = [0, 1]) => {
214
+ const [rangeMin, rangeMax] = range;
215
+ const normalized = array.map(value =>
216
+ ((value - min) / (max - min)) * (rangeMax - rangeMin) + rangeMin
217
+ );
218
+ return normalized;
197
219
  }