ohlcv-indicators 1.9.1 → 1.9.3
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 +101 -146
- package/package.json +1 -1
- package/src/moving-averages/bollingerBands.js +42 -80
- package/src/moving-averages/donchianChannel.js +43 -56
- package/src/moving-averages/ema.js +15 -40
- package/src/moving-averages/macd.js +43 -46
- package/src/moving-averages/relativeVolume.js +28 -39
- package/src/moving-averages/sma.js +15 -35
- package/src/oscillators/rsi.js +34 -52
- package/src/oscillators/volumeOscillator.js +32 -36
- package/src/studies/candleStudies.js +156 -168
- package/src/studies/lag.js +27 -0
- package/src/utilities/parsing-utilities.js +143 -125
- package/src/utilities/setIndicatorsFromInputParams.js +43 -0
- package/src/oscillators/orb.js +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{t.r(e),t.d(e,{default:()=>re});var r=1e6,n="[big.js] ",o=n+"Invalid ",i=o+"decimal places",u=o+"rounding mode",l=n+"Division by zero",a={},c=void 0,s=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(t,e,r,n){var o=t.c;if(r===c&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(u);if(e<1)n=3===r&&(n||!!o[0])||0===e&&(1===r&&o[0]>=5||2===r&&(o[0]>5||5===o[0]&&(n||o[1]!==c))),o.length=1,n?(t.e=t.e-e+1,o[0]=1):o[0]=t.e=0;else if(e<o.length){if(n=1===r&&o[e]>=5||2===r&&(o[e]>5||5===o[e]&&(n||o[e+1]!==c||1&o[e-1]))||3===r&&(n||!!o[0]),o.length=e,n)for(;++o[--e]>9;)if(o[e]=0,0===e){++t.e,o.unshift(1);break}for(e=o.length;!o[--e];)o.pop()}return t}function h(t,e,r){var n=t.e,o=t.c.join(""),i=o.length;if(e)o=o.charAt(0)+(i>1?"."+o.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)o="0"+o;o="0."+o}else if(n>0)if(++n>i)for(n-=i;n--;)o+="0";else n<i&&(o=o.slice(0,n)+"."+o.slice(n));else i>1&&(o=o.charAt(0)+"."+o.slice(1));return t.s<0&&r?"-"+o:o}function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function v(t){var e="function"==typeof Map?new Map:void 0;return v=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(y())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&b(o,r.prototype),o}(t,arguments,d(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(r,t)},v(t)}function y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(y=function(){return!!t})()}function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}a.abs=function(){var t=new this.constructor(this);return t.s=1,t},a.cmp=function(t){var e,r=this,n=r.c,o=(t=new r.constructor(t)).c,i=r.s,u=t.s,l=r.e,a=t.e;if(!n[0]||!o[0])return n[0]?i:o[0]?-u:0;if(i!=u)return i;if(e=i<0,l!=a)return l>a^e?1:-1;for(u=(l=n.length)<(a=o.length)?l:a,i=-1;++i<u;)if(n[i]!=o[i])return n[i]>o[i]^e?1:-1;return l==a?0:l>a^e?1:-1},a.div=function(t){var e=this,n=e.constructor,o=e.c,u=(t=new n(t)).c,a=e.s==t.s?1:-1,s=n.DP;if(s!==~~s||s<0||s>r)throw Error(i);if(!u[0])throw Error(l);if(!o[0])return t.s=a,t.c=[t.e=0],t;var h,p,v,y,b,d=u.slice(),g=h=u.length,m=o.length,w=o.slice(0,h),O=w.length,_=t,j=_.c=[],S=0,P=s+(_.e=e.e-t.e)+1;for(_.s=a,a=P<0?0:P,d.unshift(0);O++<h;)w.push(0);do{for(v=0;v<10;v++){if(h!=(O=w.length))y=h>O?1:-1;else for(b=-1,y=0;++b<h;)if(u[b]!=w[b]){y=u[b]>w[b]?1:-1;break}if(!(y<0))break;for(p=O==h?u:d;O;){if(w[--O]<p[O]){for(b=O;b&&!w[--b];)w[b]=9;--w[b],w[O]+=10}w[O]-=p[O]}for(;!w[0];)w.shift()}j[S++]=y?v:++v,w[0]&&y?w[O]=o[g]||0:w=[o[g]]}while((g++<m||w[0]!==c)&&a--);return j[0]||1==S||(j.shift(),_.e--,P--),S>P&&f(_,P,n.RM,w[0]!==c),_},a.eq=function(t){return 0===this.cmp(t)},a.gt=function(t){return this.cmp(t)>0},a.gte=function(t){return this.cmp(t)>-1},a.lt=function(t){return this.cmp(t)<0},a.lte=function(t){return this.cmp(t)<1},a.minus=a.sub=function(t){var e,r,n,o,i=this,u=i.constructor,l=i.s,a=(t=new u(t)).s;if(l!=a)return t.s=-a,i.plus(t);var c=i.c.slice(),s=i.e,f=t.c,h=t.e;if(!c[0]||!f[0])return f[0]?t.s=-a:c[0]?t=new u(i):t.s=1,t;if(l=s-h){for((o=l<0)?(l=-l,n=c):(h=s,n=f),n.reverse(),a=l;a--;)n.push(0);n.reverse()}else for(r=((o=c.length<f.length)?c:f).length,l=a=0;a<r;a++)if(c[a]!=f[a]){o=c[a]<f[a];break}if(o&&(n=c,c=f,f=n,t.s=-t.s),(a=(r=f.length)-(e=c.length))>0)for(;a--;)c[e++]=0;for(a=e;r>l;){if(c[--r]<f[r]){for(e=r;e&&!c[--e];)c[e]=9;--c[e],c[r]+=10}c[r]-=f[r]}for(;0===c[--a];)c.pop();for(;0===c[0];)c.shift(),--h;return c[0]||(t.s=1,c=[h=0]),t.c=c,t.e=h,t},a.mod=function(t){var e,r=this,n=r.constructor,o=r.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(l);return r.s=t.s=1,e=1==t.cmp(r),r.s=o,t.s=i,e?new n(r):(o=n.DP,i=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=o,n.RM=i,this.minus(r.times(t)))},a.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},a.plus=a.add=function(t){var e,r,n,o=this,i=o.constructor;if(t=new i(t),o.s!=t.s)return t.s=-t.s,o.minus(t);var u=o.e,l=o.c,a=t.e,c=t.c;if(!l[0]||!c[0])return c[0]||(l[0]?t=new i(o):t.s=o.s),t;if(l=l.slice(),e=u-a){for(e>0?(a=u,n=c):(e=-e,n=l),n.reverse();e--;)n.push(0);n.reverse()}for(l.length-c.length<0&&(n=c,c=l,l=n),e=c.length,r=0;e;l[e]%=10)r=(l[--e]=l[e]+c[e]+r)/10|0;for(r&&(l.unshift(r),++a),e=l.length;0===l[--e];)l.pop();return t.c=l,t.e=a,t},a.pow=function(t){var e=this,r=new e.constructor("1"),n=r,i=t<0;if(t!==~~t||t<-1e6||t>1e6)throw Error(o+"exponent");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},a.prec=function(t,e){if(t!==~~t||t<1||t>r)throw Error(o+"precision");return f(new this.constructor(this),t,e)},a.round=function(t,e){if(t===c)t=0;else if(t!==~~t||t<-r||t>r)throw Error(i);return f(new this.constructor(this),t+this.e+1,e)},a.sqrt=function(){var t,e,r,o=this,i=o.constructor,u=o.s,l=o.e,a=new i("0.5");if(!o.c[0])return new i(o);if(u<0)throw Error(n+"No square root");0===(u=Math.sqrt(o+""))||u===1/0?((e=o.c.join("")).length+l&1||(e+="0"),l=((l+1)/2|0)-(l<0||1&l),t=new i(((u=Math.sqrt(e))==1/0?"5e":(u=u.toExponential()).slice(0,u.indexOf("e")+1))+l)):t=new i(u+""),l=t.e+(i.DP+=4);do{r=t,t=a.times(r.plus(o.div(r)))}while(r.c.slice(0,l).join("")!==t.c.slice(0,l).join(""));return f(t,(i.DP-=4)+t.e+1,i.RM)},a.times=a.mul=function(t){var e,r=this,n=r.constructor,o=r.c,i=(t=new n(t)).c,u=o.length,l=i.length,a=r.e,c=t.e;if(t.s=r.s==t.s?1:-1,!o[0]||!i[0])return t.c=[t.e=0],t;for(t.e=a+c,u<l&&(e=o,o=i,i=e,c=u,u=l,l=c),e=new Array(c=u+l);c--;)e[c]=0;for(a=l;a--;){for(l=0,c=u+a;c>a;)l=e[c]+i[a]*o[c-a-1]+l,e[c--]=l%10,l=l/10|0;e[c]=l}for(l?++t.e:e.shift(),a=e.length;!e[--a];)e.pop();return t.c=e,t},a.toExponential=function(t,e){var n=this,o=n.c[0];if(t!==c){if(t!==~~t||t<0||t>r)throw Error(i);for(n=f(new n.constructor(n),++t,e);n.c.length<t;)n.c.push(0)}return h(n,!0,!!o)},a.toFixed=function(t,e){var n=this,o=n.c[0];if(t!==c){if(t!==~~t||t<0||t>r)throw Error(i);for(t=t+(n=f(new n.constructor(n),t+n.e+1,e)).e+1;n.c.length<t;)n.c.push(0)}return h(n,!1,!!o)},a[Symbol.for("nodejs.util.inspect.custom")]=a.toJSON=a.toString=function(){var t=this,e=t.constructor;return h(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},a.toNumber=function(){var t=Number(h(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(n+"Imprecise conversion");return t},a.toPrecision=function(t,e){var n=this,i=n.constructor,u=n.c[0];if(t!==c){if(t!==~~t||t<1||t>r)throw Error(o+"precision");for(n=f(new i(n),t,e);n.c.length<t;)n.c.push(0)}return h(n,t<=n.e||n.e<=i.NE||n.e>=i.PE,!!u)},a.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(n+"valueOf disallowed");return h(t,t.e<=e.NE||t.e>=e.PE,!0)},function t(){function e(r){var n=this;if(!(n instanceof e))return r===c?t():new e(r);if(r instanceof e)n.s=r.s,n.e=r.e,n.c=r.c.slice();else{if("string"!=typeof r){if(!0===e.strict&&"bigint"!=typeof r)throw TypeError(o+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,i;if(!s.test(e))throw Error(o+"number");for(t.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),i=e.length,n=0;n<i&&"0"==e.charAt(n);)++n;if(n==i)t.c=[t.e=0];else{for(;i>0&&"0"==e.charAt(--i););for(t.e=r-n-1,t.c=[],r=0;n<=i;)t.c[r++]=+e.charAt(n++)}}(n,r)}n.constructor=e}return e.prototype=a,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();var g=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),t=function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==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,y()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,e,[r]),Object.setPrototypeOf(t,(this instanceof e?this.constructor:void 0).prototype),t.name="NotEnoughDataError",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&b(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(v(Error));function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function w(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_(n.key),n)}}function O(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t){var e=function(t,e){if("object"!=m(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=m(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==m(e)?e:e+""}var j=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),O(this,"previousHighest",void 0),O(this,"highest",void 0),O(this,"previousLowest",void 0),O(this,"lowest",void 0),O(this,"previousResult",void 0),O(this,"result",void 0)},(e=[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&w(t.prototype,e),r&&w(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function S(t){return S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},S(t)}function P(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,M(n.key),n)}}function E(t,e,r){return e=k(e),function(t,e){if(e&&("object"==S(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,A()?Reflect.construct(e,r||[],k(t).constructor):e.apply(t,r))}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function k(t){return k=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},k(t)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}function M(t){var e=function(t,e){if("object"!=S(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==S(e)?e:e+""}var T=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=M(o="interval"))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}(e,t),r=e,(n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&P(r.prototype,n),o&&P(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(j);function x(t){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(t)}function D(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,F(n.key),n)}}function C(t,e,r){return e=I(e),function(t,e){if(e&&("object"==x(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,B()?Reflect.construct(e,r||[],I(t).constructor):e.apply(t,r))}function B(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(B=function(){return!!t})()}function I(t){return I=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},I(t)}function L(t,e){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},L(t,e)}function F(t){var e=function(t,e){if("object"!=x(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=x(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==x(e)?e:e+""}var N=function(t){function e(){var t,r,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,u=new Array(i),l=0;l<i;l++)u[l]=arguments[l];return r=t=C(this,e,[].concat(u)),o=[],(n=F(n="prices"))in r?Object.defineProperty(r,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[n]=o,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&L(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}],n&&D(r.prototype,n),o&&D(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(T);function H(t){return H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},H(t)}function q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,W(n.key),n)}}function V(t,e,r){return e=G(e),function(t,e){if(e&&("object"==H(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,z()?Reflect.construct(e,r||[],G(t).constructor):e.apply(t,r))}function z(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(z=function(){return!!t})()}function G(t){return G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},G(t)}function U(t,e){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},U(t,e)}function $(t,e,r){return(e=W(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function W(t){var e=function(t,e){if("object"!=H(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=H(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==H(e)?e:e+""}var J=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),$(r=V(this,e),"interval",void 0),$(r,"indicator",void 0),$(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new N(t),r.smoothingFactor=1/r.interval,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&U(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&q(r.prototype,n),o&&q(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(j);function K(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}function Y(t){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Y(t)}function Q(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Z(n.key),n)}}function X(t,e,r){return(e=Z(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Z(t){var e=function(t,e){if("object"!=Y(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Y(e)?e:e+""}var tt=function(){return t=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),X(this,"interval",void 0),X(this,"deviationMultiplier",void 0),X(this,"prices",[]),X(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=K(this.prices),r=function(t,e){var r=e||K(t),n=K(t.map((function(t){return t-r})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,e);return this.result={lower:e-r*this.deviationMultiplier,middle:e,upper:e+r*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&Q(t.prototype,e),r&&Q(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function et(t){return et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},et(t)}function rt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,at(n.key),n)}}function nt(t,e,r){return e=it(e),function(t,e){if(e&&("object"==et(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,ot()?Reflect.construct(e,r||[],it(t).constructor):e.apply(t,r))}function ot(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ot=function(){return!!t})()}function it(t){return it=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},it(t)}function ut(t,e){return ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ut(t,e)}function lt(t,e,r){return(e=at(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function at(t){var e=function(t,e){if("object"!=et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==et(e)?e:e+""}var ct=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),lt(r=nt(this,e,[t]),"interval",void 0),lt(r,"pricesCounter",0),lt(r,"weightFactor",void 0),r.interval=t,r.weightFactor=2/(r.interval+1),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ut(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?e&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,e&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),e):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),e)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new g;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&rt(r.prototype,n),o&&rt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(T);function st(t){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},st(t)}function ft(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,pt(n.key),n)}}function ht(t,e,r){return(e=pt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pt(t){var e=function(t,e){if("object"!=st(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=st(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==st(e)?e:e+""}var vt=function(){return t=function t(e,r,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),ht(this,"short",void 0),ht(this,"long",void 0),ht(this,"signal",void 0),ht(this,"prices",[]),ht(this,"result",void 0),this.short=e,this.long=r,this.signal=n},e=[{key:"getResult",value:function(){if(void 0===this.result)throw new g;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var o=r-n,i=this.signal.update(o,e);return this.result={histogram:o-i,macd:o,signal:i}}}}],e&&ft(t.prototype,e),r&&ft(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function yt(t){return yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yt(t)}function bt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_t(n.key),n)}}function dt(t,e,r){return e=mt(e),function(t,e){if(e&&("object"==yt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,gt()?Reflect.construct(e,r||[],mt(t).constructor):e.apply(t,r))}function gt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(gt=function(){return!!t})()}function mt(t){return mt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},mt(t)}function wt(t,e){return wt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},wt(t,e)}function Ot(t,e,r){return(e=_t(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _t(t){var e=function(t,e){if("object"!=yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}var jt=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ot(r=dt(this,e),"interval",void 0),Ot(r,"previousPrices",[]),Ot(r,"avgGain",void 0),Ot(r,"avgLoss",void 0),Ot(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&wt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var o=this.avgLoss.getResult();if(0===o)return this.setResult(100,e);var i=this.avgGain.getResult()/o;return this.setResult(this.maxValue-this.maxValue/(i+1),e)}}}}],n&&bt(r.prototype,n),o&&bt(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,o}(j);function St(t){return St="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},St(t)}function Pt(t){return Pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pt(t)}var Et=function(t,e){if(void 0===t||void 0===e)throw Error("undefined param in getEMA");for(var r=t.length,n=new Array(r).fill(null),o=new ct(e),i=0;i<r;i++){var u=null;if(null!==t[i]){o.update(t[i]);try{u=o.getResult()}catch(t){u=null}}n[i]=u}return n};function At(t){return At="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},At(t)}var kt=function(t,e){if(void 0===t||void 0===e)throw Error("undefined param in getSMA");for(var r=t.length,n=new Array(r).fill(null),o=new N(e),i=0;i<r;i++){var u=null;if(null!==t[i]){o.update(t[i]);try{u=o.getResult()}catch(t){u=null}}n[i]=u}return n};function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Mt=function(t,e){return t===e},Tt=function(t,e){return t>e},xt=function(t,e){return t<e},Dt=function(t){var e=t.fast,r=t.high,n=t.low,o=t.slow,i=e.length;if(i==!o.length)throw Error("fast and slow do not have the same length");for(var u=new Array(i).fill(.5),l=0;l<i;l++){var a=(null==u?void 0:u[l-1])||.5,c=e[l],s=o[l],f=null==r?void 0:r[l],h=null==n?void 0:n[l];if(!r&&!n||void 0!==f&&void 0!==h){var p=o[l-1],v=null==r?void 0:r[l-1],y=null==n?void 0:n[l-1];if(!r&&!n||void 0!==v&&void 0!==y&&void 0!==p){var b=void 0;null===c||null===s?b=.5:Mt(c,s)?b=a:Tt(c,s)?b=xt(h,s)&&Tt(y,p)?0:1:xt(c,s)&&(b=Tt(f,s)&&xt(v,p)?1:0),u[l]=b}}}var d=Bt(u);return Ct(d)},Ct=function(t){var e=t.map((function(t){return t.length}));return t.map((function(t,r){var n=e[r];return t.map((function(t,e){var r=n-e;return.5===t&&(r=0),1===t&&(r*=1),0===t&&(r*=-1),r})).reverse()})).flat()},Bt=function(t){return 0===t.length?[]:t.reduce((function(t,e,r,n){if(0===r)t.push([e]);else{var o=n[r-1],i=t[t.length-1];e!==o?t.push([e]):i.push(e)}return t}),[])},It=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5;if(null===t||null===e||null===r)return null;if(n<2)throw new Error("numLevels must be at least 2");for(var o=4*r/(n-1),i=[],u=0;u<n-1;u++)i.push(e-2*r+u*o);for(var l=i.length-1;l>=0;l--)if(t>i[l])return(l+1)/(n-1);return 0};function Lt(t){return Lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lt(t)}function Ft(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Nt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ft(Object(r),!0).forEach((function(e){Ht(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ft(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Ht(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Lt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Lt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qt(t){return qt="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},qt(t)}var Vt={getSMA:kt,getEMA:Et},zt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"SMA",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:14,o=t.length;if(o<e)return[];for(var i=new Array(o).fill(null),u=new jt(e),l=0;l<o;l++){var a=null;if(null!==t[l]){u.update(t[l]);try{a=u.getResult()}catch(t){a=null}}i[l]=a}var c,s,f,h=(c={},s="rsi_".concat(e),f=i,(s=function(t){var e=function(t,e){if("object"!=qt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=qt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qt(e)?e:e+""}(s))in c?Object.defineProperty(c,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[s]=f,c);if("string"==typeof r&&"number"==typeof n&&Vt.hasOwnProperty("get".concat(r))){var p=Vt["get".concat(r)](i,n);h["rsi_".concat(r,"_").concat(n)]=p,h["rsi_".concat(e,"_x_rsi_").concat(r,"_").concat(n)]=Dt({fast:i,slow:p})}return h};function Gt(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 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))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(l)throw i}}}}function 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 $t={midPriceOpenClose:!1,midPriceHighLow:!1,sessionIndex:!1,sessionIntradayIndex:!1,dayOfTheWeek:!1,dayOfTheMonth:!1,weekOfTheMonth:!1},Wt=function(t){var e=new Date(t),r=e.getDay(),n=e.getDate(),o=new Date(e.getFullYear(),e.getMonth(),1).getDay();return{day_of_the_week:r,day_of_the_month:n,week_of_the_month:Math.ceil((n+o)/7)}},Jt=function(t,e){for(var r=t.length,n=new N(e),o=new Array(r),i=0,u=0,l=0,a=0;a<r;a++)if(n.update(t[a]),n.isStable){var c=n.getResult();o[a]=c,i+=c,u+=c*c,l++}else o[a]=null;var s=i/l,f=u/l-s*s,h=Math.sqrt(f);return o.map((function(t){return null!==t?(t-s)/h:null}))},Kt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)throw new Error("Both arrays must have the same length");for(var n=Jt(t,r),o=Jt(e,r),i=t.length,u=[],l=0,a=0,c=0,s=0,f=0,h=0,p=-1,v=0;v<i;v++){if(null!==n[v]&&null!==o[v]){p=v;break}u.push(0)}if(-1===p)return new Array(i).fill(0);for(var y=p;y<i;y++){var b=n[y],d=o[y];if(null!==b&&null!==d)if(l+=b,a+=d,c+=b*d,s+=b*b,f+=d*d,++h<2)u.push(0);else{var g=h*c-l*a,m=Math.sqrt((h*s-l*l)*(h*f-a*a)),w=0===m?0:g/m;u.push(w)}else l=a=c=s=f=h=0,u.push(0)}return u};function Yt(t){return Yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(t)}function Qt(t,e,r){return(e=ee(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Xt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(t,e)||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)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Zt(t,e){(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 te(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,ee(n.key),n)}}function ee(t){var e=function(t,e){if("object"!=Yt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yt(e)?e:e+""}var re=function(){return t=function t(e){var r=e.input,n=e.ticker,o=void 0===n?null:n,i=e.studyOptions,u=void 0===i?null:i;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(r))throw Error("input ohlcv must be an array: "+o);if(0===r.length)throw Error("input ohlcv must not be empty: "+o);if(!r[0].hasOwnProperty("close"))throw Error("input ohlcv array objects require at least close property: "+o);return this.priceBased=["open","high","low","close","mid_price_open_close","mid_price_high_low"],this.len=r.length,this.crossPairsArr=[],this.inputOhlcv=r,this.studyOptions=null===u?$t:u,this.verticalOhlcv=function(t,e,r){if(Boolean(r))for(var n in r)if(!$t.hasOwnProperty(n))throw new Error("Key ".concat(n," not found in defaultStudyOptions. Available options: ").concat(Object.keys($t).join(", ")));var o=r.midPriceOpenClose,i=r.midPriceHighLow,u=r.sessionIndex,l=r.sessionIntradayIndex,a=r.dayOfTheWeek,c=r.dayOfTheMonth,s=r.weekOfTheMonth,f=["open","high","low","close","volume"];o&&f.push("mid_price_open_close"),i&&f.push("mid_price_high_low");for(var h=new Set(f),p={},v=0,y=f;v<y.length;v++)p[y[v]]=new Array(e);for(var b,d=[],g=0,m=Object.keys(t[0]);g<m.length;g++){var w=m[g];h.has(w)||(p[w]=new Array(e),d.push(w))}var O,_=0,j=0,S=(O=t)[0].hasOwnProperty("date")&&"string"==typeof O[0].date&&/^\d{4}-\d{2}-\d{2}/.test(O[0].date);S&&(u&&(p.session_index=new Array(e)),l&&(p.session_intraday_index=new Array(e)),a&&(p.day_of_the_week=new Array(e)),c&&(p.day_of_the_month=new Array(e)),s&&(p.week_of_the_month=new Array(e)),b=t[0].date.slice(0,10));for(var P=0;P<e;P++){var E=t[P];p.open[P]=E.open,p.high[P]=E.high,p.low[P]=E.low,p.close[P]=E.close,p.volume[P]=E.volume,o&&(p.mid_price_open_close[P]=(E.open+E.close)/2),i&&(p.mid_price_high_low[P]=(E.high+E.low)/2);var A,k=Gt(d);try{for(k.s();!(A=k.n()).done;){var R=A.value;p[R][P]=E[R]}}catch(t){k.e(t)}finally{k.f()}if(S){var M=E.date.slice(0,10);M!==b&&(b=M,_++,j=0);var T=Wt(M),x=T.day_of_the_week,D=T.day_of_the_month,C=T.week_of_the_month;a&&(p.day_of_the_week[P]=x),c&&(p.day_of_the_month[P]=D),s&&(p.week_of_the_month[P]=C),u&&(p.session_index[P]=_),l&&(p.session_intraday_index[P]=j),j++}}return p}(r,this.len,this.studyOptions),this.indicators={},this.studies={},this.utilities={correlation:Kt},this},e=[{key:"getData",value:function(){this.compute();for(var t=this.verticalOhlcv,e=Object.keys(t),r=t[e[0]].length,n=e.length,o=[],i=0;i<r;i++){for(var u={},l=!1,a=0;a<n;a++){var c=e[a],s=t[c][i];if(null==s){l=!0;break}u[c]=s}l||o.push(u)}return o}},{key:"getLastValues",value:function(){return this.getData()[this.getData().length-1]}},{key:"compute",value:function(){if(0===Object.keys(this.indicators).length)return this;for(var t=this.addColumn.bind(this),e=0,r=Object.entries(this.indicators);e<r.length;e++){var n=Xt(r[e],2),o=n[0],i=n[1];this.verticalOhlcv.hasOwnProperty(o)?delete this.indicators[o]:t(o,i)}return this}},{key:"addColumn",value:function(t,e){var r=this.len;if(t=t.toLowerCase(),e.length>r)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");if(e.length<r){var n=r-e.length;e=new Array(n).fill(null).concat(e)}this.verticalOhlcv[t]=e}},{key:"crossPairs",value:function(t){this.compute();var e=function(t,e){var r,n=t.verticalOhlcv,o=t.len,i={},u={},l={},a=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){l=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(l)throw i}}}}(e);try{var c=function(){var t=r.value,e=t.fast,a=t.slow,c=t.count;if(!e||!a)return 1;"number"!=typeof a||i[a]||(i[a]=Array(o).fill(a));var s="".concat(e,"_x_").concat(a),f="".concat(e,"_c_").concat(a),h=function(t){return void 0!==c?t.slice(-c).filter((function(t){return 1===t||-1===t})).length:0};if(n[s]){var p=n[s];u[s]=p,void 0!==c&&(l[f]=h(p))}else if((n[e]||"price"===e)&&n[a]){var v=Dt("price"===e?{fast:n.close,high:n.high,low:n.low,slow:n[a]}:{fast:n[e],slow:n[a]});u[s]=v,void 0!==c&&(l[f]=h(v))}else{if(!n[e]||!i[a])throw Error("Missing ohlcv properties for ".concat(e," or ").concat(a));var y=Dt({fast:n[e],slow:i[a]});u[s]=y,void 0!==c&&(l[f]=h(y))}};for(a.s();!(r=a.n()).done;)c()}catch(t){a.e(t)}finally{a.f()}return{x:u,c:l}}(this,t),r=e.x,n=e.c;return Object.assign(this.indicators,r),Object.assign(this.studies,n),this.compute(),this}},{key:"lag",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.compute();for(var n=this.verticalOhlcv,o=this.priceBased,i=0;i<e.length;i++)for(var u=function(){var r="".concat(e[i],"_lag_").concat(l),u=n[e[i]].slice(0,-l);Object.assign(t.indicators,Qt({},r,u)),o.find((function(t){return r.startsWith(t)}))&&t.priceBased.push(r)},l=1;l<=r;l++)u();return this.compute(),this}},{key:"relativeVolume",value:function(t){var e=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=function(t,e){for(var r=new N(e),n=new Array(t.length).fill(null),o=new Array(t.length).fill(null),i=0;i<t.length;i++){var u=null;r.update(t[i]);try{u=r.getResult()}catch(t){u=null}n[i]=u,"number"==typeof n[i-1]&&(o[i]=t[i]/n[i-1])}return o}(t.verticalOhlcv.volume,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=St(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=St(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==St(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"relative_volume_".concat(e),r)}(this,t);return Object.assign(this.indicators,e),this}},{key:"ema",value:function(t){var e=function(t,e){var r=t.verticalOhlcv.close,n=Et(r,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Pt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"ema_".concat(e),n)}(this,t);return Object.assign(this.indicators,e),this.priceBased.push("ema_".concat(t)),this}},{key:"sma",value:function(t){var e=function(t,e){var r=t.verticalOhlcv.close,n=kt(r,e);return function(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=At(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=At(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==At(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},"sma_".concat(e),n)}(this,t);return Object.assign(this.indicators,e),this.priceBased.push("sma_".concat(t)),this}},{key:"macd",value:function(t,e,r){var n=function(t,e,r,n){return function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:26,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:9,o=t.length,i=new Array(o).fill(null),u=new Array(o).fill(null),l=new Array(o).fill(null),a=new vt(new ct(e),new ct(r),new ct(n)),c=0;c<o;c++){var s={};a.update(t[c]);try{s=a.getResult()}catch(t){s={macd:null,signal:null,histogram:null}}i[c]=s.macd,u[c]=s.signal,l[c]=s.histogram}return{macd_diff:i,macd_dea:u,macd_histogram:l,macd_diff_x_macd_dea:Dt({fast:i,slow:u})}}(t.verticalOhlcv.close,e,r,n)}(this,t,e,r);return Object.assign(this.indicators,n),this}},{key:"bollingerBands",value:function(t,e,r){var n=function(t,e,r,n){return function(t){var e,r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,u=arguments.length>3&&void 0!==arguments[3]&&arguments[3],l=t.length,a=Array(l).fill(null),c=Array(l).fill(null),s=Array(l).fill(null),f=null,h=null;u&&(e=Array(l).fill(null),r=Array(l).fill(null),n=new N(o));for(var p,v,y,b=new tt(o,i),d=0;d<l;d++){var g={};b.update(t[d]);var m=!1,w=void 0;try{g=b.getResult()}catch(t){m=!0,g={upper:null,middle:null,lower:null}}if(a[d]=g.upper,c[d]=g.middle,s[d]=g.lower,!1!==u){if(m)e[d]=null,r[d]=null;else{var O=(p=t[d],v=g.upper,{range:(p-(y=g.lower))/(v-y),height:v-y});f=O.range,h=O.height,n.update(h);try{w=n.getResult()}catch(t){w=null}}e[d]=f,r[d]=It(h,w,1.5)}}var _={bollinger_bands_upper:a,bollinger_bands_middle:c,bollinger_bands_lower:s};return u&&(_=Nt(Nt({},_),{},{bollinger_bands_range:e,bollinger_bands_height:r})),_}(t.verticalOhlcv.close,e,r,n)}(this,t,e,r);return Object.assign(this.indicators,n),this.priceBased.push("bollinger_bands_middle","bollinger_bands_upper","bollinger_bands_lower"),this}},{key:"rsi",value:function(t,e,r){var n=function(t,e,r,n){var o=t.verticalOhlcv.close;return"number"==typeof e&&void 0===n&&(n=e),zt(o,e,r,n)}(this,t,e,r);return Object.assign(this.indicators,n),this}},{key:"orb",value:function(){var t=function(t,e){for(var r=new Array(e).fill(0),n=new Array(e).fill(0),o=0,i=null,u=0,l=0,a=0;a<e;a++){var c=t[a];if(0===a&&!c.hasOwnProperty("date"))throw Error("input ohlcv array must have a date property available in candle datapoint");var s=c.date.split(" ")[0];s!==i&&(i=s,u=c.high,l=c.low),r[o]=u,n[o]=l,o++}return{orb_high:r,orb_low:n}}(this.inputOhlcv,this.len);return Object.assign(this.indicators,t),this.priceBased.push("orb_high","orb_low"),this}},{key:"donchianChannels",value:function(t,e){var r=function(t,e,r){var n=t.verticalOhlcv,o=t.len;return function(t,e,r,n,o){for(var i=new Array(o).fill(null),u=new Array(o).fill(null),l=new Array(o).fill(null),a=[],c=[],s=0;s<o;s++){for(;a.length&&a[0]<=s-r;)a.shift();for(;a.length&&t[a[a.length-1]]<=t[s];)a.pop();for(a.push(s);c.length&&c[0]<=s-r;)c.shift();for(;c.length&&e[c[c.length-1]]>=e[s];)c.pop();if(c.push(s),s>=r-1){var f=t[a[0]],h=e[c[0]],p=(f+h)/2,v=s+n;v>=0&&v<o&&(i[v]=f,u[v]=h,l[v]=p)}}return{donchian_channel_upper:i,donchian_channel_lower:u,donchian_channel_basis:l}}(n.high,n.low,e,r,o)}(this,t,e);return Object.assign(this.indicators,r),this.priceBased.push("donchian_channel_upper","donchian_channel_lower","donchian_channel_basis"),this}},{key:"candlesStudies",value:function(t,e,r){var n=function(t,e,r,n){return function(t){var e,r,n,o,i,u,l,a,c,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,f=arguments.length>2?arguments[2]:void 0,h=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],p=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},v=p.changeLevel,y=void 0===v?7:v,b=p.sizeLevel,d=void 0===b?5:b,g=new Array(f).fill(null),m=new Array(f).fill(null),w=new Array(f).fill(null),O=new Array(f).fill(null),_=new Array(f).fill(null),j=new Array(f).fill(null),S=new Array(f).fill(null),P=new Array(f).fill(null),E=new Array(f).fill(null);h&&(e=new N(s),r=new N(s),n=new N(s),o=new N(s),i=new N(s),u=new N(s),l=new N(s),a=new N(s),c=new N(s));for(var A=0;A<f;A++){var k=t[A],R=t[A-1];if(void 0!==R){var M=k.open,T=k.high,x=k.low,D=k.close,C=null,B=null,I=null,L=null,F=null,H=null,q=null,V=null,z=null,G=D>M,U=Math.abs(D-M),$=Math.abs(k.high-k.low),W=T-Math.max(M,D),J=Math.min(M,D)-x,K=Math.abs(R.close-k.open),Y=Math.abs(k.close-R.close),Q=Math.abs(k.high-R.high),X=Math.abs(k.low-R.low),Z=Math.abs(k.open-R.open);if(h){e.update(Math.abs(W)),r.update(Math.abs(J)),i.update(Math.abs($)),n.update(K),o.update(U),u.update(Y),l.update(Q),a.update(X),c.update(Z);try{I=e.getResult(),B=r.getResult(),C=n.getResult(),L=o.getResult(),F=i.getResult(),H=u.getResult(),q=l.getResult(),V=a.getResult(),z=c.getResult()}catch(t){L=null,C=null,I=null,B=null,F=null,H=null,q=null,V=null,z=null}g[A]=G?It(U,L,2,y):-Math.abs(It(U,L,2,y))||0,O[A]=G?It(K,C,2,y):-Math.abs(It(K,C,2,y))||0,j[A]=G?It(Y,H,2,y):-Math.abs(It(Y,H,2,y))||0,S[A]=G?It(Q,q,2,y):-Math.abs(It(Q,q,2,y))||0,P[A]=G?It(X,V,2,y):-Math.abs(It(X,V,2,y))||0,E[A]=G?It(Z,z,2,y):-Math.abs(It(Z,z,2,y))||0,m[A]=It(W,I,.5,d),w[A]=It(J,B,.5,d),_[A]=It($,F,.5,d)}else g[A]=U,O[A]=K,j[A]=Y,S[A]=Q,P[A]=X,m[A]=W,w[A]=J,_[A]=$}}return{candle_gap_size:O,candle_body_size:g,candle_top_size:m,candle_bottom_size:w,candle_shadow_size:_,candle_close_direction:j,candle_high_direction:S,candle_low_direction:P,candle_open_direction:E}}(t.inputOhlcv,e,t.len,r,n)}(this,t,e,r);return Object.assign(this.indicators,n),this}},{key:"map",value:function(t){this.compute();for(var e=Object.keys(this.verticalOhlcv),r={},n=0;n<this.len;n++){for(var o={},i=0;i<e.length;i++)Object.assign(o,Qt({},e[i],this.verticalOhlcv[e[i]][n]));for(var u=0,l=Object.entries(t(o));u<l.length;u++){var a=Xt(l[u],2),c=a[0],s=a[1];0===n&&(r[c]=new Array(this.len).fill(null)),r[c][n]=s}}return Object.assign(this.indicators,r),this}}],e&&te(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
|
|
1
|
+
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{function r(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}t.r(e),t.d(e,{default:()=>te});var n=function(t,e){return t===e},i=function(t,e){return t>e},o=function(t,e){return t<e},a=function(t){var e=t.fast,r=t.high,a=t.low,u=t.slow,s=e.length;if(s==!u.length)throw Error("fast and slow do not have the same length");for(var f=new Array(s).fill(.5),h=0;h<s;h++){var v=(null==f?void 0:f[h-1])||.5,p=e[h],y=u[h],d=null==r?void 0:r[h],b=null==a?void 0:a[h];if(!r&&!a||void 0!==d&&void 0!==b){var m=u[h-1],g=null==r?void 0:r[h-1],w=null==a?void 0:a[h-1];if(!r&&!a||void 0!==g&&void 0!==w&&void 0!==m){var _=void 0;null===p||null===y?_=.5:n(p,y)?_=v:i(p,y)?_=o(b,y)&&i(w,m)?0:1:o(p,y)&&(_=i(d,y)&&o(g,m)?1:0),f[h]=_}}}var O=c(f);return l(O)},l=function(t){var e=t.map((function(t){return t.length}));return t.map((function(t,r){var n=e[r];return t.map((function(t,e){var r=n-e;return.5===t&&(r=0),1===t&&(r*=1),0===t&&(r*=-1),r})).reverse()})).flat()},c=function(t){return 0===t.length?[]:t.reduce((function(t,e,r,n){if(0===r)t.push([e]);else{var i=n[r-1],o=t[t.length-1];e!==i?t.push([e]):o.push(e)}return t}),[])},u=1e6,s="[big.js] ",f=s+"Invalid ",h=f+"decimal places",v=f+"rounding mode",p=s+"Division by zero",y={},d=void 0,b=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function m(t,e,r,n){var i=t.c;if(r===d&&(r=t.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(v);if(e<1)n=3===r&&(n||!!i[0])||0===e&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(n||i[1]!==d))),i.length=1,n?(t.e=t.e-e+1,i[0]=1):i[0]=t.e=0;else if(e<i.length){if(n=1===r&&i[e]>=5||2===r&&(i[e]>5||5===i[e]&&(n||i[e+1]!==d||1&i[e-1]))||3===r&&(n||!!i[0]),i.length=e,n)for(;++i[--e]>9;)if(i[e]=0,0===e){++t.e,i.unshift(1);break}for(e=i.length;!i[--e];)i.pop()}return t}function g(t,e,r){var n=t.e,i=t.c.join(""),o=i.length;if(e)i=i.charAt(0)+(o>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+="0";else n<o&&(i=i.slice(0,n)+"."+i.slice(n));else o>1&&(i=i.charAt(0)+"."+i.slice(1));return t.s<0&&r?"-"+i:i}function 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 _(t){var e="function"==typeof Map?new Map:void 0;return _=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(O())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var i=new(t.bind.apply(t,n));return r&&P(i,r.prototype),i}(t,arguments,S(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),P(r,t)},_(t)}function O(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(O=function(){return!!t})()}function P(t,e){return P=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},P(t,e)}function S(t){return S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},S(t)}y.abs=function(){var t=new this.constructor(this);return t.s=1,t},y.cmp=function(t){var e,r=this,n=r.c,i=(t=new r.constructor(t)).c,o=r.s,a=t.s,l=r.e,c=t.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-a:0;if(o!=a)return o;if(e=o<0,l!=c)return l>c^e?1:-1;for(a=(l=n.length)<(c=i.length)?l:c,o=-1;++o<a;)if(n[o]!=i[o])return n[o]>i[o]^e?1:-1;return l==c?0:l>c^e?1:-1},y.div=function(t){var e=this,r=e.constructor,n=e.c,i=(t=new r(t)).c,o=e.s==t.s?1:-1,a=r.DP;if(a!==~~a||a<0||a>u)throw Error(h);if(!i[0])throw Error(p);if(!n[0])return t.s=o,t.c=[t.e=0],t;var l,c,s,f,v,y=i.slice(),b=l=i.length,g=n.length,w=n.slice(0,l),_=w.length,O=t,P=O.c=[],S=0,j=a+(O.e=e.e-t.e)+1;for(O.s=o,o=j<0?0:j,y.unshift(0);_++<l;)w.push(0);do{for(s=0;s<10;s++){if(l!=(_=w.length))f=l>_?1:-1;else for(v=-1,f=0;++v<l;)if(i[v]!=w[v]){f=i[v]>w[v]?1:-1;break}if(!(f<0))break;for(c=_==l?i:y;_;){if(w[--_]<c[_]){for(v=_;v&&!w[--v];)w[v]=9;--w[v],w[_]+=10}w[_]-=c[_]}for(;!w[0];)w.shift()}P[S++]=f?s:++s,w[0]&&f?w[_]=n[b]||0:w=[n[b]]}while((b++<g||w[0]!==d)&&o--);return P[0]||1==S||(P.shift(),O.e--,j--),S>j&&m(O,j,r.RM,w[0]!==d),O},y.eq=function(t){return 0===this.cmp(t)},y.gt=function(t){return this.cmp(t)>0},y.gte=function(t){return this.cmp(t)>-1},y.lt=function(t){return this.cmp(t)<0},y.lte=function(t){return this.cmp(t)<1},y.minus=y.sub=function(t){var e,r,n,i,o=this,a=o.constructor,l=o.s,c=(t=new a(t)).s;if(l!=c)return t.s=-c,o.plus(t);var u=o.c.slice(),s=o.e,f=t.c,h=t.e;if(!u[0]||!f[0])return f[0]?t.s=-c:u[0]?t=new a(o):t.s=1,t;if(l=s-h){for((i=l<0)?(l=-l,n=u):(h=s,n=f),n.reverse(),c=l;c--;)n.push(0);n.reverse()}else for(r=((i=u.length<f.length)?u:f).length,l=c=0;c<r;c++)if(u[c]!=f[c]){i=u[c]<f[c];break}if(i&&(n=u,u=f,f=n,t.s=-t.s),(c=(r=f.length)-(e=u.length))>0)for(;c--;)u[e++]=0;for(c=e;r>l;){if(u[--r]<f[r]){for(e=r;e&&!u[--e];)u[e]=9;--u[e],u[r]+=10}u[r]-=f[r]}for(;0===u[--c];)u.pop();for(;0===u[0];)u.shift(),--h;return u[0]||(t.s=1,u=[h=0]),t.c=u,t.e=h,t},y.mod=function(t){var e,r=this,n=r.constructor,i=r.s,o=(t=new n(t)).s;if(!t.c[0])throw Error(p);return r.s=t.s=1,e=1==t.cmp(r),r.s=i,t.s=o,e?new n(r):(i=n.DP,o=n.RM,n.DP=n.RM=0,r=r.div(t),n.DP=i,n.RM=o,this.minus(r.times(t)))},y.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t},y.plus=y.add=function(t){var e,r,n,i=this,o=i.constructor;if(t=new o(t),i.s!=t.s)return t.s=-t.s,i.minus(t);var a=i.e,l=i.c,c=t.e,u=t.c;if(!l[0]||!u[0])return u[0]||(l[0]?t=new o(i):t.s=i.s),t;if(l=l.slice(),e=a-c){for(e>0?(c=a,n=u):(e=-e,n=l),n.reverse();e--;)n.push(0);n.reverse()}for(l.length-u.length<0&&(n=u,u=l,l=n),e=u.length,r=0;e;l[e]%=10)r=(l[--e]=l[e]+u[e]+r)/10|0;for(r&&(l.unshift(r),++c),e=l.length;0===l[--e];)l.pop();return t.c=l,t.e=c,t},y.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(f+"exponent");for(i&&(t=-t);1&t&&(n=n.times(e)),t>>=1;)e=e.times(e);return i?r.div(n):n},y.prec=function(t,e){if(t!==~~t||t<1||t>u)throw Error(f+"precision");return m(new this.constructor(this),t,e)},y.round=function(t,e){if(t===d)t=0;else if(t!==~~t||t<-u||t>u)throw Error(h);return m(new this.constructor(this),t+this.e+1,e)},y.sqrt=function(){var t,e,r,n=this,i=n.constructor,o=n.s,a=n.e,l=new i("0.5");if(!n.c[0])return new i(n);if(o<0)throw Error(s+"No square root");0===(o=Math.sqrt(n+""))||o===1/0?((e=n.c.join("")).length+a&1||(e+="0"),a=((a+1)/2|0)-(a<0||1&a),t=new i(((o=Math.sqrt(e))==1/0?"5e":(o=o.toExponential()).slice(0,o.indexOf("e")+1))+a)):t=new i(o+""),a=t.e+(i.DP+=4);do{r=t,t=l.times(r.plus(n.div(r)))}while(r.c.slice(0,a).join("")!==t.c.slice(0,a).join(""));return m(t,(i.DP-=4)+t.e+1,i.RM)},y.times=y.mul=function(t){var e,r=this,n=r.constructor,i=r.c,o=(t=new n(t)).c,a=i.length,l=o.length,c=r.e,u=t.e;if(t.s=r.s==t.s?1:-1,!i[0]||!o[0])return t.c=[t.e=0],t;for(t.e=c+u,a<l&&(e=i,i=o,o=e,u=a,a=l,l=u),e=new Array(u=a+l);u--;)e[u]=0;for(c=l;c--;){for(l=0,u=a+c;u>c;)l=e[u]+o[c]*i[u-c-1]+l,e[u--]=l%10,l=l/10|0;e[u]=l}for(l?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t},y.toExponential=function(t,e){var r=this,n=r.c[0];if(t!==d){if(t!==~~t||t<0||t>u)throw Error(h);for(r=m(new r.constructor(r),++t,e);r.c.length<t;)r.c.push(0)}return g(r,!0,!!n)},y.toFixed=function(t,e){var r=this,n=r.c[0];if(t!==d){if(t!==~~t||t<0||t>u)throw Error(h);for(t=t+(r=m(new r.constructor(r),t+r.e+1,e)).e+1;r.c.length<t;)r.c.push(0)}return g(r,!1,!!n)},y[Symbol.for("nodejs.util.inspect.custom")]=y.toJSON=y.toString=function(){var t=this,e=t.constructor;return g(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])},y.toNumber=function(){var t=Number(g(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(t.toString()))throw Error(s+"Imprecise conversion");return t},y.toPrecision=function(t,e){var r=this,n=r.constructor,i=r.c[0];if(t!==d){if(t!==~~t||t<1||t>u)throw Error(f+"precision");for(r=m(new n(r),t,e);r.c.length<t;)r.c.push(0)}return g(r,t<=r.e||r.e<=n.NE||r.e>=n.PE,!!i)},y.valueOf=function(){var t=this,e=t.constructor;if(!0===e.strict)throw Error(s+"valueOf disallowed");return g(t,t.e<=e.NE||t.e>=e.PE,!0)},function t(){function e(r){var n=this;if(!(n instanceof e))return r===d?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(f+"value");r=0===r&&1/r<0?"-0":String(r)}!function(t,e){var r,n,i;if(!b.test(e))throw Error(f+"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=y,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=!1,e.roundDown=0,e.roundHalfUp=1,e.roundHalfEven=2,e.roundUp=3,e}();var j=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=S(e),function(t,e){if(e&&("object"==w(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,O()?Reflect.construct(e,r||[],S(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&&P(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(_(Error));function A(t){return A="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},A(t)}function E(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,k(n.key),n)}}function R(t,e,r){return(e=k(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function k(t){var e=function(t,e){if("object"!=A(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=A(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==A(e)?e:e+""}var I=function(){return t=function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),R(this,"previousHighest",void 0),R(this,"highest",void 0),R(this,"previousLowest",void 0),R(this,"lowest",void 0),R(this,"previousResult",void 0),R(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 j;return this.result}},{key:"setResult",value:function(t,e){return e&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:t>this.highest?(this.previousHighest=this.highest,this.highest=t):this.previousHighest=this.highest,void 0===this.lowest?this.lowest=t:t<this.lowest?(this.previousLowest=this.lowest,this.lowest=t):this.previousLowest=this.lowest,this.previousResult=this.result,this.result=t}},{key:"replace",value:function(t){return this.update(t,!0)}}])&&E(t.prototype,e),r&&E(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function M(t){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(t)}function T(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,L(n.key),n)}}function C(t,e,r){return e=x(e),function(t,e){if(e&&("object"==M(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,D()?Reflect.construct(e,r||[],x(t).constructor):e.apply(t,r))}function D(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(D=function(){return!!t})()}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}function B(t,e){return B=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},B(t,e)}function L(t){var e=function(t,e){if("object"!=M(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=M(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==M(e)?e:e+""}var z=function(t){function e(t){var r,n,i,o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=r=C(this,e),o=void 0,(i=L(i="interval"))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o,r.interval=t,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&B(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)}}])&&T(r.prototype,n),i&&T(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(I);function F(t){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},F(t)}function N(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,G(n.key),n)}}function V(t,e,r){return e=q(e),function(t,e){if(e&&("object"==F(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,H()?Reflect.construct(e,r||[],q(t).constructor):e.apply(t,r))}function H(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(H=function(){return!!t})()}function q(t){return q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},q(t)}function U(t,e){return U=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},U(t,e)}function G(t){var e=function(t,e){if("object"!=F(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=F(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==F(e)?e:e+""}var $=function(t){function e(){var t,r,n,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return r=t=V(this,e,[].concat(a)),i=[],(n=G(n="prices"))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&U(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t),this.prices.length>this.interval&&this.prices.shift(),this.prices.length===this.interval){var r=this.prices.reduce((function(t,e){return t+e}),0);return this.setResult(r/this.prices.length,e)}}}],n&&N(r.prototype,n),i&&N(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(z);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 J(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,tt(n.key),n)}}function K(t,e,r){return e=Q(e),function(t,e){if(e&&("object"==W(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Y()?Reflect.construct(e,r||[],Q(t).constructor):e.apply(t,r))}function Y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Y=function(){return!!t})()}function Q(t){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Q(t)}function X(t,e){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},X(t,e)}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"!=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 et=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=K(this,e),"interval",void 0),Z(r,"indicator",void 0),Z(r,"smoothingFactor",void 0),r.interval=t,r.indicator=new $(t),r.smoothingFactor=1/r.interval,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&X(t,e)}(e,t),r=e,n=[{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.indicator.update(t);if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e&&void 0!==this.result){var i=(t-this.result)*this.smoothingFactor;return this.setResult(i+this.result,e)}if(void 0===this.result&&void 0!==r)return this.setResult(r,e)}}],n&&J(r.prototype,n),i&&J(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(I);function rt(t){return t.length?t.reduce((function(t,e){return t+e}),0)/t.length:0}function nt(t){return nt="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},nt(t)}function it(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,at(n.key),n)}}function ot(t,e,r){return(e=at(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function at(t){var e=function(t,e){if("object"!=nt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=nt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nt(e)?e:e+""}var lt=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),ot(this,"interval",void 0),ot(this,"deviationMultiplier",void 0),ot(this,"prices",[]),ot(this,"result",void 0),this.interval=e,this.deviationMultiplier=r},(e=[{key:"update",value:function(t){if(this.prices.push(t),this.prices.length>this.interval){this.prices.shift();var e=rt(this.prices),r=function(t,e){var r=e||rt(t),n=rt(t.map((function(t){return t-r})).map((function(t){return t*t})));return Math.sqrt(n)}(this.prices,e);return this.result={lower:e-r*this.deviationMultiplier,middle:e,upper:e+r*this.deviationMultiplier}}}},{key:"getResult",value:function(){if(void 0===this.result)throw new j;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}}])&&it(t.prototype,e),r&&it(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function ct(t){return ct="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ct(t)}function ut(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,yt(n.key),n)}}function st(t,e,r){return e=ht(e),function(t,e){if(e&&("object"==ct(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,ft()?Reflect.construct(e,r||[],ht(t).constructor):e.apply(t,r))}function ft(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ft=function(){return!!t})()}function ht(t){return ht=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ht(t)}function vt(t,e){return vt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},vt(t,e)}function pt(t,e,r){return(e=yt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function yt(t){var e=function(t,e){if("object"!=ct(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ct(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ct(e)?e:e+""}var dt=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),pt(r=st(this,e,[t]),"interval",void 0),pt(r,"pricesCounter",0),pt(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&&vt(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?e&&0===this.pricesCounter&&this.pricesCounter++:this.pricesCounter++,e&&void 0!==this.previousResult?this.setResult(t*this.weightFactor+this.previousResult*(1-this.weightFactor),e):this.setResult(t*this.weightFactor+(void 0!==this.result?this.result:t)*(1-this.weightFactor),e)}},{key:"getResult",value:function(){if(this.pricesCounter<this.interval)throw new j;return this.result}},{key:"isStable",get:function(){try{return this.getResult(),!0}catch(t){return!1}}}],n&&ut(r.prototype,n),i&&ut(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(z);function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function mt(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,wt(n.key),n)}}function gt(t,e,r){return(e=wt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function wt(t){var e=function(t,e){if("object"!=bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bt(e)?e:e+""}var _t=function(){return t=function t(e,r,n){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),gt(this,"short",void 0),gt(this,"long",void 0),gt(this,"signal",void 0),gt(this,"prices",[]),gt(this,"result",void 0),this.short=e,this.long=r,this.signal=n},e=[{key:"getResult",value:function(){if(void 0===this.result)throw new j;return this.result}},{key:"isStable",get:function(){return void 0!==this.result}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.prices.length&&e?this.prices[this.prices.length-1]=t:this.prices.push(t);var r=this.short.update(t,e),n=this.long.update(t,e);if(this.prices.length>this.long.interval&&this.prices.shift(),this.prices.length===this.long.interval){var i=r-n,o=this.signal.update(i,e);return this.result={histogram:i-o,macd:i,signal:o}}}}],e&&mt(t.prototype,e),r&&mt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function Ot(t){return Ot="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},Ot(t)}function Pt(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,kt(n.key),n)}}function St(t,e,r){return e=At(e),function(t,e){if(e&&("object"==Ot(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,jt()?Reflect.construct(e,r||[],At(t).constructor):e.apply(t,r))}function jt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(jt=function(){return!!t})()}function At(t){return At=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},At(t)}function Et(t,e){return Et=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Et(t,e)}function Rt(t,e,r){return(e=kt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function kt(t){var e=function(t,e){if("object"!=Ot(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ot(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ot(e)?e:e+""}var It=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Rt(r=St(this,e),"interval",void 0),Rt(r,"previousPrices",[]),Rt(r,"avgGain",void 0),Rt(r,"avgLoss",void 0),Rt(r,"maxValue",100),r.interval=t,r.avgGain=new n(r.interval),r.avgLoss=new n(r.interval),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Et(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.previousPrices.length&&e?this.previousPrices[this.previousPrices.length-1]=t:this.previousPrices.push(t),!(this.previousPrices.length<2)){var r=t,n=this.previousPrices[this.previousPrices.length-2];if(r>n?(this.avgLoss.update(0,e),this.avgGain.update(t-n,e)):(this.avgLoss.update(n-r,e),this.avgGain.update(0,e)),this.avgGain.isStable){var i=this.avgLoss.getResult();if(0===i)return this.setResult(100,e);var o=this.avgGain.getResult()/i;return this.setResult(this.maxValue-this.maxValue/(o+1),e)}}}}],n&&Pt(r.prototype,n),i&&Pt(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n,i}(I);function Mt(t){return function(t){if(Array.isArray(t))return Tt(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 Tt(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)?Tt(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 Tt(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 Ct=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5;if(null===t||null===e||null===r)return null;if(n<2)throw new Error("numLevels must be at least 2");for(var i=4*r/(n-1),o=[],a=0;a<n-1;a++)o.push(e-2*r+a*i);for(var l=o.length-1;l>=0;l--)if(t>o[l])return(l+1)/(n-1);return 0};function Dt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Lt(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){l=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw o}}}}function xt(t){return function(t){if(Array.isArray(t))return zt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Lt(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 Bt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,l=[],c=!0,u=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(t){u=!0,i=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return l}}(t,e)||Lt(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 Lt(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}}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 Ft={rsi:function(t,e,r){var n,i,o=t.verticalOhlcv.close[e];t.instances.hasOwnProperty("rsi_".concat(r))||(t.autoCrossPairsList.push({fast:"rsi_".concat(r),slow:"rsi_sma_".concat(r)}),t.instances["rsi_".concat(r)]=new It(r),t.instances["rsi_sma_".concat(r)]=new $(r),t.verticalOhlcv["rsi_".concat(r)]=new Array(t.len).fill(null),t.verticalOhlcv["rsi_sma_".concat(r)]=new Array(t.len).fill(null)),t.instances["rsi_".concat(r)].update(o);try{n=t.instances["rsi_".concat(r)].getResult()}catch(t){n=null}n&&(t.verticalOhlcv["rsi_".concat(r)][e]=n,t.instances["rsi_sma_".concat(r)].update(n));try{i=t.instances["rsi_sma_".concat(r)].getResult()}catch(t){i=null}return i&&(t.verticalOhlcv["rsi_sma_".concat(r)][e]=i),!0},sma:function(t,e,r){var n,i=t.verticalOhlcv.close[e];t.instances.hasOwnProperty("sma_".concat(r))||(t.instances["sma_".concat(r)]=new $(r),t.verticalOhlcv["sma_".concat(r)]=new Array(t.len).fill(null)),t.instances["sma_".concat(r)].update(i);try{n=t.instances["sma_".concat(r)].getResult()}catch(t){n=null}n&&(t.verticalOhlcv["sma_".concat(r)][e]=n)},ema:function(t,e,r){var n,i=t.verticalOhlcv.close[e];t.instances.hasOwnProperty("ema_".concat(r))||(t.instances["ema_".concat(r)]=new dt(r),t.verticalOhlcv["ema_".concat(r)]=new Array(t.len).fill(null)),t.instances["ema_".concat(r)].update(i);try{n=t.instances["ema_".concat(r)].getResult()}catch(t){n=null}n&&(t.verticalOhlcv["ema_".concat(r)][e]=n)},macd:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:12,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:26,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:9,o=t.verticalOhlcv.close[e];t.instances.hasOwnProperty("macd")||(t.autoCrossPairsList.push({fast:"macd_diff",slow:"macd_dea"}),t.instances.macd=new _t(new dt(r),new dt(n),new dt(i)),t.verticalOhlcv.macd_diff=new Array(t.len).fill(null),t.verticalOhlcv.macd_dea=new Array(t.len).fill(null),t.verticalOhlcv.macd_histogram=new Array(t.len).fill(null));var a,l=t.instances.macd;l.update(o);try{a=l.getResult()}catch(t){a={macd:null,signal:null,histogram:null}}var c=a,u=c.macd,s=c.signal,f=c.histogram;return null!==u&&(t.verticalOhlcv.macd_diff[e]=u),null!==s&&(t.verticalOhlcv.macd_dea[e]=s),null!==f&&(t.verticalOhlcv.macd_histogram[e]=f),!0},relativeVolume:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,n=t.verticalOhlcv.volume[e];t.instances.hasOwnProperty("relative_volume_".concat(r))||(t.instances["relative_volume_".concat(r)]=new $(r),t.verticalOhlcv["relative_volume_".concat(r)]=new Array(t.len).fill(null),t.verticalOhlcv["relative_volume_sma_".concat(r)]=new Array(t.len).fill(null));var i,o=t.instances["relative_volume_".concat(r)];o.update(n);try{i=o.getResult()}catch(t){i=null}return t.verticalOhlcv["relative_volume_sma_".concat(r)][e]=i,null!==i&&"number"==typeof t.verticalOhlcv["relative_volume_sma_".concat(r)][e-1]?t.verticalOhlcv["relative_volume_".concat(r)][e]=n/t.verticalOhlcv["relative_volume_sma_".concat(r)][e-1]:t.verticalOhlcv["relative_volume_".concat(r)][e]=null,!0},donchianChannels:function(t,e,r,n){var i=t.verticalOhlcv,o=i.high,a=i.low;if(e-n<r-1)return!0;t.instances.hasOwnProperty("donchian_channels")||(t.instances.donchian_channels={},i.donchian_channel_upper=new Array(t.len).fill(null),i.donchian_channel_basis=new Array(t.len).fill(null),i.donchian_channel_lower=new Array(t.len).fill(null));var l=e-n+1,c=l-r;if(c<0||l>t.len)return!0;var u=o.slice(c,l),s=a.slice(c,l),f=Math.max.apply(Math,Mt(u)),h=Math.min.apply(Math,Mt(s)),v=(f+h)/2,p=e;return p>=0&&p<t.len&&(i.donchian_channel_upper[p]=f,i.donchian_channel_basis[p]=v,i.donchian_channel_lower[p]=h),!0},bollingerBands:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=t.verticalOhlcv.close[e];t.instances.hasOwnProperty("bollinger_bands")||(t.instances.bollinger_bands={instance:new lt(r,n),heightInstance:i?new $(r):null},t.verticalOhlcv.bollinger_bands_upper=new Array(t.len).fill(null),t.verticalOhlcv.bollinger_bands_middle=new Array(t.len).fill(null),t.verticalOhlcv.bollinger_bands_lower=new Array(t.len).fill(null),i&&(t.verticalOhlcv.bollinger_bands_range=new Array(t.len).fill(null),t.verticalOhlcv.bollinger_bands_height=new Array(t.len).fill(null)));var a,l=t.instances.bollinger_bands,c=l.instance,u=l.heightInstance;c.update(o);try{a=c.getResult()}catch(t){a={upper:null,middle:null,lower:null}}var s=a,f=s.upper,h=s.middle,v=s.lower;if(t.verticalOhlcv.bollinger_bands_upper[e]=f,t.verticalOhlcv.bollinger_bands_middle[e]=h,t.verticalOhlcv.bollinger_bands_lower[e]=v,!i)return!0;var p,y=null,d=null;if(null!==f&&null!==v){y=(o-v)/(f-v),d=f-v,u.update(d);try{p=u.getResult()}catch(t){p=null}}return t.verticalOhlcv.bollinger_bands_range[e]=y,t.verticalOhlcv.bollinger_bands_height[e]=Ct(d,p,1.5),!0},volumeOscillator:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,i=t.verticalOhlcv.volume[e];t.instances.hasOwnProperty("volume_oscillator")||(t.instances.volume_oscillator={fastEMA:new dt(r),slowEMA:new dt(n)},t.verticalOhlcv.volume_oscillator=new Array(t.len).fill(null),t.autoCrossPairsList.push({fast:"volume_oscillator",slow:0}));var o=t.instances.volume_oscillator,a=o.fastEMA,l=o.slowEMA;a.update(i),l.update(i);var c=null,u=null;try{c=a.getResult()}catch(t){c=null}try{u=l.getResult()}catch(t){u=null}return t.verticalOhlcv.volume_oscillator[e]="number"==typeof c&&"number"==typeof u&&0!==u?100*(c-u)/u:null,!0},candlesStudies:function(t,e,r){for(var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},o=i.changeLevel,a=void 0===o?7:o,l=i.sizeLevel,c=void 0===l?5:l,u=0,s=["candle_gap_size","candle_body_size","candle_top_size","candle_bottom_size","candle_shadow_size","candle_close_direction","candle_high_direction","candle_low_direction","candle_open_direction"];u<s.length;u++){var f=s[u];t.verticalOhlcv.hasOwnProperty(f)||(t.verticalOhlcv[f]=new Array(t.len).fill(null))}if(n){t.instances.hasOwnProperty("candleStudies")||(t.instances.candleStudies={});for(var h=0,v=["topInstance","bottomInstance","gapInstance","bodySizeInstance","shadowSizeInstance","closeDirectionInstance","highDirectionInstance","lowDirectionInstance","openDirectionInstance"];h<v.length;h++){var p=v[h];t.instances.candleStudies.hasOwnProperty(p)||(t.instances.candleStudies[p]=new $(r))}}var y=t.verticalOhlcv.open[e-1],d=t.verticalOhlcv.high[e-1],b=t.verticalOhlcv.low[e-1],m=t.verticalOhlcv.close[e-1];if([y,d,b,m].some((function(t){return void 0===t})))return!0;var g=t.verticalOhlcv.open[e],w=t.verticalOhlcv.high[e],_=t.verticalOhlcv.low[e],O=t.verticalOhlcv.close[e],P=O>g,S=Math.abs(O-g),j=Math.abs(w-_),A=w-Math.max(g,O),E=Math.min(g,O)-_,R=Math.abs(m-g),k=Math.abs(O-m),I=Math.abs(w-d),M=Math.abs(_-b),T=Math.abs(g-y),C=null,D=null,x=null,B=null,L=null,z=null,F=null,N=null,V=null;if(n){var H=t.instances.candleStudies,q=H.topInstance,U=H.bottomInstance,G=H.gapInstance,W=H.bodySizeInstance,J=H.shadowSizeInstance,K=H.closeDirectionInstance,Y=H.highDirectionInstance,Q=H.lowDirectionInstance,X=H.openDirectionInstance;q.update(Math.abs(A)),U.update(Math.abs(E)),J.update(Math.abs(j)),G.update(R),W.update(S),K.update(k),Y.update(I),Q.update(M),X.update(T);try{x=q.getResult(),D=U.getResult(),C=G.getResult(),B=W.getResult(),L=J.getResult(),z=K.getResult(),F=Y.getResult(),N=Q.getResult(),V=X.getResult()}catch(t){}t.verticalOhlcv.candle_body_size[e]=P?Ct(S,B,2,a):-Math.abs(Ct(S,B,2,a))||0,t.verticalOhlcv.candle_gap_size[e]=P?Ct(R,C,2,a):-Math.abs(Ct(R,C,2,a))||0,t.verticalOhlcv.candle_close_direction[e]=P?Ct(k,z,2,a):-Math.abs(Ct(k,z,2,a))||0,t.verticalOhlcv.candle_high_direction[e]=P?Ct(I,F,2,a):-Math.abs(Ct(I,F,2,a))||0,t.verticalOhlcv.candle_low_direction[e]=P?Ct(M,N,2,a):-Math.abs(Ct(M,N,2,a))||0,t.verticalOhlcv.candle_open_direction[e]=P?Ct(T,V,2,a):-Math.abs(Ct(T,V,2,a))||0,t.verticalOhlcv.candle_top_size[e]=Ct(A,x,.5,c),t.verticalOhlcv.candle_bottom_size[e]=Ct(E,D,.5,c),t.verticalOhlcv.candle_shadow_size[e]=Ct(j,L,.5,c)}else t.verticalOhlcv.candle_body_size[e]=P?S:-S,t.verticalOhlcv.candle_gap_size[e]=P?R:-R,t.verticalOhlcv.candle_close_direction[e]=P?k:-k,t.verticalOhlcv.candle_high_direction[e]=P?I:-I,t.verticalOhlcv.candle_low_direction[e]=P?M:-M,t.verticalOhlcv.candle_open_direction[e]=P?T:-T,t.verticalOhlcv.candle_top_size[e]=A,t.verticalOhlcv.candle_bottom_size[e]=E,t.verticalOhlcv.candle_shadow_size[e]=j;return!0},lag:function(t,e){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:["close"],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=t.verticalOhlcv,o=t.len,a=0;a<r.length;a++)for(var l=1;l<=n;l++){var c="".concat(r[a],"_lag_").concat(l);i.hasOwnProperty(c)||(i[c]=new Array(o).fill(null));var u=e-l,s=u>=0?i[r[a]][u]:null;i[c][e]=s}return!0}},Nt={midPriceOpenClose:!1,midPriceHighLow:!1,sessionIndex:!1,sessionIntradayIndex:!1,dayOfTheWeek:!1,dayOfTheMonth:!1,weekOfTheMonth:!1},Vt=function(t){var e=new Date(t),r=e.getDay(),n=e.getDate(),i=new Date(e.getFullYear(),e.getMonth(),1).getDay();return{day_of_the_week:r,day_of_the_month:n,week_of_the_month:Math.ceil((n+i)/7)}},Ht=function(t,e){for(var r=t.length,n=new $(e),i=new Array(r),o=0,a=0,l=0,c=0;c<r;c++)if(n.update(t[c]),n.isStable){var u=n.getResult();i[c]=u,o+=u,a+=u*u,l++}else i[c]=null;var s=o/l,f=a/l-s*s,h=Math.sqrt(f);return i.map((function(t){return null!==t?(t-s)/h:null}))},qt=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;if(t.length!==e.length)throw new Error("Both arrays must have the same length");for(var n=Ht(t,r),i=Ht(e,r),o=t.length,a=[],l=0,c=0,u=0,s=0,f=0,h=0,v=-1,p=0;p<o;p++){if(null!==n[p]&&null!==i[p]){v=p;break}a.push(0)}if(-1===v)return new Array(o).fill(0);for(var y=v;y<o;y++){var d=n[y],b=i[y];if(null!==d&&null!==b)if(l+=d,c+=b,u+=d*b,s+=d*d,f+=b*b,++h<2)a.push(0);else{var m=h*u-l*c,g=Math.sqrt((h*s-l*l)*(h*f-c*c)),w=0===g?0:m/g;a.push(w)}else l=c=u=s=f=h=0,a.push(0)}return a};function Ut(t){return function(t){if(Array.isArray(t))return Wt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||$t(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 Gt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,l=[],c=!0,u=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(t){u=!0,i=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return l}}(t,e)||$t(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 $t(t,e){if(t){if("string"==typeof t)return Wt(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)?Wt(t,e):void 0}}function Wt(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 Jt=function(t){for(var e=t.input,r=t.inputParams,n=new(0,t.OHLCV_INDICATORS)({input:e,studyOptions:t.studyOptions}),i=0,o=Object.entries(r);i<o.length;i++){var a=Gt(o[i],2),l=a[0],c=a[1];if(!["crossPairs","lag"].includes(l)&&Array.isArray(c))for(var u=0;u<c.length;u++){var s=c[u];Array.isArray(s)&&(s.length>0?n[l].apply(n,Ut(s)):n[l]())}}for(var f=0,h=Object.entries(r);f<h.length;f++){var v=Gt(h[f],2),p=v[0],y=v[1];if(["crossPairs","lag"].includes(p)&&Array.isArray(y))for(var d=0;d<y.length;d++){var b=y[d];Array.isArray(b)&&(b.length>0?n[p].apply(n,Ut(b)):n[p]())}}return n};function Kt(t){return Kt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kt(t)}function Yt(t){return function(t){if(Array.isArray(t))return 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=e.input,n=e.ticker,i=void 0===n?null:n,o=e.studyOptions,a=void 0===o?null:o;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!Array.isArray(r))throw Error("input ohlcv must be an array: "+i);if(0===r.length)throw Error("input ohlcv must not be empty: "+i);if(!r[0].hasOwnProperty("close"))throw Error("input ohlcv array objects require at least close property: "+i);return this.input=r,this.priceBased=["open","high","low","close","mid_price_open_close","mid_price_high_low"],this.len=r.length,this.crossPairsArr=[],this.inputOhlcv=r,this.studyOptions=null===a?Nt:a,this.instances={},this.autoCrossPairsList=[],this.verticalOhlcv={},this.inputParams={crossPairs:null,lag:null,relativeVolume:null,ema:null,sma:null,macd:null,bollingerBands:null,rsi:null,donchianChannels:null,candlesStudies:null,volumeOscillator:null},this.studies={},this.utilities={correlation:qt},this.setIndicatorsFromInputParams=Jt,this},e=[{key:"getData",value:function(){this.compute();for(var t=this.verticalOhlcv,e=Object.keys(t),r=t[e[0]].length,n=e.length,i=[],o=0;o<r;o++){for(var a={},l=!1,c=0;c<n;c++){var u=e[c],s=t[u][o];if(null==s){l=!0;break}a[u]=s}l||i.push(a)}return i}},{key:"getLastValues",value:function(){return this.getData()[this.getData().length-1]}},{key:"compute",value:function(){return function(t,e){var r=e.len,n=e.studyOptions,i=e.inputParams;if(Boolean(n))for(var o in n)if(!Nt.hasOwnProperty(o))throw new Error("Key ".concat(o," not found in defaultStudyOptions. Available options: ").concat(Object.keys(Nt).join(", ")));var a=n.midPriceOpenClose,l=n.midPriceHighLow,c=n.sessionIndex,u=n.sessionIntradayIndex,s=n.dayOfTheWeek,f=n.dayOfTheMonth,h=n.weekOfTheMonth,v=["open","high","low","close","volume"];a&&v.push("mid_price_open_close"),l&&v.push("mid_price_high_low");for(var p=new Set(v),y=0,d=v;y<d.length;y++){var b=d[y];e.verticalOhlcv[b]=new Array(r)}for(var m,g=[],w=0,_=Object.keys(t[0]);w<_.length;w++){var O=_[w];p.has(O)||(e.verticalOhlcv[O]=new Array(r),g.push(O))}var P,S=0,j=0,A=(P=t)[0].hasOwnProperty("date")&&"string"==typeof P[0].date&&/^\d{4}-\d{2}-\d{2}/.test(P[0].date);A&&(c&&(e.verticalOhlcv.session_index=new Array(r)),u&&(e.verticalOhlcv.session_intraday_index=new Array(r)),s&&(e.verticalOhlcv.day_of_the_week=new Array(r)),f&&(e.verticalOhlcv.day_of_the_month=new Array(r)),h&&(e.verticalOhlcv.week_of_the_month=new Array(r)),m=t[0].date.slice(0,10));for(var E=0;E<r;E++){var R=t[E];e.verticalOhlcv.open[E]=R.open,e.verticalOhlcv.high[E]=R.high,e.verticalOhlcv.low[E]=R.low,e.verticalOhlcv.close[E]=R.close,e.verticalOhlcv.volume[E]=R.volume;for(var k=0,I=Object.entries(i);k<I.length;k++){var M=Bt(I[k],2),T=M[0],C=M[1];if(!["crossPairs"].includes(T)&&Array.isArray(C))for(var D=0;D<C.length;D++){var x=C[D];Array.isArray(x)&&(x.length>0?Ft[T].apply(Ft,[e,E].concat(xt(x))):Ft[T](e,E))}}a&&(e.verticalOhlcv.mid_price_open_close[E]=(R.open+R.close)/2),l&&(e.verticalOhlcv.mid_price_high_low[E]=(R.high+R.low)/2);var B,L=Dt(g);try{for(L.s();!(B=L.n()).done;){var z=B.value;e.verticalOhlcv[z][E]=R[z]}}catch(t){L.e(t)}finally{L.f()}if(A){var F=R.date.slice(0,10);F!==m&&(m=F,S++,j=0);var N=Vt(F),V=N.day_of_the_week,H=N.day_of_the_month,q=N.week_of_the_month;s&&(e.verticalOhlcv.day_of_the_week[E]=V),f&&(e.verticalOhlcv.day_of_the_month[E]=H),h&&(e.verticalOhlcv.week_of_the_month[E]=q),c&&(e.verticalOhlcv.session_index[E]=S),u&&(e.verticalOhlcv.session_intraday_index[E]=j),j++}}}(this.input,this),this}},{key:"crossPairs",value:function(t){var e,n;this.compute();var i=[].concat(Yt(this.autoCrossPairsList),Yt(t));null!==(n=(e=this.inputParams).crossPairs)&&void 0!==n||(e.crossPairs=[]),this.inputParams.crossPairs.push([i]);var o=function(t,e){var n,i=t.verticalOhlcv,o=t.len,l={},c={},u={},s=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},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 a,l=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return l=t.done,t},e:function(t){c=!0,a=t},f:function(){try{l||null==n.return||n.return()}finally{if(c)throw a}}}}(e);try{var f=function(){var t=n.value,e=t.fast,r=t.slow,s=t.count;if(!e||!r)return 1;"number"!=typeof r||l[r]||(l[r]=Array(o).fill(r));var f="".concat(e,"_x_").concat(r),h="".concat(e,"_c_").concat(r),v=function(t){return void 0!==s?t.slice(-s).filter((function(t){return 1===t||-1===t})).length:0};if(i[f]){var p=i[f];c[f]=p,void 0!==s&&(u[h]=v(p))}else if((i[e]||"price"===e)&&i[r]){var y=a("price"===e?{fast:i.close,high:i.high,low:i.low,slow:i[r]}:{fast:i[e],slow:i[r]});c[f]=y,void 0!==s&&(u[h]=v(y))}else{if(!i[e]||!l[r])throw Error("Missing ohlcv properties for ".concat(e," or ").concat(r));var d=a({fast:i[e],slow:l[r]});c[f]=d,void 0!==s&&(u[h]=v(d))}};for(s.s();!(n=s.n()).done;)f()}catch(t){s.e(t)}finally{s.f()}return{x:c,c:u}}(this,i),l=o.x,c=o.c;return Object.assign(this.verticalOhlcv,l),Object.assign(this.studies,c),this}},{key:"lag",value:function(){var t,e,r=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;null!==(e=(t=this.inputParams).lag)&&void 0!==e||(t.lag=[]),this.inputParams.lag.push([n,i]);for(var o=function(){var t=n[a];r.priceBased.find((function(e){return t.startsWith(e)}))&&r.priceBased.push(t)},a=0;a<n.length;a++)o();return this}},{key:"relativeVolume",value:function(t){var e,r;return null!==(r=(e=this.inputParams).relativeVolume)&&void 0!==r||(e.relativeVolume=[]),this.inputParams.relativeVolume.push([t]),this}},{key:"ema",value:function(t){var e,r;return null!==(r=(e=this.inputParams).ema)&&void 0!==r||(e.ema=[]),this.inputParams.ema.push([t]),this.priceBased.push("ema_".concat(t)),this}},{key:"sma",value:function(t){var e,r;return null!==(r=(e=this.inputParams).sma)&&void 0!==r||(e.sma=[]),this.inputParams.sma.push([t]),this.priceBased.push("sma_".concat(t)),this}},{key:"macd",value:function(t,e,r){var n,i;return null!==(i=(n=this.inputParams).macd)&&void 0!==i||(n.macd=[]),this.inputParams.macd.push([t,e,r]),this}},{key:"bollingerBands",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,i=arguments.length>2?arguments[2]:void 0;if("number"!=typeof r||r<=0)throw new Error('Invalid parameter: "size" must be a positive number.');if("number"!=typeof n||n<=0)throw new Error('Invalid parameter: "times" must be a positive number.');return null!==(e=(t=this.inputParams).bollingerBands)&&void 0!==e||(t.bollingerBands=[]),this.inputParams.bollingerBands.push([r,n,i]),this.priceBased.push("bollinger_bands_middle","bollinger_bands_upper","bollinger_bands_lower"),this}},{key:"rsi",value:function(t){var e,r;return null!==(r=(e=this.inputParams).rsi)&&void 0!==r||(e.rsi=[]),this.inputParams.rsi.push([t]),this}},{key:"donchianChannels",value:function(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if("number"!=typeof r||r<=0)throw new Error('The "period" must be a positive number.');if("number"!=typeof n||n<=0)throw new Error('The "offset" must be a positive number.');return null!==(e=(t=this.inputParams).donchianChannels)&&void 0!==e||(t.donchianChannels=[]),this.inputParams.donchianChannels.push([r,n]),this.priceBased.push("donchian_channel_upper","donchian_channel_lower","donchian_channel_basis"),this}},{key:"candlesStudies",value:function(t,e,r){var n,i;return null!==(i=(n=this.inputParams).candlesStudies)&&void 0!==i||(n.candlesStudies=[]),this.inputParams.candlesStudies.push([t,e,r]),this}},{key:"volumeOscillator",value:function(t,e){var r,n;return null!==(n=(r=this.inputParams).volumeOscillator)&&void 0!==n||(r.volumeOscillator=[]),this.inputParams.volumeOscillator.push([t,e]),this}}],e&&Xt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
|
package/index.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import { relativeVolume } from './src/moving-averages/relativeVolume.js'
|
|
2
|
-
import {ema} from './src/moving-averages/ema.js'
|
|
3
|
-
import {sma} from './src/moving-averages/sma.js'
|
|
4
|
-
import {macd} from './src/moving-averages/macd.js'
|
|
5
|
-
import {bollingerBands} from './src/moving-averages/bollingerBands.js'
|
|
6
|
-
import { rsi } from './src/oscillators/rsi.js'
|
|
7
1
|
import {crossPairs} from './src/studies/findCrosses.js'
|
|
8
|
-
import { orb } from './src/oscillators/orb.js'
|
|
9
|
-
import { donchianChannels } from './src/moving-averages/donchianChannel.js'
|
|
10
2
|
import { parseOhlcvToVertical, defaultStudyOptions } from './src/utilities/parsing-utilities.js'
|
|
11
|
-
import { candlesStudies } from './src/studies/candleStudies.js'
|
|
12
3
|
import { correlation } from './src/studies/correlation.js'
|
|
13
|
-
import {
|
|
4
|
+
import { setIndicatorsFromInputParams } from './src/utilities/setIndicatorsFromInputParams.js'
|
|
14
5
|
|
|
15
6
|
export default class OHLCV_INDICATORS {
|
|
16
7
|
constructor({input, ticker = null, studyOptions = null}) {
|
|
@@ -19,22 +10,44 @@ export default class OHLCV_INDICATORS {
|
|
|
19
10
|
if(input.length === 0) throw Error('input ohlcv must not be empty: ' + ticker)
|
|
20
11
|
if(!input[0].hasOwnProperty('close')) throw Error('input ohlcv array objects require at least close property: ' + ticker)
|
|
21
12
|
|
|
13
|
+
this.input = input
|
|
22
14
|
this.priceBased = ['open', 'high', 'low', 'close', 'mid_price_open_close', 'mid_price_high_low']
|
|
23
15
|
this.len = input.length
|
|
24
|
-
this.crossPairsArr = []
|
|
25
|
-
this.inputOhlcv = input
|
|
26
16
|
this.studyOptions = (studyOptions === null) ? defaultStudyOptions : studyOptions
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
17
|
+
this.instances = {}
|
|
18
|
+
this.autoCrossPairsList = []
|
|
19
|
+
this.verticalOhlcv = {}
|
|
20
|
+
|
|
21
|
+
this.inputParams = {
|
|
22
|
+
crossPairs: null,
|
|
23
|
+
lag: null,
|
|
24
|
+
relativeVolume: null,
|
|
25
|
+
ema: null,
|
|
26
|
+
sma: null,
|
|
27
|
+
macd: null,
|
|
28
|
+
bollingerBands: null,
|
|
29
|
+
rsi: null,
|
|
30
|
+
donchianChannels: null,
|
|
31
|
+
candlesStudies: null,
|
|
32
|
+
volumeOscillator: null,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
29
36
|
this.studies = {}
|
|
30
37
|
this.utilities = {
|
|
31
38
|
correlation
|
|
32
39
|
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
this.setIndicatorsFromInputParams = setIndicatorsFromInputParams
|
|
43
|
+
|
|
33
44
|
return this
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
getData() {
|
|
37
|
-
|
|
48
|
+
|
|
49
|
+
this.compute()
|
|
50
|
+
|
|
38
51
|
const {verticalOhlcv} = this
|
|
39
52
|
const keys = Object.keys(verticalOhlcv);
|
|
40
53
|
const len = verticalOhlcv[keys[0]].length;
|
|
@@ -81,200 +94,142 @@ export default class OHLCV_INDICATORS {
|
|
|
81
94
|
|
|
82
95
|
compute() {
|
|
83
96
|
|
|
84
|
-
|
|
85
|
-
if(Object.keys(this.indicators).length === 0) return this
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const addColumn = this.addColumn.bind(this)
|
|
89
|
-
|
|
90
|
-
for(const [key, arr] of Object.entries( this.indicators))
|
|
91
|
-
{
|
|
92
|
-
if(!this.verticalOhlcv.hasOwnProperty(key))
|
|
93
|
-
{
|
|
94
|
-
addColumn(key, arr)
|
|
95
|
-
}
|
|
96
|
-
else
|
|
97
|
-
{
|
|
98
|
-
delete this.indicators[key]
|
|
99
|
-
}
|
|
100
|
-
}
|
|
97
|
+
parseOhlcvToVertical(this.input, this)
|
|
101
98
|
|
|
102
99
|
return this
|
|
103
100
|
}
|
|
104
|
-
|
|
105
|
-
addColumn(key, arr) {
|
|
106
|
-
const {len} = this
|
|
107
|
-
key = key.toLowerCase();
|
|
108
|
-
|
|
109
|
-
if (arr.length > len) {
|
|
110
|
-
throw new Error(`Invalid column data: The length of the new column exceeds the length of the OHLCV data`);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (arr.length < len) {
|
|
114
|
-
const nanCount = len - arr.length
|
|
115
|
-
arr = new Array(nanCount).fill(null).concat(arr)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
this.verticalOhlcv[key] = arr
|
|
119
|
-
}
|
|
120
101
|
|
|
121
102
|
|
|
122
103
|
crossPairs(arr)
|
|
123
104
|
{
|
|
124
|
-
|
|
105
|
+
|
|
125
106
|
this.compute()
|
|
126
107
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
108
|
+
const crossList = [...this.autoCrossPairsList, ...arr]
|
|
109
|
+
this.inputParams.crossPairs ??= []
|
|
110
|
+
this.inputParams.crossPairs.push([crossList])
|
|
130
111
|
|
|
131
|
-
this
|
|
112
|
+
const {x, c} = crossPairs(this, crossList)
|
|
113
|
+
Object.assign(this.verticalOhlcv, x)
|
|
114
|
+
Object.assign(this.studies, c)
|
|
132
115
|
|
|
133
116
|
return this
|
|
134
117
|
}
|
|
135
118
|
|
|
136
119
|
lag(colKeys = ['close'], lags = 1) {
|
|
137
|
-
this.compute();
|
|
138
|
-
const {verticalOhlcv, priceBased} = this;
|
|
139
|
-
|
|
140
|
-
for (let x = 0; x < colKeys.length; x++) {
|
|
141
|
-
for (let lag = 1; lag <= lags; lag++) {
|
|
142
|
-
// Create lagged column name and slice the array with the correct lag
|
|
143
|
-
const key = `${colKeys[x]}_lag_${lag}`;
|
|
144
|
-
const values = verticalOhlcv[colKeys[x]].slice(0, -(lag));
|
|
145
|
-
|
|
146
|
-
Object.assign(this.indicators, {[key]: values})
|
|
147
120
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
121
|
+
this.inputParams.lag ??= []
|
|
122
|
+
this.inputParams.lag.push([colKeys, lags])
|
|
123
|
+
|
|
124
|
+
for(let x = 0; x < colKeys.length; x++)
|
|
125
|
+
{
|
|
126
|
+
const key = colKeys[x]
|
|
127
|
+
|
|
128
|
+
if(this.priceBased.find(v => key.startsWith(v)))
|
|
129
|
+
{
|
|
130
|
+
this.priceBased.push(key)
|
|
152
131
|
}
|
|
153
132
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
this.compute();
|
|
133
|
+
|
|
157
134
|
return this;
|
|
158
135
|
}
|
|
159
136
|
|
|
160
137
|
relativeVolume(size) {
|
|
161
138
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
139
|
+
this.inputParams.relativeVolume ??= []
|
|
140
|
+
this.inputParams.relativeVolume.push([size])
|
|
165
141
|
|
|
166
142
|
return this
|
|
167
143
|
}
|
|
168
144
|
|
|
169
145
|
ema(size) {
|
|
170
146
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
this.priceBased.push(`ema_${size}`)
|
|
147
|
+
this.inputParams.ema ??= []
|
|
148
|
+
this.inputParams.ema.push([size])
|
|
149
|
+
this.priceBased.push(`ema_${size}`)
|
|
176
150
|
|
|
177
151
|
return this
|
|
178
152
|
}
|
|
179
153
|
sma(size) {
|
|
180
154
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
155
|
+
this.inputParams.sma ??= []
|
|
156
|
+
this.inputParams.sma.push([size])
|
|
184
157
|
this.priceBased.push(`sma_${size}`)
|
|
185
158
|
|
|
186
159
|
return this
|
|
187
160
|
}
|
|
188
161
|
macd(fastLine, slowLine, signalLine) {
|
|
189
162
|
|
|
190
|
-
|
|
191
|
-
|
|
163
|
+
this.inputParams.macd ??= []
|
|
164
|
+
this.inputParams.macd.push([fastLine, slowLine, signalLine])
|
|
192
165
|
|
|
193
166
|
return this
|
|
194
167
|
|
|
195
168
|
}
|
|
196
|
-
bollingerBands(size, times, bollingerBandsStudies)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
169
|
+
bollingerBands(size = 20, times = 2, bollingerBandsStudies) {
|
|
170
|
+
// Validate size and times
|
|
171
|
+
if (typeof size !== 'number' || size <= 0) {
|
|
172
|
+
throw new Error('Invalid parameter: "size" must be a positive number in bollingerBands.');
|
|
173
|
+
}
|
|
174
|
+
if (typeof times !== 'number' || times <= 0) {
|
|
175
|
+
throw new Error('Invalid parameter: "times" must be a positive number in bollingerBands.');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this.inputParams.bollingerBands ??= [];
|
|
179
|
+
this.inputParams.bollingerBands.push([size, times, bollingerBandsStudies]);
|
|
180
|
+
this.priceBased.push('bollinger_bands_middle', 'bollinger_bands_upper', 'bollinger_bands_lower');
|
|
181
|
+
|
|
182
|
+
return this;
|
|
205
183
|
}
|
|
206
|
-
|
|
184
|
+
|
|
185
|
+
rsi(size)
|
|
207
186
|
{
|
|
187
|
+
// Validate size and times
|
|
188
|
+
if (typeof size !== 'number' || size <= 0) {
|
|
189
|
+
throw new Error('Invalid parameter: "size" must be a positive number in rsi.');
|
|
190
|
+
}
|
|
208
191
|
|
|
209
|
-
|
|
210
|
-
|
|
192
|
+
this.inputParams.rsi ??= []
|
|
193
|
+
this.inputParams.rsi.push([size])
|
|
211
194
|
|
|
212
195
|
return this
|
|
213
196
|
}
|
|
214
|
-
|
|
197
|
+
donchianChannels(size = 20, offset = 0)
|
|
215
198
|
{
|
|
216
|
-
|
|
217
|
-
|
|
199
|
+
if (typeof size !== 'number' || size <= 0) {
|
|
200
|
+
throw new Error('The "size" must be a positive number or 0 in donchianChannels.');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (typeof offset !== 'number' || offset <= 0) {
|
|
204
|
+
throw new Error('The "offset" must be a positive number or 0 in donchianChannels.');
|
|
205
|
+
}
|
|
218
206
|
|
|
219
|
-
this.
|
|
207
|
+
this.inputParams.donchianChannels ??= []
|
|
208
|
+
this.inputParams.donchianChannels.push([size, offset])
|
|
209
|
+
this.priceBased.push('donchian_channel_upper', 'donchian_channel_lower', 'donchian_channel_basis')
|
|
220
210
|
|
|
221
211
|
return this
|
|
222
212
|
}
|
|
223
|
-
|
|
213
|
+
candlesStudies(size = 20, classify = true, classificationLevels)
|
|
224
214
|
{
|
|
225
|
-
const result = donchianChannels(this, period, offset)
|
|
226
|
-
Object.assign(this.indicators, result)
|
|
227
215
|
|
|
228
|
-
|
|
216
|
+
if (typeof size !== 'number' || size <= 0) {
|
|
217
|
+
throw new Error('The "size" must be a positive number or 0 in candlesStudies.');
|
|
218
|
+
}
|
|
229
219
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
{
|
|
234
|
-
const result = candlesStudies(this, period, classify, classificationLevels)
|
|
235
|
-
Object.assign(this.indicators, result)
|
|
220
|
+
if (typeof classify !== 'boolean') {
|
|
221
|
+
throw new Error('The "classify" must be a true or false in candlesStudies.');
|
|
222
|
+
}
|
|
236
223
|
|
|
224
|
+
this.inputParams.candlesStudies ??= []
|
|
225
|
+
this.inputParams.candlesStudies.push([size, classify, classificationLevels])
|
|
237
226
|
return this
|
|
238
227
|
}
|
|
239
228
|
|
|
240
|
-
volumeOscillator(
|
|
229
|
+
volumeOscillator(fastSize, slowSize)
|
|
241
230
|
{
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
231
|
+
this.inputParams.volumeOscillator ??= []
|
|
232
|
+
this.inputParams.volumeOscillator.push([fastSize, slowSize])
|
|
245
233
|
return this
|
|
246
234
|
}
|
|
247
|
-
|
|
248
|
-
map(callback)
|
|
249
|
-
{
|
|
250
|
-
this.compute()
|
|
251
|
-
|
|
252
|
-
const keyNames = Object.keys(this.verticalOhlcv)
|
|
253
|
-
const result = {}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
for(let x = 0; x < this.len; x++)
|
|
257
|
-
{
|
|
258
|
-
let row = {}
|
|
259
|
-
|
|
260
|
-
for(let k = 0; k < keyNames.length; k++)
|
|
261
|
-
{
|
|
262
|
-
Object.assign(row, {[keyNames[k]]: this.verticalOhlcv[keyNames[k]][x]})
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
for(const [k, value] of Object.entries(callback(row)))
|
|
266
|
-
{
|
|
267
|
-
if(x === 0)
|
|
268
|
-
{
|
|
269
|
-
result[k] = new Array(this.len).fill(null)
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
result[k][x] = value
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
Object.assign(this.indicators, result)
|
|
277
|
-
|
|
278
|
-
return this
|
|
279
|
-
}
|
|
280
235
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
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",
|