ohlcv-indicators 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ohlcv-indicators.min.js +1 -1
- package/index.js +23 -56
- package/package.json +1 -1
- package/src/oscillators/rsi.js +1 -8
- package/src/studies/findCrosses.js +5 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see ohlcv-indicators.min.js.LICENSE.txt */
|
|
2
|
-
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{t.r(e),t.d(e,{default:()=>fe});var r=1e6,n="[big.js] ",o=n+"Invalid ",i=o+"decimal places",a=o+"rounding mode",c=n+"Division by zero",l={},u=void 0,s=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function h(t,e,r,n){var o=t.c;if(r===u&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(a);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==u))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==u||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function f(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}l.abs=function(){var t=new this.constructor(this);return t.s=1,t},l.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,a=t.s,c=r.e,l=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=i<0,c!=l)return c>l^e?1:-1;for(a=(c=n.length)<(l=o.length)?c:l,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return c==l?0:c>l^e?1:-1},l.div=function(t){var e=this,n=e.constructor,o=e.c,a=(t=new n(t)).c,l=e.s==t.s?1:-1,s=n.DP;if(s!==~~s||s<0||s>r)throw Error(i);if(!a[0])throw Error(c);if(!o[0])return t.s=l,t.c=[t.e=0],t;var f,p,v,y,m,b=a.slice(),d=f=a.length,g=o.length,w=o.slice(0,f),M=w.length,S=t,j=S.c=[],O=0,P=s+(S.e=e.e-t.e)+1;for(S.s=l,l=P<0?0:P,b.unshift(0);M++<f;)w.push(0);do{for(v=0;v<10;v++){if(f!=(M=w.length))y=f>M?1:-1;else for(m=-1,y=0;++m<f;)if(a[m]!=w[m]){y=a[m]>w[m]?1:-1;break}if(!(y<0))break;for(p=M==f?a:b;M;){if(w[--M]<p[M]){for(m=M;m&&!w[--m];)w[m]=9;--w[m],w[M]+=10}w[M]-=p[M]}for(;!w[0];)w.shift()}j[O++]=y?v:++v,w[0]&&y?w[M]=o[d]||0:w=[o[d]]}while((d++<g||w[0]!==u)&&l--);return j[0]||1==O||(j.shift(),S.e--,P--),O>P&&h(S,P,n.RM,w[0]!==u),S},l.eq=function(t){return 0===this.cmp(t)},l.gt=function(t){return this.cmp(t)>0},l.gte=function(t){return this.cmp(t)>-1},l.lt=function(t){return this.cmp(t)<0},l.lte=function(t){return this.cmp(t)<1},l.minus=l.sub=function(t){var e,r,n,o,i=this,a=i.constructor,c=i.s,l=(t=new a(t)).s;if(c!=l)return t.s=-l,i.plus(t);var u=i.c.slice(),s=i.e,h=t.c,f=t.e;if(!u[0]||!h[0])return h[0]?t.s=-l:u[0]?t=new a(i):t.s=1,t;if(c=s-f){for((o=c<0)?(c=-c,n=u):(f=s,n=h),n.reverse(),l=c;l--;)n.push(0);n.reverse()}else for(r=((o=u.length<h.length)?u:h).length,c=l=0;l<r;l++)if(u[l]!=h[l]){o=u[l]<h[l];break}if(o&&(n=u,u=h,h=n,t.s=-t.s),(l=(r=h.length)-(e=u.length))>0)for(;l--;)u[e++]=0;for(l=e;r>c;){if(u[--r]<h[r]){for(e=r;e&&!u[--e];)u[e]=9;--u[e],u[r]+=10}u[r]-=h[r]}for(;0===u[--l];)u.pop();for(;0===u[0];)u.shift(),--f;return u[0]||(t.s=1,u=[f=0]),t.c=u,t.e=f,t},l.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(c);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},l.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},l.plus=l.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var a=o.e,c=o.c,l=t.e,u=t.c;if(!c[0]||!u[0])return u[0]||(c[0]?t=new i(o):t.s=o.s),t;if(c=c.slice(),e=a-l){for(e>0?(l=a,n=u):(e=-e,n=c),n.reverse();e--;)n.push(0);n.reverse()}for(c.length-u.length<0&&(n=u,u=c,c=n),e=u.length,r=0;e;c[e]%=10)r=(c[--e]=c[e]+u[e]+r)/10|0;for(r&&(c.unshift(r),++l),e=c.length;0===c[--e];)c.pop();return t.c=c,t.e=l,t},l.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(o+"exponent");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},l.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(o+"precision");return h(new this.constructor(this),t,e)},l.round=function(t,e){if(t===u)t=0;else if(t!==~~t||t<-r||t>r)throw Error(i);return h(new this.constructor(this),t+this.e+1,e)},l.sqrt=function(){var t,e,r,o=this,i=o.constructor,a=o.s,c=o.e,l=new i("0.5");if(!o.c[0])return new i(o);if(a<0)throw Error(n+"No square root");0===(a=Math.sqrt(o+""))||a===1/0?((e=o.c.join("")).length+c&1||(e+="0"),c=((c+1)/2|0)-(c<0||1&c),t=new i(((a=Math.sqrt(e))==1/0?"5e":(a=a.toExponential()).slice(0,a.indexOf("e")+1))+c)):t=new i(a+""),c=t.e+(i.DP+=4);do{r=t,t=l.times(r.plus(o.div(r)))}while(r.c.slice(0,c).join("")!==t.c.slice(0,c).join(""));return h(t,(i.DP-=4)+t.e+1,i.RM)},l.times=l.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,a=o.length,c=i.length,l=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=l+u,a<c&&(e=o,o=i,i=e,u=a,a=c,c=u),e=new Array(u=a+c);u--;)e[u]=0;for(l=c;l--;){for(c=0,u=a+l;u>l;)c=e[u]+i[l]*o[u-l-1]+c,e[u--]=c%10,c=c/10|0;e[u]=c}for(c?++t.e:e.shift(),l=e.length;!e[--l];)e.pop();return t.c=e,t},l.toExponential=function(t,e){var n=this,o=n.c[0];if(t!==u){if(t!==~~t||t<0||t>r)throw Error(i);for(n=h(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return f(n,!0,!!o)},l.toFixed=function(t,e){var n=this,o=n.c[0];if(t!==u){if(t!==~~t||t<0||t>r)throw Error(i);for(t=t+(n=h(new n.constructor(n),t+n.e+1,e)).e+1;n.c.length<t;)n.c.push(0)}return f(n,!1,!!o)},l[Symbol.for("nodejs.util.inspect.custom")]=l.toJSON=l.toString=function(){var t=this,e=t.constructor;return f(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},l.toNumber=function(){var t=Number(f(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},l.toPrecision=function(t,e){var n=this,i=n.constructor,a=n.c[0];if(t!==u){if(t!==~~t||t<1||t>r)throw Error(o+"precision");for(n=h(new i(n),t,e);n.c.length<t;)n.c.push(0)}return f(n,t<=n.e||n.e<=i.NE||n.e>=i.PE,!!a)},l.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return f(t,t.e<=e.NE||t.e>=e.PE,!0)};const p=function t(){function e(r){var n=this;if(!(n instanceof e))return r===u?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(o+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,i;if(!s.test(e))throw Error(o+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&"0"==e.charAt(n);)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&"0"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=l,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();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 y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(m())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&b(o,r.prototype),o}(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(r,t)},y(t)}function m(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(m=function(){return!!t})()}function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}var g=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,m()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&b(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(y(Error));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 M(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,j(n.key),n)}}function S(t,e,r){return(e=j(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function j(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.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(e)?e:e+""}var O=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),S(this,"previousHighest",void 0),S(this,"highest",void 0),S(this,"previousLowest",void 0),S(this,"lowest",void 0),S(this,"previousResult",void 0),S(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t.gt(this.highest)?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t.lt(this.lowest)?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&M(t.prototype,e),r&&M(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function _(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,A(n.key),n)}}function E(t,e,r){return e=k(e),function(t,e){if(e&&("object"==P(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,x()?Reflect.construct(e,r||[],k(t).constructor):e.apply(t,r))}function x(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(x=function(){return!!t})()}function k(t){return k=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},k(t)}function T(t,e){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},T(t,e)}function A(t){var e=function(t,e){if("object"!=P(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}var L=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=E(this,e),i=void 0,(o=A(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&T(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&_(r.prototype,n),o&&_(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(O);function R(t){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(t)}function B(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,D(n.key),n)}}function I(t,e,r){return e=C(e),function(t,e){if(e&&("object"==R(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,N()?Reflect.construct(e,r||[],C(t).constructor):e.apply(t,r))}function N(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(N=function(){return!!t})()}function C(t){return C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},C(t)}function F(t,e){return F=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},F(t,e)}function D(t){var e=function(t,e){if("object"!=R(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=R(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==R(e)?e:e+""}var V=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,a=new Array(i),c=0;c<i;c++)a[c]=arguments[c];return r=t=I(this,e,[].concat(a)),o=[],(n=D(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&F(t,e)}(e,t),r=e,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)return this.setResult(e.getResultFromBatch(this.prices),r)}}],o=[{key:"getResultFromBatch",value:function(t){return t.reduce((function(t,e){return t.plus(e)}),new p("0")).div(t.length||1)}}],n&&B(r.prototype,n),o&&B(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(L);function G(t){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(t)}function H(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Y(n.key),n)}}function q(t,e,r){return e=W(e),function(t,e){if(e&&("object"==G(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,U()?Reflect.construct(e,r||[],W(t).constructor):e.apply(t,r))}function U(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(U=function(){return!!t})()}function W(t){return W=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},W(t)}function $(t,e){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$(t,e)}function z(t,e,r){return(e=Y(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Y(t){var e=function(t,e){if("object"!=G(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=G(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==G(e)?e:e+""}var K=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),z(r=q(this,e,[t]),"interval",void 0),z(r,"indicator",void 0),z(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new V(t),r.smoothingFactor=new p(1).div(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t,e);if(e&&this.previousResult){var n=new p(t).minus(this.previousResult).mul(this.smoothingFactor);return this.setResult(n.plus(this.previousResult),e)}if(!e&&this.result){var o=new p(t).minus(this.result).mul(this.smoothingFactor);return this.setResult(o.plus(this.result),e)}if(void 0===this.result&&r)return this.setResult(r,e)}}],n&&H(r.prototype,n),o&&H(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(L);function J(t){return t.reduce((function(t,e){return t.add(e)}),new p(0)).div(t.length||1)}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 X(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,tt(n.key),n)}}function Z(t,e,r){return(e=tt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function tt(t){var e=function(t,e){if("object"!=Q(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.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(e)?e:e+""}var et=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),Z(this,"interval",void 0),Z(this,"deviationMultiplier",void 0),Z(this,"prices",[]),Z(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){if(this.prices.push(new p(t)),this.prices.length>this.interval){this.prices.shift();var e=V.getResultFromBatch(this.prices),r=function(t,e){var r=e||J(t);return J(t.map((function(t){return new p(t).sub(r).pow(2)}))).sqrt()}(this.prices,e);return this.result={lower:e.sub(r.times(this.deviationMultiplier)),middle:e,upper:e.add(r.times(this.deviationMultiplier))}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}}])&&X(t.prototype,e),r&&X(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();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 nt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ut(n.key),n)}}function ot(t,e,r){return e=at(e),function(t,e){if(e&&("object"==rt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,it()?Reflect.construct(e,r||[],at(t).constructor):e.apply(t,r))}function it(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(it=function(){return!!t})()}function at(t){return at=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},at(t)}function ct(t,e){return ct=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ct(t,e)}function lt(t,e,r){return(e=ut(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ut(t){var e=function(t,e){if("object"!=rt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.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(e)?e:e+""}var st=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),lt(r=ot(this,e,[t]),"interval",void 0),lt(r,"pricesCounter",0),lt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ct(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r?r&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++;var n=new p(t);return r&&this.previousResult?this.setResult(n.times(this.weightFactor).add(this.previousResult.times(1-this.weightFactor)),r):this.setResult(n.times(this.weightFactor).add((null!==(e=this.result)&&void 0!==e?e:n).times(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&&nt(r.prototype,n),o&&nt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(L);function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function ft(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vt(n.key),n)}}function pt(t,e,r){return(e=vt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vt(t){var e=function(t,e){if("object"!=ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ht(e)?e:e+""}var yt=function(){return t=function t(e){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),pt(this,"prices",[]),pt(this,"long",void 0),pt(this,"short",void 0),pt(this,"signal",void 0),pt(this,"result",void 0),this.long=new e.indicator(e.longInterval),this.short=new e.indicator(e.shortInterval),this.signal=new e.indicator(e.signalInterval)},e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new p(t);this.prices.length&&e?this.prices[this.prices.length-1]=r:this.prices.push(r);var n=this.short.update(r,e),o=this.long.update(r,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var i=n.sub(o),a=this.signal.update(i);return this.result={histogram:i.sub(a),macd:i,signal:a}}}},{key:"getResult",value:function(){if(!this.isStable||void 0===this.result)throw new g;return this.result}}],e&&ft(t.prototype,e),r&&ft(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function mt(t){return mt="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},mt(t)}function bt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function dt(t,e,r){return e=wt(e),function(t,e){if(e&&("object"==mt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,gt()?Reflect.construct(e,r||[],wt(t).constructor):e.apply(t,r))}function gt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(gt=function(){return!!t})()}function wt(t){return wt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},wt(t)}function Mt(t,e){return Mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mt(t,e)}function St(t,e,r){return(e=jt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jt(t){var e=function(t,e){if("object"!=mt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=mt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mt(e)?e:e+""}var Ot=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),St(r=dt(this,e),"interval",void 0),St(r,"previousPrices",[]),St(r,"avgGain",void 0),St(r,"avgLoss",void 0),St(r,"maxValue",new p(100)),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Mt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=new p(t),n=new p(this.previousPrices[this.previousPrices.length-2]);if(r.gt(n)?(this.avgLoss.update(new p(0),e),this.avgGain.update(r.sub(n),e)):(this.avgLoss.update(n.sub(r),e),this.avgGain.update(new p(0),e)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(o.eq(0))return this.setResult(new p(100),e);var i=this.avgGain.getResult().div(o);return this.setResult(this.maxValue.minus(this.maxValue.div(i.add(1))),e)}}}}],n&&bt(r.prototype,n),o&&bt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(O);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,e){for(var r=[],n=new st(e),o=t.length,i=0;i<o;i++){var a=null;n.update(t[i]);try{a=n.getResult()}catch(t){a=null}r.push(a)}return r};function Et(t){return Et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Et(t)}var xt=function(t,e){for(var r=[],n=new V(e),o=t.length,i=0;i<o;i++){var a=null;n.update(t[i]);try{a=n.getResult()}catch(t){a=null}r.push(a)}return r};function kt(t){return kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kt(t)}function Tt(){Tt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:_(t,r,c)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var f="suspendedStart",p="suspendedYield",v="executing",y="completed",m={};function b(){}function d(){}function g(){}var w={};u(w,a,(function(){return this}));var M=Object.getPrototypeOf,S=M&&M(M(A([])));S&&S!==r&&n.call(S,a)&&(w=S);var j=g.prototype=b.prototype=Object.create(w);function O(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(o,i,a,c){var l=h(t[o],t,i);if("throw"!==l.type){var u=l.arg,s=u.value;return s&&"object"==kt(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(l.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function _(e,r,n){var o=f;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var l=E(c,n);if(l){if(l===m)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=h(e,r,n);if("normal"===u.type){if(o=n.done?y:p,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function E(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function A(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(kt(e)+" is not iterable")}return d.prototype=g,o(j,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:d,configurable:!0}),d.displayName=u(g,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,u(t,l,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},O(P.prototype),u(P.prototype,c,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new P(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),u(j,l,"Generator"),u(j,a,(function(){return this})),u(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=A,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var l=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:A(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function At(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=kt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Bt(t,e,r,n,o,i,a){try{var c=t[i](a),l=c.value}catch(t){return void r(t)}c.done?e(l):Promise.resolve(l).then(n,o)}var It=function(t,e){t=t.filter((function(t){return t instanceof p})),e=e.filter((function(t){return t instanceof p}));var r=Math.min(t.length,e.length);t=t.slice(-r),e=e.slice(-r);var n=t.map((function(t,r){if(t.eq(e[r]))return"neutral";if(t.gt(e[r]))return"up";if(t.lt(e[r]))return"down";throw Error("undefined error in findCrosses")})),o=Nt(n),i=o.map((function(t){return t.length}));return o.map((function(t,e){var r=i[e];return t.map((function(t,e){var n=r-e;return"neutral"===t&&(n=0),"up"===t&&(n*=1),"down"===t&&(n*=-1),n})).reverse()})).flat()},Nt=function(t){return 0===t.length?[]:t.reduce((function(t,e,r,n){if(0===r)t.push([e]);else{var o=n[r-1],i=t[t.length-1];e!==o?t.push([e]):i.push(e)}return t}),[])},Ct=function(){var t,e=(t=Tt().mark((function t(e,r){var n,o,i,a,c,l,u,s,h,f,v,y,m,b;return Tt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.ohlcv,o={},i=[],a=Lt(r),t.prev=4,a.s();case 6:if((c=a.n()).done){t.next=14;break}if(l=c.value,u=l.fast,s=l.slow,u&&s){t.next=10;break}return t.abrupt("continue",12);case 10:"number"!=typeof s||o[s]||(o[s]=Array(n.close.length).fill(new p(s))),n[u]&&n[s]?(h=It(n[u],n[s]),i.push(Promise.resolve(At({},"".concat(u,"_x_").concat(s),h)))):n[u]&&o[s]?(f=It(n[u],o[s]),i.push(Promise.resolve(At({},"".concat(u,"_x_").concat(s),f)))):console.log("Missing ohlcv properties for ".concat(u," or ").concat(s));case 12:t.next=6;break;case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(4),a.e(t.t0);case 19:return t.prev=19,a.f(),t.finish(19);case 22:return t.next=24,Promise.all(i);case 24:for(v=t.sent,y=0;y<v.length;y++)m=v[y],b=Object.keys(m)[0],e.addColumn(b,m[b]);return t.abrupt("return",!0);case 27:case"end":return t.stop()}}),t,null,[[4,16,19,22]])})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Bt(i,n,o,a,c,"next",t)}function c(t){Bt(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t,r){return e.apply(this,arguments)}}(),Ft=function(t,e){for(var r=e.bollinger_bands_upper,n=e.bollinger_bands_lower,o=new Array(t.length),i=0;i<t.length;i++)if(null!=r[i]&&null!=n[i]&&null!=t[i]){var a=new p(r[i]),c=new p(n[i]),l=new p(t[i]),u=a.minus(c);o[i]=l.minus(c).div(u).times(100)}else o[i]=null;return o};function Dt(t){return Dt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dt(t)}var Vt={getSMA:xt,getEMA:_t},Gt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"SMA",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:14;if(t.length<e)return[];var o=[];e=parseInt(e),n=parseInt(n);for(var i=new Ot(e),a=t.length,c=0;c<a;c++){var l=null;i.update(t[c]);try{l=i.getResult()}catch(t){l=null}o.push(l)}o=o.filter((function(t){return t}));var u,s,h,f=(u={},s="rsi_".concat(e),h=o,(s=function(t){var e=function(t,e){if("object"!=Dt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Dt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dt(e)?e:e+""}(s))in u?Object.defineProperty(u,s,{value:h,enumerable:!0,configurable:!0,writable:!0}):u[s]=h,u);if("string"==typeof r&&"number"==typeof n&&Vt.hasOwnProperty("get".concat(r))){var p=Vt["get".concat(r)](o,n);f["rsi_".concat(r,"_").concat(n)]=p,f["rsi_".concat(e,"_x_rsi_").concat(r,"_").concat(n)]=It(o,p)}return f};function Ht(t){return Ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ht(t)}function qt(t){return function(t){if(Array.isArray(t))return Ut(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ut(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ut(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Wt=function(t){if(!t||0===t.length)throw new Error("Bins array is empty or not provided");var e=t[0],r=t[0];return t.forEach((function(t){t.grossVolume>e.grossVolume&&(e=t),t.grossVolume<r.grossVolume&&(r=t)})),{high:e,low:r}},$t=function(t,e,r){var n,o,i,a=new Date(t[r][t[r].length-1]),c=new Date(a);c.setDate(c.getDate()-e),c.setHours(0,0,0,0);for(var l=(n={open:[],high:[],low:[],close:[],volume:[]},i=[],(o=function(t){var e=function(t,e){if("object"!=Ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ht(e)?e:e+""}(o=r))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,n),u=0;u<t[r].length;u++)new Date(t[r][u])>=c&&(l.open.push(t.open[u]),l.high.push(t.high[u]),l.low.push(t.low[u]),l.close.push(t.close[u]),l.volume.push(t.volume[u]),l[r].push(t[r][u]));return l};function zt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Yt=function(t){var e=t.open,r=t.high,n=t.low,o=t.close,i=e.length;if(![e,r,n,o].every((function(t){return Array.isArray(t)&&t.length>1&&t.length===i})))return{pattern:Array(i).fill("Neutral"),name:Array(i).fill("No Pattern"),score:Array(i).fill(0)};for(var a=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-4;return Math.abs(t-e)<r},c={bullish:[{name:"Marubozu",condition:function(t,e){return a(e.open,e.low)&&a(e.close,e.high)},score:2},{name:"Engulfing",condition:function(t,e){return e.open<t.close&&e.close>t.open&&e.low<t.low&&e.high>t.high},score:2},{name:"Kicker",condition:function(t,e){return e.open<t.open&&e.close>e.open&&t.close<t.open},score:2},{name:"Morning Star",condition:function(t,e){return e.close>t.close&&e.open<t.open&&t.close<t.open},score:2},{name:"Piercing Line",condition:function(t,e){return e.close>t.close&&e.open<t.open&&e.close>(t.open+t.close)/2},score:1},{name:"Belt Hold",condition:function(t,e){return e.open>t.open&&a(e.close,e.high)&&a(t.close,t.low)},score:1},{name:"Harami",condition:function(t,e){return e.open>t.close&&e.close<t.open&&e.open<t.open&&e.close>t.close},score:1},{name:"Doji",condition:function(t,e){return a(e.close,e.open)&&e.high-e.low>Math.abs(e.close-e.open)},score:0}],bearish:[{name:"Marubozu",condition:function(t,e){return a(e.open,e.high)&&a(e.close,e.low)},score:-2},{name:"Engulfing",condition:function(t,e){return e.open>t.close&&e.close<t.open&&e.high>t.high&&e.low<t.low},score:-2},{name:"Kicker",condition:function(t,e){return e.open>t.open&&e.close<e.open&&t.close>t.open},score:-2},{name:"Evening Star",condition:function(t,e){return e.close<t.close&&e.open>t.open&&t.close<t.open},score:-2},{name:"Dark Cloud Cover",condition:function(t,e){return e.close<t.close&&e.open>t.open&&e.close<(t.open+t.close)/2},score:-1},{name:"Belt Hold",condition:function(t,e){return e.open<t.open&&a(e.close,e.low)&&a(t.close,t.high)},score:-1},{name:"Harami",condition:function(t,e){return e.open<t.close&&e.close>t.open&&e.open>t.open&&e.close<t.close},score:-1},{name:"Doji",condition:function(t,e){return a(e.close,e.open)&&e.high-e.low>Math.abs(e.close-e.open)},score:0}]},l=function(t,e,r){var n,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return zt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?zt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r);try{for(o.s();!(n=o.n()).done;){var i=n.value,a=i.name,c=i.condition,l=i.score;if(c(t,e))return{name:a,score:l}}}catch(t){o.e(t)}finally{o.f()}return null},u=["Neutral"],s=["No Pattern"],h=[0],f=1;f<i;f++){var p={open:e[f-1],high:r[f-1],low:n[f-1],close:o[f-1]},v={open:e[f],high:r[f],low:n[f],close:o[f]},y=l(p,v,c.bullish)||l(p,v,c.bearish);y?(u.push(y.score>0?"Bullish":"Bearish"),s.push(y.name),h.push(y.score)):(u.push("Neutral"),s.push("No Pattern"),h.push(0))}return{candle_pattern:u,candle_name:s,candle_score:h}};function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Jt(t){return function(t){if(Array.isArray(t))return Qt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Qt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qt(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Xt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Zt(n.key),n)}}function Zt(t){var e=function(t,e){if("object"!=Kt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kt(e)?e:e+""}var te=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=["open","high","low","close"];this.ohlcv={};for(var o=0,i=Object.keys(e);o<i.length;o++){var a=i[o];n.includes(a)&&(this.ohlcv[a]=e[a].slice(-r))}},(e=[{key:"init",value:function(){if(this.ohlcv.close.length<50)return console.log("PatternRecognizer requires at least 50 datapoints"),{chart_pattern:"Neutral",chart_score:0};for(var t=0,e=[{name:"Bullish Flag",condition:this.isBullishFlag.bind(this),score:2},{name:"Bearish Flag",condition:this.isBearishFlag.bind(this),score:-2},{name:"Bullish Pennant",condition:this.isBullishPennant.bind(this),score:2},{name:"Bearish Pennant",condition:this.isBearishPennant.bind(this),score:-2},{name:"Bearish Double Top",condition:this.isDoubleTop.bind(this),score:-1},{name:"Bullish Double Bottom",condition:this.isDoubleBottom.bind(this),score:1},{name:"Bearish Triple Top",condition:this.isTripleTop.bind(this),score:-1},{name:"Bullish Triple Bottom",condition:this.isTripleBottom.bind(this),score:1},{name:"Bearish Head And Shoulders",condition:this.isHeadAndShoulders.bind(this),score:-1},{name:"Bullish Inverse Head And Shoulders",condition:this.isInverseHeadAndShoulders.bind(this),score:1},{name:"Bearish Rising Wedge",condition:this.isRisingWedge.bind(this),score:-1},{name:"Bullish Falling Wedge",condition:this.isFallingWedge.bind(this),score:1},{name:"Bullish Triangle",condition:this.isBullishTriangle.bind(this),score:1},{name:"Bearish Triangle",condition:this.isBearishTriangle.bind(this),score:-1},{name:"Bullish Rectangle",condition:this.isBullishRectangle.bind(this),score:1},{name:"Bearish Rectangle",condition:this.isBearishRectangle.bind(this),score:-1}];t<e.length;t++){var r=e[t],n=r.name,o=r.condition,i=r.score;if(o())return{chart_pattern:n,chart_score:i}}return{chart_pattern:"Neutral",chart_score:0}}},{key:"isBullishFlag",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=(Math.floor(e/2),this.ohlcv.close[t-2*e]);if((this.ohlcv.close[t-e]-r)/r<.15)return!1;var n=this.ohlcv.close[t-e];if((n-this.ohlcv.close[t-1])/n>.05)return!1;for(var o=t-e;o<t-1;o++)if(this.ohlcv.high[o]>this.ohlcv.high[o+1]||this.ohlcv.low[o]>this.ohlcv.low[o+1])return!1;return!0}},{key:"isBearishFlag",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=(Math.floor(e/2),this.ohlcv.close[t-2*e]);if((r-this.ohlcv.close[t-e])/r<.15)return!1;var n=this.ohlcv.close[t-e];if((this.ohlcv.close[t-1]-n)/n>.05)return!1;for(var o=t-e;o<t-1;o++)if(this.ohlcv.high[o]<this.ohlcv.high[o+1]||this.ohlcv.low[o]<this.ohlcv.low[o+1])return!1;return!0}},{key:"isBullishPennant",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.floor(e/2),n=this.ohlcv.close[t-2*e];if((this.ohlcv.close[t-e]-n)/n<.15)return!1;var o=this.ohlcv.close[t-e];if((o-this.ohlcv.close[t-1])/o>.05)return!1;for(var i=t-r;i<t-1;i++)if(this.ohlcv.high[i]<this.ohlcv.high[i+1]&&this.ohlcv.low[i]<this.ohlcv.low[i+1]||this.ohlcv.high[i]>this.ohlcv.high[i+1]&&this.ohlcv.low[i]>this.ohlcv.low[i+1])return!1;return!0}},{key:"isBearishPennant",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.floor(e/2),n=this.ohlcv.close[t-2*e];if((n-this.ohlcv.close[t-e])/n<.15)return!1;var o=this.ohlcv.close[t-e];if((this.ohlcv.close[t-1]-o)/o>.05)return!1;for(var i=t-r;i<t-1;i++)if(this.ohlcv.high[i]>this.ohlcv.high[i+1]&&this.ohlcv.low[i]>this.ohlcv.low[i+1]||this.ohlcv.high[i]<this.ohlcv.high[i+1]&&this.ohlcv.low[i]<this.ohlcv.low[i+1])return!1;return!0}},{key:"isDoubleTop",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e)));if(r<=0||n<=0)return!1;var o=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),i=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e)));return!((r-o)/r<.1||(n-i)/n<.1)&&Math.abs(r-n)/r<.03}},{key:"isDoubleBottom",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e)));if(r<=0||n<=0)return!1;var o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),i=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e)));return!((o-r)/r<.1||(i-n)/n<.1)&&Math.abs(r-n)/r<.03}},{key:"isTripleTop",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=(r-Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))))/r,a=(n-Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))))/n,c=(o-Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e))))/o;return!(i<.1||a<.1||c<.1)&&Math.abs(r-n)/r<.03&&Math.abs(r-o)/r<.03}},{key:"isTripleBottom",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=(Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e)))-r)/r,a=(Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e)))-n)/n,c=(Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e)))-o)/o;return!(i<.1||a<.1||c<.1)&&Math.abs(r-n)/r<.03&&Math.abs(r-o)/r<.03}},{key:"isHeadAndShoulders",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e))),l=(n-a)/n,u=(Math.max(i,c)-Math.min(i,c))/Math.min(i,c);return l>.15&&u<.03}},{key:"isInverseHeadAndShoulders",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),a=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),c=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e))),l=(a-n)/n,u=(Math.min(i,c)-Math.max(i,c))/Math.max(i,c);return l>.15&&u<.03}},{key:"isRisingWedge",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e))),i=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e)));return r<n&&n<o&&i<a&&a<c}},{key:"isFallingWedge",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e))),i=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e)));return r>n&&n>o&&i>a&&a>c}},{key:"isBullishTriangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,Jt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.high.slice(e))),o=Math.min.apply(Math,Jt(this.ohlcv.low.slice(0,e))),i=Math.min.apply(Math,Jt(this.ohlcv.low.slice(e)));return r>n&&o<i}},{key:"isBearishTriangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,Jt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.high.slice(e)));return Math.min.apply(Math,Jt(this.ohlcv.low.slice(0,e)))<Math.min.apply(Math,Jt(this.ohlcv.low.slice(e)))&&r>n}},{key:"isBullishRectangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.high.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.high.slice(2*e))),i=Math.min.apply(Math,Jt(this.ohlcv.low.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.low.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.low.slice(2*e))),l=Math.abs(r-n)/r<.03&&Math.abs(n-o)/n<.03,u=Math.abs(i-a)/i<.03&&Math.abs(a-c)/a<.03;return l&&u}},{key:"isBearishRectangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.high.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.high.slice(2*e))),i=Math.min.apply(Math,Jt(this.ohlcv.low.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.low.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.low.slice(2*e))),l=Math.abs(r-n)/r<.03&&Math.abs(n-o)/n<.03,u=Math.abs(i-a)/i<.03&&Math.abs(a-c)/a<.03;return l&&u}}])&&Xt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),ee=["open","high","low","close","volume"];function re(t){return re="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},re(t)}function ne(t){return function(t){if(Array.isArray(t))return ce(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ae(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function oe(){oe=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:_(t,r,c)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var f="suspendedStart",p="suspendedYield",v="executing",y="completed",m={};function b(){}function d(){}function g(){}var w={};u(w,a,(function(){return this}));var M=Object.getPrototypeOf,S=M&&M(M(A([])));S&&S!==r&&n.call(S,a)&&(w=S);var j=g.prototype=b.prototype=Object.create(w);function O(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(o,i,a,c){var l=h(t[o],t,i);if("throw"!==l.type){var u=l.arg,s=u.value;return s&&"object"==re(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(l.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function _(e,r,n){var o=f;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var l=E(c,n);if(l){if(l===m)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=h(e,r,n);if("normal"===u.type){if(o=n.done?y:p,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function E(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function A(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(re(e)+" is not iterable")}return d.prototype=g,o(j,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:d,configurable:!0}),d.displayName=u(g,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,u(t,l,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},O(P.prototype),u(P.prototype,c,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new P(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),u(j,l,"Generator"),u(j,a,(function(){return this})),u(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=A,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var l=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:A(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function ie(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],l=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);l=!0);}catch(t){u=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||ae(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ae(t,e){if(t){if("string"==typeof t)return ce(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ce(t,e):void 0}}function ce(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function le(t,e,r,n,o,i,a){try{var c=t[i](a),l=c.value}catch(t){return void r(t)}c.done?e(l):Promise.resolve(l).then(n,o)}function ue(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){le(i,n,o,a,c,"next",t)}function c(t){le(i,n,o,a,c,"throw",t)}a(void 0)}))}}function se(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,he(n.key),n)}}function he(t){var e=function(t,e){if("object"!=re(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=re(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==re(e)?e:e+""}var fe=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.ChartPatterns=function(t){return new te(t).init()}},e=[{key:"init",value:function(t){return this.promises=[],this.crossPairsArr=[],this.ohlcv=t.reduce((function(t,e){var r=e.open,n=e.high,o=e.low,i=e.close,a=e.volume,c=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.includes(r)||{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(e,ee);t.open.push(new p(r)),t.high.push(new p(n)),t.low.push(new p(o)),t.close.push(new p(i)),t.volume.push(new p(a));for(var l=0,u=Object.keys(c);l<u.length;l++){var s=u[l];t[s]||(t[s]=[]),t[s].push(c[s])}return t}),{open:[],high:[],low:[],close:[],volume:[]}),this}},{key:"computePromises",value:(o=ue(oe().mark((function t(){var e,r=this;return oe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=function(){var t=ue(oe().mark((function t(e,n){return oe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Promise.all(e[n]).then((function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)for(var n=0,o=Object.entries(t[e]);n<o.length;n++){var i=ie(o[n],2),a=i[0],c=i[1];r.addColumn("".concat(a).toLowerCase(),c)}return!0})));case 1:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),t.next=3,e(this,"promises");case 3:return t.next=5,Ct(this,this.crossPairsArr);case 5:return t.abrupt("return",this.ohlcv);case 6:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"getData",value:(n=ue(oe().mark((function t(){var e,r,n;return oe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.computePromises();case 2:return e=this.ohlcv,r=Object.keys(e),n=r.length,t.abrupt("return",e.open.map((function(t,o){for(var i={},a=0;a<n;a++){var c=r[a],l=e[c][o];i[c]=l instanceof p?l.toNumber():l}return i})));case 6:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"getLastValues",value:(r=ue(oe().mark((function t(){var e,r,n,o,i,a,c;return oe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.computePromises();case 2:for(e={},r=0,n=Object.entries(this.ohlcv);r<n.length;r++)o=ie(n[r],2),i=o[0],a=o[1],c=a[a.length-1],e[i]=c instanceof p?c.toNumber():c;return t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"addColumn",value:function(t,e){var r=this.ohlcv.open.length;if(e.length>r)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");var n=new Array(r-e.length).fill(null);e=[].concat(ne(n),ne(e)),this.ohlcv[t]=e}},{key:"crossPairs",value:function(t){return this.crossPairsArr=t,this}},{key:"ema",value:function(t){return this.promises.push(Promise.resolve(function(t,e){var r=t.ohlcv.close,n=_t(r,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Pt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"ema_".concat(e),n)}(this,t))),this}},{key:"sma",value:function(t){return this.promises.push(Promise.resolve(function(t,e){var r=t.ohlcv.close,n=xt(r,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Et(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"sma_".concat(e),n)}(this,t))),this}},{key:"macd",value:function(t,e,r){return this.promises.push(Promise.resolve(function(t,e,r,n){var o=t.ohlcv.close,i=Math.max(e,r,n);return function(t){for(var e=[],r=[],n=[],o=new yt({indicator:st,shortInterval:arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,longInterval:arguments.length>2&&void 0!==arguments[2]?arguments[2]:26,signalInterval:arguments.length>3&&void 0!==arguments[3]?arguments[3]:9}),i=t.length,a=0;a<i;a++){var c={};o.update(t[a]);try{c=o.getResult()}catch(t){c={macd:null,signal:null,histogram:null}}e.push(c.macd),r.push(c.signal),n.push(c.histogram)}return{macd_diff:e,macd_dea:r,macd_histogram:n,macd_diff_x_macd_dea:It(e,r)}}(o.slice(-3*i),e,r,n)}(this,t,e,r))),this}},{key:"bollingerBands",value:function(t,e,r){return this.promises.push(Promise.resolve(function(t,e,r){return function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=t.length,o={bollinger_bands_upper:[],bollinger_bands_middle:[],bollinger_bands_lower:[]},i=new et(e,r),a=0;a<n;a++){var c={};i.update(t[a]);try{c=i.getResult()}catch(t){c={upper:null,middle:null,lower:null}}o.bollinger_bands_upper.push(c.upper),o.bollinger_bands_middle.push(c.middle),o.bollinger_bands_lower.push(c.lower)}var l=o.bollinger_bands_upper,u=o.bollinger_bands_middle,s=o.bollinger_bands_lower;return{bollinger_bands_upper:l,bollinger_bands_middle:u,bollinger_bands_lower:s,bollinger_bands_range:Ft(t,{bollinger_bands_upper:l,bollinger_bands_lower:s})}}(t.ohlcv.close.slice(-3*e),e,r)}(this,t,e))),this}},{key:"rsi",value:function(t,e,r){return this.promises.push(Promise.resolve(function(t,e,r,n){var o=t.ohlcv.close.slice(-3*e);return"number"==typeof e&&void 0===n&&(n=e),Gt(o,e,r,n)}(this,t,e,r))),this}},{key:"candles",value:function(){var t;return this.promises.push(Promise.resolve((t=this.ohlcv,Yt(t)))),this}},{key:"volumeProfile",value:function(t,e,r){return this.promises.push(Promise.resolve(function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3?arguments[3]:void 0,o=t.ohlcv,i=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,r=t.open,n=t.high,o=t.low,i=t.close,a=t.volume,c=Math.min.apply(Math,qt(o)),l=(Math.max.apply(Math,qt(n))-c)/e,u={upVolume:0,downVolume:0,grossVolume:0},s=Array.from({length:e},(function(t,e){return{price:c+l*e,upVolume:0,downVolume:0,grossVolume:0}})),h=1/l,f=0;f<i.length;f++)for(var p=i[f],v=r[f],y=n[f],m=o[f],b=a[f],d=p>=v?b:0,g=p<v?b:0,w=Math.max(0,Math.floor((m-c)*h)),M=Math.min(e,Math.ceil((y-c)*h)),S=w;S<M;S++)s[S].upVolume+=d,s[S].downVolume+=g,s[S].grossVolume+=d+g;for(var j=0,O=s;j<O.length;j++){var P=O[j],_=P.upVolume,E=P.downVolume,x=P.grossVolume;u.upVolume+=_,u.downVolume+=E,u.grossVolume+=x}return{bins:s,nodes:Wt(s)}}($t(o,r,n),e);return{volume_profile_high:[i.nodes.high.price],volume_profile_low:[i.nodes.low.price]}}(this,t,e,r))),this}}],e&&se(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}()})(),OHLCV_INDICATORS=e})();
|
|
2
|
+
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{t.r(e),t.d(e,{default:()=>fe});var r=1e6,n="[big.js] ",o=n+"Invalid ",i=o+"decimal places",a=o+"rounding mode",c=n+"Division by zero",l={},u=void 0,s=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function h(t,e,r,n){var o=t.c;if(r===u&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(a);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==u))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==u||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function f(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}l.abs=function(){var t=new this.constructor(this);return t.s=1,t},l.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,a=t.s,c=r.e,l=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-a:0;if(i!=a)return i;if(e=i<0,c!=l)return c>l^e?1:-1;for(a=(c=n.length)<(l=o.length)?c:l,i=-1;++i<a;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return c==l?0:c>l^e?1:-1},l.div=function(t){var e=this,n=e.constructor,o=e.c,a=(t=new n(t)).c,l=e.s==t.s?1:-1,s=n.DP;if(s!==~~s||s<0||s>r)throw Error(i);if(!a[0])throw Error(c);if(!o[0])return t.s=l,t.c=[t.e=0],t;var f,p,v,y,m,b=a.slice(),d=f=a.length,g=o.length,w=o.slice(0,f),M=w.length,S=t,j=S.c=[],O=0,P=s+(S.e=e.e-t.e)+1;for(S.s=l,l=P<0?0:P,b.unshift(0);M++<f;)w.push(0);do{for(v=0;v<10;v++){if(f!=(M=w.length))y=f>M?1:-1;else for(m=-1,y=0;++m<f;)if(a[m]!=w[m]){y=a[m]>w[m]?1:-1;break}if(!(y<0))break;for(p=M==f?a:b;M;){if(w[--M]<p[M]){for(m=M;m&&!w[--m];)w[m]=9;--w[m],w[M]+=10}w[M]-=p[M]}for(;!w[0];)w.shift()}j[O++]=y?v:++v,w[0]&&y?w[M]=o[d]||0:w=[o[d]]}while((d++<g||w[0]!==u)&&l--);return j[0]||1==O||(j.shift(),S.e--,P--),O>P&&h(S,P,n.RM,w[0]!==u),S},l.eq=function(t){return 0===this.cmp(t)},l.gt=function(t){return this.cmp(t)>0},l.gte=function(t){return this.cmp(t)>-1},l.lt=function(t){return this.cmp(t)<0},l.lte=function(t){return this.cmp(t)<1},l.minus=l.sub=function(t){var e,r,n,o,i=this,a=i.constructor,c=i.s,l=(t=new a(t)).s;if(c!=l)return t.s=-l,i.plus(t);var u=i.c.slice(),s=i.e,h=t.c,f=t.e;if(!u[0]||!h[0])return h[0]?t.s=-l:u[0]?t=new a(i):t.s=1,t;if(c=s-f){for((o=c<0)?(c=-c,n=u):(f=s,n=h),n.reverse(),l=c;l--;)n.push(0);n.reverse()}else for(r=((o=u.length<h.length)?u:h).length,c=l=0;l<r;l++)if(u[l]!=h[l]){o=u[l]<h[l];break}if(o&&(n=u,u=h,h=n,t.s=-t.s),(l=(r=h.length)-(e=u.length))>0)for(;l--;)u[e++]=0;for(l=e;r>c;){if(u[--r]<h[r]){for(e=r;e&&!u[--e];)u[e]=9;--u[e],u[r]+=10}u[r]-=h[r]}for(;0===u[--l];)u.pop();for(;0===u[0];)u.shift(),--f;return u[0]||(t.s=1,u=[f=0]),t.c=u,t.e=f,t},l.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(c);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},l.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},l.plus=l.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var a=o.e,c=o.c,l=t.e,u=t.c;if(!c[0]||!u[0])return u[0]||(c[0]?t=new i(o):t.s=o.s),t;if(c=c.slice(),e=a-l){for(e>0?(l=a,n=u):(e=-e,n=c),n.reverse();e--;)n.push(0);n.reverse()}for(c.length-u.length<0&&(n=u,u=c,c=n),e=u.length,r=0;e;c[e]%=10)r=(c[--e]=c[e]+u[e]+r)/10|0;for(r&&(c.unshift(r),++l),e=c.length;0===c[--e];)c.pop();return t.c=c,t.e=l,t},l.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(o+"exponent");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},l.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(o+"precision");return h(new this.constructor(this),t,e)},l.round=function(t,e){if(t===u)t=0;else if(t!==~~t||t<-r||t>r)throw Error(i);return h(new this.constructor(this),t+this.e+1,e)},l.sqrt=function(){var t,e,r,o=this,i=o.constructor,a=o.s,c=o.e,l=new i("0.5");if(!o.c[0])return new i(o);if(a<0)throw Error(n+"No square root");0===(a=Math.sqrt(o+""))||a===1/0?((e=o.c.join("")).length+c&1||(e+="0"),c=((c+1)/2|0)-(c<0||1&c),t=new i(((a=Math.sqrt(e))==1/0?"5e":(a=a.toExponential()).slice(0,a.indexOf("e")+1))+c)):t=new i(a+""),c=t.e+(i.DP+=4);do{r=t,t=l.times(r.plus(o.div(r)))}while(r.c.slice(0,c).join("")!==t.c.slice(0,c).join(""));return h(t,(i.DP-=4)+t.e+1,i.RM)},l.times=l.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,a=o.length,c=i.length,l=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=l+u,a<c&&(e=o,o=i,i=e,u=a,a=c,c=u),e=new Array(u=a+c);u--;)e[u]=0;for(l=c;l--;){for(c=0,u=a+l;u>l;)c=e[u]+i[l]*o[u-l-1]+c,e[u--]=c%10,c=c/10|0;e[u]=c}for(c?++t.e:e.shift(),l=e.length;!e[--l];)e.pop();return t.c=e,t},l.toExponential=function(t,e){var n=this,o=n.c[0];if(t!==u){if(t!==~~t||t<0||t>r)throw Error(i);for(n=h(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return f(n,!0,!!o)},l.toFixed=function(t,e){var n=this,o=n.c[0];if(t!==u){if(t!==~~t||t<0||t>r)throw Error(i);for(t=t+(n=h(new n.constructor(n),t+n.e+1,e)).e+1;n.c.length<t;)n.c.push(0)}return f(n,!1,!!o)},l[Symbol.for("nodejs.util.inspect.custom")]=l.toJSON=l.toString=function(){var t=this,e=t.constructor;return f(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},l.toNumber=function(){var t=Number(f(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},l.toPrecision=function(t,e){var n=this,i=n.constructor,a=n.c[0];if(t!==u){if(t!==~~t||t<1||t>r)throw Error(o+"precision");for(n=h(new i(n),t,e);n.c.length<t;)n.c.push(0)}return f(n,t<=n.e||n.e<=i.NE||n.e>=i.PE,!!a)},l.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return f(t,t.e<=e.NE||t.e>=e.PE,!0)};const p=function t(){function e(r){var n=this;if(!(n instanceof e))return r===u?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(o+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,i;if(!s.test(e))throw Error(o+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&"0"==e.charAt(n);)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&"0"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=l,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();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 y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(m())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&b(o,r.prototype),o}(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(r,t)},y(t)}function m(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(m=function(){return!!t})()}function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}var g=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,m()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&b(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(y(Error));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 M(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,j(n.key),n)}}function S(t,e,r){return(e=j(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function j(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.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(e)?e:e+""}var O=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),S(this,"previousHighest",void 0),S(this,"highest",void 0),S(this,"previousLowest",void 0),S(this,"lowest",void 0),S(this,"previousResult",void 0),S(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t.gt(this.highest)?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t.lt(this.lowest)?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&M(t.prototype,e),r&&M(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function _(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,A(n.key),n)}}function E(t,e,r){return e=k(e),function(t,e){if(e&&("object"==P(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,x()?Reflect.construct(e,r||[],k(t).constructor):e.apply(t,r))}function x(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(x=function(){return!!t})()}function k(t){return k=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},k(t)}function T(t,e){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},T(t,e)}function A(t){var e=function(t,e){if("object"!=P(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}var L=function(t){function e(t){var r,n,o,i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=E(this,e),i=void 0,(o=A(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&T(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&_(r.prototype,n),o&&_(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(O);function R(t){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(t)}function B(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,D(n.key),n)}}function I(t,e,r){return e=C(e),function(t,e){if(e&&("object"==R(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,N()?Reflect.construct(e,r||[],C(t).constructor):e.apply(t,r))}function N(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(N=function(){return!!t})()}function C(t){return C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},C(t)}function F(t,e){return F=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},F(t,e)}function D(t){var e=function(t,e){if("object"!=R(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=R(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==R(e)?e:e+""}var V=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,a=new Array(i),c=0;c<i;c++)a[c]=arguments[c];return r=t=I(this,e,[].concat(a)),o=[],(n=D(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&F(t,e)}(e,t),r=e,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)return this.setResult(e.getResultFromBatch(this.prices),r)}}],o=[{key:"getResultFromBatch",value:function(t){return t.reduce((function(t,e){return t.plus(e)}),new p("0")).div(t.length||1)}}],n&&B(r.prototype,n),o&&B(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(L);function G(t){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(t)}function H(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Y(n.key),n)}}function q(t,e,r){return e=W(e),function(t,e){if(e&&("object"==G(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,U()?Reflect.construct(e,r||[],W(t).constructor):e.apply(t,r))}function U(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(U=function(){return!!t})()}function W(t){return W=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},W(t)}function $(t,e){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$(t,e)}function z(t,e,r){return(e=Y(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Y(t){var e=function(t,e){if("object"!=G(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=G(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==G(e)?e:e+""}var K=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),z(r=q(this,e,[t]),"interval",void 0),z(r,"indicator",void 0),z(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new V(t),r.smoothingFactor=new p(1).div(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t,e);if(e&&this.previousResult){var n=new p(t).minus(this.previousResult).mul(this.smoothingFactor);return this.setResult(n.plus(this.previousResult),e)}if(!e&&this.result){var o=new p(t).minus(this.result).mul(this.smoothingFactor);return this.setResult(o.plus(this.result),e)}if(void 0===this.result&&r)return this.setResult(r,e)}}],n&&H(r.prototype,n),o&&H(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(L);function J(t){return t.reduce((function(t,e){return t.add(e)}),new p(0)).div(t.length||1)}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 X(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,tt(n.key),n)}}function Z(t,e,r){return(e=tt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function tt(t){var e=function(t,e){if("object"!=Q(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.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(e)?e:e+""}var et=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),Z(this,"interval",void 0),Z(this,"deviationMultiplier",void 0),Z(this,"prices",[]),Z(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){if(this.prices.push(new p(t)),this.prices.length>this.interval){this.prices.shift();var e=V.getResultFromBatch(this.prices),r=function(t,e){var r=e||J(t);return J(t.map((function(t){return new p(t).sub(r).pow(2)}))).sqrt()}(this.prices,e);return this.result={lower:e.sub(r.times(this.deviationMultiplier)),middle:e,upper:e.add(r.times(this.deviationMultiplier))}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}}])&&X(t.prototype,e),r&&X(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();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 nt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ut(n.key),n)}}function ot(t,e,r){return e=at(e),function(t,e){if(e&&("object"==rt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,it()?Reflect.construct(e,r||[],at(t).constructor):e.apply(t,r))}function it(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(it=function(){return!!t})()}function at(t){return at=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},at(t)}function ct(t,e){return ct=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ct(t,e)}function lt(t,e,r){return(e=ut(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ut(t){var e=function(t,e){if("object"!=rt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.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(e)?e:e+""}var st=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),lt(r=ot(this,e,[t]),"interval",void 0),lt(r,"pricesCounter",0),lt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ct(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r?r&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++;var n=new p(t);return r&&this.previousResult?this.setResult(n.times(this.weightFactor).add(this.previousResult.times(1-this.weightFactor)),r):this.setResult(n.times(this.weightFactor).add((null!==(e=this.result)&&void 0!==e?e:n).times(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&&nt(r.prototype,n),o&&nt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(L);function ht(t){return ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ht(t)}function ft(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vt(n.key),n)}}function pt(t,e,r){return(e=vt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vt(t){var e=function(t,e){if("object"!=ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ht(e)?e:e+""}var yt=function(){return t=function t(e){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),pt(this,"prices",[]),pt(this,"long",void 0),pt(this,"short",void 0),pt(this,"signal",void 0),pt(this,"result",void 0),this.long=new e.indicator(e.longInterval),this.short=new e.indicator(e.shortInterval),this.signal=new e.indicator(e.signalInterval)},e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new p(t);this.prices.length&&e?this.prices[this.prices.length-1]=r:this.prices.push(r);var n=this.short.update(r,e),o=this.long.update(r,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var i=n.sub(o),a=this.signal.update(i);return this.result={histogram:i.sub(a),macd:i,signal:a}}}},{key:"getResult",value:function(){if(!this.isStable||void 0===this.result)throw new g;return this.result}}],e&&ft(t.prototype,e),r&&ft(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function mt(t){return mt="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},mt(t)}function bt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jt(n.key),n)}}function dt(t,e,r){return e=wt(e),function(t,e){if(e&&("object"==mt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,gt()?Reflect.construct(e,r||[],wt(t).constructor):e.apply(t,r))}function gt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(gt=function(){return!!t})()}function wt(t){return wt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},wt(t)}function Mt(t,e){return Mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mt(t,e)}function St(t,e,r){return(e=jt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jt(t){var e=function(t,e){if("object"!=mt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=mt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mt(e)?e:e+""}var Ot=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),St(r=dt(this,e),"interval",void 0),St(r,"previousPrices",[]),St(r,"avgGain",void 0),St(r,"avgLoss",void 0),St(r,"maxValue",new p(100)),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Mt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=new p(t),n=new p(this.previousPrices[this.previousPrices.length-2]);if(r.gt(n)?(this.avgLoss.update(new p(0),e),this.avgGain.update(r.sub(n),e)):(this.avgLoss.update(n.sub(r),e),this.avgGain.update(new p(0),e)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(o.eq(0))return this.setResult(new p(100),e);var i=this.avgGain.getResult().div(o);return this.setResult(this.maxValue.minus(this.maxValue.div(i.add(1))),e)}}}}],n&&bt(r.prototype,n),o&&bt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(O);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,e){for(var r=[],n=new st(e),o=t.length,i=0;i<o;i++){var a=null;n.update(t[i]);try{a=n.getResult()}catch(t){a=null}r.push(a)}return r};function Et(t){return Et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Et(t)}var xt=function(t,e){for(var r=[],n=new V(e),o=t.length,i=0;i<o;i++){var a=null;n.update(t[i]);try{a=n.getResult()}catch(t){a=null}r.push(a)}return r};function kt(t){return kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kt(t)}function Tt(){Tt=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:_(t,r,c)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var f="suspendedStart",p="suspendedYield",v="executing",y="completed",m={};function b(){}function d(){}function g(){}var w={};u(w,a,(function(){return this}));var M=Object.getPrototypeOf,S=M&&M(M(A([])));S&&S!==r&&n.call(S,a)&&(w=S);var j=g.prototype=b.prototype=Object.create(w);function O(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(o,i,a,c){var l=h(t[o],t,i);if("throw"!==l.type){var u=l.arg,s=u.value;return s&&"object"==kt(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(l.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function _(e,r,n){var o=f;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var l=E(c,n);if(l){if(l===m)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=h(e,r,n);if("normal"===u.type){if(o=n.done?y:p,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function E(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function A(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(kt(e)+" is not iterable")}return d.prototype=g,o(j,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:d,configurable:!0}),d.displayName=u(g,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,u(t,l,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},O(P.prototype),u(P.prototype,c,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new P(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),u(j,l,"Generator"),u(j,a,(function(){return this})),u(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=A,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var l=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:A(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function At(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=kt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Bt(t,e,r,n,o,i,a){try{var c=t[i](a),l=c.value}catch(t){return void r(t)}c.done?e(l):Promise.resolve(l).then(n,o)}var It=function(t,e){t=t.filter((function(t){return t instanceof p})),e=e.filter((function(t){return t instanceof p}));var r=Math.min(t.length,e.length);t=t.slice(-r),e=e.slice(-r);var n=t.map((function(t,r){if(t.eq(e[r]))return"neutral";if(t.gt(e[r]))return"up";if(t.lt(e[r]))return"down";throw Error("undefined error in findCrosses")})),o=Nt(n),i=o.map((function(t){return t.length}));return o.map((function(t,e){var r=i[e];return t.map((function(t,e){var n=r-e;return"neutral"===t&&(n=0),"up"===t&&(n*=1),"down"===t&&(n*=-1),n})).reverse()})).flat()},Nt=function(t){return 0===t.length?[]:t.reduce((function(t,e,r,n){if(0===r)t.push([e]);else{var o=n[r-1],i=t[t.length-1];e!==o?t.push([e]):i.push(e)}return t}),[])},Ct=function(){var t,e=(t=Tt().mark((function t(e,r){var n,o,i,a,c,l,u,s,h,f,v,y,m,b;return Tt().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.ohlcv,o={},i=[],a=Lt(r),t.prev=4,a.s();case 6:if((c=a.n()).done){t.next=14;break}if(l=c.value,u=l.fast,s=l.slow,u&&s){t.next=10;break}return t.abrupt("continue",12);case 10:"number"!=typeof s||o[s]||(o[s]=Array(n.close.length).fill(new p(s))),n[u]&&n[s]?(h=It(n[u],n[s]),i.push(Promise.resolve(At({},"".concat(u,"_x_").concat(s),h)))):n[u]&&o[s]?(f=It(n[u],o[s]),i.push(Promise.resolve(At({},"".concat(u,"_x_").concat(s),f)))):console.log("Missing ohlcv properties for ".concat(u," or ").concat(s));case 12:t.next=6;break;case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(4),a.e(t.t0);case 19:return t.prev=19,a.f(),t.finish(19);case 22:return t.next=24,Promise.all(i);case 24:for(v=t.sent,y=0;y<v.length;y++)m=v[y],b=Object.keys(m)[0],e.addColumn(b,m[b]);return t.abrupt("return",!0);case 27:case"end":return t.stop()}}),t,null,[[4,16,19,22]])})),function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Bt(i,n,o,a,c,"next",t)}function c(t){Bt(i,n,o,a,c,"throw",t)}a(void 0)}))});return function(t,r){return e.apply(this,arguments)}}(),Ft=function(t,e){for(var r=e.bollinger_bands_upper,n=e.bollinger_bands_lower,o=new Array(t.length),i=0;i<t.length;i++)if(null!=r[i]&&null!=n[i]&&null!=t[i]){var a=new p(r[i]),c=new p(n[i]),l=new p(t[i]),u=a.minus(c);o[i]=l.minus(c).div(u).times(100)}else o[i]=null;return o};function Dt(t){return Dt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dt(t)}var Vt={getSMA:xt,getEMA:_t},Gt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"SMA",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:14;if(t.length<e)return[];var o=[];e=parseInt(e),n=parseInt(n);for(var i=new Ot(e),a=t.length,c=0;c<a;c++){var l=null;i.update(t[c]);try{l=i.getResult()}catch(t){l=null}o.push(l)}o=o.filter((function(t){return t}));var u,s,h,f=(u={},s="rsi_".concat(e),h=o,(s=function(t){var e=function(t,e){if("object"!=Dt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Dt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dt(e)?e:e+""}(s))in u?Object.defineProperty(u,s,{value:h,enumerable:!0,configurable:!0,writable:!0}):u[s]=h,u);if("string"==typeof r&&"number"==typeof n&&Vt.hasOwnProperty("get".concat(r))){var p=Vt["get".concat(r)](o,n);f["rsi_".concat(r,"_").concat(n)]=p,f["rsi_".concat(e,"_x_rsi_").concat(r,"_").concat(n)]=It(o,p)}return f};function Ht(t){return Ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ht(t)}function qt(t){return function(t){if(Array.isArray(t))return Ut(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ut(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ut(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Wt=function(t){if(!t||0===t.length)throw new Error("Bins array is empty or not provided");var e=t[0],r=t[0];return t.forEach((function(t){t.grossVolume>e.grossVolume&&(e=t),t.grossVolume<r.grossVolume&&(r=t)})),{high:e,low:r}},$t=function(t,e,r){var n,o,i,a=new Date(t[r][t[r].length-1]),c=new Date(a);c.setDate(c.getDate()-e),c.setHours(0,0,0,0);for(var l=(n={open:[],high:[],low:[],close:[],volume:[]},i=[],(o=function(t){var e=function(t,e){if("object"!=Ht(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ht(e)?e:e+""}(o=r))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,n),u=0;u<t[r].length;u++)new Date(t[r][u])>=c&&(l.open.push(t.open[u]),l.high.push(t.high[u]),l.low.push(t.low[u]),l.close.push(t.close[u]),l.volume.push(t.volume[u]),l[r].push(t[r][u]));return l};function zt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Yt=function(t){var e=t.open,r=t.high,n=t.low,o=t.close,i=e.length;if(![e,r,n,o].every((function(t){return Array.isArray(t)&&t.length>1&&t.length===i})))return{pattern:Array(i).fill("Neutral"),name:Array(i).fill("No Pattern"),score:Array(i).fill(0)};for(var a=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-4;return Math.abs(t-e)<r},c={bullish:[{name:"Marubozu",condition:function(t,e){return a(e.open,e.low)&&a(e.close,e.high)},score:2},{name:"Engulfing",condition:function(t,e){return e.open<t.close&&e.close>t.open&&e.low<t.low&&e.high>t.high},score:2},{name:"Kicker",condition:function(t,e){return e.open<t.open&&e.close>e.open&&t.close<t.open},score:2},{name:"Morning Star",condition:function(t,e){return e.close>t.close&&e.open<t.open&&t.close<t.open},score:2},{name:"Piercing Line",condition:function(t,e){return e.close>t.close&&e.open<t.open&&e.close>(t.open+t.close)/2},score:1},{name:"Belt Hold",condition:function(t,e){return e.open>t.open&&a(e.close,e.high)&&a(t.close,t.low)},score:1},{name:"Harami",condition:function(t,e){return e.open>t.close&&e.close<t.open&&e.open<t.open&&e.close>t.close},score:1},{name:"Doji",condition:function(t,e){return a(e.close,e.open)&&e.high-e.low>Math.abs(e.close-e.open)},score:0}],bearish:[{name:"Marubozu",condition:function(t,e){return a(e.open,e.high)&&a(e.close,e.low)},score:-2},{name:"Engulfing",condition:function(t,e){return e.open>t.close&&e.close<t.open&&e.high>t.high&&e.low<t.low},score:-2},{name:"Kicker",condition:function(t,e){return e.open>t.open&&e.close<e.open&&t.close>t.open},score:-2},{name:"Evening Star",condition:function(t,e){return e.close<t.close&&e.open>t.open&&t.close<t.open},score:-2},{name:"Dark Cloud Cover",condition:function(t,e){return e.close<t.close&&e.open>t.open&&e.close<(t.open+t.close)/2},score:-1},{name:"Belt Hold",condition:function(t,e){return e.open<t.open&&a(e.close,e.low)&&a(t.close,t.high)},score:-1},{name:"Harami",condition:function(t,e){return e.open<t.close&&e.close>t.open&&e.open>t.open&&e.close<t.close},score:-1},{name:"Doji",condition:function(t,e){return a(e.close,e.open)&&e.high-e.low>Math.abs(e.close-e.open)},score:0}]},l=function(t,e,r){var n,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return zt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?zt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}(r);try{for(o.s();!(n=o.n()).done;){var i=n.value,a=i.name,c=i.condition,l=i.score;if(c(t,e))return{name:a,score:l}}}catch(t){o.e(t)}finally{o.f()}return null},u=["Neutral"],s=["No Pattern"],h=[0],f=1;f<i;f++){var p={open:e[f-1],high:r[f-1],low:n[f-1],close:o[f-1]},v={open:e[f],high:r[f],low:n[f],close:o[f]},y=l(p,v,c.bullish)||l(p,v,c.bearish);y?(u.push(y.score>0?"Bullish":"Bearish"),s.push(y.name),h.push(y.score)):(u.push("Neutral"),s.push("No Pattern"),h.push(0))}return{candle_pattern:u,candle_name:s,candle_score:h}};function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Jt(t){return function(t){if(Array.isArray(t))return Qt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Qt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qt(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Xt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Zt(n.key),n)}}function Zt(t){var e=function(t,e){if("object"!=Kt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Kt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Kt(e)?e:e+""}var te=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=["open","high","low","close"];this.ohlcv={};for(var o=0,i=Object.keys(e);o<i.length;o++){var a=i[o];n.includes(a)&&(this.ohlcv[a]=e[a].slice(-r))}},(e=[{key:"init",value:function(){if(this.ohlcv.close.length<50)return console.log("PatternRecognizer requires at least 50 datapoints"),{chart_pattern:"Neutral",chart_score:0};for(var t=0,e=[{name:"Bullish Flag",condition:this.isBullishFlag.bind(this),score:2},{name:"Bearish Flag",condition:this.isBearishFlag.bind(this),score:-2},{name:"Bullish Pennant",condition:this.isBullishPennant.bind(this),score:2},{name:"Bearish Pennant",condition:this.isBearishPennant.bind(this),score:-2},{name:"Bearish Double Top",condition:this.isDoubleTop.bind(this),score:-1},{name:"Bullish Double Bottom",condition:this.isDoubleBottom.bind(this),score:1},{name:"Bearish Triple Top",condition:this.isTripleTop.bind(this),score:-1},{name:"Bullish Triple Bottom",condition:this.isTripleBottom.bind(this),score:1},{name:"Bearish Head And Shoulders",condition:this.isHeadAndShoulders.bind(this),score:-1},{name:"Bullish Inverse Head And Shoulders",condition:this.isInverseHeadAndShoulders.bind(this),score:1},{name:"Bearish Rising Wedge",condition:this.isRisingWedge.bind(this),score:-1},{name:"Bullish Falling Wedge",condition:this.isFallingWedge.bind(this),score:1},{name:"Bullish Triangle",condition:this.isBullishTriangle.bind(this),score:1},{name:"Bearish Triangle",condition:this.isBearishTriangle.bind(this),score:-1},{name:"Bullish Rectangle",condition:this.isBullishRectangle.bind(this),score:1},{name:"Bearish Rectangle",condition:this.isBearishRectangle.bind(this),score:-1}];t<e.length;t++){var r=e[t],n=r.name,o=r.condition,i=r.score;if(o())return{chart_pattern:n,chart_score:i}}return{chart_pattern:"Neutral",chart_score:0}}},{key:"isBullishFlag",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=(Math.floor(e/2),this.ohlcv.close[t-2*e]);if((this.ohlcv.close[t-e]-r)/r<.15)return!1;var n=this.ohlcv.close[t-e];if((n-this.ohlcv.close[t-1])/n>.05)return!1;for(var o=t-e;o<t-1;o++)if(this.ohlcv.high[o]>this.ohlcv.high[o+1]||this.ohlcv.low[o]>this.ohlcv.low[o+1])return!1;return!0}},{key:"isBearishFlag",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=(Math.floor(e/2),this.ohlcv.close[t-2*e]);if((r-this.ohlcv.close[t-e])/r<.15)return!1;var n=this.ohlcv.close[t-e];if((this.ohlcv.close[t-1]-n)/n>.05)return!1;for(var o=t-e;o<t-1;o++)if(this.ohlcv.high[o]<this.ohlcv.high[o+1]||this.ohlcv.low[o]<this.ohlcv.low[o+1])return!1;return!0}},{key:"isBullishPennant",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.floor(e/2),n=this.ohlcv.close[t-2*e];if((this.ohlcv.close[t-e]-n)/n<.15)return!1;var o=this.ohlcv.close[t-e];if((o-this.ohlcv.close[t-1])/o>.05)return!1;for(var i=t-r;i<t-1;i++)if(this.ohlcv.high[i]<this.ohlcv.high[i+1]&&this.ohlcv.low[i]<this.ohlcv.low[i+1]||this.ohlcv.high[i]>this.ohlcv.high[i+1]&&this.ohlcv.low[i]>this.ohlcv.low[i+1])return!1;return!0}},{key:"isBearishPennant",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.floor(e/2),n=this.ohlcv.close[t-2*e];if((n-this.ohlcv.close[t-e])/n<.15)return!1;var o=this.ohlcv.close[t-e];if((this.ohlcv.close[t-1]-o)/o>.05)return!1;for(var i=t-r;i<t-1;i++)if(this.ohlcv.high[i]>this.ohlcv.high[i+1]&&this.ohlcv.low[i]>this.ohlcv.low[i+1]||this.ohlcv.high[i]<this.ohlcv.high[i+1]&&this.ohlcv.low[i]<this.ohlcv.low[i+1])return!1;return!0}},{key:"isDoubleTop",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e)));if(r<=0||n<=0)return!1;var o=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),i=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e)));return!((r-o)/r<.1||(n-i)/n<.1)&&Math.abs(r-n)/r<.03}},{key:"isDoubleBottom",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e)));if(r<=0||n<=0)return!1;var o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),i=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e)));return!((o-r)/r<.1||(i-n)/n<.1)&&Math.abs(r-n)/r<.03}},{key:"isTripleTop",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=(r-Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))))/r,a=(n-Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))))/n,c=(o-Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e))))/o;return!(i<.1||a<.1||c<.1)&&Math.abs(r-n)/r<.03&&Math.abs(r-o)/r<.03}},{key:"isTripleBottom",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=(Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e)))-r)/r,a=(Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e)))-n)/n,c=(Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e)))-o)/o;return!(i<.1||a<.1||c<.1)&&Math.abs(r-n)/r<.03&&Math.abs(r-o)/r<.03}},{key:"isHeadAndShoulders",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e))),l=(n-a)/n,u=(Math.max(i,c)-Math.min(i,c))/Math.min(i,c);return l>.15&&u<.03}},{key:"isInverseHeadAndShoulders",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e)));if(r<=0||n<=0||o<=0)return!1;var i=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),a=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),c=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e))),l=(a-n)/n,u=(Math.min(i,c)-Math.max(i,c))/Math.max(i,c);return l>.15&&u<.03}},{key:"isRisingWedge",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e))),i=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e)));return r<n&&n<o&&i<a&&a<c}},{key:"isFallingWedge",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.close.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.close.slice(2*e))),i=Math.min.apply(Math,Jt(this.ohlcv.close.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.close.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.close.slice(2*e)));return r>n&&n>o&&i>a&&a>c}},{key:"isBullishTriangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,Jt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.high.slice(e))),o=Math.min.apply(Math,Jt(this.ohlcv.low.slice(0,e))),i=Math.min.apply(Math,Jt(this.ohlcv.low.slice(e)));return r>n&&o<i}},{key:"isBearishTriangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/2),r=Math.max.apply(Math,Jt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.high.slice(e)));return Math.min.apply(Math,Jt(this.ohlcv.low.slice(0,e)))<Math.min.apply(Math,Jt(this.ohlcv.low.slice(e)))&&r>n}},{key:"isBullishRectangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.high.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.high.slice(2*e))),i=Math.min.apply(Math,Jt(this.ohlcv.low.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.low.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.low.slice(2*e))),l=Math.abs(r-n)/r<.03&&Math.abs(n-o)/n<.03,u=Math.abs(i-a)/i<.03&&Math.abs(a-c)/a<.03;return l&&u}},{key:"isBearishRectangle",value:function(){var t=this.ohlcv.close.length,e=Math.floor(t/3),r=Math.max.apply(Math,Jt(this.ohlcv.high.slice(0,e))),n=Math.max.apply(Math,Jt(this.ohlcv.high.slice(e,2*e))),o=Math.max.apply(Math,Jt(this.ohlcv.high.slice(2*e))),i=Math.min.apply(Math,Jt(this.ohlcv.low.slice(0,e))),a=Math.min.apply(Math,Jt(this.ohlcv.low.slice(e,2*e))),c=Math.min.apply(Math,Jt(this.ohlcv.low.slice(2*e))),l=Math.abs(r-n)/r<.03&&Math.abs(n-o)/n<.03,u=Math.abs(i-a)/i<.03&&Math.abs(a-c)/a<.03;return l&&u}}])&&Xt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),ee=["open","high","low","close","volume"];function re(t){return re="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},re(t)}function ne(t){return function(t){if(Array.isArray(t))return ce(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ae(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function oe(){oe=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:_(t,r,c)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var f="suspendedStart",p="suspendedYield",v="executing",y="completed",m={};function b(){}function d(){}function g(){}var w={};u(w,a,(function(){return this}));var M=Object.getPrototypeOf,S=M&&M(M(A([])));S&&S!==r&&n.call(S,a)&&(w=S);var j=g.prototype=b.prototype=Object.create(w);function O(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function r(o,i,a,c){var l=h(t[o],t,i);if("throw"!==l.type){var u=l.arg,s=u.value;return s&&"object"==re(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(l.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function _(e,r,n){var o=f;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var l=E(c,n);if(l){if(l===m)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=h(e,r,n);if("normal"===u.type){if(o=n.done?y:p,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function E(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function A(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(re(e)+" is not iterable")}return d.prototype=g,o(j,"constructor",{value:g,configurable:!0}),o(g,"constructor",{value:d,configurable:!0}),d.displayName=u(g,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,u(t,l,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},O(P.prototype),u(P.prototype,c,(function(){return this})),e.AsyncIterator=P,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new P(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(j),u(j,l,"Generator"),u(j,a,(function(){return this})),u(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=A,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(k),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var l=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:A(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function ie(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],l=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);l=!0);}catch(t){u=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||ae(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ae(t,e){if(t){if("string"==typeof t)return ce(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ce(t,e):void 0}}function ce(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function le(t,e,r,n,o,i,a){try{var c=t[i](a),l=c.value}catch(t){return void r(t)}c.done?e(l):Promise.resolve(l).then(n,o)}function ue(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){le(i,n,o,a,c,"next",t)}function c(t){le(i,n,o,a,c,"throw",t)}a(void 0)}))}}function se(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,he(n.key),n)}}function he(t){var e=function(t,e){if("object"!=re(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=re(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==re(e)?e:e+""}var fe=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.ChartPatterns=function(t){return new te(t).init()}},e=[{key:"init",value:function(t){return this.promises=[],this.crossPairsArr=[],this.ohlcv=t.reduce((function(t,e){var r=e.open,n=e.high,o=e.low,i=e.close,a=e.volume,c=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.includes(r)||{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(e,ee);t.open.push(new p(r)),t.high.push(new p(n)),t.low.push(new p(o)),t.close.push(new p(i)),t.volume.push(new p(a));for(var l=0,u=Object.keys(c);l<u.length;l++){var s=u[l];t[s]||(t[s]=[]),t[s].push(c[s])}return t}),{open:[],high:[],low:[],close:[],volume:[]}),this}},{key:"computePromises",value:(o=ue(oe().mark((function t(){var e,r=this;return oe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=function(){var t=ue(oe().mark((function t(e,n){return oe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Promise.all(e[n]).then((function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)for(var n=0,o=Object.entries(t[e]);n<o.length;n++){var i=ie(o[n],2),a=i[0],c=i[1];r.addColumn("".concat(a).toLowerCase(),c)}return!0})));case 1:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),t.next=3,e(this,"promises");case 3:if(!t.sent){t.next=7;break}return t.next=7,Ct(this,this.crossPairsArr);case 7:return t.abrupt("return",this.ohlcv);case 8:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"getData",value:(n=ue(oe().mark((function t(){var e,r,n;return oe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.computePromises();case 2:return e=this.ohlcv,r=Object.keys(e),n=r.length,t.abrupt("return",e.open.map((function(t,o){for(var i={},a=0;a<n;a++){var c=r[a],l=e[c][o];i[c]=l instanceof p?l.toNumber():l}return i})));case 6:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"getLastValues",value:(r=ue(oe().mark((function t(){var e,r,n,o,i,a,c;return oe().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.computePromises();case 2:for(e={},r=0,n=Object.entries(this.ohlcv);r<n.length;r++)o=ie(n[r],2),i=o[0],a=o[1],c=a[a.length-1],e[i]=c instanceof p?c.toNumber():c;return t.abrupt("return",e);case 5:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"addColumn",value:function(t,e){var r=this.ohlcv.open.length;if(e.length>r)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");var n=new Array(r-e.length).fill(null);e=[].concat(ne(n),ne(e)),this.ohlcv[t]=e}},{key:"crossPairs",value:function(t){return this.crossPairsArr=t,this}},{key:"ema",value:function(t){return this.promises.push(Promise.resolve(function(t,e){var r=t.ohlcv.close,n=_t(r,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Pt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"ema_".concat(e),n)}(this,t))),this}},{key:"sma",value:function(t){return this.promises.push(Promise.resolve(function(t,e){var r=t.ohlcv.close,n=xt(r,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Et(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"sma_".concat(e),n)}(this,t))),this}},{key:"macd",value:function(t,e,r){return this.promises.push(Promise.resolve(function(t,e,r,n){var o=t.ohlcv.close,i=Math.max(e,r,n);return function(t){for(var e=[],r=[],n=[],o=new yt({indicator:st,shortInterval:arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,longInterval:arguments.length>2&&void 0!==arguments[2]?arguments[2]:26,signalInterval:arguments.length>3&&void 0!==arguments[3]?arguments[3]:9}),i=t.length,a=0;a<i;a++){var c={};o.update(t[a]);try{c=o.getResult()}catch(t){c={macd:null,signal:null,histogram:null}}e.push(c.macd),r.push(c.signal),n.push(c.histogram)}return{macd_diff:e,macd_dea:r,macd_histogram:n,macd_diff_x_macd_dea:It(e,r)}}(o.slice(-3*i),e,r,n)}(this,t,e,r))),this}},{key:"bollingerBands",value:function(t,e,r){return this.promises.push(Promise.resolve(function(t,e,r){return function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,n=t.length,o={bollinger_bands_upper:[],bollinger_bands_middle:[],bollinger_bands_lower:[]},i=new et(e,r),a=0;a<n;a++){var c={};i.update(t[a]);try{c=i.getResult()}catch(t){c={upper:null,middle:null,lower:null}}o.bollinger_bands_upper.push(c.upper),o.bollinger_bands_middle.push(c.middle),o.bollinger_bands_lower.push(c.lower)}var l=o.bollinger_bands_upper,u=o.bollinger_bands_middle,s=o.bollinger_bands_lower;return{bollinger_bands_upper:l,bollinger_bands_middle:u,bollinger_bands_lower:s,bollinger_bands_range:Ft(t,{bollinger_bands_upper:l,bollinger_bands_lower:s})}}(t.ohlcv.close.slice(-3*e),e,r)}(this,t,e))),this}},{key:"rsi",value:function(t,e,r){return this.promises.push(Promise.resolve(function(t,e,r,n){var o=t.ohlcv.close.slice(-3*e);return"number"==typeof e&&void 0===n&&(n=e),Gt(o,e,r,n)}(this,t,e,r))),this}},{key:"candles",value:function(){var t;return this.promises.push(Promise.resolve((t=this.ohlcv,Yt(t)))),this}},{key:"volumeProfile",value:function(t,e,r){return this.promises.push(Promise.resolve(function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3?arguments[3]:void 0,o=t.ohlcv,i=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,r=t.open,n=t.high,o=t.low,i=t.close,a=t.volume,c=Math.min.apply(Math,qt(o)),l=(Math.max.apply(Math,qt(n))-c)/e,u={upVolume:0,downVolume:0,grossVolume:0},s=Array.from({length:e},(function(t,e){return{price:c+l*e,upVolume:0,downVolume:0,grossVolume:0}})),h=1/l,f=0;f<i.length;f++)for(var p=i[f],v=r[f],y=n[f],m=o[f],b=a[f],d=p>=v?b:0,g=p<v?b:0,w=Math.max(0,Math.floor((m-c)*h)),M=Math.min(e,Math.ceil((y-c)*h)),S=w;S<M;S++)s[S].upVolume+=d,s[S].downVolume+=g,s[S].grossVolume+=d+g;for(var j=0,O=s;j<O.length;j++){var P=O[j],_=P.upVolume,E=P.downVolume,x=P.grossVolume;u.upVolume+=_,u.downVolume+=E,u.grossVolume+=x}return{bins:s,nodes:Wt(s)}}($t(o,r,n),e);return{volume_profile_high:[i.nodes.high.price],volume_profile_low:[i.nodes.low.price]}}(this,t,e,r))),this}}],e&&se(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,o}()})(),OHLCV_INDICATORS=e})();
|
package/index.js
CHANGED
|
@@ -16,7 +16,6 @@ export default class OHLCV_INDICATORS {
|
|
|
16
16
|
|
|
17
17
|
init(ohlcv) {
|
|
18
18
|
|
|
19
|
-
this.promises = []
|
|
20
19
|
this.crossPairsArr = []
|
|
21
20
|
this.ohlcv = ohlcv.reduce((acc, { open, high, low, close, volume, ...rest }) => {
|
|
22
21
|
acc.open.push(new Big(open))
|
|
@@ -35,37 +34,9 @@ export default class OHLCV_INDICATORS {
|
|
|
35
34
|
return this
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
const resolvePromises = async (main, promiseName) => {
|
|
41
|
-
|
|
42
|
-
return Promise.all(main[promiseName]).then(thisPromise => {
|
|
43
|
-
|
|
44
|
-
if(Array.isArray(thisPromise))
|
|
45
|
-
{
|
|
46
|
-
for(let x = 0; x < thisPromise.length; x++)
|
|
47
|
-
{
|
|
48
|
-
for(const [key, arr] of Object.entries(thisPromise[x]))
|
|
49
|
-
{
|
|
50
|
-
this.addColumn(`${key}`.toLowerCase(), arr)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return true
|
|
56
|
-
})
|
|
57
|
-
}
|
|
37
|
+
getData() {
|
|
58
38
|
|
|
59
|
-
const promises = await resolvePromises(this, 'promises')
|
|
60
39
|
|
|
61
|
-
if(promises) await crossPairs(this, this.crossPairsArr)
|
|
62
|
-
|
|
63
|
-
return this.ohlcv
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async getData() {
|
|
67
|
-
|
|
68
|
-
await this.computePromises()
|
|
69
40
|
const {ohlcv} = this
|
|
70
41
|
const keys = Object.keys(ohlcv)
|
|
71
42
|
const keysLength = keys.length
|
|
@@ -86,8 +57,9 @@ export default class OHLCV_INDICATORS {
|
|
|
86
57
|
return row
|
|
87
58
|
})
|
|
88
59
|
}
|
|
89
|
-
|
|
90
|
-
|
|
60
|
+
getLastValues(){
|
|
61
|
+
|
|
62
|
+
|
|
91
63
|
const output = {}
|
|
92
64
|
|
|
93
65
|
for (const [k, arr] of Object.entries(this.ohlcv)) {
|
|
@@ -98,8 +70,17 @@ export default class OHLCV_INDICATORS {
|
|
|
98
70
|
return output
|
|
99
71
|
}
|
|
100
72
|
|
|
73
|
+
addObjectColumns(obj) {
|
|
74
|
+
|
|
75
|
+
for(const [key, arr] of Object.entries(obj))
|
|
76
|
+
{
|
|
77
|
+
this.addColumn(key, arr)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
101
81
|
addColumn(key, arr) {
|
|
102
82
|
|
|
83
|
+
key = key.toLowerCase()
|
|
103
84
|
const ohlcvLength = this.ohlcv.open.length;
|
|
104
85
|
|
|
105
86
|
if (arr.length > ohlcvLength) {
|
|
@@ -115,67 +96,53 @@ export default class OHLCV_INDICATORS {
|
|
|
115
96
|
|
|
116
97
|
crossPairs(arr)
|
|
117
98
|
{
|
|
118
|
-
this
|
|
99
|
+
crossPairs(this, arr)
|
|
119
100
|
|
|
120
101
|
return this
|
|
121
102
|
}
|
|
122
103
|
|
|
123
104
|
ema(size) {
|
|
124
105
|
|
|
125
|
-
this.
|
|
126
|
-
Promise.resolve(ema(this, size))
|
|
127
|
-
)
|
|
106
|
+
this.addObjectColumns(ema(this, size))
|
|
128
107
|
|
|
129
108
|
return this
|
|
130
109
|
}
|
|
131
110
|
sma(size) {
|
|
132
111
|
|
|
133
|
-
this.
|
|
134
|
-
Promise.resolve(sma(this, size))
|
|
135
|
-
)
|
|
112
|
+
this.addObjectColumns(sma(this, size))
|
|
136
113
|
|
|
137
114
|
return this
|
|
138
115
|
}
|
|
139
116
|
macd(fastLine, slowLine, signalLine) {
|
|
140
117
|
|
|
141
|
-
this.
|
|
142
|
-
Promise.resolve(macd(this, fastLine, slowLine, signalLine))
|
|
143
|
-
)
|
|
118
|
+
this.addObjectColumns(macd(this, fastLine, slowLine, signalLine))
|
|
144
119
|
|
|
145
120
|
return this
|
|
146
121
|
}
|
|
147
122
|
bollingerBands(data, size, times)
|
|
148
123
|
{
|
|
124
|
+
this.addObjectColumns(bollingerBands(this, data, size, times))
|
|
149
125
|
|
|
150
|
-
this.promises.push(
|
|
151
|
-
Promise.resolve(bollingerBands(this, data, size, times))
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
|
|
155
126
|
return this
|
|
156
127
|
}
|
|
157
128
|
rsi(period, movingAverage, movingAveragePeriod)
|
|
158
129
|
{
|
|
159
|
-
|
|
130
|
+
|
|
131
|
+
this.addObjectColumns(rsi(this, period, movingAverage, movingAveragePeriod))
|
|
160
132
|
|
|
161
133
|
return this
|
|
162
134
|
}
|
|
163
135
|
candles()
|
|
164
136
|
{
|
|
165
137
|
|
|
166
|
-
this.
|
|
167
|
-
|
|
168
|
-
)
|
|
169
|
-
|
|
138
|
+
this.addObjectColumns(candles(this))
|
|
139
|
+
|
|
170
140
|
|
|
171
141
|
return this
|
|
172
142
|
}
|
|
173
143
|
volumeProfile(numBins, daysBack, targetDateKey)
|
|
174
144
|
{
|
|
175
|
-
|
|
176
|
-
this.promises.push(
|
|
177
|
-
Promise.resolve(volumeProfile(this, numBins, daysBack, targetDateKey))
|
|
178
|
-
)
|
|
145
|
+
this.addObjectColumns(volumeProfile(this, numBins, daysBack, targetDateKey))
|
|
179
146
|
|
|
180
147
|
return this
|
|
181
148
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
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",
|
package/src/oscillators/rsi.js
CHANGED
|
@@ -18,14 +18,7 @@ export const rsi = (main, period, movingAverage, movingAveragePeriod) => {
|
|
|
18
18
|
|
|
19
19
|
const col = getRSI(sliceData, period, movingAverage, movingAveragePeriod)
|
|
20
20
|
|
|
21
|
-
return col
|
|
22
|
-
|
|
23
|
-
for(let k in col)
|
|
24
|
-
{
|
|
25
|
-
main.addColumn(`${k}`.toLowerCase(), col[k])
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
return col
|
|
29
22
|
}
|
|
30
23
|
|
|
31
24
|
export const getRSI = (data, period = 14, movingAverage = 'SMA', movingAveragePeriod = 14) => {
|
|
@@ -90,30 +90,25 @@ export const crossPairs = async (main, arr) => {
|
|
|
90
90
|
slowNumArrCache[slow] = Array(ohlcv.close.length).fill(new Big(slow))
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
const keyName = `${fast}_x_${slow}`
|
|
94
|
+
|
|
93
95
|
// Find and add crosses
|
|
94
96
|
if (ohlcv[fast] && ohlcv[slow]) {
|
|
95
97
|
|
|
96
98
|
const cross = findCrosses(ohlcv[fast], ohlcv[slow]);
|
|
97
99
|
|
|
98
|
-
|
|
100
|
+
main.addColumn(keyName, cross)
|
|
101
|
+
|
|
99
102
|
|
|
100
103
|
} else if (ohlcv[fast] && slowNumArrCache[slow]) {
|
|
101
104
|
const cross = findCrosses(ohlcv[fast], slowNumArrCache[slow])
|
|
102
105
|
|
|
103
|
-
|
|
106
|
+
main.addColumn(keyName, cross)
|
|
104
107
|
|
|
105
108
|
} else {
|
|
106
109
|
console.log(`Missing ohlcv properties for ${fast} or ${slow}`);
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
|
|
110
|
-
const resolvedPromises = await Promise.all(promises)
|
|
111
|
-
|
|
112
|
-
for (let i = 0; i < resolvedPromises.length; i++) {
|
|
113
|
-
const item = resolvedPromises[i];
|
|
114
|
-
const key = Object.keys(item)[0];
|
|
115
|
-
main.addColumn(key, item[key]);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
113
|
return true
|
|
119
114
|
}
|