ohlcv-indicators 1.6.2 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(r,e)=>{for(var n in e)t.o(e,n)&&!t.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},r={};(()=>{t.r(r),t.d(r,{default:()=>Xt});var e=1e6,n="[big.js] ",o=n+"Invalid ",i=o+"decimal places",u=o+"rounding mode",l=n+"Division by zero",c={},a=void 0,s=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(t,r,e,n){var o=t.c;if(e===a&&(e=t.constructor.RM),0!==e&&1!==e&&2!==e&&3!==e)throw Error(u);if(r<1)n=3===e&&(n||!!o[0])||0===r&&(1===e&&o[0]>=5||2===e&&(o[0]>5||5===o[0]&&(n||o[1]!==a))),o.length=1,n?(t.e=t.e-r+1,o[0]=1):o[0]=t.e=0;else if(r<o.length){if(n=1===e&&o[r]>=5||2===e&&(o[r]>5||5===o[r]&&(n||o[r+1]!==a||1&o[r-1]))||3===e&&(n||!!o[0]),o.length=r,n)for(;++o[--r]>9;)if(o[r]=0,0===r){++t.e,o.unshift(1);break}for(r=o.length;!o[--r];)o.pop()}return t}function h(t,r,e){var n=t.e,o=t.c.join(""),i=o.length;if(r)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&e?"-"+o:o}function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function v(t){var r="function"==typeof Map?new Map:void 0;return v=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(r){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return function(t,r,e){if(y())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,r);var o=new(t.bind.apply(t,n));return e&&b(o,e.prototype),o}(t,arguments,d(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),b(e,t)},v(t)}function y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(y=function(){return!!t})()}function b(t,r){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},b(t,r)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}c.abs=function(){var t=new this.constructor(this);return t.s=1,t},c.cmp=function(t){var r,e=this,n=e.c,o=(t=new e.constructor(t)).c,i=e.s,u=t.s,l=e.e,c=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-u:0;if(i!=u)return i;if(r=i<0,l!=c)return l>c^r?1:-1;for(u=(l=n.length)<(c=o.length)?l:c,i=-1;++i<u;)if(n[i]!=o[i])return n[i]>o[i]^r?1:-1;return l==c?0:l>c^r?1:-1},c.div=function(t){var r=this,n=r.constructor,o=r.c,u=(t=new n(t)).c,c=r.s==t.s?1:-1,s=n.DP;if(s!==~~s||s<0||s>e)throw Error(i);if(!u[0])throw Error(l);if(!o[0])return t.s=c,t.c=[t.e=0],t;var h,p,v,y,b,d=u.slice(),g=h=u.length,m=o.length,w=o.slice(0,h),O=w.length,j=t,S=j.c=[],P=0,_=s+(j.e=r.e-t.e)+1;for(j.s=c,c=_<0?0:_,d.unshift(0);O++<h;)w.push(0);do{for(v=0;v<10;v++){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(p=O==h?u:d;O;){if(w[--O]<p[O]){for(b=O;b&&!w[--b];)w[b]=9;--w[b],w[O]+=10}w[O]-=p[O]}for(;!w[0];)w.shift()}S[P++]=y?v:++v,w[0]&&y?w[O]=o[g]||0:w=[o[g]]}while((g++<m||w[0]!==a)&&c--);return S[0]||1==P||(S.shift(),j.e--,_--),P>_&&f(j,_,n.RM,w[0]!==a),j},c.eq=function(t){return 0===this.cmp(t)},c.gt=function(t){return this.cmp(t)>0},c.gte=function(t){return this.cmp(t)>-1},c.lt=function(t){return this.cmp(t)<0},c.lte=function(t){return this.cmp(t)<1},c.minus=c.sub=function(t){var r,e,n,o,i=this,u=i.constructor,l=i.s,c=(t=new u(t)).s;if(l!=c)return t.s=-c,i.plus(t);var a=i.c.slice(),s=i.e,f=t.c,h=t.e;if(!a[0]||!f[0])return f[0]?t.s=-c:a[0]?t=new u(i):t.s=1,t;if(l=s-h){for((o=l<0)?(l=-l,n=a):(h=s,n=f),n.reverse(),c=l;c--;)n.push(0);n.reverse()}else for(e=((o=a.length<f.length)?a:f).length,l=c=0;c<e;c++)if(a[c]!=f[c]){o=a[c]<f[c];break}if(o&&(n=a,a=f,f=n,t.s=-t.s),(c=(e=f.length)-(r=a.length))>0)for(;c--;)a[r++]=0;for(c=r;e>l;){if(a[--e]<f[e]){for(r=e;r&&!a[--r];)a[r]=9;--a[r],a[e]+=10}a[e]-=f[e]}for(;0===a[--c];)a.pop();for(;0===a[0];)a.shift(),--h;return a[0]||(t.s=1,a=[h=0]),t.c=a,t.e=h,t},c.mod=function(t){var r,e=this,n=e.constructor,o=e.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(l);return e.s=t.s=1,r=1==t.cmp(e),e.s=o,t.s=i,r?new n(e):(o=n.DP,i=n.RM,n.DP=n.RM=0,e=e.div(t),n.DP=o,n.RM=i,this.minus(e.times(t)))},c.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},c.plus=c.add=function(t){var r,e,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var u=o.e,l=o.c,c=t.e,a=t.c;if(!l[0]||!a[0])return a[0]||(l[0]?t=new i(o):t.s=o.s),t;if(l=l.slice(),r=u-c){for(r>0?(c=u,n=a):(r=-r,n=l),n.reverse();r--;)n.push(0);n.reverse()}for(l.length-a.length<0&&(n=a,a=l,l=n),r=a.length,e=0;r;l[r]%=10)e=(l[--r]=l[r]+a[r]+e)/10|0;for(e&&(l.unshift(e),++c),r=l.length;0===l[--r];)l.pop();return t.c=l,t.e=c,t},c.pow=function(t){var r=this,e=new r.constructor("1"),n=e,i=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(o+"exponent");for(i&&(t=-t);1&t&&(n=n.times(r)),t>>=1;)r=r.times(r);return i?e.div(n):n},c.prec=function(t,r){if(t!==~~t||t<1||t>e)throw Error(o+"precision");return f(new this.constructor(this),t,r)},c.round=function(t,r){if(t===a)t=0;else if(t!==~~t||t<-e||t>e)throw Error(i);return f(new this.constructor(this),t+this.e+1,r)},c.sqrt=function(){var t,r,e,o=this,i=o.constructor,u=o.s,l=o.e,c=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?((r=o.c.join("")).length+l&1||(r+="0"),l=((l+1)/2|0)-(l<0||1&l),t=new i(((u=Math.sqrt(r))==1/0?"5e":(u=u.toExponential()).slice(0,u.indexOf("e")+1))+l)):t=new i(u+""),l=t.e+(i.DP+=4);do{e=t,t=c.times(e.plus(o.div(e)))}while(e.c.slice(0,l).join("")!==t.c.slice(0,l).join(""));return f(t,(i.DP-=4)+t.e+1,i.RM)},c.times=c.mul=function(t){var r,e=this,n=e.constructor,o=e.c,i=(t=new n(t)).c,u=o.length,l=i.length,c=e.e,a=t.e;if(t.s=e.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=c+a,u<l&&(r=o,o=i,i=r,a=u,u=l,l=a),r=new Array(a=u+l);a--;)r[a]=0;for(c=l;c--;){for(l=0,a=u+c;a>c;)l=r[a]+i[c]*o[a-c-1]+l,r[a--]=l%10,l=l/10|0;r[a]=l}for(l?++t.e:r.shift(),c=r.length;!r[--c];)r.pop();return t.c=r,t},c.toExponential=function(t,r){var n=this,o=n.c[0];if(t!==a){if(t!==~~t||t<0||t>e)throw Error(i);for(n=f(new n.constructor(n),++t,r);n.c.length<t;)n.c.push(0)}return h(n,!0,!!o)},c.toFixed=function(t,r){var n=this,o=n.c[0];if(t!==a){if(t!==~~t||t<0||t>e)throw Error(i);for(t=t+(n=f(new n.constructor(n),t+n.e+1,r)).e+1;n.c.length<t;)n.c.push(0)}return h(n,!1,!!o)},c[Symbol.for("nodejs.util.inspect.custom")]=c.toJSON=c.toString=function(){var t=this,r=t.constructor;return h(t,t.e<=r.NE||t.e>=r.PE,!!t.c[0])},c.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},c.toPrecision=function(t,r){var n=this,i=n.constructor,u=n.c[0];if(t!==a){if(t!==~~t||t<1||t>e)throw Error(o+"precision");for(n=f(new i(n),t,r);n.c.length<t;)n.c.push(0)}return h(n,t<=n.e||n.e<=i.NE||n.e>=i.PE,!!u)},c.valueOf=function(){var t=this,r=t.constructor;if(!0===r.strict)throw Error(n+"valueOf disallowed");return h(t,t.e<=r.NE||t.e>=r.PE,!0)},function t(){function r(e){var n=this;if(!(n instanceof r))return e===a?t():new r(e);if(e instanceof r)n.s=e.s,n.e=e.e,n.c=e.c.slice();else{if("string"!=typeof e){if(!0===r.strict&&"bigint"!=typeof e)throw TypeError(o+"value");e=0===e&&1/e<0?"-0":String(e)}!function(t,r){var e,n,i;if(!s.test(r))throw Error(o+"number");for(t.s="-"==r.charAt(0)?(r=r.slice(1),-1):1,(e=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(e<0&&(e=n),e+=+r.slice(n+1),r=r.substring(0,n)):e<0&&(e=r.length),i=r.length,n=0;n<i&&"0"==r.charAt(n);)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&"0"==r.charAt(--i););for(t.e=e-n-1,t.c=[],e=0;n<=i;)t.c[e++]=+r.charAt(n++)}}(n,e)}n.constructor=r}return r.prototype=c,r.DP=20,r.RM=1,r.NE=-7,r.PE=21,r.strict=!1,r.roundDown=0,r.roundHalfUp=1,r.roundHalfEven=2,r.roundUp=3,r}();var g=function(t){function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),t=function(t,r,e){return r=d(r),function(t,r){if(r&&("object"==p(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,y()?Reflect.construct(r,e||[],d(t).constructor):r.apply(t,e))}(this,r,[e]),Object.setPrototypeOf(t,(this instanceof r?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&b(t,r)}(r,t),e=r,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}(v(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,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,j(n.key),n)}}function O(t,r,e){return(r=j(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function j(t){var r=function(t,r){if("object"!=m(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var S=function(){return t=function t(){(function(t,r){if(!(t instanceof r))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)},(r=[{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,r){return r&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&w(t.prototype,r),e&&w(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function _(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,T(n.key),n)}}function E(t,r,e){return r=R(r),function(t,r){if(r&&("object"==P(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,A()?Reflect.construct(r,e||[],R(t).constructor):r.apply(t,e))}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function R(t){return R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},R(t)}function k(t,r){return k=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},k(t,r)}function T(t){var r=function(t,r){if("object"!=P(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(r)?r:r+""}var M=function(t){function r(t){var e,n,o,i;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),n=e=E(this,r),i=void 0,(o=T(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,e.interval=t,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&k(t,r)}(r,t),e=r,(n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&_(e.prototype,n),o&&_(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(S);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,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,F(n.key),n)}}function D(t,r,e){return r=L(r),function(t,r){if(r&&("object"==x(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,I()?Reflect.construct(r,e||[],L(t).constructor):r.apply(t,e))}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,r){return B=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},B(t,r)}function F(t){var r=function(t,r){if("object"!=x(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var N=function(t){function r(){var t,e,n,o;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);for(var i=arguments.length,u=new Array(i),l=0;l<i;l++)u[l]=arguments[l];return e=t=D(this,r,[].concat(u)),o=[],(n=F(n="prices"))in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&B(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var e=this.prices.reduce((function(t,r){return t+r}),0);return this.setResult(e/this.prices.length,r)}}}],n&&C(e.prototype,n),o&&C(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(M);function q(t){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q(t)}function H(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,J(n.key),n)}}function V(t,r,e){return r=z(r),function(t,r){if(r&&("object"==q(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,G()?Reflect.construct(r,e||[],z(t).constructor):r.apply(t,e))}function G(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(G=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,r){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},U(t,r)}function $(t,r,e){return(r=J(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function J(t){var r=function(t,r){if("object"!=q(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==q(r)?r:r+""}var K=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),$(e=V(this,r),"interval",void 0),$(e,"indicator",void 0),$(e,"smoothingFactor",void 0),e.interval=t,e.indicator=new N(t),e.smoothingFactor=1/e.interval,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&U(t,r)}(r,t),e=r,n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.indicator.update(t);if(r&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,r)}if(!r&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,r)}if(void 0===this.result&&void 0!==e)return this.setResult(e,r)}}],n&&H(e.prototype,n),o&&H(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(S);function Q(t){return t.length?t.reduce((function(t,r){return t+r}),0)/t.length:0}function W(t){return W="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},W(t)}function X(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Z(n.key),n)}}function Y(t,r,e){return(r=Z(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Z(t){var r=function(t,r){if("object"!=W(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=W(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==W(r)?r:r+""}var tt=function(){return t=function t(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),Y(this,"interval",void 0),Y(this,"deviationMultiplier",void 0),Y(this,"prices",[]),Y(this,"result",void 0),this.interval=r,this.deviationMultiplier=e},(r=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var r=Q(this.prices),e=function(t,r){var e=r||Q(t),n=Q(t.map((function(t){return t-e})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,r);return this.result={lower:r-e*this.deviationMultiplier,middle:r,upper:r+e*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&X(t.prototype,r),e&&X(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function rt(t){return rt="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},rt(t)}function et(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ct(n.key),n)}}function nt(t,r,e){return r=it(r),function(t,r){if(r&&("object"==rt(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ot()?Reflect.construct(r,e||[],it(t).constructor):r.apply(t,e))}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,r){return ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ut(t,r)}function lt(t,r,e){return(r=ct(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function ct(t){var r=function(t,r){if("object"!=rt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=rt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rt(r)?r:r+""}var at=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),lt(e=nt(this,r,[t]),"interval",void 0),lt(e,"pricesCounter",0),lt(e,"weightFactor",void 0),e.interval=t,e.weightFactor=2/(e.interval+1),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ut(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return r?r&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,r&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),r):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),r)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new g;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&et(e.prototype,n),o&&et(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,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,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,pt(n.key),n)}}function ht(t,r,e){return(r=pt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function pt(t){var r=function(t,r){if("object"!=st(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var vt=function(){return t=function t(r,e,n){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),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=r,this.long=e,this.signal=n},r=[{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 r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t);var e=this.short.update(t,r),n=this.long.update(t,r);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=e-n,i=this.signal.update(o,r);return this.result={histogram:o-i,macd:o,signal:i}}}}],r&&ft(t.prototype,r),e&&ft(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();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,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function dt(t,r,e){return r=mt(r),function(t,r){if(r&&("object"==yt(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,gt()?Reflect.construct(r,e||[],mt(t).constructor):r.apply(t,e))}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,r){return wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},wt(t,r)}function Ot(t,r,e){return(r=jt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function jt(t){var r=function(t,r){if("object"!=yt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(r)?r:r+""}var St=function(t){function r(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),Ot(e=dt(this,r),"interval",void 0),Ot(e,"previousPrices",[]),Ot(e,"avgGain",void 0),Ot(e,"avgLoss",void 0),Ot(e,"maxValue",100),e.interval=t,e.avgGain=new n(e.interval),e.avgLoss=new n(e.interval),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&wt(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&r?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var e=t,n=this.previousPrices[this.previousPrices.length-2];if(e>n?(this.avgLoss.update(0,r),this.avgGain.update(t-n,r)):(this.avgLoss.update(n-e,r),this.avgGain.update(0,r)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,r);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),r)}}}}],n&&bt(e.prototype,n),o&&bt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(S);function Pt(t){return Pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pt(t)}var _t=function(t,r){if(void 0===t||void 0===r)throw Error("undefined param in getEMA");for(var e=t.length,n=new Array(e).fill(null),o=new at(r),i=0;i<e;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 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)}var At=function(t,r){if(void 0===t||void 0===r)throw Error("undefined param in getSMA");for(var e=t.length,n=new Array(e).fill(null),o=new N(r),i=0;i<e;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,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var kt=function(t,r){return t>r},Tt=function(t,r){return t<r},Mt=function(t){var r=t.fast,e=t.slow,n=r.length;if(n==!e.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=r[i],l=e[i],c=void 0;null===u||null===l?c="neutral":u===l?c=kt(r[i-1],e[i-1])?1:Tt(r[i-1],e[i-1])?0:.5:kt(u,l)?c=1:Tt(u,l)&&(c=0),o[i]=c}var a=Ct(o);return xt(a)},xt=function(t){var r=t.map((function(t){return t.length}));return t.map((function(t,e){var n=r[e];return t.map((function(t,r){var e=n-r;return.5===t&&(e=0),1===t&&(e*=1),0===t&&(e*=-1),e})).reverse()})).flat()},Ct=function(t){return 0===t.length?[]:t.reduce((function(t,r,e,n){if(0===e)t.push([r]);else{var o=n[e-1],i=t[t.length-1];r!==o?t.push([r]):i.push(r)}return t}),[])},Dt=function(t,r){var e=t.verticalOhlcv;if(!e.hasOwnProperty(r))throw Error("property ".concat(r," not found in verticalOhlcv. Invoked by findDirectionCross."));for(var n=e[r],o=n.length,i=new Array(o).fill(null),u=0;u<o;u++)if(u>0&&null!==n[u]){var l=n[u],c=n[u-1];kt(l,c)?i[u]=1:Tt(l,c)?i[u]=0:i[u]=.5}return i},It=function(t,r){if(!t.verticalOhlcv.hasOwnProperty(r))throw Error("property ".concat(r," not found in verticalOhlcv. Invoked by findDirectionCross."));var e=Dt(t,r),n=Ct(e);return xt(n)};function Lt(t){return Lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lt(t)}var Bt={getSMA:At,getEMA:_t},Ft=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,e=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<r)return[];for(var i=new Array(o).fill(null),u=new St(r),l=0;l<o;l++){var c=null;if(null!==t[l]){u.update(t[l]);try{c=u.getResult()}catch(t){c=null}}i[l]=c}var a,s,f,h=(a={},s="rsi_".concat(r),f=i,(s=function(t){var r=function(t,r){if("object"!=Lt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Lt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lt(r)?r:r+""}(s))in a?Object.defineProperty(a,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):a[s]=f,a);if("string"==typeof e&&"number"==typeof n&&Bt.hasOwnProperty("get".concat(e))){var p=Bt["get".concat(e)](i,n);h["rsi_".concat(e,"_").concat(n)]=p,h["rsi_".concat(r,"_x_rsi_").concat(e,"_").concat(n)]=Mt({fast:i,slow:p})}return h};function Nt(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return qt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?qt(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(l)throw i}}}}function qt(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ht=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.25;return null===t||null===r?null:t>r*(5*e)?1:t<r*(3*e)?0:2*e},Vt=function(t,r){if(!r)return null;var e=t.open,n=t.high,o=t.low,i=t.close,u=r.high,l=r.low,c=[n,u],a=[o,l];i>e?(c.push(i),a.push(e)):(c.push(e),a.push(i));var s=Math.max(n,u)-Math.min(o,l)-(Math.abs(u-l)+Math.abs(n-o));return s>0?s:.01},Gt=function(t,r){for(var e=t.length,n=new N(r),o=new Array(e),i=0,u=0,l=0,c=0;c<e;c++)if(n.update(t[c]),n.isStable){var a=n.getResult();o[c]=a,i+=a,u+=a*a,l++}else o[c]=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}))},zt=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==r.length)throw new Error("Both arrays must have the same length");for(var n=Gt(t,e),o=Gt(r,e),i=t.length,u=[],l=0,c=0,a=0,s=0,f=0,h=0,p=-1,v=0;v<i;v++){if(null!==n[v]&&null!==o[v]){p=v;break}u.push(0)}if(-1===p)return new Array(i).fill(0);for(var y=p;y<i;y++){var b=n[y],d=o[y];if(null!==b&&null!==d)if(l+=b,c+=d,a+=b*d,s+=b*b,f+=d*d,++h<2)u.push(0);else{var g=h*a-l*c,m=Math.sqrt((h*s-l*l)*(h*f-c*c)),w=0===m?0:g/m;u.push(w)}else l=c=a=s=f=h=0,u.push(0)}return u};function Ut(t){return Ut="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ut(t)}function $t(t,r,e){return(r=Wt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Jt(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,u,l=[],c=!0,a=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;c=!1}else for(;!(c=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);c=!0);}catch(t){a=!0,o=t}finally{try{if(!c&&null!=e.return&&(u=e.return(),Object(u)!==u))return}finally{if(a)throw o}}return l}}(t,r)||function(t,r){if(t){if("string"==typeof t)return Kt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Kt(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Kt(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Qt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Wt(n.key),n)}}function Wt(t){var r=function(t,r){if("object"!=Ut(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ut(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ut(r)?r:r+""}var Xt=function(){return t=function t(r){var e=r.input,n=r.ticker,o=void 0===n?"undefined":n;if(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(e))throw Error("input ohlcv must be an array: "+o);if(0===e.length)throw Error("input ohlcv must not be empty: "+o);if(!e[0].hasOwnProperty("close"))throw Error("input ohlcv array objects require at least close property: "+o);return this.len=e.length,this.crossPairsArr=[],this.inputOhlcv=e,this.verticalOhlcv=function(t,r){for(var e=["open","high","low","close","volume"],n=new Set(e),o={},i=0,u=e;i<u.length;i++)o[u[i]]=new Array(r);for(var l,c=[],a=0,s=Object.keys(t[0]);a<s.length;a++){var f=s[a];n.has(f)||(o[f]=new Array(r),c.push(f))}var h,p=0,v=0,y=(h=t)[0].hasOwnProperty("date")&&"string"==typeof h[0].date&&/^\d{4}-\d{2}-\d{2}/.test(h[0].date);y&&(o.session_index=new Array(r),o.session_intraday_index=new Array(r),l=t[0].date.slice(0,10));for(var b=0;b<r;b++){var d=t[b];o.open[b]=d.open,o.high[b]=d.high,o.low[b]=d.low,o.close[b]=d.close,o.volume[b]=d.volume;var g,m=Nt(c);try{for(m.s();!(g=m.n()).done;){var w=g.value;o[w][b]=d[w]}}catch(t){m.e(t)}finally{m.f()}if(y){var O=d.date.slice(0,10);O!==l&&(l=O,p++,v=0),o.session_index[b]=p,o.session_intraday_index[b]=v,v++}}return o}(e,this.len),this.indicators={},this.studies={},this.utilities={correlation:zt},this},r=[{key:"getData",value:function(){this.compute();for(var t=this.verticalOhlcv,r=Object.keys(t),e=t[r[0]].length,n=r.length,o=[],i=0;i<e;i++){for(var u={},l=!1,c=0;c<n;c++){var a=r[c],s=t[a][i];if(null==s){l=!0;break}u[a]=s}l||o.push(u)}return o}},{key:"getLastValues",value:function(){this.compute();for(var t=this.verticalOhlcv,r=this.len,e={},n=0,o=Object.entries(t);n<o.length;n++){var i=Jt(o[n],2),u=i[0],l=i[1][r-1];e[u]=l}return Object.assign(e,this.studies),e}},{key:"compute",value:function(){for(var t=this.indicators,r=this.addColumn.bind(this),e=0,n=Object.entries(t);e<n.length;e++){var o=Jt(n[e],2),i=o[0],u=o[1];this.verticalOhlcv.hasOwnProperty(i)?delete this.indicators[i]:r(i,u)}return this}},{key:"addColumn",value:function(t,r){var e=this.len;if(t=t.toLowerCase(),r.length>e)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");if(r.length<e){var n=e-r.length;r=new Array(n).fill(null).concat(r)}this.verticalOhlcv[t]=r}},{key:"crossPairs",value:function(t){this.compute();var r=function(t,r){var e,n=t.verticalOhlcv,o=t.len,i={},u={},l={},c=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Rt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Rt(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(l)throw i}}}}(r);try{var a=function(){var t=e.value,r=t.fast,c=t.slow,a=t.count;if(!r||!c)return 1;"number"!=typeof c||i[c]||(i[c]=Array(o).fill(c));var s="".concat(r,"_x_").concat(c),f="".concat(r,"_c_").concat(c),h=function(t){return void 0!==a?t.slice(-a).filter((function(t){return 1===t||-1===t})).length:0};if(n[s]){var p=n[s];u[s]=p,void 0!==a&&(l[f]=h(p))}else if(n[r]&&n[c]){var v=Mt({fast:n[r],slow:n[c]});u[s]=v,void 0!==a&&(l[f]=h(v))}else if(n[r]&&i[c]){var y=Mt({fast:n[r],slow:i[c]});u[s]=y,void 0!==a&&(l[f]=h(y))}else console.log("Missing ohlcv properties for ".concat(r," or ").concat(c))};for(c.s();!(e=c.n()).done;)a()}catch(t){c.e(t)}finally{c.f()}return{x:u,c:l}}(this,t),e=r.x,n=r.c;return Object.assign(this.indicators,e),Object.assign(this.studies,n),this.compute(),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.compute();for(var e=this.verticalOhlcv,n=0;n<t.length;n++)for(var o=1;o<=r;o++){var i="".concat(t[n],"_lag_").concat(o),u=e[t[n]].slice(0,-o);Object.assign(this.indicators,$t({},i,u))}return this.compute(),this}},{key:"ema",value:function(t){var r=function(t,r){var e=t.verticalOhlcv.close,n=_t(e,r);return function(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Pt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}({},"ema_".concat(r),n)}(this,t);return Object.assign(this.indicators,r),this}},{key:"sma",value:function(t){var r=function(t,r){var e=t.verticalOhlcv.close,n=At(e,r);return function(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Et(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}({},"sma_".concat(r),n)}(this,t);return Object.assign(this.indicators,r),this}},{key:"macd",value:function(t,r,e){var n=function(t,r,e,n){return function(t){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,e=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),c=new vt(new at(r),new at(e),new at(n)),a=0;a<o;a++){var s={};c.update(t[a]);try{s=c.getResult()}catch(t){s={macd:null,signal:null,histogram:null}}i[a]=s.macd,u[a]=s.signal,l[a]=s.histogram}return{macd_diff:i,macd_dea:u,macd_histogram:l,macd_diff_x_macd_dea:Mt({fast:i,slow:u})}}(t.verticalOhlcv.close,r,e,n)}(this,t,r,e);return Object.assign(this.indicators,n),this}},{key:"bollingerBands",value:function(t,r){var e=function(t,r,e){return function(t){for(var r,e,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),c=Array(u).fill(null),a=Array(u).fill(null),s=Array(u).fill(null),f=Array(u).fill(null),h=null,p=null,v=new tt(o,i),y=0;y<u;y++){var b={};v.update(t[y]);var d=!1;try{b=v.getResult()}catch(t){d=!0,b={upper:null,middle:null,lower:null}}if(l[y]=b.upper,c[y]=b.middle,a[y]=b.lower,d)s[y]=null,f[y]=null;else{var g=(r=t[y],e=b.upper,{range:(r-(n=b.lower))/(e-n)*100,height:(e-n)/n*100});h=g.range,p=g.height}s[y]=h,f[y]=p}return{bollinger_bands_upper:l,bollinger_bands_middle:c,bollinger_bands_lower:a,bollinger_bands_range:s,bollinger_bands_height:f}}(t.verticalOhlcv.close,r,e)}(this,t,r);return Object.assign(this.indicators,e),this}},{key:"rsi",value:function(t,r,e){var n=function(t,r,e,n){var o=t.verticalOhlcv.close;return"number"==typeof r&&void 0===n&&(n=r),Ft(o,r,e,n)}(this,t,r,e);return Object.assign(this.indicators,n),this}},{key:"orb",value:function(){var t=function(t,r){for(var e=new Array(r).fill(0),n=new Array(r).fill(0),o=0,i=null,u=0,l=0,c=0;c<r;c++){var a=t[c];if(0===c&&!a.hasOwnProperty("date"))throw Error("input ohlcv array must have a date property available in candle datapoint");var s=a.date.split(" ")[0];s!==i&&(i=s,u=a.high,l=a.low),e[o]=u,n[o]=l,o++}return{orb_high:e,orb_low:n}}(this.inputOhlcv,this.len);return Object.assign(this.indicators,t),this}},{key:"donchianChannels",value:function(t,r){var e=function(t,r,e){var n=t.verticalOhlcv,o=t.len;return function(t,r,e,n,o){for(var i=new Array(o).fill(null),u=new Array(o).fill(null),l=new Array(o).fill(null),c=[],a=[],s=0;s<o;s++){for(;c.length&&c[0]<=s-e;)c.shift();for(;c.length&&t[c[c.length-1]]<=t[s];)c.pop();for(c.push(s);a.length&&a[0]<=s-e;)a.shift();for(;a.length&&r[a[a.length-1]]>=r[s];)a.pop();if(a.push(s),s>=e-1){var f=t[c[0]],h=r[a[0]],p=(f+h)/2,v=s+n;v>=0&&v<o&&(i[v]=f,u[v]=h,l[v]=p)}}return{donchian_channel_upper:i,donchian_channel_lower:u,donchian_channel_basis:l}}(n.high,n.low,r,e,o)}(this,t,r);return Object.assign(this.indicators,e),this}},{key:"candlesStudies",value:function(t){var r=function(t,r){return function(t){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,e=arguments.length>2?arguments[2]:void 0,n=function(t,r){return Math.abs(t-r)},o=new Array(e).fill(null),i=new Array(e).fill(null),u=new Array(e).fill(null),l=new Array(e).fill(null),c=new Array(e).fill(null),a=new N(r),s=new N(parseInt(r/2)),f=0;f<e;f++){var h=t[f],p=h.open,v=h.high,y=h.low,b=h.close,d=void 0!==t[f-1]?Vt(t[f],t[f-1]):null,g=null,m=null,w=n(p,b),O=void 0,j=void 0,S=b>p?1:0;1===S?(O=n(v,b),j=n(p,y)):(O=n(v,p),j=n(b,y)),a.update(w),d&&s.update(d);try{g=a.getResult(),m=s.getResult()}catch(t){g=null,m=null}o[f]=S,i[f]=Ht(w,g,.25),u[f]=Ht(O,g,.25),l[f]=Ht(j,g,.25),c[f]=Ht(d,m,.25)}return{candle_direction:o,candle_gap_size:c,candle_body_size:i,candle_top_size:u,candle_bottom_size:l}}(t.inputOhlcv,r,t.len)}(this,t);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 r=0;r<t.length;r++){var e=t[r],n=It(this,e);Object.assign(this.indicators,$t({},"".concat(e,"_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 r=0;r<t.length;r++){var e=t[r],n=Dt(this,e);Object.assign(this.indicators,$t({},"".concat(e,"_linear_direction"),n))}return this.compute(),this}},{key:"gt",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{a:"high",b:"low"}];this.compute();for(var e=this.verticalOhlcv,n=function(){var n,i=r[o],u=i.a,l=i.b;"string"==typeof l?n=e[l]:"number"==typeof l&&(n=new Array(e[u].length).fill(l));var c=e[u].map((function(t,r){return t>n[r]?1:0}));Object.assign(t.indicators,$t({},"".concat(u,"_gt_").concat(l),c))},o=0;o<r.length;o++)n();return this.compute(),this}}],r&&Qt(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}()})(),OHLCV_INDICATORS=r})();
|
|
1
|
+
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(r,e)=>{for(var n in e)t.o(e,n)&&!t.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},r={};(()=>{t.r(r),t.d(r,{default:()=>Zt});var e=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,r,e,n){var o=t.c;if(e===c&&(e=t.constructor.RM),0!==e&&1!==e&&2!==e&&3!==e)throw Error(u);if(r<1)n=3===e&&(n||!!o[0])||0===r&&(1===e&&o[0]>=5||2===e&&(o[0]>5||5===o[0]&&(n||o[1]!==c))),o.length=1,n?(t.e=t.e-r+1,o[0]=1):o[0]=t.e=0;else if(r<o.length){if(n=1===e&&o[r]>=5||2===e&&(o[r]>5||5===o[r]&&(n||o[r+1]!==c||1&o[r-1]))||3===e&&(n||!!o[0]),o.length=r,n)for(;++o[--r]>9;)if(o[r]=0,0===r){++t.e,o.unshift(1);break}for(r=o.length;!o[--r];)o.pop()}return t}function h(t,r,e){var n=t.e,o=t.c.join(""),i=o.length;if(r)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&e?"-"+o:o}function 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 r="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(r){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return function(t,r,e){if(y())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,r);var o=new(t.bind.apply(t,n));return e&&b(o,e.prototype),o}(t,arguments,d(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),b(e,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,r){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},b(t,r)}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 r,e=this,n=e.c,o=(t=new e.constructor(t)).c,i=e.s,u=t.s,l=e.e,a=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-u:0;if(i!=u)return i;if(r=i<0,l!=a)return l>a^r?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]^r?1:-1;return l==a?0:l>a^r?1:-1},a.div=function(t){var r=this,n=r.constructor,o=r.c,u=(t=new n(t)).c,a=r.s==t.s?1:-1,s=n.DP;if(s!==~~s||s<0||s>e)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(),m=h=u.length,g=o.length,w=o.slice(0,h),O=w.length,j=t,_=j.c=[],S=0,P=s+(j.e=r.e-t.e)+1;for(j.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()}_[S++]=y?p:++p,w[0]&&y?w[O]=o[m]||0:w=[o[m]]}while((m++<g||w[0]!==c)&&a--);return _[0]||1==S||(_.shift(),j.e--,P--),S>P&&f(j,P,n.RM,w[0]!==c),j},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 r,e,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(e=((o=c.length<f.length)?c:f).length,l=a=0;a<e;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=(e=f.length)-(r=c.length))>0)for(;a--;)c[r++]=0;for(a=r;e>l;){if(c[--e]<f[e]){for(r=e;r&&!c[--r];)c[r]=9;--c[r],c[e]+=10}c[e]-=f[e]}for(;0===c[--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 r,e=this,n=e.constructor,o=e.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(l);return e.s=t.s=1,r=1==t.cmp(e),e.s=o,t.s=i,r?new n(e):(o=n.DP,i=n.RM,n.DP=n.RM=0,e=e.div(t),n.DP=o,n.RM=i,this.minus(e.times(t)))},a.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},a.plus=a.add=function(t){var r,e,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var 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(),r=u-a){for(r>0?(a=u,n=c):(r=-r,n=l),n.reverse();r--;)n.push(0);n.reverse()}for(l.length-c.length<0&&(n=c,c=l,l=n),r=c.length,e=0;r;l[r]%=10)e=(l[--r]=l[r]+c[r]+e)/10|0;for(e&&(l.unshift(e),++a),r=l.length;0===l[--r];)l.pop();return t.c=l,t.e=a,t},a.pow=function(t){var r=this,e=new r.constructor("1"),n=e,i=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(o+"exponent");for(i&&(t=-t);1&t&&(n=n.times(r)),t>>=1;)r=r.times(r);return i?e.div(n):n},a.prec=function(t,r){if(t!==~~t||t<1||t>e)throw Error(o+"precision");return f(new this.constructor(this),t,r)},a.round=function(t,r){if(t===c)t=0;else if(t!==~~t||t<-e||t>e)throw Error(i);return f(new this.constructor(this),t+this.e+1,r)},a.sqrt=function(){var t,r,e,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?((r=o.c.join("")).length+l&1||(r+="0"),l=((l+1)/2|0)-(l<0||1&l),t=new i(((u=Math.sqrt(r))==1/0?"5e":(u=u.toExponential()).slice(0,u.indexOf("e")+1))+l)):t=new i(u+""),l=t.e+(i.DP+=4);do{e=t,t=a.times(e.plus(o.div(e)))}while(e.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 r,e=this,n=e.constructor,o=e.c,i=(t=new n(t)).c,u=o.length,l=i.length,a=e.e,c=t.e;if(t.s=e.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=a+c,u<l&&(r=o,o=i,i=r,c=u,u=l,l=c),r=new Array(c=u+l);c--;)r[c]=0;for(a=l;a--;){for(l=0,c=u+a;c>a;)l=r[c]+i[a]*o[c-a-1]+l,r[c--]=l%10,l=l/10|0;r[c]=l}for(l?++t.e:r.shift(),a=r.length;!r[--a];)r.pop();return t.c=r,t},a.toExponential=function(t,r){var n=this,o=n.c[0];if(t!==c){if(t!==~~t||t<0||t>e)throw Error(i);for(n=f(new n.constructor(n),++t,r);n.c.length<t;)n.c.push(0)}return h(n,!0,!!o)},a.toFixed=function(t,r){var n=this,o=n.c[0];if(t!==c){if(t!==~~t||t<0||t>e)throw Error(i);for(t=t+(n=f(new n.constructor(n),t+n.e+1,r)).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,r=t.constructor;return h(t,t.e<=r.NE||t.e>=r.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,r){var n=this,i=n.constructor,u=n.c[0];if(t!==c){if(t!==~~t||t<1||t>e)throw Error(o+"precision");for(n=f(new i(n),t,r);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,r=t.constructor;if(!0===r.strict)throw Error(n+"valueOf disallowed");return h(t,t.e<=r.NE||t.e>=r.PE,!0)},function t(){function r(e){var n=this;if(!(n instanceof r))return e===c?t():new r(e);if(e instanceof r)n.s=e.s,n.e=e.e,n.c=e.c.slice();else{if("string"!=typeof e){if(!0===r.strict&&"bigint"!=typeof e)throw TypeError(o+"value");e=0===e&&1/e<0?"-0":String(e)}!function(t,r){var e,n,i;if(!s.test(r))throw Error(o+"number");for(t.s="-"==r.charAt(0)?(r=r.slice(1),-1):1,(e=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(e<0&&(e=n),e+=+r.slice(n+1),r=r.substring(0,n)):e<0&&(e=r.length),i=r.length,n=0;n<i&&"0"==r.charAt(n);)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&"0"==r.charAt(--i););for(t.e=e-n-1,t.c=[],e=0;n<=i;)t.c[e++]=+r.charAt(n++)}}(n,e)}n.constructor=r}return r.prototype=a,r.DP=20,r.RM=1,r.NE=-7,r.PE=21,r.strict=!1,r.roundDown=0,r.roundHalfUp=1,r.roundHalfEven=2,r.roundUp=3,r}();var m=function(t){function r(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),t=function(t,r,e){return r=d(r),function(t,r){if(r&&("object"==v(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,y()?Reflect.construct(r,e||[],d(t).constructor):r.apply(t,e))}(this,r,[e]),Object.setPrototypeOf(t,(this instanceof r?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&b(t,r)}(r,t),e=r,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}(p(Error));function g(t){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g(t)}function w(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,j(n.key),n)}}function O(t,r,e){return(r=j(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function j(t){var r=function(t,r){if("object"!=g(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==g(r)?r:r+""}var _=function(){return t=function t(){(function(t,r){if(!(t instanceof r))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)},(r=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new m;return this.result}},{key:"setResult",value:function(t,r){return r&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&w(t.prototype,r),e&&w(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();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,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,T(n.key),n)}}function E(t,r,e){return r=k(r),function(t,r){if(r&&("object"==S(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,A()?Reflect.construct(r,e||[],k(t).constructor):r.apply(t,e))}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,r){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},R(t,r)}function T(t){var r=function(t,r){if("object"!=S(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var M=function(t){function r(t){var e,n,o,i;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),n=e=E(this,r),i=void 0,(o=T(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,e.interval=t,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&R(t,r)}(r,t),e=r,(n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&P(e.prototype,n),o&&P(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(_);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,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,F(n.key),n)}}function D(t,r,e){return r=L(r),function(t,r){if(r&&("object"==x(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,I()?Reflect.construct(r,e||[],L(t).constructor):r.apply(t,e))}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,r){return B=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},B(t,r)}function F(t){var r=function(t,r){if("object"!=x(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var N=function(t){function r(){var t,e,n,o;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r);for(var i=arguments.length,u=new Array(i),l=0;l<i;l++)u[l]=arguments[l];return e=t=D(this,r,[].concat(u)),o=[],(n=F(n="prices"))in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,t}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&B(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var e=this.prices.reduce((function(t,r){return t+r}),0);return this.setResult(e/this.prices.length,r)}}}],n&&C(e.prototype,n),o&&C(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(M);function q(t){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q(t)}function G(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,J(n.key),n)}}function H(t,r,e){return r=z(r),function(t,r){if(r&&("object"==q(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,V()?Reflect.construct(r,e||[],z(t).constructor):r.apply(t,e))}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,r){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},U(t,r)}function $(t,r,e){return(r=J(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function J(t){var r=function(t,r){if("object"!=q(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==q(r)?r:r+""}var Y=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),$(e=H(this,r),"interval",void 0),$(e,"indicator",void 0),$(e,"smoothingFactor",void 0),e.interval=t,e.indicator=new N(t),e.smoothingFactor=1/e.interval,e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&U(t,r)}(r,t),e=r,n=[{key:"updates",value:function(t){var r=this;return t.forEach((function(t){return r.update(t)})),this.result}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.indicator.update(t);if(r&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,r)}if(!r&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,r)}if(void 0===this.result&&void 0!==e)return this.setResult(e,r)}}],n&&G(e.prototype,n),o&&G(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(_);function K(t){return t.length?t.reduce((function(t,r){return t+r}),0)/t.length:0}function Q(t){return Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Q(t)}function W(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Z(n.key),n)}}function X(t,r,e){return(r=Z(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Z(t){var r=function(t,r){if("object"!=Q(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Q(r)?r:r+""}var tt=function(){return t=function t(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),X(this,"interval",void 0),X(this,"deviationMultiplier",void 0),X(this,"prices",[]),X(this,"result",void 0),this.interval=r,this.deviationMultiplier=e},(r=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var r=K(this.prices),e=function(t,r){var e=r||K(t),n=K(t.map((function(t){return t-e})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,r);return this.result={lower:r-e*this.deviationMultiplier,middle:r,upper:r+e*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new m;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&W(t.prototype,r),e&&W(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();function rt(t){return rt="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},rt(t)}function et(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,at(n.key),n)}}function nt(t,r,e){return r=it(r),function(t,r){if(r&&("object"==rt(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ot()?Reflect.construct(r,e||[],it(t).constructor):r.apply(t,e))}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,r){return ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ut(t,r)}function lt(t,r,e){return(r=at(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function at(t){var r=function(t,r){if("object"!=rt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=rt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rt(r)?r:r+""}var ct=function(t){function r(t){var e;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),lt(e=nt(this,r,[t]),"interval",void 0),lt(e,"pricesCounter",0),lt(e,"weightFactor",void 0),e.interval=t,e.weightFactor=2/(e.interval+1),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&ut(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return r?r&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,r&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),r):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),r)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new m;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&et(e.prototype,n),o&&et(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,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,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vt(n.key),n)}}function ht(t,r,e){return(r=vt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function vt(t){var r=function(t,r){if("object"!=st(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var pt=function(){return t=function t(r,e,n){(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")})(this,t),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=r,this.long=e,this.signal=n},r=[{key:"getResult",value:function(){if(void 0===this.result)throw new m;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&r?this.prices[this.prices.length-1]=t:this.prices.push(t);var e=this.short.update(t,r),n=this.long.update(t,r);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=e-n,i=this.signal.update(o,r);return this.result={histogram:o-i,macd:o,signal:i}}}}],r&&ft(t.prototype,r),e&&ft(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,e}();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,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function dt(t,r,e){return r=gt(r),function(t,r){if(r&&("object"==yt(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,mt()?Reflect.construct(r,e||[],gt(t).constructor):r.apply(t,e))}function mt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(mt=function(){return!!t})()}function gt(t){return gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},gt(t)}function wt(t,r){return wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},wt(t,r)}function Ot(t,r,e){return(r=jt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function jt(t){var r=function(t,r){if("object"!=yt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(r)?r:r+""}var _t=function(t){function r(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Y;return function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,r),Ot(e=dt(this,r),"interval",void 0),Ot(e,"previousPrices",[]),Ot(e,"avgGain",void 0),Ot(e,"avgLoss",void 0),Ot(e,"maxValue",100),e.interval=t,e.avgGain=new n(e.interval),e.avgLoss=new n(e.interval),e}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&wt(t,r)}(r,t),e=r,n=[{key:"update",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&r?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var e=t,n=this.previousPrices[this.previousPrices.length-2];if(e>n?(this.avgLoss.update(0,r),this.avgGain.update(t-n,r)):(this.avgLoss.update(n-e,r),this.avgGain.update(0,r)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,r);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),r)}}}}],n&&bt(e.prototype,n),o&&bt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,o}(_);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,r){if(void 0===t||void 0===r)throw Error("undefined param in getEMA");for(var e=t.length,n=new Array(e).fill(null),o=new ct(r),i=0;i<e;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,r){if(void 0===t||void 0===r)throw Error("undefined param in getSMA");for(var e=t.length,n=new Array(e).fill(null),o=new N(r),i=0;i<e;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,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Tt=function(t,r){return t>r},Mt=function(t,r){return t<r},xt=function(t){var r=t.fast,e=t.slow,n=r.length;if(n==!e.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=r[i],l=e[i],a=void 0;null===u||null===l?a="neutral":u===l?a=Tt(r[i-1],e[i-1])?1:Mt(r[i-1],e[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 r=t.map((function(t){return t.length}));return t.map((function(t,e){var n=r[e];return t.map((function(t,r){var e=n-r;return.5===t&&(e=0),1===t&&(e*=1),0===t&&(e*=-1),e})).reverse()})).flat()},Dt=function(t){return 0===t.length?[]:t.reduce((function(t,r,e,n){if(0===e)t.push([r]);else{var o=n[e-1],i=t[t.length-1];r!==o?t.push([r]):i.push(r)}return t}),[])},It=function(t,r){var e=t.verticalOhlcv;if(!e.hasOwnProperty(r))throw Error("property ".concat(r," not found in verticalOhlcv. Invoked by findDirectionCross."));for(var n=e[r],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,r){if(!t.verticalOhlcv.hasOwnProperty(r))throw Error("property ".concat(r," not found in verticalOhlcv. Invoked by findDirectionCross."));var e=It(t,r),n=Dt(e);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 r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,e=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<r)return[];for(var i=new Array(o).fill(null),u=new _t(r),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(r),f=i,(s=function(t){var r=function(t,r){if("object"!=Bt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bt(r)?r:r+""}(s))in c?Object.defineProperty(c,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[s]=f,c);if("string"==typeof e&&"number"==typeof n&&Ft.hasOwnProperty("get".concat(e))){var v=Ft["get".concat(e)](i,n);h["rsi_".concat(e,"_").concat(n)]=v,h["rsi_".concat(r,"_x_rsi_").concat(e,"_").concat(n)]=xt({fast:i,slow:v})}return h};function qt(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Gt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Gt(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(l)throw i}}}}function Gt(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}var Ht=function(t){var r=new Date(t),e=r.getDay(),n=r.getDate(),o=new Date(r.getFullYear(),r.getMonth(),1).getDay();return{day_of_the_week:e,day_of_the_month:n,week_of_the_month:Math.ceil((n+o)/7)}},Vt=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.25;return null===t||null===r?null:t>r*(5*e)?1:t<r*(3*e)?0:2*e},zt=function(t,r){if(!r)return null;var e=t.open,n=t.high,o=t.low,i=t.close,u=r.high,l=r.low,a=[n,u],c=[o,l];i>e?(a.push(i),c.push(e)):(a.push(e),c.push(i));var s=Math.max(n,u)-Math.min(o,l)-(Math.abs(u-l)+Math.abs(n-o));return s>0?s:.01},Ut=function(t,r){for(var e=t.length,n=new N(r),o=new Array(e),i=0,u=0,l=0,a=0;a<e;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}))},$t=function(t,r){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==r.length)throw new Error("Both arrays must have the same length");for(var n=Ut(t,e),o=Ut(r,e),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 m=h*c-l*a,g=Math.sqrt((h*s-l*l)*(h*f-a*a)),w=0===g?0:m/g;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 Yt(t,r,e){return(r=Xt(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function Kt(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(e=e.call(t)).next,0===r){if(Object(e)!==e)return;a=!1}else for(;!(a=(n=i.call(e)).done)&&(l.push(n.value),l.length!==r);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=e.return&&(u=e.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(t,r)||function(t,r){if(t){if("string"==typeof t)return Qt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Qt(t,r):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qt(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Wt(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Xt(n.key),n)}}function Xt(t){var r=function(t,r){if("object"!=Jt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}var Zt=function(){return t=function t(r){var e=r.input,n=r.ticker,o=void 0===n?"undefined":n;if(function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(e))throw Error("input ohlcv must be an array: "+o);if(0===e.length)throw Error("input ohlcv must not be empty: "+o);if(!e[0].hasOwnProperty("close"))throw Error("input ohlcv array objects require at least close property: "+o);return this.len=e.length,this.crossPairsArr=[],this.inputOhlcv=e,this.verticalOhlcv=function(t,r){for(var e=["open","high","low","close","volume"],n=new Set(e),o={},i=0,u=e;i<u.length;i++)o[u[i]]=new Array(r);for(var l,a=[],c=0,s=Object.keys(t[0]);c<s.length;c++){var f=s[c];n.has(f)||(o[f]=new Array(r),a.push(f))}var h,v=0,p=0,y=(h=t)[0].hasOwnProperty("date")&&"string"==typeof h[0].date&&/^\d{4}-\d{2}-\d{2}/.test(h[0].date);y&&(o.session_index=new Array(r),o.session_intraday_index=new Array(r),o.day_of_the_week=new Array(r),o.day_of_the_month=new Array(r),o.week_of_the_month=new Array(r),l=t[0].date.slice(0,10));for(var b=0;b<r;b++){var d=t[b];o.open[b]=d.open,o.high[b]=d.high,o.low[b]=d.low,o.close[b]=d.close,o.volume[b]=d.volume;var m,g=qt(a);try{for(g.s();!(m=g.n()).done;){var w=m.value;o[w][b]=d[w]}}catch(t){g.e(t)}finally{g.f()}if(y){var O=d.date.slice(0,10);O!==l&&(l=O,v++,p=0);var j=Ht(O),_=j.day_of_the_week,S=j.day_of_the_month,P=j.week_of_the_month;o.day_of_the_week[b]=_,o.day_of_the_month[b]=S,o.week_of_the_month[b]=P,o.session_index[b]=v,o.session_intraday_index[b]=p,p++}}return o}(e,this.len),this.indicators={},this.studies={},this.utilities={correlation:$t},this},r=[{key:"getData",value:function(){this.compute();for(var t=this.verticalOhlcv,r=Object.keys(t),e=t[r[0]].length,n=r.length,o=[],i=0;i<e;i++){for(var u={},l=!1,a=0;a<n;a++){var c=r[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,r=this.len,e={},n=0,o=Object.entries(t);n<o.length;n++){var i=Kt(o[n],2),u=i[0],l=i[1][r-1];e[u]=l}return Object.assign(e,this.studies),e}},{key:"compute",value:function(){for(var t=this.indicators,r=this.addColumn.bind(this),e=0,n=Object.entries(t);e<n.length;e++){var o=Kt(n[e],2),i=o[0],u=o[1];this.verticalOhlcv.hasOwnProperty(i)?delete this.indicators[i]:r(i,u)}return this}},{key:"addColumn",value:function(t,r){var e=this.len;if(t=t.toLowerCase(),r.length>e)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");if(r.length<e){var n=e-r.length;r=new Array(n).fill(null).concat(r)}this.verticalOhlcv[t]=r}},{key:"crossPairs",value:function(t){this.compute();var r=function(t,r){var e,n=t.verticalOhlcv,o=t.len,i={},u={},l={},a=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return Rt(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Rt(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(l)throw i}}}}(r);try{var c=function(){var t=e.value,r=t.fast,a=t.slow,c=t.count;if(!r||!a)return 1;"number"!=typeof a||i[a]||(i[a]=Array(o).fill(a));var s="".concat(r,"_x_").concat(a),f="".concat(r,"_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[r]&&n[a]){var p=xt({fast:n[r],slow:n[a]});u[s]=p,void 0!==c&&(l[f]=h(p))}else if(n[r]&&i[a]){var y=xt({fast:n[r],slow:i[a]});u[s]=y,void 0!==c&&(l[f]=h(y))}else console.log("Missing ohlcv properties for ".concat(r," or ").concat(a))};for(a.s();!(e=a.n()).done;)c()}catch(t){a.e(t)}finally{a.f()}return{x:u,c:l}}(this,t),e=r.x,n=r.c;return Object.assign(this.indicators,e),Object.assign(this.studies,n),this.compute(),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.compute();for(var e=this.verticalOhlcv,n=0;n<t.length;n++)for(var o=1;o<=r;o++){var i="".concat(t[n],"_lag_").concat(o),u=e[t[n]].slice(0,-o);Object.assign(this.indicators,Yt({},i,u))}return this.compute(),this}},{key:"relativeVolume",value:function(t){var r=function(t,r){var e=function(t){for(var r=new N(arguments.length>1&&void 0!==arguments[1]?arguments[1]:10),e=new Array(t.length).fill(null),n=new Array(t.length).fill(null),o=0;o<t.length;o++){var i=null;r.update(t[o]);try{i=r.getResult()}catch(t){i=null}e[o]=i,"number"==typeof e[o-1]&&(n[o]=t[o]/e[o-1])}return console.log(n),n}(t.verticalOhlcv.volume,r);return function(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=St(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}({},"relative_volume_".concat(r),e)}(this,t);return Object.assign(this.indicators,r),this}},{key:"ema",value:function(t){var r=function(t,r){var e=t.verticalOhlcv.close,n=Et(e,r);return function(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=Pt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}({},"ema_".concat(r),n)}(this,t);return Object.assign(this.indicators,r),this}},{key:"sma",value:function(t){var r=function(t,r){var e=t.verticalOhlcv.close,n=kt(e,r);return function(t,r,e){return(r=function(t){var r=function(t,r){if("object"!=At(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.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(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}({},"sma_".concat(r),n)}(this,t);return Object.assign(this.indicators,r),this}},{key:"macd",value:function(t,r,e){var n=function(t,r,e,n){return function(t){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,e=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(r),new ct(e),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,r,e,n)}(this,t,r,e);return Object.assign(this.indicators,n),this}},{key:"bollingerBands",value:function(t,r){var e=function(t,r,e){return function(t){for(var r,e,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 m=(r=t[y],e=b.upper,{range:(r-(n=b.lower))/(e-n)*100,height:(e-n)/n*100});h=m.range,v=m.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,r,e)}(this,t,r);return Object.assign(this.indicators,e),this}},{key:"rsi",value:function(t,r,e){var n=function(t,r,e,n){var o=t.verticalOhlcv.close;return"number"==typeof r&&void 0===n&&(n=r),Nt(o,r,e,n)}(this,t,r,e);return Object.assign(this.indicators,n),this}},{key:"orb",value:function(){var t=function(t,r){for(var e=new Array(r).fill(0),n=new Array(r).fill(0),o=0,i=null,u=0,l=0,a=0;a<r;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),e[o]=u,n[o]=l,o++}return{orb_high:e,orb_low:n}}(this.inputOhlcv,this.len);return Object.assign(this.indicators,t),this}},{key:"donchianChannels",value:function(t,r){var e=function(t,r,e){var n=t.verticalOhlcv,o=t.len;return function(t,r,e,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-e;)a.shift();for(;a.length&&t[a[a.length-1]]<=t[s];)a.pop();for(a.push(s);c.length&&c[0]<=s-e;)c.shift();for(;c.length&&r[c[c.length-1]]>=r[s];)c.pop();if(c.push(s),s>=e-1){var f=t[a[0]],h=r[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,r,e,o)}(this,t,r);return Object.assign(this.indicators,e),this}},{key:"candlesStudies",value:function(t){var r=function(t,r){return function(t){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,e=arguments.length>2?arguments[2]:void 0,n=function(t,r){return Math.abs(t-r)},o=new Array(e).fill(null),i=new Array(e).fill(null),u=new Array(e).fill(null),l=new Array(e).fill(null),a=new Array(e).fill(null),c=new N(r),s=new N(parseInt(r/2)),f=0;f<e;f++){var h=t[f],v=h.open,p=h.high,y=h.low,b=h.close,d=void 0!==t[f-1]?zt(t[f],t[f-1]):null,m=null,g=null,w=n(v,b),O=void 0,j=void 0,_=b>v?1:0;1===_?(O=n(p,b),j=n(v,y)):(O=n(p,v),j=n(b,y)),c.update(w),d&&s.update(d);try{m=c.getResult(),g=s.getResult()}catch(t){m=null,g=null}o[f]=_,i[f]=Vt(w,m,.25),u[f]=Vt(O,m,.25),l[f]=Vt(j,m,.25),a[f]=Vt(d,g,.25)}return{candle_direction:o,candle_gap_size:a,candle_body_size:i,candle_top_size:u,candle_bottom_size:l}}(t.inputOhlcv,r,t.len)}(this,t);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 r=0;r<t.length;r++){var e=t[r],n=Lt(this,e);Object.assign(this.indicators,Yt({},"".concat(e,"_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 r=0;r<t.length;r++){var e=t[r],n=It(this,e);Object.assign(this.indicators,Yt({},"".concat(e,"_linear_direction"),n))}return this.compute(),this}},{key:"change",value:function(t){this.compute();var r=this.verticalOhlcv;if(!r.hasOwnProperty(t)){var e='key "'.concat(t,'" not found in verticalOhlcv. change method');throw Error(e)}return Object.assign(this.indicators,Yt({},"".concat(t,"_change"),function(t){if(!Array.isArray(t))throw Error("data param in arrayGt function must be array");for(var r=Array(t.length).fill(0),e=1;e<r.length;e++)if(null===t[e]||null===t[e-1])r[e];else{var n=t[e],o=t[e-1];r[e]=(n-o)/o}return r}(r[t]))),this.compute(),this}},{key:"gt",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"close",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"open";this.compute();var e,n=this.verticalOhlcv;if(!n.hasOwnProperty(t)){var o='key "'.concat(t,'" not found in verticalOhlcv. gt method');throw Error(o)}if("string"==typeof r){if(!n.hasOwnProperty(r)){var i='key "'.concat(r,'" not found in verticalOhlcv. gt method');throw Error(i)}e=n[r]}else"number"==typeof r&&(e=new Array(n[t].length).fill(r));return Object.assign(this.indicators,Yt({},"".concat(t,"_gt_").concat(r),function(t,r){if(!Array.isArray(t)||!Array.isArray(r))throw Error("a and b params in arrayGt function must be arrays");if(t.length!==r.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 e=Array(t.length).fill(.5),n=1;n<e.length;n++)null!==t[n]&&null!==r[n]||(e[n]=null),t[n]>r[n]?e[n]=1:t[n]<r[n]&&(e[n]=0);return e}(n[t],e))),this.compute(),this}}],r&&Wt(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r}()})(),OHLCV_INDICATORS=r})();
|
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { relativeVolume } from './src/moving-averages/relativeVolume.js'
|
|
1
2
|
import {ema} from './src/moving-averages/ema.js'
|
|
2
3
|
import {sma} from './src/moving-averages/sma.js'
|
|
3
4
|
import {macd} from './src/moving-averages/macd.js'
|
|
@@ -9,6 +10,7 @@ import { donchianChannels } from './src/moving-averages/donchianChannel.js'
|
|
|
9
10
|
import { parseOhlcvToVertical } from './src/utilities/parsing-utilities.js'
|
|
10
11
|
import { candlesStudies } from './src/studies/candleStudies.js'
|
|
11
12
|
import { correlation } from './src/studies/correlation.js'
|
|
13
|
+
import { arrayChange, arrayGt } from './src/utilities/math-array.js'
|
|
12
14
|
|
|
13
15
|
export default class OHLCV_INDICATORS {
|
|
14
16
|
constructor({input, ticker = 'undefined'}) {
|
|
@@ -155,6 +157,14 @@ export default class OHLCV_INDICATORS {
|
|
|
155
157
|
return this;
|
|
156
158
|
}
|
|
157
159
|
|
|
160
|
+
relativeVolume(size) {
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
const result = relativeVolume(this, size)
|
|
164
|
+
Object.assign(this.indicators, result)
|
|
165
|
+
|
|
166
|
+
return this
|
|
167
|
+
}
|
|
158
168
|
|
|
159
169
|
ema(size) {
|
|
160
170
|
|
|
@@ -246,29 +256,58 @@ export default class OHLCV_INDICATORS {
|
|
|
246
256
|
this.compute()
|
|
247
257
|
return this
|
|
248
258
|
}
|
|
249
|
-
|
|
259
|
+
|
|
260
|
+
change(key)
|
|
261
|
+
{
|
|
262
|
+
this.compute()
|
|
263
|
+
const {verticalOhlcv} = this
|
|
264
|
+
|
|
265
|
+
if(!verticalOhlcv.hasOwnProperty(key))
|
|
266
|
+
{
|
|
267
|
+
const err = `key "${key}" not found in verticalOhlcv. change method`
|
|
268
|
+
throw Error(err)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
Object.assign(this.indicators, {
|
|
272
|
+
[`${key}_change`]: arrayChange(verticalOhlcv[key])
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
this.compute()
|
|
276
|
+
|
|
277
|
+
return this
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
gt(a = 'close', b = 'open')
|
|
250
282
|
{
|
|
251
283
|
this.compute()
|
|
252
284
|
|
|
253
285
|
const {verticalOhlcv} = this
|
|
254
286
|
|
|
255
|
-
|
|
287
|
+
if(!verticalOhlcv.hasOwnProperty(a))
|
|
256
288
|
{
|
|
257
|
-
const {a
|
|
258
|
-
|
|
289
|
+
const errA = `key "${a}" not found in verticalOhlcv. gt method`
|
|
290
|
+
throw Error(errA)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
let bArr
|
|
259
294
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
else if(typeof b === 'number')
|
|
295
|
+
if(typeof b === 'string')
|
|
296
|
+
{
|
|
297
|
+
if(!verticalOhlcv.hasOwnProperty(b))
|
|
265
298
|
{
|
|
266
|
-
|
|
299
|
+
const errB = `key "${b}" not found in verticalOhlcv. gt method`
|
|
300
|
+
throw Error(errB)
|
|
267
301
|
}
|
|
268
302
|
|
|
269
|
-
|
|
270
|
-
Object.assign(this.indicators, {[`${a}_gt_${b}`]: result})
|
|
303
|
+
bArr = verticalOhlcv[b]
|
|
271
304
|
}
|
|
305
|
+
else if(typeof b === 'number')
|
|
306
|
+
{
|
|
307
|
+
bArr = new Array(verticalOhlcv[a].length).fill(b)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
Object.assign(this.indicators, {[`${a}_gt_${b}`]: arrayGt(verticalOhlcv[a], bArr)})
|
|
272
311
|
|
|
273
312
|
this.compute()
|
|
274
313
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"description": "A JavaScript library featuring optimized trading indicators for OHLCV arrays [{open, high, low, close, value}]. This library is optimized for backtesting and trading bot development.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -1,18 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {FasterSMA} from 'trading-signals'
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const relativeVolume = (main, size) => {
|
|
4
4
|
const {verticalOhlcv} = main
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
const {volume} = verticalOhlcv
|
|
6
|
+
const col = getRelativeVolume(volume, size)
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
[`relative_volume_${size}`]: col
|
|
10
|
+
}
|
|
8
11
|
}
|
|
9
12
|
|
|
10
|
-
export const getRelativeVolume = (
|
|
11
|
-
|
|
13
|
+
export const getRelativeVolume = (volume, size = 10) => {
|
|
14
|
+
|
|
15
|
+
const instance = new FasterSMA(size)
|
|
16
|
+
const sma = new Array(volume.length).fill(null)
|
|
17
|
+
const output = new Array(volume.length).fill(null)
|
|
18
|
+
|
|
19
|
+
for(let x = 0; x < volume.length; x++)
|
|
20
|
+
{
|
|
21
|
+
let value = null
|
|
22
|
+
|
|
23
|
+
instance.update(volume[x])
|
|
24
|
+
|
|
25
|
+
try
|
|
26
|
+
{
|
|
27
|
+
value = instance.getResult()
|
|
28
|
+
}
|
|
29
|
+
catch(err)
|
|
30
|
+
{
|
|
31
|
+
value = null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
sma[x] = value
|
|
35
|
+
|
|
36
|
+
if(typeof sma[x-1] === 'number')
|
|
37
|
+
{
|
|
38
|
+
output[x] = volume[x] / sma[x-1]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log(output)
|
|
12
43
|
|
|
13
|
-
return
|
|
14
|
-
const prevSma = sma[i - 1]
|
|
15
|
-
if (i === 0 || !prevSma || prevSma.isZero()) return null
|
|
16
|
-
return v.dividedBy(prevSma)
|
|
17
|
-
}).filter(v => !Number.isNaN(v))
|
|
44
|
+
return output
|
|
18
45
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//change between current and prev
|
|
2
|
+
export const arrayChange = data => {
|
|
3
|
+
|
|
4
|
+
if(!Array.isArray(data))
|
|
5
|
+
{
|
|
6
|
+
throw Error('data param in arrayGt function must be array')
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const output = Array(data.length).fill(0)
|
|
10
|
+
|
|
11
|
+
for (let x = 1; x < output.length; x++) {
|
|
12
|
+
|
|
13
|
+
if(data[x] === null || data[x - 1] === null)
|
|
14
|
+
{
|
|
15
|
+
output[x] === null
|
|
16
|
+
}
|
|
17
|
+
else
|
|
18
|
+
{
|
|
19
|
+
const curr = data[x]
|
|
20
|
+
const prev = data[x - 1]
|
|
21
|
+
output[x] = (curr - prev) / prev
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return output
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//tells if array a is greater than array b
|
|
29
|
+
|
|
30
|
+
export const arrayGt = (a, b) => {
|
|
31
|
+
|
|
32
|
+
if(!Array.isArray(a) || !Array.isArray(b))
|
|
33
|
+
{
|
|
34
|
+
throw Error('a and b params in arrayGt function must be arrays')
|
|
35
|
+
}
|
|
36
|
+
if(a.length !== b.length)
|
|
37
|
+
{
|
|
38
|
+
throw Error('array a and b must be the same length in arrayGt function')
|
|
39
|
+
}
|
|
40
|
+
if(a.length < 2)
|
|
41
|
+
{
|
|
42
|
+
throw Error('arrays in arrayGt function must have at least 2 numeric items')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const output = Array(a.length).fill(0.5)
|
|
46
|
+
|
|
47
|
+
for (let x = 1; x < output.length; x++) {
|
|
48
|
+
|
|
49
|
+
if(a[x] === null || b[x] === null)
|
|
50
|
+
{
|
|
51
|
+
output[x] = null
|
|
52
|
+
}
|
|
53
|
+
if(a[x] > b[x])
|
|
54
|
+
{
|
|
55
|
+
output[x] = 1
|
|
56
|
+
}
|
|
57
|
+
else if(a[x] < b[x])
|
|
58
|
+
{
|
|
59
|
+
output[x] = 0
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return output
|
|
64
|
+
}
|