ohlcv-indicators 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var OHLCV_INDICATORS;(()=>{"use strict";var e={d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};(()=>{e.r(r),e.d(r,{default:()=>P});var t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",l=1e14,u=14,c=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],a=1e7,h=1e9;function p(e){var r=0|e;return e>0||e===r?r:r-1}function m(e){for(var r,t,n=1,i=e.length,s=e[0]+"";n<i;){for(r=e[n++]+"",t=u-r.length;t--;r="0"+r);s+=r}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function g(e,r){var t,n,i=e.c,s=r.c,o=e.s,l=r.s,u=e.e,c=r.e;if(!o||!l)return null;if(t=i&&!i[0],n=s&&!s[0],t||n)return t?n?0:-l:o;if(o!=l)return o;if(t=o<0,n=u==c,!i||!s)return n?0:!i^t?1:-1;if(!n)return u>c^t?1:-1;for(l=(u=i.length)<(c=s.length)?u:c,o=0;o<l;o++)if(i[o]!=s[o])return i[o]>s[o]^t?1:-1;return u==c?0:u>c^t?1:-1}function d(e,r,t,n){if(e<r||e>t||e!==i(e))throw Error(s+(n||"Argument")+("number"==typeof e?e<r||e>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function w(e){var r=e.c.length-1;return p(e.e/u)==r&&e.c[r]%2!=0}function v(e,r){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function y(e,r,t){var n,i;if(r<0){for(i=t+".";++r;i+=t);e=i+e}else if(++r>(n=e.length)){for(i=t,r-=n;--r;i+=t);e+=i}else r<n&&(e=e.slice(0,r)+"."+e.slice(r));return e}const b=function e(r){var b,N,O,B,_,E,A,T,C,D,S=F.prototype={constructor:F,toString:null,valueOf:null},V=new F(1),L=20,P=4,R=-7,x=21,I=-1e7,M=1e7,$=!1,U=1,G=0,j={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},k="0123456789abcdefghijklmnopqrstuvwxyz",q=!0;function F(e,r){var n,s,l,f,a,h,p,m,g=this;if(!(g instanceof F))return new F(e,r);if(null==r){if(e&&!0===e._isBigNumber)return g.s=e.s,void(!e.c||e.e>M?g.c=g.e=null:e.e<I?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(f=0,a=e;a>=10;a/=10,f++);return void(f>M?g.c=g.e=null:(g.e=f,g.c=[e]))}m=String(e)}else{if(!t.test(m=String(e)))return O(g,m,h);g.s=45==m.charCodeAt(0)?(m=m.slice(1),-1):1}(f=m.indexOf("."))>-1&&(m=m.replace(".","")),(a=m.search(/e/i))>0?(f<0&&(f=a),f+=+m.slice(a+1),m=m.substring(0,a)):f<0&&(f=m.length)}else{if(d(r,2,k.length,"Base"),10==r&&q)return X(g=new F(e),L+g.e+1,P);if(m=String(e),h="number"==typeof e){if(0*e!=0)return O(g,m,h,r);if(g.s=1/e<0?(m=m.slice(1),-1):1,F.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(o+e)}else g.s=45===m.charCodeAt(0)?(m=m.slice(1),-1):1;for(n=k.slice(0,r),f=a=0,p=m.length;a<p;a++)if(n.indexOf(s=m.charAt(a))<0){if("."==s){if(a>f){f=p;continue}}else if(!l&&(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase()))){l=!0,a=-1,f=0;continue}return O(g,String(e),h,r)}h=!1,(f=(m=N(m,r,10,g.s)).indexOf("."))>-1?m=m.replace(".",""):f=m.length}for(a=0;48===m.charCodeAt(a);a++);for(p=m.length;48===m.charCodeAt(--p););if(m=m.slice(a,++p)){if(p-=a,h&&F.DEBUG&&p>15&&(e>c||e!==i(e)))throw Error(o+g.s*e);if((f=f-a-1)>M)g.c=g.e=null;else if(f<I)g.c=[g.e=0];else{if(g.e=f,g.c=[],a=(f+1)%u,f<0&&(a+=u),a<p){for(a&&g.c.push(+m.slice(0,a)),p-=u;a<p;)g.c.push(+m.slice(a,a+=u));a=u-(m=m.slice(a)).length}else a-=p;for(;a--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}function H(e,r,t,n){var i,s,o,l,u;if(null==t?t=P:d(t,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,null==r)u=m(e.c),u=1==n||2==n&&(o<=R||o>=x)?v(u,o):y(u,o,"0");else if(s=(e=X(new F(e),r,t)).e,l=(u=m(e.c)).length,1==n||2==n&&(r<=s||s<=R)){for(;l<r;u+="0",l++);u=v(u,s)}else if(r-=o,u=y(u,s,"0"),s+1>l){if(--r>0)for(u+=".";r--;u+="0");}else if((r+=s-l)>0)for(s+1==l&&(u+=".");r--;u+="0");return e.s<0&&i?"-"+u:u}function z(e,r){for(var t,n,i=1,s=new F(e[0]);i<e.length;i++)(!(n=new F(e[i])).s||(t=g(s,n))===r||0===t&&s.s===r)&&(s=n);return s}function W(e,r,t){for(var n=1,i=r.length;!r[--i];r.pop());for(i=r[0];i>=10;i/=10,n++);return(t=n+t*u-1)>M?e.c=e.e=null:t<I?e.c=[e.e=0]:(e.e=t,e.c=r),e}function X(e,r,t,s){var o,c,a,h,p,m,g,d=e.c,w=f;if(d){e:{for(o=1,h=d[0];h>=10;h/=10,o++);if((c=r-o)<0)c+=u,a=r,p=d[m=0],g=i(p/w[o-a-1]%10);else if((m=n((c+1)/u))>=d.length){if(!s)break e;for(;d.length<=m;d.push(0));p=g=0,o=1,a=(c%=u)-u+1}else{for(p=h=d[m],o=1;h>=10;h/=10,o++);g=(a=(c%=u)-u+o)<0?0:i(p/w[o-a-1]%10)}if(s=s||r<0||null!=d[m+1]||(a<0?p:p%w[o-a-1]),s=t<4?(g||s)&&(0==t||t==(e.s<0?3:2)):g>5||5==g&&(4==t||s||6==t&&(c>0?a>0?p/w[o-a]:0:d[m-1])%10&1||t==(e.s<0?8:7)),r<1||!d[0])return d.length=0,s?(r-=e.e+1,d[0]=w[(u-r%u)%u],e.e=-r||0):d[0]=e.e=0,e;if(0==c?(d.length=m,h=1,m--):(d.length=m+1,h=w[u-c],d[m]=a>0?i(p/w[o-a]%w[a])*h:0),s)for(;;){if(0==m){for(c=1,a=d[0];a>=10;a/=10,c++);for(a=d[0]+=h,h=1;a>=10;a/=10,h++);c!=h&&(e.e++,d[0]==l&&(d[0]=1));break}if(d[m]+=h,d[m]!=l)break;d[m--]=0,h=1}for(c=d.length;0===d[--c];d.pop());}e.e>M?e.c=e.e=null:e.e<I&&(e.c=[e.e=0])}return e}function Y(e){var r,t=e.e;return null===t?e.toString():(r=m(e.c),r=t<=R||t>=x?v(r,t):y(r,t,"0"),e.s<0?"-"+r:r)}return F.clone=e,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(e){var r,t;if(null!=e){if("object"!=typeof e)throw Error(s+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(d(t=e[r],0,h,r),L=t),e.hasOwnProperty(r="ROUNDING_MODE")&&(d(t=e[r],0,8,r),P=t),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((t=e[r])&&t.pop?(d(t[0],-h,0,r),d(t[1],0,h,r),R=t[0],x=t[1]):(d(t,-h,h,r),R=-(x=t<0?-t:t))),e.hasOwnProperty(r="RANGE"))if((t=e[r])&&t.pop)d(t[0],-h,-1,r),d(t[1],1,h,r),I=t[0],M=t[1];else{if(d(t,-h,h,r),!t)throw Error(s+r+" cannot be zero: "+t);I=-(M=t<0?-t:t)}if(e.hasOwnProperty(r="CRYPTO")){if((t=e[r])!==!!t)throw Error(s+r+" not true or false: "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw $=!t,Error(s+"crypto unavailable");$=t}else $=t}if(e.hasOwnProperty(r="MODULO_MODE")&&(d(t=e[r],0,9,r),U=t),e.hasOwnProperty(r="POW_PRECISION")&&(d(t=e[r],0,h,r),G=t),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(t=e[r]))throw Error(s+r+" not an object: "+t);j=t}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(t=e[r])||/^.?$|[+\-.\s]|(.).*\1/.test(t))throw Error(s+r+" invalid: "+t);q="0123456789"==t.slice(0,10),k=t}}return{DECIMAL_PLACES:L,ROUNDING_MODE:P,EXPONENTIAL_AT:[R,x],RANGE:[I,M],CRYPTO:$,MODULO_MODE:U,POW_PRECISION:G,FORMAT:j,ALPHABET:k}},F.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!F.DEBUG)return!0;var r,t,n=e.c,o=e.e,c=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===c||-1===c)&&o>=-h&&o<=h&&o===i(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break e}if((r=(o+1)%u)<1&&(r+=u),String(n[0]).length==r){for(r=0;r<n.length;r++)if((t=n[r])<0||t>=l||t!==i(t))break e;if(0!==t)return!0}}}else if(null===n&&null===o&&(null===c||1===c||-1===c))return!0;throw Error(s+"Invalid BigNumber: "+e)},F.maximum=F.max=function(){return z(arguments,-1)},F.minimum=F.min=function(){return z(arguments,1)},F.random=(B=9007199254740992,_=Math.random()*B&2097151?function(){return i(Math.random()*B)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,t,o,l,c,a=0,p=[],m=new F(V);if(null==e?e=L:d(e,0,h),l=n(e/u),$)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(l*=2));a<l;)(c=131072*r[a]+(r[a+1]>>>11))>=9e15?(t=crypto.getRandomValues(new Uint32Array(2)),r[a]=t[0],r[a+1]=t[1]):(p.push(c%1e14),a+=2);a=l/2}else{if(!crypto.randomBytes)throw $=!1,Error(s+"crypto unavailable");for(r=crypto.randomBytes(l*=7);a<l;)(c=281474976710656*(31&r[a])+1099511627776*r[a+1]+4294967296*r[a+2]+16777216*r[a+3]+(r[a+4]<<16)+(r[a+5]<<8)+r[a+6])>=9e15?crypto.randomBytes(7).copy(r,a):(p.push(c%1e14),a+=7);a=l/7}if(!$)for(;a<l;)(c=_())<9e15&&(p[a++]=c%1e14);for(l=p[--a],e%=u,l&&e&&(c=f[u-e],p[a]=i(l/c)*c);0===p[a];p.pop(),a--);if(a<0)p=[o=0];else{for(o=-1;0===p[0];p.splice(0,1),o-=u);for(a=1,c=p[0];c>=10;c/=10,a++);a<u&&(o-=u-a)}return m.e=o,m.c=p,m}),F.sum=function(){for(var e=1,r=arguments,t=new F(r[0]);e<r.length;)t=t.plus(r[e++]);return t},N=function(){var e="0123456789";function r(e,r,t,n){for(var i,s,o=[0],l=0,u=e.length;l<u;){for(s=o.length;s--;o[s]*=r);for(o[0]+=n.indexOf(e.charAt(l++)),i=0;i<o.length;i++)o[i]>t-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/t|0,o[i]%=t)}return o.reverse()}return function(t,n,i,s,o){var l,u,c,f,a,h,p,g,d=t.indexOf("."),w=L,v=P;for(d>=0&&(f=G,G=0,t=t.replace(".",""),h=(g=new F(n)).pow(t.length-d),G=f,g.c=r(y(m(h.c),h.e,"0"),10,i,e),g.e=g.c.length),c=f=(p=r(t,n,i,o?(l=k,e):(l=e,k))).length;0==p[--f];p.pop());if(!p[0])return l.charAt(0);if(d<0?--c:(h.c=p,h.e=c,h.s=s,p=(h=b(h,g,w,v,i)).c,a=h.r,c=h.e),d=p[u=c+w+1],f=i/2,a=a||u<0||null!=p[u+1],a=v<4?(null!=d||a)&&(0==v||v==(h.s<0?3:2)):d>f||d==f&&(4==v||a||6==v&&1&p[u-1]||v==(h.s<0?8:7)),u<1||!p[0])t=a?y(l.charAt(1),-w,l.charAt(0)):l.charAt(0);else{if(p.length=u,a)for(--i;++p[--u]>i;)p[u]=0,u||(++c,p=[1].concat(p));for(f=p.length;!p[--f];);for(d=0,t="";d<=f;t+=l.charAt(p[d++]));t=y(t,c,l.charAt(0))}return t}}(),b=function(){function e(e,r,t){var n,i,s,o,l=0,u=e.length,c=r%a,f=r/a|0;for(e=e.slice();u--;)l=((i=c*(s=e[u]%a)+(n=f*s+(o=e[u]/a|0)*c)%a*a+l)/t|0)+(n/a|0)+f*o,e[u]=i%t;return l&&(e=[l].concat(e)),e}function r(e,r,t,n){var i,s;if(t!=n)s=t>n?1:-1;else for(i=s=0;i<t;i++)if(e[i]!=r[i]){s=e[i]>r[i]?1:-1;break}return s}function t(e,r,t,n){for(var i=0;t--;)e[t]-=i,i=e[t]<r[t]?1:0,e[t]=i*n+e[t]-r[t];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,s,o,c,f){var a,h,m,g,d,w,v,y,b,N,O,B,_,E,A,T,C,D=n.s==s.s?1:-1,S=n.c,V=s.c;if(!(S&&S[0]&&V&&V[0]))return new F(n.s&&s.s&&(S?!V||S[0]!=V[0]:V)?S&&0==S[0]||!V?0*D:D/0:NaN);for(b=(y=new F(D)).c=[],D=o+(h=n.e-s.e)+1,f||(f=l,h=p(n.e/u)-p(s.e/u),D=D/u|0),m=0;V[m]==(S[m]||0);m++);if(V[m]>(S[m]||0)&&h--,D<0)b.push(1),g=!0;else{for(E=S.length,T=V.length,m=0,D+=2,(d=i(f/(V[0]+1)))>1&&(V=e(V,d,f),S=e(S,d,f),T=V.length,E=S.length),_=T,O=(N=S.slice(0,T)).length;O<T;N[O++]=0);C=V.slice(),C=[0].concat(C),A=V[0],V[1]>=f/2&&A++;do{if(d=0,(a=r(V,N,T,O))<0){if(B=N[0],T!=O&&(B=B*f+(N[1]||0)),(d=i(B/A))>1)for(d>=f&&(d=f-1),v=(w=e(V,d,f)).length,O=N.length;1==r(w,N,v,O);)d--,t(w,T<v?C:V,v,f),v=w.length,a=1;else 0==d&&(a=d=1),v=(w=V.slice()).length;if(v<O&&(w=[0].concat(w)),t(N,w,O,f),O=N.length,-1==a)for(;r(V,N,T,O)<1;)d++,t(N,T<O?C:V,O,f),O=N.length}else 0===a&&(d++,N=[0]);b[m++]=d,N[0]?N[O++]=S[_]||0:(N=[S[_]],O=1)}while((_++<E||null!=N[0])&&D--);g=null!=N[0],b[0]||b.splice(0,1)}if(f==l){for(m=1,D=b[0];D>=10;D/=10,m++);X(y,o+(y.e=m+h*u-1)+1,c,g)}else y.e=h,y.r=+g;return y}}(),E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,A=/^([^.]+)\.$/,T=/^\.([^.]+)$/,C=/^-?(Infinity|NaN)$/,D=/^\s*\+(?=[\w.])|^\s+|\s+$/g,O=function(e,r,t,n){var i,o=t?r:r.replace(D,"");if(C.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!t&&(o=o.replace(E,(function(e,r,t){return i="x"==(t=t.toLowerCase())?16:"b"==t?2:8,n&&n!=i?e:r})),n&&(i=n,o=o.replace(A,"$1").replace(T,"0.$1")),r!=o))return new F(o,i);if(F.DEBUG)throw Error(s+"Not a"+(n?" base "+n:"")+" number: "+r);e.s=null}e.c=e.e=null},S.absoluteValue=S.abs=function(){var e=new F(this);return e.s<0&&(e.s=1),e},S.comparedTo=function(e,r){return g(this,new F(e,r))},S.decimalPlaces=S.dp=function(e,r){var t,n,i,s=this;if(null!=e)return d(e,0,h),null==r?r=P:d(r,0,8),X(new F(s),e+s.e+1,r);if(!(t=s.c))return null;if(n=((i=t.length-1)-p(this.e/u))*u,i=t[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},S.dividedBy=S.div=function(e,r){return b(this,new F(e,r),L,P)},S.dividedToIntegerBy=S.idiv=function(e,r){return b(this,new F(e,r),0,1)},S.exponentiatedBy=S.pow=function(e,r){var t,o,l,c,f,a,h,p,m=this;if((e=new F(e)).c&&!e.isInteger())throw Error(s+"Exponent not an integer: "+Y(e));if(null!=r&&(r=new F(r)),f=e.e>14,!m.c||!m.c[0]||1==m.c[0]&&!m.e&&1==m.c.length||!e.c||!e.c[0])return p=new F(Math.pow(+Y(m),f?e.s*(2-w(e)):+Y(e))),r?p.mod(r):p;if(a=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new F(NaN);(o=!a&&m.isInteger()&&r.isInteger())&&(m=m.mod(r))}else{if(e.e>9&&(m.e>0||m.e<-1||(0==m.e?m.c[0]>1||f&&m.c[1]>=24e7:m.c[0]<8e13||f&&m.c[0]<=9999975e7)))return c=m.s<0&&w(e)?-0:0,m.e>-1&&(c=1/c),new F(a?1/c:c);G&&(c=n(G/u+2))}for(f?(t=new F(.5),a&&(e.s=1),h=w(e)):h=(l=Math.abs(+Y(e)))%2,p=new F(V);;){if(h){if(!(p=p.times(m)).c)break;c?p.c.length>c&&(p.c.length=c):o&&(p=p.mod(r))}if(l){if(0===(l=i(l/2)))break;h=l%2}else if(X(e=e.times(t),e.e+1,1),e.e>14)h=w(e);else{if(0==(l=+Y(e)))break;h=l%2}m=m.times(m),c?m.c&&m.c.length>c&&(m.c.length=c):o&&(m=m.mod(r))}return o?p:(a&&(p=V.div(p)),r?p.mod(r):c?X(p,G,P,void 0):p)},S.integerValue=function(e){var r=new F(this);return null==e?e=P:d(e,0,8),X(r,r.e+1,e)},S.isEqualTo=S.eq=function(e,r){return 0===g(this,new F(e,r))},S.isFinite=function(){return!!this.c},S.isGreaterThan=S.gt=function(e,r){return g(this,new F(e,r))>0},S.isGreaterThanOrEqualTo=S.gte=function(e,r){return 1===(r=g(this,new F(e,r)))||0===r},S.isInteger=function(){return!!this.c&&p(this.e/u)>this.c.length-2},S.isLessThan=S.lt=function(e,r){return g(this,new F(e,r))<0},S.isLessThanOrEqualTo=S.lte=function(e,r){return-1===(r=g(this,new F(e,r)))||0===r},S.isNaN=function(){return!this.s},S.isNegative=function(){return this.s<0},S.isPositive=function(){return this.s>0},S.isZero=function(){return!!this.c&&0==this.c[0]},S.minus=function(e,r){var t,n,i,s,o=this,c=o.s;if(r=(e=new F(e,r)).s,!c||!r)return new F(NaN);if(c!=r)return e.s=-r,o.plus(e);var f=o.e/u,a=e.e/u,h=o.c,m=e.c;if(!f||!a){if(!h||!m)return h?(e.s=-r,e):new F(m?o:NaN);if(!h[0]||!m[0])return m[0]?(e.s=-r,e):new F(h[0]?o:3==P?-0:0)}if(f=p(f),a=p(a),h=h.slice(),c=f-a){for((s=c<0)?(c=-c,i=h):(a=f,i=m),i.reverse(),r=c;r--;i.push(0));i.reverse()}else for(n=(s=(c=h.length)<(r=m.length))?c:r,c=r=0;r<n;r++)if(h[r]!=m[r]){s=h[r]<m[r];break}if(s&&(i=h,h=m,m=i,e.s=-e.s),(r=(n=m.length)-(t=h.length))>0)for(;r--;h[t++]=0);for(r=l-1;n>c;){if(h[--n]<m[n]){for(t=n;t&&!h[--t];h[t]=r);--h[t],h[n]+=l}h[n]-=m[n]}for(;0==h[0];h.splice(0,1),--a);return h[0]?W(e,h,a):(e.s=3==P?-1:1,e.c=[e.e=0],e)},S.modulo=S.mod=function(e,r){var t,n,i=this;return e=new F(e,r),!i.c||!e.s||e.c&&!e.c[0]?new F(NaN):!e.c||i.c&&!i.c[0]?new F(i):(9==U?(n=e.s,e.s=1,t=b(i,e,0,3),e.s=n,t.s*=n):t=b(i,e,0,U),(e=i.minus(t.times(e))).c[0]||1!=U||(e.s=i.s),e)},S.multipliedBy=S.times=function(e,r){var t,n,i,s,o,c,f,h,m,g,d,w,v,y,b,N=this,O=N.c,B=(e=new F(e,r)).c;if(!(O&&B&&O[0]&&B[0]))return!N.s||!e.s||O&&!O[0]&&!B||B&&!B[0]&&!O?e.c=e.e=e.s=null:(e.s*=N.s,O&&B?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=p(N.e/u)+p(e.e/u),e.s*=N.s,(f=O.length)<(g=B.length)&&(v=O,O=B,B=v,i=f,f=g,g=i),i=f+g,v=[];i--;v.push(0));for(y=l,b=a,i=g;--i>=0;){for(t=0,d=B[i]%b,w=B[i]/b|0,s=i+(o=f);s>i;)t=((h=d*(h=O[--o]%b)+(c=w*h+(m=O[o]/b|0)*d)%b*b+v[s]+t)/y|0)+(c/b|0)+w*m,v[s--]=h%y;v[s]=t}return t?++n:v.splice(0,1),W(e,v,n)},S.negated=function(){var e=new F(this);return e.s=-e.s||null,e},S.plus=function(e,r){var t,n=this,i=n.s;if(r=(e=new F(e,r)).s,!i||!r)return new F(NaN);if(i!=r)return e.s=-r,n.minus(e);var s=n.e/u,o=e.e/u,c=n.c,f=e.c;if(!s||!o){if(!c||!f)return new F(i/0);if(!c[0]||!f[0])return f[0]?e:new F(c[0]?n:0*i)}if(s=p(s),o=p(o),c=c.slice(),i=s-o){for(i>0?(o=s,t=f):(i=-i,t=c),t.reverse();i--;t.push(0));t.reverse()}for((i=c.length)-(r=f.length)<0&&(t=f,f=c,c=t,r=i),i=0;r;)i=(c[--r]=c[r]+f[r]+i)/l|0,c[r]=l===c[r]?0:c[r]%l;return i&&(c=[i].concat(c),++o),W(e,c,o)},S.precision=S.sd=function(e,r){var t,n,i,s=this;if(null!=e&&e!==!!e)return d(e,1,h),null==r?r=P:d(r,0,8),X(new F(s),e,r);if(!(t=s.c))return null;if(n=(i=t.length-1)*u+1,i=t[i]){for(;i%10==0;i/=10,n--);for(i=t[0];i>=10;i/=10,n++);}return e&&s.e+1>n&&(n=s.e+1),n},S.shiftedBy=function(e){return d(e,-9007199254740991,c),this.times("1e"+e)},S.squareRoot=S.sqrt=function(){var e,r,t,n,i,s=this,o=s.c,l=s.s,u=s.e,c=L+4,f=new F("0.5");if(1!==l||!o||!o[0])return new F(!l||l<0&&(!o||o[0])?NaN:o?s:1/0);if(0==(l=Math.sqrt(+Y(s)))||l==1/0?(((r=m(o)).length+u)%2==0&&(r+="0"),l=Math.sqrt(+r),u=p((u+1)/2)-(u<0||u%2),t=new F(r=l==1/0?"5e"+u:(r=l.toExponential()).slice(0,r.indexOf("e")+1)+u)):t=new F(l+""),t.c[0])for((l=(u=t.e)+c)<3&&(l=0);;)if(i=t,t=f.times(i.plus(b(s,i,c,1))),m(i.c).slice(0,l)===(r=m(t.c)).slice(0,l)){if(t.e<u&&--l,"9999"!=(r=r.slice(l-3,l+1))&&(n||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(X(t,t.e+L+2,1),e=!t.times(t).eq(s));break}if(!n&&(X(i,i.e+L+2,0),i.times(i).eq(s))){t=i;break}c+=4,l+=4,n=1}return X(t,t.e+L+1,P,e)},S.toExponential=function(e,r){return null!=e&&(d(e,0,h),e++),H(this,e,r,1)},S.toFixed=function(e,r){return null!=e&&(d(e,0,h),e=e+this.e+1),H(this,e,r)},S.toFormat=function(e,r,t){var n,i=this;if(null==t)null!=e&&r&&"object"==typeof r?(t=r,r=null):e&&"object"==typeof e?(t=e,e=r=null):t=j;else if("object"!=typeof t)throw Error(s+"Argument not an object: "+t);if(n=i.toFixed(e,r),i.c){var o,l=n.split("."),u=+t.groupSize,c=+t.secondaryGroupSize,f=t.groupSeparator||"",a=l[0],h=l[1],p=i.s<0,m=p?a.slice(1):a,g=m.length;if(c&&(o=u,u=c,c=o,g-=o),u>0&&g>0){for(o=g%u||u,a=m.substr(0,o);o<g;o+=u)a+=f+m.substr(o,u);c>0&&(a+=f+m.slice(o)),p&&(a="-"+a)}n=h?a+(t.decimalSeparator||"")+((c=+t.fractionGroupSize)?h.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(t.fractionGroupSeparator||"")):h):a}return(t.prefix||"")+n+(t.suffix||"")},S.toFraction=function(e){var r,t,n,i,o,l,c,a,h,p,g,d,w=this,v=w.c;if(null!=e&&(!(c=new F(e)).isInteger()&&(c.c||1!==c.s)||c.lt(V)))throw Error(s+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+Y(c));if(!v)return new F(w);for(r=new F(V),h=t=new F(V),n=a=new F(V),d=m(v),o=r.e=d.length-w.e-1,r.c[0]=f[(l=o%u)<0?u+l:l],e=!e||c.comparedTo(r)>0?o>0?r:h:c,l=M,M=1/0,c=new F(d),a.c[0]=0;p=b(c,r,0,1),1!=(i=t.plus(p.times(n))).comparedTo(e);)t=n,n=i,h=a.plus(p.times(i=h)),a=i,r=c.minus(p.times(i=r)),c=i;return i=b(e.minus(t),n,0,1),a=a.plus(i.times(h)),t=t.plus(i.times(n)),a.s=h.s=w.s,g=b(h,n,o*=2,P).minus(w).abs().comparedTo(b(a,t,o,P).minus(w).abs())<1?[h,n]:[a,t],M=l,g},S.toNumber=function(){return+Y(this)},S.toPrecision=function(e,r){return null!=e&&d(e,1,h),H(this,e,r,2)},S.toString=function(e){var r,t=this,n=t.s,i=t.e;return null===i?n?(r="Infinity",n<0&&(r="-"+r)):r="NaN":(null==e?r=i<=R||i>=x?v(m(t.c),i):y(m(t.c),i,"0"):10===e&&q?r=y(m((t=X(new F(t),L+i+1,P)).c),t.e,"0"):(d(e,2,k.length,"Base"),r=N(y(m(t.c),i,"0"),10,e,n,!0)),n<0&&t.c[0]&&(r="-"+r)),r},S.valueOf=S.toJSON=function(){return Y(this)},S._isBigNumber=!0,S[Symbol.toStringTag]="BigNumber",S[Symbol.for("nodejs.util.inspect.custom")]=S.valueOf,null!=r&&F.set(r),F}(),N=(e,r,t)=>{const n=e(2/(t+1)),i=r.length,s=[];if(n.isGreaterThan(1))return Array(i);if(n.isEqualTo(1))return[...r];let o=0,l=0;for(;l<i;l++){const e=r[l];if("object"==typeof e){s[l]=e,o=e,l++;break}}if(Array.isArray(n))for(;l<i;l++){const e=r[l];"object"==typeof e&&"object"==typeof n[l]?o=s[l]=n[l].multipliedBy(e).plus(n[l].minus(1).multipliedBy(o)):s[l]=s[l-1]}else{const t=e(1).minus(n);for(;l<i;l++){const e=r[l];o="object"==typeof e?n.multipliedBy(e).plus(t.multipliedBy(o)):s[l-1],s[l]=o}}return s},O=(e,r,t)=>{let n=[],i=e(0),s=[];for(let e=0;e<r.length;e++)s.push(r[e]),i=i.plus(r[e]),s.length>t&&(i=i.minus(s.shift())),e>=t-1?n.push(i.dividedBy(t)):n.push(i.dividedBy(s.length));return n},B=(e,r,t)=>{let n=new Array(r.length).fill(0),i=0;const s=new e(r[0]),o=new e(t[0]);s.isGreaterThan(o)?(i=1,n[0]=1):s.isLessThan(o)?(i=-1,n[0]=-1):(i=0,n[0]=0);for(let s=1;s<r.length;s++){const o=new e(r[s]),l=new e(t[s]),u=new e(r[s-1]),c=new e(t[s-1]);o.isGreaterThan(l)&&u.isLessThanOrEqualTo(c)?(i=1,n[s]=1):o.isLessThan(l)&&u.isGreaterThanOrEqualTo(c)?(i=-1,n[s]=-1):n[s]=1===i?n[s-1]+1:-1===i?n[s-1]-1:0}return n},_=(e,r,t)=>{const n=new e(0),i=r.length,s=O(e,r,t),o=new Array(i).fill(n);for(let e=t-1;e<i;e++){let i=n;for(let n=e-t+1;n<=e;n++)i=i.plus(r[n].minus(s[e]).pow(2));o[e]=i.dividedBy(t).sqrt()}return o},E=(e,r)=>{let{upper:t,lower:n}=r;const i=t.map(((e,r)=>e.minus(n[r])));return e.map(((e,r)=>e.minus(n[r]).dividedBy(i[r]).times(100)))},A=(e,r,t,n)=>r.slice(0,r.length-n+1).map(((i,s)=>{const o=r.slice(s,s+n),l=t.slice(s,s+n);return e.maximum(...o).plus(e.minimum(...l)).dividedBy(2)})),T=(e,r,t,n)=>{const i=e.slice(t).map(((e,t)=>t<r.length?e.plus(r[t]).dividedBy(2):null)).filter((e=>null!==e));return i.slice(0,i.length-n+1)},C=(e,r,t,n,i)=>{let s=r.slice(n).map(((i,s)=>{const o=r.slice(s,s+n),l=t.slice(s,s+n);return e.maximum(...o).plus(e.minimum(...l)).dividedBy(2)}));return s.slice(0,s.length-i+2)},D=(e,r)=>e.slice(0,e.length-r+1),S={getSMA:O,getEMA:N},V=(e,r,t=10,n)=>{const{open:i,high:s,low:o,close:l,volume:u}=r,c=e.min(...o),f=e.max(...s).minus(c).dividedBy(t),a=e(0),h={upVolume:a,downVolume:a,grossVolume:a},p=Array.from({length:t},((e,r)=>({price:c.plus(f.multipliedBy(r)),upVolume:a,downVolume:a,grossVolume:a}))),m=e(1).dividedBy(f);for(let r=0;r<l.length;r++){const n=l[r],f=i[r],h=s[r],g=o[r],d=u[r],w=n.isGreaterThanOrEqualTo(f)?d:a,v=n.isLessThan(f)?d:a,y=Math.max(0,g.minus(c).multipliedBy(m).integerValue(e.ROUND_FLOOR).toNumber()),b=Math.min(t,h.minus(c).multipliedBy(m).integerValue(e.ROUND_CEIL).toNumber());for(let e=y;e<b;e++)p[e].upVolume=p[e].upVolume.plus(w),p[e].downVolume=p[e].downVolume.plus(v),p[e].grossVolume=p[e].grossVolume.plus(w.plus(v))}for(const{upVolume:e,downVolume:r,grossVolume:t}of p)h.upVolume=h.upVolume.plus(e),h.downVolume=h.downVolume.plus(r),h.grossVolume=h.grossVolume.plus(t);return{bins:p,nodes:L(p)}},L=e=>{if(!e||0===e.length)throw new Error("Bins array is empty or not provided");let r=e[0],t=e[0];return e.forEach((e=>{e.grossVolume.isGreaterThan(r.grossVolume)&&(r=e),e.grossVolume.isLessThan(t.grossVolume)&&(t=e)})),{highestVolumeNode:r,lowestVolumeNode:t}};class P{constructor(){this.BigNumber=b,this.VolumeProfile=V}init(e){const{BigNumber:r}=this;return this.ohlcv=e.reduce(((e,{open:t,high:n,low:i,close:s,volume:o,...l})=>{e.open.push(r(t)),e.high.push(r(n)),e.low.push(r(i)),e.close.push(r(s)),e.volume.push(r(o));for(const r of Object.keys(l))e[r]||(e[r]=[]),e[r].push(l[r]);return e}),{open:[],high:[],low:[],close:[],volume:[]}),this}getHeaders(){return Object.keys(this.getData())}getData(){return this.ohlcv}getLastValues(){const e={};for(const[r,t]of Object.entries(this.ohlcv)){let n=t[t.length-1];e[r]=b.isBigNumber(n)?n.toNumber():n}return e}addColumn(e,r){const t=this.ohlcv.open.length;if(r.length>t)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");r=[...new Array(t-r.length).fill(NaN),...r],this.ohlcv[e]=r}crossPairs(e){const r=this.getData(),t={},n=e=>{if(!r.hasOwnProperty(e)&&"string"==typeof e){const[r,...t]=e.split("_");this[r.toUpperCase()]&&t.length>0&&this[r.toUpperCase()](...t)}};for(const{fast:i,slow:s}of e)if(i&&s)if(n(i),n(s),"number"!=typeof s||t[s]||(t[s]=r.close.map((()=>s))),r[i]&&r[s]){const e=B(this.BigNumber,r[i],r[s]);this.addColumn(`${i}_x_${s}`,e)}else if(r[i]&&t[s]){const e=B(this.BigNumber,r[i],t[s]);this.addColumn(`${i}_x_${s}`,e)}else console.error(`Missing ohlcv properties for ${i} or ${s}`)}EMA(e){return((e,r)=>{const t=e.getData().close,n=N(e.BigNumber,t,r);e.addColumn(`ema_${r}`,n)})(this,e),this}SMA(e){return((e,r)=>{const t=e.getData().close,n=O(e.BigNumber,t,r);e.addColumn(`sma_${r}`,n)})(this,e),this}MACD(e,r,t){return((e,r=12,t=26,n=9)=>{const i=e.getData().close,s=((e,r,t=12,n=26,i=9)=>{const s=N(e,r,t),o=N(e,r,n),l=s.map(((e,r)=>e.minus(o[r]))),u=N(e,l,i),c=l.map(((e,r)=>e.minus(u[r]))),f=B(e,l,u);return{macd_diff:l,macd_dea:u,macd_histogram:c,macd_diff_x_macd_dea:f}})(e.BigNumber,i,r,t,n);for(let r in s)e.addColumn(r,s[r])})(this,e,r,t),this}BollingerBands(e,r,t){return((e,r,t)=>{const n=e.getData().close,i=((e,r,t=20,n=2)=>{n=new e(n);const i=O(e,r,t),s=_(e,r,t).map((e=>e.times(n)));let o=i.map(((e,r)=>e.plus(s[r]))),l=i,u=i.map(((e,r)=>e.minus(s[r])));return{upper:o,mid:l,lower:u,range:E(r,{upper:o,lower:u})}})(e.BigNumber,n,r,t);for(let r in i)e.addColumn(`bollinger_bands_${r}`,i[r])})(this,e,r),this}IchimokuCloud(e,r,t){return((e,r,t,n)=>{const i=e.getData(),s=((e,r,t=9,n=26,i=52)=>{const s=t,o=n,l=o-s,u=i,{high:c,low:f,close:a}=r,h=A(e,c,f,s),p=A(e,c,f,o);return{conversion_line:h,base_line:p,leading_span_a:T(h,p,l,o),leading_span_b:C(e,c,f,u,o),lagging_span:D(a,o)}})(e.BigNumber,i,r,t,n);for(let r in s)e.addColumn(`ichimoku_${r}`,s[r])})(this,e,r,t),this}RSI(e,r,t){return((e,r,t,n)=>{const i=e.getData().close,s=((e,r,t=14,n="SMA",i=14)=>{if(r.length<t)return[];const s=new e(0),o=new e(100),l=new e(1);let u=[],c=s,f=s;for(let n=1;n<=t;n++){const t=new e(r[n]),i=new e(r[n-1]),o=t.minus(i);o.isLessThan(s)?f=f.plus(o.abs()):c=c.plus(o)}let a=c.dividedBy(t),h=f.dividedBy(t),p=h.isEqualTo(s)?s:a.dividedBy(h);u.push(o.minus(o.dividedBy(l.plus(p))));for(let n=t+1;n<r.length;n++){const i=new e(r[n]),m=new e(r[n-1]),g=i.minus(m);g.isLessThan(s)?(f=g.abs(),c=s):(c=g,f=s),a=a.times(t-1).plus(c).dividedBy(t),h=h.times(t-1).plus(f).dividedBy(t),p=h.isEqualTo(s)?s:a.dividedBy(h),u.push(o.minus(o.dividedBy(l.plus(p))))}let m={[`rsi_${t}`]:u};if("string"==typeof n&&"number"==typeof i&&S.hasOwnProperty(`get${n}`)){const r=S[`get${n}`](e,u,i);m[`rsi_${n}_${i}`]=r,m[`rsi_${t}_x_rsi_${n}_${i}`]=B(e,u,r)}return m})(e.BigNumber,i,r,t,n);for(let r in s)e.addColumn(`${r}`.toLowerCase(),s[r])})(this,e,r,t),this}MFI(e){return((e,r=14)=>{const t=e.getData(),n=((e,r,t=14)=>{const{high:n,low:i,close:s,volume:o}=r,l=e(0),u=e(100),c=e(1),f=[],a=[],h=[],p=[],m=[],g=[];for(let e=0;e<s.length;e++){const r=n[e].plus(i[e]).plus(s[e]).dividedBy(3),t=r.times(o[e]);f.push(r),a.push(t)}for(let e=1;e<f.length;e++)f[e].isGreaterThan(f[e-1])?(h.push(a[e]),p.push(l)):f[e].isLessThan(f[e-1])?(h.push(l),p.push(a[e])):(h.push(l),p.push(l));for(let e=t;e<=h.length;e++){const r=h.slice(e-t,e),n=p.slice(e-t,e),i=r.reduce(((e,r)=>e.plus(r)),l),s=n.reduce(((e,r)=>e.plus(r)),l),o=i.dividedBy(s);m.push(o)}for(let e=0;e<m.length;e++){const r=u.minus(u.dividedBy(c.plus(m[e])));g.push(r)}return g})(e.BigNumber,t,r);e.addColumn(`mfi_${r}`,n)})(this,e),this}RelativeVolume(e){return((e,r)=>{const t=e.getData().volume,n=((e,r,t=10)=>{const n=O(e,r,t);return r.map(((e,r)=>0!==r&&n[r-2]?n[r-2].isZero()?NaN:e.dividedBy(n[r-2]):NaN)).filter((e=>!Number.isNaN(e)))})(e.BigNumber,t,r);e.addColumn(`relative_volume_${r}`,n)})(this,e),this}}})(),OHLCV_INDICATORS=r})();
1
+ var OHLCV_INDICATORS;(()=>{"use strict";var e={d:(r,n)=>{for(var t in n)e.o(n,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:n[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};(()=>{e.r(r),e.d(r,{default:()=>R});var n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,t=Math.ceil,i=Math.floor,o="[BigNumber Error] ",s=o+"Number primitive has more than 15 significant digits: ",l=1e14,u=14,c=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],a=1e7,h=1e9;function p(e){var r=0|e;return e>0||e===r?r:r-1}function m(e){for(var r,n,t=1,i=e.length,o=e[0]+"";t<i;){for(r=e[t++]+"",n=u-r.length;n--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function g(e,r){var n,t,i=e.c,o=r.c,s=e.s,l=r.s,u=e.e,c=r.e;if(!s||!l)return null;if(n=i&&!i[0],t=o&&!o[0],n||t)return n?t?0:-l:s;if(s!=l)return s;if(n=s<0,t=u==c,!i||!o)return t?0:!i^n?1:-1;if(!t)return u>c^n?1:-1;for(l=(u=i.length)<(c=o.length)?u:c,s=0;s<l;s++)if(i[s]!=o[s])return i[s]>o[s]^n?1:-1;return u==c?0:u>c^n?1:-1}function d(e,r,n,t){if(e<r||e>n||e!==i(e))throw Error(o+(t||"Argument")+("number"==typeof e?e<r||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function w(e){var r=e.c.length-1;return p(e.e/u)==r&&e.c[r]%2!=0}function v(e,r){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function y(e,r,n){var t,i;if(r<0){for(i=n+".";++r;i+=n);e=i+e}else if(++r>(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else r<t&&(e=e.slice(0,r)+"."+e.slice(r));return e}const b=function e(r){var b,N,O,B,_,E,A,T,C,S,V=F.prototype={constructor:F,toString:null,valueOf:null},L=new F(1),P=20,R=4,x=-7,D=21,I=-1e7,M=1e7,$=!1,U=1,j=0,G={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},k="0123456789abcdefghijklmnopqrstuvwxyz",q=!0;function F(e,r){var t,o,l,f,a,h,p,m,g=this;if(!(g instanceof F))return new F(e,r);if(null==r){if(e&&!0===e._isBigNumber)return g.s=e.s,void(!e.c||e.e>M?g.c=g.e=null:e.e<I?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(f=0,a=e;a>=10;a/=10,f++);return void(f>M?g.c=g.e=null:(g.e=f,g.c=[e]))}m=String(e)}else{if(!n.test(m=String(e)))return O(g,m,h);g.s=45==m.charCodeAt(0)?(m=m.slice(1),-1):1}(f=m.indexOf("."))>-1&&(m=m.replace(".","")),(a=m.search(/e/i))>0?(f<0&&(f=a),f+=+m.slice(a+1),m=m.substring(0,a)):f<0&&(f=m.length)}else{if(d(r,2,k.length,"Base"),10==r&&q)return X(g=new F(e),P+g.e+1,R);if(m=String(e),h="number"==typeof e){if(0*e!=0)return O(g,m,h,r);if(g.s=1/e<0?(m=m.slice(1),-1):1,F.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(s+e)}else g.s=45===m.charCodeAt(0)?(m=m.slice(1),-1):1;for(t=k.slice(0,r),f=a=0,p=m.length;a<p;a++)if(t.indexOf(o=m.charAt(a))<0){if("."==o){if(a>f){f=p;continue}}else if(!l&&(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase()))){l=!0,a=-1,f=0;continue}return O(g,String(e),h,r)}h=!1,(f=(m=N(m,r,10,g.s)).indexOf("."))>-1?m=m.replace(".",""):f=m.length}for(a=0;48===m.charCodeAt(a);a++);for(p=m.length;48===m.charCodeAt(--p););if(m=m.slice(a,++p)){if(p-=a,h&&F.DEBUG&&p>15&&(e>c||e!==i(e)))throw Error(s+g.s*e);if((f=f-a-1)>M)g.c=g.e=null;else if(f<I)g.c=[g.e=0];else{if(g.e=f,g.c=[],a=(f+1)%u,f<0&&(a+=u),a<p){for(a&&g.c.push(+m.slice(0,a)),p-=u;a<p;)g.c.push(+m.slice(a,a+=u));a=u-(m=m.slice(a)).length}else a-=p;for(;a--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}function H(e,r,n,t){var i,o,s,l,u;if(null==n?n=R:d(n,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==r)u=m(e.c),u=1==t||2==t&&(s<=x||s>=D)?v(u,s):y(u,s,"0");else if(o=(e=X(new F(e),r,n)).e,l=(u=m(e.c)).length,1==t||2==t&&(r<=o||o<=x)){for(;l<r;u+="0",l++);u=v(u,o)}else if(r-=s,u=y(u,o,"0"),o+1>l){if(--r>0)for(u+=".";r--;u+="0");}else if((r+=o-l)>0)for(o+1==l&&(u+=".");r--;u+="0");return e.s<0&&i?"-"+u:u}function z(e,r){for(var n,t,i=1,o=new F(e[0]);i<e.length;i++)(!(t=new F(e[i])).s||(n=g(o,t))===r||0===n&&o.s===r)&&(o=t);return o}function W(e,r,n){for(var t=1,i=r.length;!r[--i];r.pop());for(i=r[0];i>=10;i/=10,t++);return(n=t+n*u-1)>M?e.c=e.e=null:n<I?e.c=[e.e=0]:(e.e=n,e.c=r),e}function X(e,r,n,o){var s,c,a,h,p,m,g,d=e.c,w=f;if(d){e:{for(s=1,h=d[0];h>=10;h/=10,s++);if((c=r-s)<0)c+=u,a=r,p=d[m=0],g=i(p/w[s-a-1]%10);else if((m=t((c+1)/u))>=d.length){if(!o)break e;for(;d.length<=m;d.push(0));p=g=0,s=1,a=(c%=u)-u+1}else{for(p=h=d[m],s=1;h>=10;h/=10,s++);g=(a=(c%=u)-u+s)<0?0:i(p/w[s-a-1]%10)}if(o=o||r<0||null!=d[m+1]||(a<0?p:p%w[s-a-1]),o=n<4?(g||o)&&(0==n||n==(e.s<0?3:2)):g>5||5==g&&(4==n||o||6==n&&(c>0?a>0?p/w[s-a]:0:d[m-1])%10&1||n==(e.s<0?8:7)),r<1||!d[0])return d.length=0,o?(r-=e.e+1,d[0]=w[(u-r%u)%u],e.e=-r||0):d[0]=e.e=0,e;if(0==c?(d.length=m,h=1,m--):(d.length=m+1,h=w[u-c],d[m]=a>0?i(p/w[s-a]%w[a])*h:0),o)for(;;){if(0==m){for(c=1,a=d[0];a>=10;a/=10,c++);for(a=d[0]+=h,h=1;a>=10;a/=10,h++);c!=h&&(e.e++,d[0]==l&&(d[0]=1));break}if(d[m]+=h,d[m]!=l)break;d[m--]=0,h=1}for(c=d.length;0===d[--c];d.pop());}e.e>M?e.c=e.e=null:e.e<I&&(e.c=[e.e=0])}return e}function Y(e){var r,n=e.e;return null===n?e.toString():(r=m(e.c),r=n<=x||n>=D?v(r,n):y(r,n,"0"),e.s<0?"-"+r:r)}return F.clone=e,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(e){var r,n;if(null!=e){if("object"!=typeof e)throw Error(o+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(d(n=e[r],0,h,r),P=n),e.hasOwnProperty(r="ROUNDING_MODE")&&(d(n=e[r],0,8,r),R=n),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((n=e[r])&&n.pop?(d(n[0],-h,0,r),d(n[1],0,h,r),x=n[0],D=n[1]):(d(n,-h,h,r),x=-(D=n<0?-n:n))),e.hasOwnProperty(r="RANGE"))if((n=e[r])&&n.pop)d(n[0],-h,-1,r),d(n[1],1,h,r),I=n[0],M=n[1];else{if(d(n,-h,h,r),!n)throw Error(o+r+" cannot be zero: "+n);I=-(M=n<0?-n:n)}if(e.hasOwnProperty(r="CRYPTO")){if((n=e[r])!==!!n)throw Error(o+r+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw $=!n,Error(o+"crypto unavailable");$=n}else $=n}if(e.hasOwnProperty(r="MODULO_MODE")&&(d(n=e[r],0,9,r),U=n),e.hasOwnProperty(r="POW_PRECISION")&&(d(n=e[r],0,h,r),j=n),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(n=e[r]))throw Error(o+r+" not an object: "+n);G=n}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(n=e[r])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(o+r+" invalid: "+n);q="0123456789"==n.slice(0,10),k=n}}return{DECIMAL_PLACES:P,ROUNDING_MODE:R,EXPONENTIAL_AT:[x,D],RANGE:[I,M],CRYPTO:$,MODULO_MODE:U,POW_PRECISION:j,FORMAT:G,ALPHABET:k}},F.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!F.DEBUG)return!0;var r,n,t=e.c,s=e.e,c=e.s;e:if("[object Array]"=={}.toString.call(t)){if((1===c||-1===c)&&s>=-h&&s<=h&&s===i(s)){if(0===t[0]){if(0===s&&1===t.length)return!0;break e}if((r=(s+1)%u)<1&&(r+=u),String(t[0]).length==r){for(r=0;r<t.length;r++)if((n=t[r])<0||n>=l||n!==i(n))break e;if(0!==n)return!0}}}else if(null===t&&null===s&&(null===c||1===c||-1===c))return!0;throw Error(o+"Invalid BigNumber: "+e)},F.maximum=F.max=function(){return z(arguments,-1)},F.minimum=F.min=function(){return z(arguments,1)},F.random=(B=9007199254740992,_=Math.random()*B&2097151?function(){return i(Math.random()*B)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,n,s,l,c,a=0,p=[],m=new F(L);if(null==e?e=P:d(e,0,h),l=t(e/u),$)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(l*=2));a<l;)(c=131072*r[a]+(r[a+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[a]=n[0],r[a+1]=n[1]):(p.push(c%1e14),a+=2);a=l/2}else{if(!crypto.randomBytes)throw $=!1,Error(o+"crypto unavailable");for(r=crypto.randomBytes(l*=7);a<l;)(c=281474976710656*(31&r[a])+1099511627776*r[a+1]+4294967296*r[a+2]+16777216*r[a+3]+(r[a+4]<<16)+(r[a+5]<<8)+r[a+6])>=9e15?crypto.randomBytes(7).copy(r,a):(p.push(c%1e14),a+=7);a=l/7}if(!$)for(;a<l;)(c=_())<9e15&&(p[a++]=c%1e14);for(l=p[--a],e%=u,l&&e&&(c=f[u-e],p[a]=i(l/c)*c);0===p[a];p.pop(),a--);if(a<0)p=[s=0];else{for(s=-1;0===p[0];p.splice(0,1),s-=u);for(a=1,c=p[0];c>=10;c/=10,a++);a<u&&(s-=u-a)}return m.e=s,m.c=p,m}),F.sum=function(){for(var e=1,r=arguments,n=new F(r[0]);e<r.length;)n=n.plus(r[e++]);return n},N=function(){var e="0123456789";function r(e,r,n,t){for(var i,o,s=[0],l=0,u=e.length;l<u;){for(o=s.length;o--;s[o]*=r);for(s[0]+=t.indexOf(e.charAt(l++)),i=0;i<s.length;i++)s[i]>n-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(n,t,i,o,s){var l,u,c,f,a,h,p,g,d=n.indexOf("."),w=P,v=R;for(d>=0&&(f=j,j=0,n=n.replace(".",""),h=(g=new F(t)).pow(n.length-d),j=f,g.c=r(y(m(h.c),h.e,"0"),10,i,e),g.e=g.c.length),c=f=(p=r(n,t,i,s?(l=k,e):(l=e,k))).length;0==p[--f];p.pop());if(!p[0])return l.charAt(0);if(d<0?--c:(h.c=p,h.e=c,h.s=o,p=(h=b(h,g,w,v,i)).c,a=h.r,c=h.e),d=p[u=c+w+1],f=i/2,a=a||u<0||null!=p[u+1],a=v<4?(null!=d||a)&&(0==v||v==(h.s<0?3:2)):d>f||d==f&&(4==v||a||6==v&&1&p[u-1]||v==(h.s<0?8:7)),u<1||!p[0])n=a?y(l.charAt(1),-w,l.charAt(0)):l.charAt(0);else{if(p.length=u,a)for(--i;++p[--u]>i;)p[u]=0,u||(++c,p=[1].concat(p));for(f=p.length;!p[--f];);for(d=0,n="";d<=f;n+=l.charAt(p[d++]));n=y(n,c,l.charAt(0))}return n}}(),b=function(){function e(e,r,n){var t,i,o,s,l=0,u=e.length,c=r%a,f=r/a|0;for(e=e.slice();u--;)l=((i=c*(o=e[u]%a)+(t=f*o+(s=e[u]/a|0)*c)%a*a+l)/n|0)+(t/a|0)+f*s,e[u]=i%n;return l&&(e=[l].concat(e)),e}function r(e,r,n,t){var i,o;if(n!=t)o=n>t?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function n(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n]<r[n]?1:0,e[n]=i*t+e[n]-r[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(t,o,s,c,f){var a,h,m,g,d,w,v,y,b,N,O,B,_,E,A,T,C,S=t.s==o.s?1:-1,V=t.c,L=o.c;if(!(V&&V[0]&&L&&L[0]))return new F(t.s&&o.s&&(V?!L||V[0]!=L[0]:L)?V&&0==V[0]||!L?0*S:S/0:NaN);for(b=(y=new F(S)).c=[],S=s+(h=t.e-o.e)+1,f||(f=l,h=p(t.e/u)-p(o.e/u),S=S/u|0),m=0;L[m]==(V[m]||0);m++);if(L[m]>(V[m]||0)&&h--,S<0)b.push(1),g=!0;else{for(E=V.length,T=L.length,m=0,S+=2,(d=i(f/(L[0]+1)))>1&&(L=e(L,d,f),V=e(V,d,f),T=L.length,E=V.length),_=T,O=(N=V.slice(0,T)).length;O<T;N[O++]=0);C=L.slice(),C=[0].concat(C),A=L[0],L[1]>=f/2&&A++;do{if(d=0,(a=r(L,N,T,O))<0){if(B=N[0],T!=O&&(B=B*f+(N[1]||0)),(d=i(B/A))>1)for(d>=f&&(d=f-1),v=(w=e(L,d,f)).length,O=N.length;1==r(w,N,v,O);)d--,n(w,T<v?C:L,v,f),v=w.length,a=1;else 0==d&&(a=d=1),v=(w=L.slice()).length;if(v<O&&(w=[0].concat(w)),n(N,w,O,f),O=N.length,-1==a)for(;r(L,N,T,O)<1;)d++,n(N,T<O?C:L,O,f),O=N.length}else 0===a&&(d++,N=[0]);b[m++]=d,N[0]?N[O++]=V[_]||0:(N=[V[_]],O=1)}while((_++<E||null!=N[0])&&S--);g=null!=N[0],b[0]||b.splice(0,1)}if(f==l){for(m=1,S=b[0];S>=10;S/=10,m++);X(y,s+(y.e=m+h*u-1)+1,c,g)}else y.e=h,y.r=+g;return y}}(),E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,A=/^([^.]+)\.$/,T=/^\.([^.]+)$/,C=/^-?(Infinity|NaN)$/,S=/^\s*\+(?=[\w.])|^\s+|\s+$/g,O=function(e,r,n,t){var i,s=n?r:r.replace(S,"");if(C.test(s))e.s=isNaN(s)?null:s<0?-1:1;else{if(!n&&(s=s.replace(E,(function(e,r,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,t&&t!=i?e:r})),t&&(i=t,s=s.replace(A,"$1").replace(T,"0.$1")),r!=s))return new F(s,i);if(F.DEBUG)throw Error(o+"Not a"+(t?" base "+t:"")+" number: "+r);e.s=null}e.c=e.e=null},V.absoluteValue=V.abs=function(){var e=new F(this);return e.s<0&&(e.s=1),e},V.comparedTo=function(e,r){return g(this,new F(e,r))},V.decimalPlaces=V.dp=function(e,r){var n,t,i,o=this;if(null!=e)return d(e,0,h),null==r?r=R:d(r,0,8),X(new F(o),e+o.e+1,r);if(!(n=o.c))return null;if(t=((i=n.length-1)-p(this.e/u))*u,i=n[i])for(;i%10==0;i/=10,t--);return t<0&&(t=0),t},V.dividedBy=V.div=function(e,r){return b(this,new F(e,r),P,R)},V.dividedToIntegerBy=V.idiv=function(e,r){return b(this,new F(e,r),0,1)},V.exponentiatedBy=V.pow=function(e,r){var n,s,l,c,f,a,h,p,m=this;if((e=new F(e)).c&&!e.isInteger())throw Error(o+"Exponent not an integer: "+Y(e));if(null!=r&&(r=new F(r)),f=e.e>14,!m.c||!m.c[0]||1==m.c[0]&&!m.e&&1==m.c.length||!e.c||!e.c[0])return p=new F(Math.pow(+Y(m),f?e.s*(2-w(e)):+Y(e))),r?p.mod(r):p;if(a=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new F(NaN);(s=!a&&m.isInteger()&&r.isInteger())&&(m=m.mod(r))}else{if(e.e>9&&(m.e>0||m.e<-1||(0==m.e?m.c[0]>1||f&&m.c[1]>=24e7:m.c[0]<8e13||f&&m.c[0]<=9999975e7)))return c=m.s<0&&w(e)?-0:0,m.e>-1&&(c=1/c),new F(a?1/c:c);j&&(c=t(j/u+2))}for(f?(n=new F(.5),a&&(e.s=1),h=w(e)):h=(l=Math.abs(+Y(e)))%2,p=new F(L);;){if(h){if(!(p=p.times(m)).c)break;c?p.c.length>c&&(p.c.length=c):s&&(p=p.mod(r))}if(l){if(0===(l=i(l/2)))break;h=l%2}else if(X(e=e.times(n),e.e+1,1),e.e>14)h=w(e);else{if(0==(l=+Y(e)))break;h=l%2}m=m.times(m),c?m.c&&m.c.length>c&&(m.c.length=c):s&&(m=m.mod(r))}return s?p:(a&&(p=L.div(p)),r?p.mod(r):c?X(p,j,R,void 0):p)},V.integerValue=function(e){var r=new F(this);return null==e?e=R:d(e,0,8),X(r,r.e+1,e)},V.isEqualTo=V.eq=function(e,r){return 0===g(this,new F(e,r))},V.isFinite=function(){return!!this.c},V.isGreaterThan=V.gt=function(e,r){return g(this,new F(e,r))>0},V.isGreaterThanOrEqualTo=V.gte=function(e,r){return 1===(r=g(this,new F(e,r)))||0===r},V.isInteger=function(){return!!this.c&&p(this.e/u)>this.c.length-2},V.isLessThan=V.lt=function(e,r){return g(this,new F(e,r))<0},V.isLessThanOrEqualTo=V.lte=function(e,r){return-1===(r=g(this,new F(e,r)))||0===r},V.isNaN=function(){return!this.s},V.isNegative=function(){return this.s<0},V.isPositive=function(){return this.s>0},V.isZero=function(){return!!this.c&&0==this.c[0]},V.minus=function(e,r){var n,t,i,o,s=this,c=s.s;if(r=(e=new F(e,r)).s,!c||!r)return new F(NaN);if(c!=r)return e.s=-r,s.plus(e);var f=s.e/u,a=e.e/u,h=s.c,m=e.c;if(!f||!a){if(!h||!m)return h?(e.s=-r,e):new F(m?s:NaN);if(!h[0]||!m[0])return m[0]?(e.s=-r,e):new F(h[0]?s:3==R?-0:0)}if(f=p(f),a=p(a),h=h.slice(),c=f-a){for((o=c<0)?(c=-c,i=h):(a=f,i=m),i.reverse(),r=c;r--;i.push(0));i.reverse()}else for(t=(o=(c=h.length)<(r=m.length))?c:r,c=r=0;r<t;r++)if(h[r]!=m[r]){o=h[r]<m[r];break}if(o&&(i=h,h=m,m=i,e.s=-e.s),(r=(t=m.length)-(n=h.length))>0)for(;r--;h[n++]=0);for(r=l-1;t>c;){if(h[--t]<m[t]){for(n=t;n&&!h[--n];h[n]=r);--h[n],h[t]+=l}h[t]-=m[t]}for(;0==h[0];h.splice(0,1),--a);return h[0]?W(e,h,a):(e.s=3==R?-1:1,e.c=[e.e=0],e)},V.modulo=V.mod=function(e,r){var n,t,i=this;return e=new F(e,r),!i.c||!e.s||e.c&&!e.c[0]?new F(NaN):!e.c||i.c&&!i.c[0]?new F(i):(9==U?(t=e.s,e.s=1,n=b(i,e,0,3),e.s=t,n.s*=t):n=b(i,e,0,U),(e=i.minus(n.times(e))).c[0]||1!=U||(e.s=i.s),e)},V.multipliedBy=V.times=function(e,r){var n,t,i,o,s,c,f,h,m,g,d,w,v,y,b,N=this,O=N.c,B=(e=new F(e,r)).c;if(!(O&&B&&O[0]&&B[0]))return!N.s||!e.s||O&&!O[0]&&!B||B&&!B[0]&&!O?e.c=e.e=e.s=null:(e.s*=N.s,O&&B?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=p(N.e/u)+p(e.e/u),e.s*=N.s,(f=O.length)<(g=B.length)&&(v=O,O=B,B=v,i=f,f=g,g=i),i=f+g,v=[];i--;v.push(0));for(y=l,b=a,i=g;--i>=0;){for(n=0,d=B[i]%b,w=B[i]/b|0,o=i+(s=f);o>i;)n=((h=d*(h=O[--s]%b)+(c=w*h+(m=O[s]/b|0)*d)%b*b+v[o]+n)/y|0)+(c/b|0)+w*m,v[o--]=h%y;v[o]=n}return n?++t:v.splice(0,1),W(e,v,t)},V.negated=function(){var e=new F(this);return e.s=-e.s||null,e},V.plus=function(e,r){var n,t=this,i=t.s;if(r=(e=new F(e,r)).s,!i||!r)return new F(NaN);if(i!=r)return e.s=-r,t.minus(e);var o=t.e/u,s=e.e/u,c=t.c,f=e.c;if(!o||!s){if(!c||!f)return new F(i/0);if(!c[0]||!f[0])return f[0]?e:new F(c[0]?t:0*i)}if(o=p(o),s=p(s),c=c.slice(),i=o-s){for(i>0?(s=o,n=f):(i=-i,n=c),n.reverse();i--;n.push(0));n.reverse()}for((i=c.length)-(r=f.length)<0&&(n=f,f=c,c=n,r=i),i=0;r;)i=(c[--r]=c[r]+f[r]+i)/l|0,c[r]=l===c[r]?0:c[r]%l;return i&&(c=[i].concat(c),++s),W(e,c,s)},V.precision=V.sd=function(e,r){var n,t,i,o=this;if(null!=e&&e!==!!e)return d(e,1,h),null==r?r=R:d(r,0,8),X(new F(o),e,r);if(!(n=o.c))return null;if(t=(i=n.length-1)*u+1,i=n[i]){for(;i%10==0;i/=10,t--);for(i=n[0];i>=10;i/=10,t++);}return e&&o.e+1>t&&(t=o.e+1),t},V.shiftedBy=function(e){return d(e,-9007199254740991,c),this.times("1e"+e)},V.squareRoot=V.sqrt=function(){var e,r,n,t,i,o=this,s=o.c,l=o.s,u=o.e,c=P+4,f=new F("0.5");if(1!==l||!s||!s[0])return new F(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);if(0==(l=Math.sqrt(+Y(o)))||l==1/0?(((r=m(s)).length+u)%2==0&&(r+="0"),l=Math.sqrt(+r),u=p((u+1)/2)-(u<0||u%2),n=new F(r=l==1/0?"5e"+u:(r=l.toExponential()).slice(0,r.indexOf("e")+1)+u)):n=new F(l+""),n.c[0])for((l=(u=n.e)+c)<3&&(l=0);;)if(i=n,n=f.times(i.plus(b(o,i,c,1))),m(i.c).slice(0,l)===(r=m(n.c)).slice(0,l)){if(n.e<u&&--l,"9999"!=(r=r.slice(l-3,l+1))&&(t||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(X(n,n.e+P+2,1),e=!n.times(n).eq(o));break}if(!t&&(X(i,i.e+P+2,0),i.times(i).eq(o))){n=i;break}c+=4,l+=4,t=1}return X(n,n.e+P+1,R,e)},V.toExponential=function(e,r){return null!=e&&(d(e,0,h),e++),H(this,e,r,1)},V.toFixed=function(e,r){return null!=e&&(d(e,0,h),e=e+this.e+1),H(this,e,r)},V.toFormat=function(e,r,n){var t,i=this;if(null==n)null!=e&&r&&"object"==typeof r?(n=r,r=null):e&&"object"==typeof e?(n=e,e=r=null):n=G;else if("object"!=typeof n)throw Error(o+"Argument not an object: "+n);if(t=i.toFixed(e,r),i.c){var s,l=t.split("."),u=+n.groupSize,c=+n.secondaryGroupSize,f=n.groupSeparator||"",a=l[0],h=l[1],p=i.s<0,m=p?a.slice(1):a,g=m.length;if(c&&(s=u,u=c,c=s,g-=s),u>0&&g>0){for(s=g%u||u,a=m.substr(0,s);s<g;s+=u)a+=f+m.substr(s,u);c>0&&(a+=f+m.slice(s)),p&&(a="-"+a)}t=h?a+(n.decimalSeparator||"")+((c=+n.fractionGroupSize)?h.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):h):a}return(n.prefix||"")+t+(n.suffix||"")},V.toFraction=function(e){var r,n,t,i,s,l,c,a,h,p,g,d,w=this,v=w.c;if(null!=e&&(!(c=new F(e)).isInteger()&&(c.c||1!==c.s)||c.lt(L)))throw Error(o+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+Y(c));if(!v)return new F(w);for(r=new F(L),h=n=new F(L),t=a=new F(L),d=m(v),s=r.e=d.length-w.e-1,r.c[0]=f[(l=s%u)<0?u+l:l],e=!e||c.comparedTo(r)>0?s>0?r:h:c,l=M,M=1/0,c=new F(d),a.c[0]=0;p=b(c,r,0,1),1!=(i=n.plus(p.times(t))).comparedTo(e);)n=t,t=i,h=a.plus(p.times(i=h)),a=i,r=c.minus(p.times(i=r)),c=i;return i=b(e.minus(n),t,0,1),a=a.plus(i.times(h)),n=n.plus(i.times(t)),a.s=h.s=w.s,g=b(h,t,s*=2,R).minus(w).abs().comparedTo(b(a,n,s,R).minus(w).abs())<1?[h,t]:[a,n],M=l,g},V.toNumber=function(){return+Y(this)},V.toPrecision=function(e,r){return null!=e&&d(e,1,h),H(this,e,r,2)},V.toString=function(e){var r,n=this,t=n.s,i=n.e;return null===i?t?(r="Infinity",t<0&&(r="-"+r)):r="NaN":(null==e?r=i<=x||i>=D?v(m(n.c),i):y(m(n.c),i,"0"):10===e&&q?r=y(m((n=X(new F(n),P+i+1,R)).c),n.e,"0"):(d(e,2,k.length,"Base"),r=N(y(m(n.c),i,"0"),10,e,t,!0)),t<0&&n.c[0]&&(r="-"+r)),r},V.valueOf=V.toJSON=function(){return Y(this)},V._isBigNumber=!0,V[Symbol.toStringTag]="BigNumber",V[Symbol.for("nodejs.util.inspect.custom")]=V.valueOf,null!=r&&F.set(r),F}(),N=(e,r,n)=>{const t=e(2/(n+1)),i=r.length,o=[];if(t.isGreaterThan(1))return Array(i);if(t.isEqualTo(1))return[...r];let s=0,l=0;for(;l<i;l++){const e=r[l];if("object"==typeof e){o[l]=e,s=e,l++;break}}if(Array.isArray(t))for(;l<i;l++){const e=r[l];"object"==typeof e&&"object"==typeof t[l]?s=o[l]=t[l].multipliedBy(e).plus(t[l].minus(1).multipliedBy(s)):o[l]=o[l-1]}else{const n=e(1).minus(t);for(;l<i;l++){const e=r[l];s="object"==typeof e?t.multipliedBy(e).plus(n.multipliedBy(s)):o[l-1],o[l]=s}}return o},O=(e,r,n)=>{let t=[],i=e(0),o=[];for(let e=0;e<r.length;e++)o.push(r[e]),i=i.plus(r[e]),o.length>n&&(i=i.minus(o.shift())),e>=n-1?t.push(i.dividedBy(n)):t.push(i.dividedBy(o.length));return t},B=(e,r,n)=>{let t=new Array(r.length).fill(0),i=0;const o=new e(r[0]),s=new e(n[0]);o.isGreaterThan(s)?(i=1,t[0]=1):o.isLessThan(s)?(i=-1,t[0]=-1):(i=0,t[0]=0);for(let o=1;o<r.length;o++){const s=new e(r[o]),l=new e(n[o]),u=new e(r[o-1]),c=new e(n[o-1]);s.isGreaterThan(l)&&u.isLessThanOrEqualTo(c)?(i=1,t[o]=1):s.isLessThan(l)&&u.isGreaterThanOrEqualTo(c)?(i=-1,t[o]=-1):t[o]=1===i?t[o-1]+1:-1===i?t[o-1]-1:0}return t},_=(e,r,n)=>{const t=new e(0),i=r.length,o=O(e,r,n),s=new Array(i).fill(t);for(let e=n-1;e<i;e++){let i=t;for(let t=e-n+1;t<=e;t++)i=i.plus(r[t].minus(o[e]).pow(2));s[e]=i.dividedBy(n).sqrt()}return s},E=(e,r)=>{let{upper:n,lower:t}=r;const i=n.map(((e,r)=>e.minus(t[r])));return e.map(((e,r)=>e.minus(t[r]).dividedBy(i[r]).times(100)))},A=(e,r,n,t)=>r.slice(0,r.length-t+1).map(((i,o)=>{const s=r.slice(o,o+t),l=n.slice(o,o+t);return e.maximum(...s).plus(e.minimum(...l)).dividedBy(2)})),T=(e,r,n,t)=>{const i=e.slice(n).map(((e,n)=>n<r.length?e.plus(r[n]).dividedBy(2):null)).filter((e=>null!==e));return i.slice(0,i.length-t+1)},C=(e,r,n,t,i)=>{let o=r.slice(t).map(((i,o)=>{const s=r.slice(o,o+t),l=n.slice(o,o+t);return e.maximum(...s).plus(e.minimum(...l)).dividedBy(2)}));return o.slice(0,o.length-i+2)},S=(e,r)=>e.slice(0,e.length-r+1),V={getSMA:O,getEMA:N},L=(e,r,n=10,t)=>{const{open:i,high:o,low:s,close:l,volume:u}=r,c=e.min(...s),f=e.max(...o).minus(c).dividedBy(n),a=e(0),h={upVolume:a,downVolume:a,grossVolume:a},p=Array.from({length:n},((e,r)=>({price:c.plus(f.multipliedBy(r)),upVolume:a,downVolume:a,grossVolume:a}))),m=e(1).dividedBy(f);for(let r=0;r<l.length;r++){const t=l[r],f=i[r],h=o[r],g=s[r],d=u[r],w=t.isGreaterThanOrEqualTo(f)?d:a,v=t.isLessThan(f)?d:a,y=Math.max(0,g.minus(c).multipliedBy(m).integerValue(e.ROUND_FLOOR).toNumber()),b=Math.min(n,h.minus(c).multipliedBy(m).integerValue(e.ROUND_CEIL).toNumber());for(let e=y;e<b;e++)p[e].upVolume=p[e].upVolume.plus(w),p[e].downVolume=p[e].downVolume.plus(v),p[e].grossVolume=p[e].grossVolume.plus(w.plus(v))}for(const{upVolume:e,downVolume:r,grossVolume:n}of p)h.upVolume=h.upVolume.plus(e),h.downVolume=h.downVolume.plus(r),h.grossVolume=h.grossVolume.plus(n);return{bins:p,nodes:P(p)}},P=e=>{if(!e||0===e.length)throw new Error("Bins array is empty or not provided");let r=e[0],n=e[0];return e.forEach((e=>{e.grossVolume.isGreaterThan(r.grossVolume)&&(r=e),e.grossVolume.isLessThan(n.grossVolume)&&(n=e)})),{highestVolumeNode:r,lowestVolumeNode:n}};class R{constructor(){this.BigNumber=b,this.VolumeProfile=L}init(e){const{BigNumber:r}=this;return this.ohlcv=e.reduce(((e,{open:n,high:t,low:i,close:o,volume:s,...l})=>{e.open.push(r(n)),e.high.push(r(t)),e.low.push(r(i)),e.close.push(r(o)),e.volume.push(r(s));for(const r of Object.keys(l))e[r]||(e[r]=[]),e[r].push(l[r]);return e}),{open:[],high:[],low:[],close:[],volume:[]}),this}getHeaders(){return Object.keys(this.ohlcv)}getData(){const{BigNumber:e,ohlcv:r}=this,n={};for(const[t,i]of Object.entries(r))n[t]=i.map((r=>e.isBigNumber(r)?r.toNumber():r));return n}getLastValues(){const e={};for(const[r,n]of Object.entries(this.ohlcv)){let t=n[n.length-1];e[r]=b.isBigNumber(t)?t.toNumber():t}return e}addColumn(e,r){const n=this.ohlcv.open.length;if(r.length>n)throw new Error("Invalid column data: The length of the new column exceeds the length of the OHLCV data");r=[...new Array(n-r.length).fill(NaN),...r],this.ohlcv[e]=r}crossPairs(e){const r=this.ohlcv,n={},t=e=>{if(!r.hasOwnProperty(e)&&"string"==typeof e){const[r,...n]=e.split("_");this[r.toUpperCase()]&&n.length>0&&this[r.toUpperCase()](...n)}};for(const{fast:i,slow:o}of e)if(i&&o)if(t(i),t(o),"number"!=typeof o||n[o]||(n[o]=r.close.map((()=>o))),r[i]&&r[o]){const e=B(this.BigNumber,r[i],r[o]);this.addColumn(`${i}_x_${o}`,e)}else if(r[i]&&n[o]){const e=B(this.BigNumber,r[i],n[o]);this.addColumn(`${i}_x_${o}`,e)}else console.error(`Missing ohlcv properties for ${i} or ${o}`)}EMA(e){return((e,r)=>{const{ohlcv:n}=e,t=n.close,i=N(e.BigNumber,t,r);e.addColumn(`ema_${r}`,i)})(this,e),this}SMA(e){return((e,r)=>{const{ohlcv:n}=e,t=n.close,i=O(e.BigNumber,t,r);e.addColumn(`sma_${r}`,i)})(this,e),this}MACD(e,r,n){return((e,r=12,n=26,t=9)=>{const{ohlcv:i}=e,o=i.close,s=((e,r,n=12,t=26,i=9)=>{const o=N(e,r,n),s=N(e,r,t),l=o.map(((e,r)=>e.minus(s[r]))),u=N(e,l,i),c=l.map(((e,r)=>e.minus(u[r]))),f=B(e,l,u);return{macd_diff:l,macd_dea:u,macd_histogram:c,macd_diff_x_macd_dea:f}})(e.BigNumber,o,r,n,t);for(let r in s)e.addColumn(r,s[r])})(this,e,r,n),this}BollingerBands(e,r,n){return((e,r,n)=>{const{ohlcv:t}=e,i=t.close,o=((e,r,n=20,t=2)=>{t=new e(t);const i=O(e,r,n),o=_(e,r,n).map((e=>e.times(t)));let s=i.map(((e,r)=>e.plus(o[r]))),l=i,u=i.map(((e,r)=>e.minus(o[r])));return{upper:s,mid:l,lower:u,range:E(r,{upper:s,lower:u})}})(e.BigNumber,i,r,n);for(let r in o)e.addColumn(`bollinger_bands_${r}`,o[r])})(this,e,r),this}IchimokuCloud(e,r,n){return((e,r,n,t)=>{const{ohlcv:i}=e,o=((e,r,n=9,t=26,i=52)=>{const o=n,s=t,l=s-o,u=i,{high:c,low:f,close:a}=r,h=A(e,c,f,o),p=A(e,c,f,s);return{conversion_line:h,base_line:p,leading_span_a:T(h,p,l,s),leading_span_b:C(e,c,f,u,s),lagging_span:S(a,s)}})(e.BigNumber,i,r,n,t);for(let r in o)e.addColumn(`ichimoku_${r}`,o[r])})(this,e,r,n),this}RSI(e,r,n){return((e,r,n,t)=>{const{ohlcv:i}=e,o=i.close,s=((e,r,n=14,t="SMA",i=14)=>{if(r.length<n)return[];const o=new e(0),s=new e(100),l=new e(1);let u=[],c=o,f=o;for(let t=1;t<=n;t++){const n=new e(r[t]),i=new e(r[t-1]),s=n.minus(i);s.isLessThan(o)?f=f.plus(s.abs()):c=c.plus(s)}let a=c.dividedBy(n),h=f.dividedBy(n),p=h.isEqualTo(o)?o:a.dividedBy(h);u.push(s.minus(s.dividedBy(l.plus(p))));for(let t=n+1;t<r.length;t++){const i=new e(r[t]),m=new e(r[t-1]),g=i.minus(m);g.isLessThan(o)?(f=g.abs(),c=o):(c=g,f=o),a=a.times(n-1).plus(c).dividedBy(n),h=h.times(n-1).plus(f).dividedBy(n),p=h.isEqualTo(o)?o:a.dividedBy(h),u.push(s.minus(s.dividedBy(l.plus(p))))}let m={[`rsi_${n}`]:u};if("string"==typeof t&&"number"==typeof i&&V.hasOwnProperty(`get${t}`)){const r=V[`get${t}`](e,u,i);m[`rsi_${t}_${i}`]=r,m[`rsi_${n}_x_rsi_${t}_${i}`]=B(e,u,r)}return m})(e.BigNumber,o,r,n,t);for(let r in s)e.addColumn(`${r}`.toLowerCase(),s[r])})(this,e,r,n),this}MFI(e){return((e,r=14)=>{const{ohlcv:n}=e,t=((e,r,n=14)=>{const{high:t,low:i,close:o,volume:s}=r,l=e(0),u=e(100),c=e(1),f=[],a=[],h=[],p=[],m=[],g=[];for(let e=0;e<o.length;e++){const r=t[e].plus(i[e]).plus(o[e]).dividedBy(3),n=r.times(s[e]);f.push(r),a.push(n)}for(let e=1;e<f.length;e++)f[e].isGreaterThan(f[e-1])?(h.push(a[e]),p.push(l)):f[e].isLessThan(f[e-1])?(h.push(l),p.push(a[e])):(h.push(l),p.push(l));for(let e=n;e<=h.length;e++){const r=h.slice(e-n,e),t=p.slice(e-n,e),i=r.reduce(((e,r)=>e.plus(r)),l),o=t.reduce(((e,r)=>e.plus(r)),l),s=i.dividedBy(o);m.push(s)}for(let e=0;e<m.length;e++){const r=u.minus(u.dividedBy(c.plus(m[e])));g.push(r)}return g})(e.BigNumber,n,r);e.addColumn(`mfi_${r}`,t)})(this,e),this}RelativeVolume(e){return((e,r)=>{const{ohlcv:n}=e,t=n.volume,i=((e,r,n=10)=>{const t=O(e,r,n);return r.map(((e,r)=>0!==r&&t[r-2]?t[r-2].isZero()?NaN:e.dividedBy(t[r-2]):NaN)).filter((e=>!Number.isNaN(e)))})(e.BigNumber,t,r);e.addColumn(`relative_volume_${r}`,i)})(this,e),this}}})(),OHLCV_INDICATORS=r})();
package/index.js CHANGED
@@ -37,11 +37,19 @@ export default class OHLCV_INDICATORS {
37
37
  }
38
38
 
39
39
  getHeaders(){
40
- return Object.keys(this.getData())
40
+ return Object.keys(this.ohlcv)
41
41
  }
42
42
 
43
43
  getData() {
44
- return this.ohlcv
44
+ const {BigNumber, ohlcv} = this
45
+ const output = {}
46
+
47
+ for(const[key, arr] of Object.entries(ohlcv))
48
+ {
49
+ output[key] = arr.map(v => (BigNumber.isBigNumber(v)) ? v.toNumber() : v)
50
+ }
51
+
52
+ return output
45
53
  }
46
54
  getLastValues(){
47
55
  const output = {}
@@ -70,7 +78,7 @@ export default class OHLCV_INDICATORS {
70
78
 
71
79
  crossPairs(arr)
72
80
  {
73
- const ohlcv = this.getData();
81
+ const ohlcv = this.ohlcv;
74
82
  const slowNumArrCache = {};
75
83
 
76
84
  // Helper function to create column if it doesn't exist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohlcv-indicators",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "A JavaScript library featuring optimized trading indicators for OHLCV arrays [{open, high, low, close, value}], utilizing BigNumber precision for enhanced accuracy. This library is optimized for backtesting and trading bot development.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2,7 +2,7 @@ import { getSMA } from "./sma.js";
2
2
 
3
3
 
4
4
  export const BollingerBands = (main, size, times) => {
5
- const ohlcv = main.getData()
5
+ const {ohlcv} = main
6
6
  const data = ohlcv['close'];
7
7
  const bb = getBollingerBands(main.BigNumber, data, size, times)
8
8
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  export const EMA = (main, size) => {
3
- const ohlcv = main.getData()
3
+ const {ohlcv} = main
4
4
  const data = ohlcv['close']
5
5
  const ema = getEMA(main.BigNumber, data, size)
6
6
  main.addColumn(`ema_${size}`, ema)
@@ -1,6 +1,6 @@
1
1
  export const IchimokuCloud = (main, tenkan, kijun, senkou) => {
2
2
 
3
- const ohlcv = main.getData()
3
+ const {ohlcv} = main
4
4
  const ichi = getIchimokuCloud(main.BigNumber, ohlcv, tenkan, kijun, senkou)
5
5
 
6
6
  for(let k in ichi)
@@ -3,7 +3,7 @@ import { getEMA } from "./ema.js";
3
3
 
4
4
 
5
5
  export const MACD = (main, fastLine = 12, slowLine = 26, signalLine = 9) => {
6
- const ohlcv = main.getData()
6
+ const {ohlcv} = main
7
7
  const data = ohlcv['close'];
8
8
  const macd = getMACD(main.BigNumber, data, fastLine, slowLine, signalLine)
9
9
 
@@ -1,7 +1,7 @@
1
1
  import { getSMA } from './sma.js'
2
2
 
3
3
  export const RelativeVolume = (main, size) => {
4
- const ohlcv = main.getData()
4
+ const {ohlcv} = main
5
5
  const data = ohlcv['volume']
6
6
  const relVolume = getRelativeVolume(main.BigNumber, data, size)
7
7
  main.addColumn(`relative_volume_${size}`, relVolume)
@@ -1,6 +1,6 @@
1
1
 
2
2
  export const SMA = (main, size) => {
3
- const ohlcv = main.getData()
3
+ const {ohlcv} = main
4
4
  const data = ohlcv['close']
5
5
  const sma = getSMA(main.BigNumber, data, size)
6
6
  main.addColumn(`sma_${size}`, sma)
@@ -1,5 +1,5 @@
1
1
  export const MFI = (main, period = 14) => {
2
- const ohlcv = main.getData()
2
+ const {ohlcv} = main
3
3
  const mfi = getMFI(main.BigNumber, ohlcv, period)
4
4
  main.addColumn(`mfi_${period}`, mfi)
5
5
  }
@@ -6,7 +6,7 @@ const ma = {getSMA, getEMA}
6
6
 
7
7
  export const RSI = (main, period, movingAverage, movingAveragePeriod) => {
8
8
 
9
- const ohlcv = main.getData()
9
+ const {ohlcv} = main
10
10
  const data = ohlcv['close']
11
11
  const rsi = getRSI(main.BigNumber, data, period, movingAverage, movingAveragePeriod)
12
12
 
package/test/test.js CHANGED
@@ -33,10 +33,10 @@ const TEST = async () => {
33
33
  const isMacdHistogramUp = ({histogram, slice=4}) => {
34
34
 
35
35
  histogram = histogram.slice(-slice)
36
- const histogramDiff = histogram.slice(1).map((value, index) => value.minus(histogram[index]))
37
- const condition1 = histogram[histogram.length -1].isGreaterThan(0)
38
- const condition2 = histogram[histogram.length -1].isGreaterThan(histogram[histogram.length -2])
39
- const condition3 = histogramDiff.filter(diff => diff.isGreaterThan(0)).length > histogramDiff.filter(diff => diff.isLessThan(0)).length
36
+ const histogramDiff = histogram.slice(1).map((value, index) => value - histogram[index])
37
+ const condition1 = histogram[histogram.length -1] > 0
38
+ const condition2 = histogram[histogram.length -1] > histogram[histogram.length -2]
39
+ const condition3 = histogramDiff.filter(diff => diff > 0).length > histogramDiff.filter(diff => diff < 0).length
40
40
 
41
41
  if(condition1 && condition2 && condition3)
42
42
  {