UNPKG

@sunrise1002/tats

Version:

Techincal Indicators written in javascript

1 lines 54.3 kB
(function(e){'use strict';function r(e){return ee[e]}function t(e){let t=r('precision');return t?parseFloat(e.toPrecision(t)):e}function l(e){te.reverseInputs(e);var r=new le(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function o(e){te.reverseInputs(e);var r=new oe(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function a(e){te.reverseInputs(e);var r=new ae(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function n(e){te.reverseInputs(e);var r=new ne(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function s(e){te.reverseInputs(e);var r=new se(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function u(e){te.reverseInputs(e);var r=new ue(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function i(e){te.reverseInputs(e);var r=new ie(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function h(e){te.reverseInputs(e);var r=new he(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function p(e){te.reverseInputs(e);var r=new pe(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function g(e){te.reverseInputs(e);var r=new ge(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function v(e){te.reverseInputs(e);var r=new me(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function c(e){te.reverseInputs(e);var r=new we(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function d(e){te.reverseInputs(e);var r=new fe(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function m(e){te.reverseInputs(e);var r=new Ie(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function x(e){te.reverseInputs(e);var r=new _e(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function w(e){te.reverseInputs(e);var r=new Pe(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function f(e){te.reverseInputs(e);var r=new Ce(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function I(e){te.reverseInputs(e);var r=new be(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function _(e){te.reverseInputs(e);var r=new qe(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function P(e){te.reverseInputs(e);var r=new Ee(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function C(e){te.reverseInputs(e);var r=new Se(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function b(e){te.reverseInputs(e);var r=new Ve(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function q(e){te.reverseInputs(e);var r=new ke(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function E(e){te.reverseInputs(e);var r=new Ae(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function S(e){te.reverseInputs(e);var r=new Be(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function V(e,r,t,l){return e<=t&&r>=t||t<=e&&l>=e}function k(e){te.reverseInputs(e);var r=new He(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function A(e){te.reverseInputs(e);var r=new Le(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function B(e){te.reverseInputs(e);var r=new De(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function H(e){te.reverseInputs(e);var r=new Te(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function z(e){te.reverseInputs(e);var r=new Me(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function L(e){te.reverseInputs(e);var r=new Oe(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function D(e){te.reverseInputs(e);var r=new Re(e).result;return e.reversedInput&&(r.open.reverse(),r.high.reverse(),r.low.reverse(),r.close.reverse(),r.volume.reverse(),r.timestamp.reverse()),te.reverseInputs(e),r}function T(e){te.reverseInputs(e);var r=new je(e).result;return e.reversedInput&&(r.open.reverse(),r.high.reverse(),r.low.reverse(),r.close.reverse(),r.volume.reverse(),r.timestamp.reverse()),te.reverseInputs(e),r}function M(e){return new Ze().hasPattern(e)}function O(e){return new $e().hasPattern(e)}function R(e){return new er().hasPattern(e)}function j(e){return new rr().hasPattern(e)}function y(e){te.reverseInputs(e);var r=new Sr(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function F(e){te.reverseInputs(e);var r=new Vr(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function U(e){te.reverseInputs(e);var r=new kr(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function W(e){te.reverseInputs(e);var r=new Ar(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function K(e){te.reverseInputs(e);var r=new Br(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}function G(){return['sma','ema','wma','wema','macd','rsi','bollingerbands','adx','atr','truerange','roc','kst','psar','stochastic','williamsr','adl','obv','trix','cci','awesomeoscillator','forceindex','vwap','volumeprofile','renko','heikinashi','stochasticrsi','mfi','averagegain','averageloss','highest','lowest','sum','FixedSizeLinkedList','sd','bullish','bearish','abandonedbaby','doji','bearishengulfingpattern','bullishengulfingpattern','darkcloudcover','downsidetasukigap','dragonflydoji','gravestonedoji','bullishharami','bearishharami','bullishharamicross','bearishharamicross','eveningdojistar','eveningstar','morningdojistar','morningstar','bullishmarubozu','bearishmarubozu','piercingline','bullishspinningtop','bearishspinningtop','threeblackcrows','threewhitesoldiers','bullishhammerstick','bearishhammerstick','bullishinvertedhammerstick','bearishinvertedhammerstick','hammerpattern','hammerpatternunconfirmed','hangingman','hangingmanunconfirmed','shootingstar','shootingstarunconfirmed','tweezertop','tweezerbottom','ichimokucloud','keltnerchannels','chandelierexit','crossup','crossdown','crossover']}var N=Math.min,X=Math.max,J=Math.abs;class Q{constructor(e,r,t){this.next=t,t&&(t.prev=this),this.prev=r,r&&(r.next=this),this.data=e}}class Y{constructor(){this._length=0}get head(){return this._head&&this._head.data}get tail(){return this._tail&&this._tail.data}get current(){return this._current&&this._current.data}get length(){return this._length}push(e){this._tail=new Q(e,this._tail),0===this._length&&(this._head=this._tail,this._current=this._head,this._next=this._head),this._length++}pop(){var e=this._tail;if(0!==this._length)return(this._length--,0===this._length)?(this._head=this._tail=this._current=this._next=void 0,e.data):(this._tail=e.prev,this._tail.next=void 0,this._current===e&&(this._current=this._tail,this._next=void 0),e.prev=void 0,e.data)}shift(){var e=this._head;if(0!==this._length)return(this._length--,0===this._length)?(this._head=this._tail=this._current=this._next=void 0,e.data):(this._head=this._head.next,this._current===e&&(this._current=this._head,this._next=this._current.next),e.next=void 0,e.data)}unshift(e){this._head=new Q(e,void 0,this._head),0===this._length&&(this._tail=this._head,this._next=this._head),this._length++}unshiftCurrent(){var e=this._current;if(e===this._head||2>this._length)return e&&e.data;e===this._tail?(this._tail=e.prev,this._tail.next=void 0,this._current=this._tail):(e.next.prev=e.prev,e.prev.next=e.next,this._current=e.prev),this._next=this._current.next;e.prev;return e.prev=void 0,e.next=this._head,e.prev=void 0,this._head.prev=e,this._head=e,e.data}removeCurrent(){var e=this._current;if(0!==this._length)return(this._length--,0===this._length)?(this._head=this._tail=this._current=this._next=void 0,e.data):(e===this._tail?(this._tail=e.prev,this._tail.next=void 0,this._current=this._tail):e===this._head?(this._head=e.next,this._head.prev=void 0,this._current=this._head):(e.next.prev=e.prev,e.prev.next=e.next,this._current=e.prev),this._next=this._current.next,e.next=void 0,e.prev=void 0,e.data)}resetCursor(){return this._current=this._next=this._head,this}next(){var e=this._next;if(void 0!==e)return this._next=e.next,this._current=e,e.data}}class Z extends Y{constructor(e,r,t,l){if(super(),this.size=e,this.maintainHigh=r,this.maintainLow=t,this.maintainSum=l,this.totalPushed=0,this.periodHigh=0,this.periodLow=Infinity,this.periodSum=0,!e||'number'!=typeof e)throw'Size required and should be a number.';this._push=this.push,this.push=function(e){this.add(e),this.totalPushed++}}add(e){this.length===this.size?(this.lastShift=this.shift(),this._push(e),this.maintainHigh&&this.lastShift==this.periodHigh&&this.calculatePeriodHigh(),this.maintainLow&&this.lastShift==this.periodLow&&this.calculatePeriodLow(),this.maintainSum&&(this.periodSum-=this.lastShift)):this._push(e),this.maintainHigh&&this.periodHigh<=e&&(this.periodHigh=e),this.maintainLow&&this.periodLow>=e&&(this.periodLow=e),this.maintainSum&&(this.periodSum+=e)}*iterator(){for(this.resetCursor();this.next();)yield this.current}calculatePeriodHigh(){for(this.resetCursor(),this.next()&&(this.periodHigh=this.current);this.next();)this.periodHigh<=this.current&&(this.periodHigh=this.current)}calculatePeriodLow(){for(this.resetCursor(),this.next()&&(this.periodLow=this.current);this.next();)this.periodLow>=this.current&&(this.periodLow=this.current)}}class ${constructor(){this.open=[],this.high=[],this.low=[],this.close=[],this.volume=[],this.timestamp=[]}}let ee={};class re{}class te{constructor(e){this.format=e.format||t}static reverseInputs(e){e.reversedInput&&(e.values?e.values.reverse():void 0,e.open?e.open.reverse():void 0,e.high?e.high.reverse():void 0,e.low?e.low.reverse():void 0,e.close?e.close.reverse():void 0,e.volume?e.volume.reverse():void 0,e.timestamp?e.timestamp.reverse():void 0)}getResult(){return this.result}}class le extends te{constructor(e){super(e),this.period=e.period,this.price=e.values;this.generator=function*(e){var r,t=new Y,l=0,o=1,a=yield;for(t.push(0);;)o<e?(o++,t.push(a),l+=a):(l=l-t.shift()+a,r=l/e,t.push(a)),a=yield r}(this.period),this.generator.next(),this.result=[],this.price.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}le.calculate=l;class oe extends te{constructor(e){super(e);var r,t=e.period,l=e.values;this.result=[],r=new le({period:t,values:[]});this.generator=function*(){for(var e,l=yield;;)void 0!=e&&void 0!==l?(e=(l-e)*(2/(t+1))+e,l=yield e):(l=yield,e=r.nextValue(l),e&&(l=yield e))}(),this.generator.next(),this.generator.next(),l.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}oe.calculate=o;class ae extends te{constructor(e){super(e);var r=e.period,t=e.values;this.result=[],this.generator=function*(){for(let t=new Y;;)if(t.length<r)t.push((yield));else{t.resetCursor();let l=0;for(let e=1;e<=r;e++)l+=t.next()*e/(r*(r+1)/2);var e=yield l;t.shift(),t.push(e)}}(),this.generator.next(),t.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}ae.calculate=a;class ne extends te{constructor(e){super(e);var r,t=e.period,l=e.values;this.result=[],r=new le({period:t,values:[]});this.generator=function*(){for(var e,l=yield;;)void 0!=e&&void 0!==l?(e=(l-e)*(1/t)+e,l=yield e):(l=yield,e=r.nextValue(l),void 0!==e&&(l=yield e))}(),this.generator.next(),this.generator.next(),l.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}ne.calculate=n;class se extends te{constructor(e){super(e);var r=e.SimpleMAOscillator?le:oe,t=e.SimpleMASignal?le:oe,l=new r({period:e.fastPeriod,values:[],format:(e)=>e}),o=new r({period:e.slowPeriod,values:[],format:(e)=>e}),a=new t({period:e.signalPeriod,values:[],format:(e)=>e}),n=this.format;this.result=[],this.generator=function*(){for(var r,t,s,u,i,h,p=0;;){if(p<e.slowPeriod){r=yield,i=l.nextValue(r),h=o.nextValue(r),p++;continue}i&&h&&(t=i-h,s=a.nextValue(t)),u=t-s,r=yield{MACD:n(t),signal:s?n(s):void 0,histogram:isNaN(u)?void 0:n(u)},i=l.nextValue(r),h=o.nextValue(r)}}(),this.generator.next(),e.values.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e).value;return r}}se.calculate=s;class ue extends te{constructor(e){super(e);let r=e.values,t=e.period,l=this.format;this.generator=function*(e){var r,t,o=yield,a=1,n=0,s=o;for(o=yield;;)t=o-s,t=0<t?t:0,0<t&&(n+=t),a<e?a++:void 0==r?r=n/e:r=(r*(e-1)+t)/e,s=o,r=void 0===r?void 0:l(r),o=yield r}(t),this.generator.next(),this.result=[],r.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}ue.calculate=u;class ie extends te{constructor(e){super(e);let r=e.values,t=e.period,l=this.format;this.generator=function*(e){var r,t,o=yield,a=1,n=0,s=o;for(o=yield;;)t=s-o,t=0<t?t:0,0<t&&(n+=t),a<e?a++:void 0==r?r=n/e:r=(r*(e-1)+t)/e,s=o,r=void 0===r?void 0:l(r),o=yield r}(t),this.generator.next(),this.result=[],r.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}ie.calculate=i;class he extends te{constructor(e){super(e);var r=e.period,t=e.values,l=new ue({period:r,values:[]}),o=new ie({period:r,values:[]});let a=1;this.generator=function*(){for(var e,r,t,n,s=yield;;)e=l.nextValue(s),r=o.nextValue(s),void 0!==e&&void 0!==r&&(0===r?n=100:0===e?n=0:(t=e/r,t=isNaN(t)?0:t,n=parseFloat((100-100/(1+t)).toFixed(2)))),a++,s=yield n}(r),this.generator.next(),this.result=[],t.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}he.calculate=h;class pe extends te{constructor(e){super(e);var r=e.period,t=e.values,l=new le({period:r,values:[],format:(e)=>e});this.result=[],this.generator=function*(){var e,t,o=new Z(r);e=yield;for(var a;;){if(o.push(e),t=l.nextValue(e),t){let e=0;for(let r of o.iterator())e+=Math.pow(r-t,2);a=Math.sqrt(e/r)}e=yield a}}(),this.generator.next(),t.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return this.format(r.value)}}pe.calculate=p;class ge extends te{constructor(e){super(e);var r,t,l=e.period,o=e.values,a=e.stdDev,n=this.format;this.result=[],r=new le({period:l,values:[],format:(e)=>e}),t=new pe({period:l,values:[],format:(e)=>e}),this.generator=function*(){var e,l,o,s;for(l=yield;;){if(o=r.nextValue(l),s=t.nextValue(l),o){let r=n(o),t=n(o+s*a),u=n(o-s*a),i=n((l-u)/(t-u));e={middle:r,upper:t,lower:u,pb:i}}l=yield e}}(),this.generator.next(),o.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){return this.generator.next(e).value}}ge.calculate=g;class ve extends te{constructor(e){super(e),this.period=e.period,this.price=e.values;this.generator=function*(e){for(var r=new Y,t=0,l=1,o=yield,a=0;;)l<e?(l++,t+=o,a=void 0):l==e?(l++,t+=o,a=t):a=a-a/e+o,o=yield a}(this.period),this.generator.next(),this.result=[],this.price.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e).value;if(r!=void 0)return this.format(r)}}ve.calculate=function(e){te.reverseInputs(e);var r=new ve(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r};class ce extends te{constructor(e){super(e);var r=e.low,t=e.high,l=this.format;if(r.length!=t.length)throw'Inputs(low,high) not of equal size';this.result=[],this.generator=function*(){for(var e,r,t=yield;;){if(r){let o=t.high-r.high,a=r.low-t.low;e=l(a>o&&0<a?a:0)}r=t,t=yield e}}(),this.generator.next(),r.forEach((e,l)=>{var o=this.generator.next({high:t[l],low:r[l]});o.value!==void 0&&this.result.push(o.value)})}static calculate(e){te.reverseInputs(e);var r=new ce(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}nextValue(e){return this.generator.next(e).value}}class de extends te{constructor(e){super(e);var r=e.low,t=e.high,l=this.format;if(r.length!=t.length)throw'Inputs(low,high) not of equal size';this.result=[],this.generator=function*(){for(var e,r,t=yield;;){if(r){let o=t.high-r.high,a=r.low-t.low;e=l(o>a&&0<o?o:0)}r=t,t=yield e}}(),this.generator.next(),r.forEach((e,l)=>{var o=this.generator.next({high:t[l],low:r[l]});o.value!==void 0&&this.result.push(o.value)})}static calculate(e){te.reverseInputs(e);var r=new de(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r}nextValue(e){return this.generator.next(e).value}}class me extends te{constructor(e){super(e);var r=e.low,t=e.high,l=e.close,o=this.format;if(r.length!=t.length)throw'Inputs(low,high) not of equal size';this.result=[],this.generator=function*(){for(var e,r,t=yield;;)void 0==e&&(e=t.close,t=yield r),r=X(t.high-t.low,isNaN(J(t.high-e))?0:J(t.high-e),isNaN(J(t.low-e))?0:J(t.low-e)),e=t.close,void 0!=r&&(r=o(r)),t=yield r}(),this.generator.next(),r.forEach((e,o)=>{var a=this.generator.next({high:t[o],low:r[o],close:l[o]});a.value!=void 0&&this.result.push(a.value)})}nextValue(e){return this.generator.next(e).value}}me.calculate=v;class xe extends re{}class we extends te{constructor(e){super(e);var r=e.low,t=e.high,l=e.close,o=e.period,a=this.format,n=new de({high:[],low:[]}),s=new ce({high:[],low:[]}),u=new ve({period:o,values:[],format:(e)=>e}),i=new ve({period:o,values:[],format:(e)=>e}),h=new ve({period:o,values:[],format:(e)=>e}),p=new ne({period:o,values:[],format:(e)=>e}),g=new me({low:[],high:[],close:[]});if(r.length!==t.length||t.length!==l.length)throw'Inputs(low,high, close) not of equal size';this.result=[],xe,this.generator=function*(){var e,r,t,l,o,a,v,c=yield;for(e=0,r=0,t=0;;){let e=g.nextValue(c),r=n.nextValue(c),t=s.nextValue(c);if(e===void 0){c=yield;continue}let d=h.nextValue(e),m=u.nextValue(r),x=i.nextValue(t);if(d!=void 0&&m!=void 0&&x!=void 0){l=100*m/d,o=100*x/d;let e=J(l-o),r=l+o;a=100*(e/r),v=p.nextValue(a)}c=yield{adx:v,pdi:l,mdi:o}}}(),this.generator.next(),r.forEach((e,o)=>{var n=this.generator.next({high:t[o],low:r[o],close:l[o]});n.value!=void 0&&n.value.adx!=void 0&&this.result.push({adx:a(n.value.adx),pdi:a(n.value.pdi),mdi:a(n.value.mdi)})})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0&&r.adx!=void 0)return{adx:this.format(r.adx),pdi:this.format(r.pdi),mdi:this.format(r.mdi)}}}we.calculate=c;class fe extends te{constructor(e){super(e);var r=e.low,t=e.high,l=e.close,o=e.period,a=this.format;if(r.length!==t.length||t.length!==l.length)throw'Inputs(low,high, close) not of equal size';var n=new me({low:[],high:[],close:[]}),s=new ne({period:o,values:[],format:(e)=>e});this.result=[],this.generator=function*(){for(var e,r,t=yield;;)r=n.nextValue({low:t.low,high:t.high,close:t.close}),e=void 0===r?void 0:s.nextValue(r),t=yield e}(),this.generator.next(),r.forEach((e,o)=>{var n=this.generator.next({high:t[o],low:r[o],close:l[o]});n.value!==void 0&&this.result.push(a(n.value))})}nextValue(e){return this.generator.next(e).value}}fe.calculate=d;class Ie extends te{constructor(e){super(e);var r=e.period,t=e.values;this.result=[],this.generator=function*(){let e=1;for(var t,l=new Z(r),o=yield;;)l.push(o),e<r?e++:t=100*((o-l.lastShift)/l.lastShift),o=yield t}(),this.generator.next(),t.forEach((e)=>{var r=this.generator.next(e);r.value==void 0||isNaN(r.value)||this.result.push(this.format(r.value))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0&&!isNaN(r.value))return this.format(r.value)}}Ie.calculate=m;class _e extends te{constructor(e){super(e);let r=e.values,t=e.ROCPer1,l=e.ROCPer2,o=e.ROCPer3,a=e.ROCPer4,n=e.SMAROCPer1,s=e.SMAROCPer2,u=e.SMAROCPer3,i=e.SMAROCPer4,h=e.signalPeriod,p=new Ie({period:t,values:[]}),g=new Ie({period:l,values:[]}),v=new Ie({period:o,values:[]}),c=new Ie({period:a,values:[]}),d=new le({period:n,values:[],format:(e)=>e}),m=new le({period:s,values:[],format:(e)=>e}),x=new le({period:u,values:[],format:(e)=>e}),w=new le({period:i,values:[],format:(e)=>e}),f=new le({period:h,values:[],format:(e)=>e});var I=this.format;this.result=[];let _=X(t+n,l+s,o+u,a+i);this.generator=function*(){for(let e,r,t,l,o,a,n,s=1,u=yield;;){let i=p.nextValue(u),h=g.nextValue(u),P=v.nextValue(u),C=c.nextValue(u);r=i===void 0?void 0:d.nextValue(i),t=h===void 0?void 0:m.nextValue(h),l=P===void 0?void 0:x.nextValue(P),o=C===void 0?void 0:w.nextValue(C),s<_?s++:e=1*r+2*t+3*l+4*o,a=e===void 0?void 0:f.nextValue(e),n=e===void 0?void 0:{kst:I(e),signal:a?I(a):void 0},u=yield n}}(),this.generator.next(),r.forEach((e)=>{let r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!=void 0)return r.value}}_e.calculate=x;class Pe extends te{constructor(e){super(e);let r=e.high||[],t=e.low||[];this.result=[],this.generator=function*(e,r){for(let t,l,o,a,n=!0,s=e,u=yield;;)t?(o+=s*(l-o),n?(o=N(o,a.low,u.low),t.high>l&&(l=t.high,s=N(s+e,r))):(o=X(o,a.high,u.high),t.low<l&&(l=t.low,s=N(s+e,r))),(n&&t.low<o||!n&&t.high>o)&&(s=e,o=l,n=!n,l=n?t.high:t.low)):(o=u.low,l=u.high),a=u,t&&(u=t),t=yield o}(e.step,e.max),this.generator.next(),t.forEach((e,l)=>{var o=this.generator.next({high:r[l],low:t[l]});o.value!==void 0&&this.result.push(o.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}Pe.calculate=w;class Ce extends te{constructor(e){super(e);let r=e.low,t=e.high,l=e.close,o=e.period,a=e.signalPeriod,n=this.format;if(r.length!==t.length||t.length!==l.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){let e,r,t=1,l=new Z(o,!0,!1),s=new Z(o,!1,!0),u=new le({period:a,values:[],format:(e)=>e});for(var i=yield;;){if(l.push(i.high),s.push(i.low),t<o){t++,i=yield;continue}let a=s.periodLow;e=100*((i.close-a)/(l.periodHigh-a)),e=isNaN(e)?0:e,r=u.nextValue(e),i=yield{k:n(e),d:void 0===r?void 0:n(r)}}}(),this.generator.next(),r.forEach((e,o)=>{var a=this.generator.next({high:t[o],low:r[o],close:l[o]});a.value!==void 0&&this.result.push(a.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}Ce.calculate=f;class be extends te{constructor(e){super(e);let r=e.low,t=e.high,l=e.close,o=e.period,a=this.format;if(r.length!==t.length||t.length!==l.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){let e,r,t=1,l=new Z(o,!0,!1),n=new Z(o,!1,!0);var s=yield;for(let u;;){if(l.push(s.high),n.push(s.low),t<o){t++,s=yield;continue}e=n.periodLow,r=l.periodHigh,u=a(-100*((r-s.close)/(r-e))),s=yield u}}(),this.generator.next(),r.forEach((e,o)=>{var a=this.generator.next({high:t[o],low:r[o],close:l[o]});a.value!==void 0&&this.result.push(a.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return this.format(r.value)}}be.calculate=I;class qe extends te{constructor(e){super(e);var r=e.high,t=e.low,l=e.close,o=e.volume;if(t.length!==r.length||r.length!==l.length||r.length!==o.length)throw'Inputs(low,high, close, volumes) not of equal size';this.result=[],this.generator=function*(){var e,r=0;for(e=yield;;){let t=(e.close-e.low-(e.high-e.close))/(e.high-e.low);t=isNaN(t)?1:t;let l=t*e.volume;r+=l,e=yield Math.round(r)}}(),this.generator.next(),r.forEach((e,r)=>{var a={high:e,low:t[r],close:l[r],volume:o[r]},n=this.generator.next(a);n.value!=void 0&&this.result.push(n.value)})}nextValue(e){return this.generator.next(e).value}}qe.calculate=_;class Ee extends te{constructor(e){super(e);var r=e.close,t=e.volume;this.result=[],this.generator=function*(){var e,r,t=0;for(e=yield,e.close&&'number'==typeof e.close&&(r=e.close,e=yield);;)r<e.close?t+=e.volume:e.close<r&&(t-=e.volume),r=e.close,e=yield t}(),this.generator.next(),r.forEach((e,l)=>{let o={close:r[l],volume:t[l]},a=this.generator.next(o);a.value!=void 0&&this.result.push(a.value)})}nextValue(e){return this.generator.next(e).value}}Ee.calculate=P;class Se extends te{constructor(e){super(e);let r=e.values,t=e.period,l=this.format,o=new oe({period:t,values:[],format:(e)=>e}),a=new oe({period:t,values:[],format:(e)=>e}),n=new oe({period:t,values:[],format:(e)=>e}),s=new Ie({period:1,values:[],format:(e)=>e});this.result=[],this.generator=function*(){for(let e=yield;;){let r=o.nextValue(e),t=r?a.nextValue(r):void 0,u=t?n.nextValue(t):void 0,i=u?s.nextValue(u):void 0;e=yield i?l(i):void 0}}(),this.generator.next(),r.forEach((e)=>{let r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}Se.calculate=C;class Ve extends te{constructor(e){super(e);var r=e.close,t=e.volume,l=e.period||1;if(t.length!==r.length)throw'Inputs(volume, close) not of equal size';let o=new oe({values:[],period:l});this.result=[],this.generator=function*(){var e=yield,r=yield;for(let t;;)t=(r.close-e.close)*r.volume,e=r,r=yield o.nextValue(t)}(),this.generator.next(),t.forEach((e,l)=>{var o=this.generator.next({close:r[l],volume:t[l]});o.value!=void 0&&this.result.push(o.value)})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0)return r}}Ve.calculate=b;class ke extends te{constructor(e){super(e);var r=e.low,t=e.high,l=e.close,o=e.period,a=this.format;var n=new Z(o),s=new le({period:o,values:[],format:(e)=>e});if(r.length!==t.length||t.length!==l.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){for(var e=yield;;){let r=(e.high+e.low+e.close)/3;n.push(r);let t,l=s.nextValue(r),a=null,u=0;if(l!=void 0){for(let e of n.iterator())u+=J(e-l);a=u/o,t=(r-l)/(.015*a)}e=yield t}}(),this.generator.next(),r.forEach((e,o)=>{var a=this.generator.next({high:t[o],low:r[o],close:l[o]});a.value!=void 0&&this.result.push(a.value)})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0)return r}}ke.calculate=q;class Ae extends te{constructor(e){super(e);var r=e.high,t=e.low,l=e.fastPeriod,o=e.slowPeriod,a=new le({values:[],period:o}),n=new le({values:[],period:l});this.result=[],this.generator=function*(){var e,r,t,l,o;for(r=yield;;)t=(r.high+r.low)/2,l=a.nextValue(t),o=n.nextValue(t),void 0!==l&&void 0!==o&&(e=o-l),r=yield e}(),this.generator.next(),r.forEach((e,r)=>{var l={high:e,low:t[r]},o=this.generator.next(l);o.value!=void 0&&this.result.push(this.format(o.value))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return this.format(r.value)}}Ae.calculate=E;class Be extends te{constructor(e){super(e);var r=e.low,t=e.high,l=e.close,o=e.volume,a=this.format;if(r.length!==t.length||t.length!==l.length)throw'Inputs(low,high, close) not of equal size';this.result=[],this.generator=function*(){var e=yield;for(let r=0,t=0;;){let l=(e.high+e.low+e.close)/3,o=e.volume*l;r+=o,t+=e.volume,e=yield r/t}}(),this.generator.next(),r.forEach((e,a)=>{var n=this.generator.next({high:t[a],low:r[a],close:l[a],volume:o[a]});n.value!=void 0&&this.result.push(n.value)})}nextValue(e){let r=this.generator.next(e).value;if(r!=void 0)return r}}Be.calculate=S;class He extends te{constructor(e){super(e);var r=e.high,t=e.low,l=e.close,o=e.open,a=e.volume,n=e.noOfBars;if(t.length!==r.length||r.length!==l.length||r.length!==a.length)throw'Inputs(low,high, close, volumes) not of equal size';this.result=[];var s=X(...r,...t,...l,...o),u=N(...r,...t,...l,...o),i=u;for(let h=0;h<n;h++){let e=i,h=e+(s-u)/n;i=h;let p=0,g=0,v=0;for(let n=0;n<r.length;n++){let s=t[n],u=r[n],i=o[n],c=l[n],d=a[n];V(e,h,s,u)&&(v+=d,i>c?g+=d:p+=d)}this.result.push({rangeStart:e,rangeEnd:h,bullishVolume:p,bearishVolume:g,totalVolume:v})}}nextValue(){throw'Next value not supported for volume profile'}}He.calculate=k;class ze extends te{constructor(e){super(e),this.result=[],this.generator=function*(){for(let e=yield;;)e=yield(e.high+e.low+e.close)/3}(),this.generator.next(),e.low.forEach((r,t)=>{var l=this.generator.next({high:e.high[t],low:e.low[t],close:e.close[t]});this.result.push(l.value)})}nextValue(e){var r=this.generator.next(e).value;return r}}ze.calculate=function(e){te.reverseInputs(e);var r=new ze(e).result;return e.reversedInput&&r.reverse(),te.reverseInputs(e),r};class Le extends te{constructor(e){super(e);var r=e.high,t=e.low,l=e.close,o=e.volume,a=e.period,n=new ze({low:[],high:[],close:[]}),s=new Z(a,!1,!1,!0),u=new Z(a,!1,!1,!0);if(t.length!==r.length||r.length!==l.length||r.length!==o.length)throw'Inputs(low,high, close, volumes) not of equal size';this.result=[],this.generator=function*(){var e,r,t,l,o,i,h=0;let p=null,g=null;for(r=yield,t=r.close,r=yield;;){var{high:v,low:c,close:d,volume:m}=r,x=0,w=0;p=n.nextValue({high:v,low:c,close:d}),h=p*m,null!=p&&null!=g&&(p>g?x=h:w=h,s.push(x),u.push(w),l=s.periodSum,i=u.periodSum,s.totalPushed>=a&&s.totalPushed>=a&&(o=l/i,e=100-100/(1+o))),g=p,r=yield e}}(),this.generator.next(),r.forEach((e,r)=>{var a={high:e,low:t[r],close:l[r],volume:o[r]},n=this.generator.next(a);n.value!=void 0&&this.result.push(parseFloat(n.value.toFixed(2)))})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return parseFloat(r.value.toFixed(2))}}Le.calculate=A;class De extends te{constructor(e){super(e);let r=e.values,t=e.rsiPeriod,l=e.stochasticPeriod,o=e.kPeriod,a=e.dPeriod,n=this.format;this.result=[],this.generator=function*(){let e,r,n,s,u=new he({period:t,values:[]}),i=new Ce({period:l,high:[],low:[],close:[],signalPeriod:o}),h=new le({period:a,values:[],format:(e)=>e});for(var p=yield;;){if(e=u.nextValue(p),void 0!==e){var g={high:e,low:e,close:e};r=i.nextValue(g),void 0!==r&&void 0!==r.d&&(n=h.nextValue(r.d),void 0!==n&&(s={stochRSI:r.k,k:r.d,d:n}))}p=yield s}}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!==void 0&&this.result.push(r.value)})}nextValue(e){let r=this.generator.next(e);if(r.value!==void 0)return r.value}}De.calculate=B;class Te extends te{constructor(e){super(e);var r=e.values,t=e.period;this.result=[];var l=new Z(t,!0,!1,!1);this.generator=function*(){var e,r;for(e=yield;;)l.push(e),l.totalPushed>=t&&(r=l.periodHigh),e=yield r}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}Te.calculate=H;class Me extends te{constructor(e){super(e);var r=e.values,t=e.period;this.result=[];var l=new Z(t,!1,!0,!1);this.generator=function*(){var e,r;for(e=yield;;)l.push(e),l.totalPushed>=t&&(r=l.periodLow),e=yield r}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}Me.calculate=z;class Oe extends te{constructor(e){super(e);var r=e.values,t=e.period;this.result=[];var l=new Z(t,!1,!1,!0);this.generator=function*(){var e,r;for(e=yield;;)l.push(e),l.totalPushed>=t&&(r=l.periodSum),e=yield r}(),this.generator.next(),r.forEach((e)=>{var r=this.generator.next(e);r.value!=void 0&&this.result.push(r.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}Oe.calculate=L;class Re extends te{constructor(e){super(e);this.format;let r=e.useATR,t=e.brickSize||0;if(r){let r=d(Object.assign({},e));t=r[r.length-1]}if(this.result=new $,0===t)return void console.error('Not enough data to calculate brickSize for renko when using ATR');let l=0,o=0,a=Infinity,n=0,s=0,u=0;this.generator=function*(){for(let e=yield;;){if(0==l){l=e.close,o=e.high,a=e.low,n=e.close,s=e.volume,u=e.timestamp,e=yield;continue}let r=J(e.close-n),i=J(e.close-l);if(r>=t&&i>=t){let u=r>i?l:n,h={open:u,high:o>e.high?o:e.high,low:a<e.Low?a:e.low,close:u>e.close?u-t:u+t,volume:s+e.volume,timestamp:e.timestamp};l=h.open,o=h.close,a=h.close,n=h.close,s=0,e=yield h}else o=o>e.high?o:e.high,a=a<e.Low?a:e.low,s+=e.volume,u=e.timestamp,e=yield}}(),this.generator.next(),e.low.forEach((r,t)=>{var l=this.generator.next({open:e.open[t],high:e.high[t],low:e.low[t],close:e.close[t],volume:e.volume[t],timestamp:e.timestamp[t]});l.value&&(this.result.open.push(l.value.open),this.result.high.push(l.value.high),this.result.low.push(l.value.low),this.result.close.push(l.value.close),this.result.volume.push(l.value.volume),this.result.timestamp.push(l.value.timestamp))})}nextValue(){return console.error('Cannot calculate next value on Renko, Every value has to be recomputed for every change, use calcualte method'),null}}Re.calculate=D;class je extends te{constructor(e){super(e);this.format;this.result=new $;let r=null,t=0,l=Infinity,o=0,a=0,n=0;this.generator=function*(){for(let e=yield,s=null;;){if(null==r)r=(e.close+e.open)/2,t=e.high,l=e.low,o=(e.close+e.open+e.high+e.low)/4,a=e.volume||0,n=e.timestamp||0,s={open:r,high:t,low:l,close:o,volume:e.volume||0,timestamp:e.timestamp||0};else{let a=(e.close+e.open+e.high+e.low)/4,n=(r+o)/2,u=X(n,a,e.high),i=N(e.low,n,a);s={close:a,open:n,high:u,low:i,volume:e.volume||0,timestamp:e.timestamp||0},o=a,r=n,t=u,l=i}e=yield s}}(),this.generator.next(),e.low.forEach((r,t)=>{var l=this.generator.next({open:e.open[t],high:e.high[t],low:e.low[t],close:e.close[t],volume:e.volume?e.volume[t]:e.volume,timestamp:e.timestamp?e.timestamp[t]:e.timestamp});l.value&&(this.result.open.push(l.value.open),this.result.high.push(l.value.high),this.result.low.push(l.value.low),this.result.close.push(l.value.close),this.result.volume.push(l.value.volume),this.result.timestamp.push(l.value.timestamp))})}nextValue(e){var r=this.generator.next(e).value;return r}}je.calculate=T;class ye{constructor(){}approximateEqual(e,r){let t=1*parseFloat(J(e-r).toPrecision(4)),l=1*parseFloat((1e-3*e).toPrecision(4));return t<=l}logic(){throw'this has to be implemented'}getAllPatternIndex(e){if(e.close.length<this.requiredCount)return console.warn('Data count less than data required for the strategy ',this.name),[];e.reversedInput&&(e.open.reverse(),e.high.reverse(),e.low.reverse(),e.close.reverse());let r=this.logic;return this._generateDataForCandleStick(e).map((e,t)=>r.call(this,e)?t:void 0).filter((e)=>e)}hasPattern(e,r){if(e.close.length<this.requiredCount)return console.warn('Data count less than data required for the strategy ',this.name),!1;e.reversedInput&&(e.open.reverse(),e.high.reverse(),e.low.reverse(),e.close.reverse());let t=this.logic;return t.call(this,this._getLastDataForCandleStick(e),r)}_getLastDataForCandleStick(e){let r=this.requiredCount;if(e.close.length===r)return e;else{let t={open:[],high:[],low:[],close:[]},l=0,o=e.close.length-r;for(;l<r;)t.open.push(e.open[o+l]),t.high.push(e.high[o+l]),t.low.push(e.low[o+l]),t.close.push(e.close[o+l]),l++;return t}}_generateDataForCandleStick(e){let r=this.requiredCount,t=e.close.map(function(t,l){let o=0,a={open:[],high:[],low:[],close:[]};for(;o<r;)a.open.push(e.open[l+o]),a.high.push(e.high[l+o]),a.low.push(e.low[l+o]),a.close.push(e.close[l+o]),o++;return a}).filter((t,l)=>l<=e.close.length-r);return t}}class Fe extends ye{constructor(){super(),this.name='MorningStar',this.requiredCount=3}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1],h=e.open[2],p=e.close[2],g=e.high[2],v=e.low[2],c=l<t&&t-l>3*J(n-s),d=p>h&&p-h>3*J(n-s)&&p>n&&p>s;return c&&d&&p>(t+l)/2&&(!r||u<a&&i<a&&h>u&&s<h)}}class Ue extends ye{constructor(){super(),this.name='BullishEngulfingPattern',this.requiredCount=2}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1];return l<t&&t<s&&(!r||t>n&&l>n)}}class We extends ye{constructor(){super(),this.requiredCount=2,this.name='BullishHarami'}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1];return t>n&&l<s&&t>u&&a<i&&(!r||l<n)}}class Ke extends ye{constructor(){super(),this.requiredCount=2,this.name='BullishHaramiCross'}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1],h=this.approximateEqual(n,s);return t>n&&l<s&&t>u&&a<i&&(!r||l<n)&&h&&h}}class Ge extends ye{constructor(){super(),this.name='Doji',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=this.approximateEqual(r,t),n=a&&this.approximateEqual(r,l),s=a&&this.approximateEqual(t,o);return a&&n==s}}class Ne extends ye{constructor(){super(),this.name='MorningDojiStar',this.requiredCount=3}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1],h=e.open[2],p=e.close[2],g=e.high[2],v=e.low[2],c=l<t&&t-l>3*J(n-s),d=new Ge().hasPattern({open:[n],close:[s],high:[u],low:[i]}),m=p>h&&p-h>3*J(n-s)&&p>n&&p>s;return c&&d&&m&&p>(t+l)/2&&(!r||u<a&&i<a&&h>u&&s<h)}}class Xe extends ye{constructor(){super(),this.requiredCount=3,this.name='DownsideTasukiGap'}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1],i=e.open[2],h=e.close[2],p=e.high[2],g=e.low[2];return t<r&&n<a&&h>i&&s<o&&a>i&&n<i&&h>a&&h<t}}class Je extends ye{constructor(){super(),this.name='BullishMarubozu',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=this.approximateEqual(t,l)&&this.approximateEqual(o,r)&&r<t&&r<l;return a}}class Qe extends ye{constructor(){super(),this.requiredCount=2,this.name='PiercingLine'}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return u<o&&t<r&&o>a&&n>(r+t)/2&&n>a}}class Ye extends ye{constructor(){super(),this.name='ThreeWhiteSoldiers',this.requiredCount=3}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1],h=e.open[2],p=e.close[2],g=e.high[2],v=e.low[2];return u>o&&g>u&&t<l&&n<s&&h<p&&(!r||l>n&&n<o&&u>h&&h<s)}}class Ze extends ye{constructor(){super(),this.name='BullishHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=t>r;return a=a&&this.approximateEqual(t,l),a=a&&2*(t-r)<=r-o,a=a&&3*(l-t)<r-o,a}}class $e extends ye{constructor(){super(),this.name='BullishInvertedHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=t>r;return a=a&&this.approximateEqual(r,o),a=a&&2*(t-r)<=l-t,a=a&&3*(r-o)<l-t,a}}class er extends ye{constructor(){super(),this.name='BearishHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=r>t;return a=a&&this.approximateEqual(r,l),a=a&&2*(r-t)<=t-o,a=a&&3*(l-r)<t-o,a}}class rr extends ye{constructor(){super(),this.name='BearishInvertedHammerStick',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=r>t;return a=a&&this.approximateEqual(t,o),a=a&&2*(r-t)<=l-r,a=a&&3*(t-o)<l-r,a}}class tr extends ye{constructor(){super(),this.name='HammerPattern',this.requiredCount=5}logic(e){let r=this.downwardTrend(e);return r=r&&this.includesHammer(e),r=r&&this.hasConfirmation(e),r}downwardTrend(e,r=!0){let t=r?3:4,l=u({values:e.close.slice(0,t),period:t-1}),o=i({values:e.close.slice(0,t),period:t-1});return o>l}includesHammer(e,r=!0){let t=r?3:4,l=r?4:void 0,o={open:e.open.slice(t,l),close:e.close.slice(t,l),low:e.low.slice(t,l),high:e.high.slice(t,l)},a=R(o);return a=a||j(o),a=a||M(o),a=a||O(o),a}hasConfirmation(e){let r={open:e.open[3],close:e.close[3],low:e.low[3],high:e.high[3]},t={open:e.open[4],close:e.close[4],low:e.low[4],high:e.high[4]},l=t.open<t.close;return l&&r.close<t.close}}class lr extends tr{constructor(){super(),this.name='HammerPatternUnconfirmed'}logic(e){let r=this.downwardTrend(e,!1);return r=r&&this.includesHammer(e,!1),r}}class or extends ye{constructor(){super(),this.name='TweezerBottom',this.requiredCount=5}logic(e){return this.downwardTrend(e)&&e.low[3]==e.low[4]}downwardTrend(e){let r=u({values:e.close.slice(0,3),period:2}),t=i({values:e.close.slice(0,3),period:2});return t>r}}let ar=[new Ue,new Xe,new We,new Ke,new Ne,new Fe,new Je,new Qe,new Ye,new Ze,new $e,new tr,new lr,new or];class nr extends ye{constructor(){super(),this.name='Bullish Candlesticks'}hasPattern(e){return ar.reduce(function(r,t){let l=t.hasPattern(e);return r||l},!1)}}class sr extends ye{constructor(){super(),this.name='BearishEngulfingPattern',this.requiredCount=2}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1];return l>t&&t>s&&(!r||t<n&&l<n)}}class ur extends ye{constructor(){super(),this.requiredCount=2,this.name='BearishHarami'}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1];return t<n&&l>s&&t<i&&o>u&&(!r||l>n)}}class ir extends ye{constructor(){super(),this.requiredCount=2,this.name='BearishHaramiCross'}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1],h=this.approximateEqual(n,s);return t<n&&l>s&&t<i&&o>u&&(!r||l>n)&&h&&h}}class hr extends ye{constructor(){super(),this.name='EveningDojiStar',this.requiredCount=3}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1],h=e.open[2],p=e.close[2],g=e.high[2],v=e.low[2],c=l>t&&t-l>3*J(n-s),d=new Ge().hasPattern({open:[n],close:[s],high:[u],low:[i]}),m=h>p&&h-p>3*J(n-s)&&h<n&&h<s;return c&&d&&m&&p<(t+l)/2&&(!r||u>o&&i>o&&h<i&&s>h)}}class pr extends ye{constructor(){super(),this.name='EveningStar',this.requiredCount=3}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1],h=e.open[2],p=e.close[2],g=e.high[2],v=e.low[2],c=l>t&&t-l>3*J(n-s),d=h>p&&h-p>3*J(n-s)&&h<n&&h<s,m=u>o&&i>o&&h<i&&s>h;return c&&m&&d&&p<(t+l)/2&&(!r||m)}}class gr extends ye{constructor(){super(),this.name='BearishMarubozu',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=this.approximateEqual(r,l)&&this.approximateEqual(o,t)&&r>t&&r>o;return a}}class vr extends ye{constructor(){super(),this.name='ThreeBlackCrows',this.requiredCount=3}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1],h=e.open[2],p=e.close[2],g=e.high[2],v=e.low[2];return a>i&&i>v&&t>l&&n>s&&h>p&&(!r||t>n&&n>l&&n>h&&h>s)}}class cr extends ye{constructor(){super(),this.name='HangingMan',this.requiredCount=5}logic(e){let r=this.upwardTrend(e);return r=r&&this.includesHammer(e),r=r&&this.hasConfirmation(e),r=r&&this.hammerShouldHasHighestOpenOrClose(e),r}upwardTrend(e,r=!0){let t=r?3:4,l=u({values:e.close.slice(0,t),period:t-1}),o=i({values:e.close.slice(0,t),period:t-1});return l>o}includesHammer(e,r=!0){let t=r?3:4,l=r?4:void 0,o={open:e.open.slice(t,l),close:e.close.slice(t,l),low:e.low.slice(t,l),high:e.high.slice(t,l)},a=R(o);return a=a||M(o),a}hammerShouldHasHighestOpenOrClose(e){const r=e.open.length,t=e.open.slice(0,r-1),l=e.close.slice(0,r-1),o=t[t.length-1],a=l[l.length-1];return[o,a].includes(X(...t,...l))}hasConfirmation(e){let r={open:e.open[3],close:e.close[3],low:e.low[3],high:e.high[3]},t={open:e.open[4],close:e.close[4],low:e.low[4],high:e.high[4]},l=t.open>t.close;return l&&r.close>t.close}}class dr extends cr{constructor(){super(),this.name='HangingManUnconfirmed'}logic(e){let r=this.upwardTrend(e,!1);return r=r&&this.includesHammer(e,!1),r=r&&this.hammerShouldHasHighestOpenOrClose(e),r}}class mr extends ye{constructor(){super(),this.name='ShootingStar',this.requiredCount=5}logic(e){let r=this.upwardTrend(e);return r=r&&this.includesHammer(e),r=r&&this.hasConfirmation(e),r=r&&this.hammerShouldHasHighestOpenOrClose(e),r}upwardTrend(e,r=!0){let t=r?3:4,l=u({values:e.close.slice(0,t),period:t-1}),o=i({values:e.close.slice(0,t),period:t-1});return l>o}includesHammer(e,r=!0){let t=r?3:4,l=r?4:void 0,o={open:e.open.slice(t,l),close:e.close.slice(t,l),low:e.low.slice(t,l),high:e.high.slice(t,l)},a=j(o);return a=a||O(o),a}hammerShouldHasHighestOpenOrClose(e){const r=e.open.length,t=e.open.slice(0,r-1),l=e.close.slice(0,r-1),o=t[t.length-1],a=l[l.length-1];return[o,a].includes(X(...t,...l))}hasConfirmation(e){let r={open:e.open[3],close:e.close[3],low:e.low[3],high:e.high[3]},t={open:e.open[4],close:e.close[4],low:e.low[4],high:e.high[4]},l=t.open>t.close;return l&&r.close>t.close}}class xr extends mr{constructor(){super(),this.name='ShootingStarUnconfirmed'}logic(e){let r=this.upwardTrend(e,!1);return r=r&&this.includesHammer(e,!1),r}}class wr extends ye{constructor(){super(),this.name='TweezerTop',this.requiredCount=5}logic(e){return this.upwardTrend(e)&&e.high[3]==e.high[4]}upwardTrend(e){let r=u({values:e.close.slice(0,3),period:2}),t=i({values:e.close.slice(0,3),period:2});return r>t}}let fr=[new sr,new ur,new ir,new hr,new pr,new gr,new vr,new er,new rr,new cr,new dr,new mr,new xr,new wr];class Ir extends ye{constructor(){super(),this.name='Bearish Candlesticks'}hasPattern(e){return fr.reduce(function(r,t){return r||t.hasPattern(e)},!1)}}class _r extends ye{constructor(){super(),this.name='AbandonedBaby',this.requiredCount=3}logic(e,r){let t=e.open[0],l=e.close[0],o=e.high[0],a=e.low[0],n=e.open[1],s=e.close[1],u=e.high[1],i=e.low[1],h=e.open[2],p=e.close[2],g=e.high[2],v=e.low[2],c=l<t&&t-l>3*J(n-s),d=new Ge().hasPattern({open:[n],close:[s],high:[u],low:[i]}),m=p>h&&p-h>3*J(n-s)&&p>n&&p>s;return c&&d&&m&&(!r||u<a&&v>u)}}class Pr extends ye{constructor(){super(),this.name='DarkCloudCover',this.requiredCount=2}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=e.open[1],n=e.close[1],s=e.high[1],u=e.low[1];return t>r&&n<a&&a>l&&n<(t+r)/2&&n>r}}class Cr extends ye{constructor(){super(),this.requiredCount=1,this.name='DragonFlyDoji'}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=this.approximateEqual(r,t),n=a&&this.approximateEqual(r,l),s=a&&this.approximateEqual(t,o);return a&&n&&!s}}class br extends ye{constructor(){super(),this.requiredCount=1,this.name='GraveStoneDoji'}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=this.approximateEqual(r,t),n=a&&this.approximateEqual(r,l),s=a&&this.approximateEqual(t,o);return a&&s&&!n}}class qr extends ye{constructor(){super(),this.name='BullishSpinningTop',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=J(t-r),n=J(l-t),s=J(r-o);return a<n&&a<s}}class Er extends ye{constructor(){super(),this.name='BearishSpinningTop',this.requiredCount=1}logic(e){let r=e.open[0],t=e.close[0],l=e.high[0],o=e.low[0],a=J(t-r),n=J(l-r),s=J(l-o);return a<n&&a<s}}class Sr extends te{constructor(e){super(e),this.result=[];var r=Object.assign({},{conversionPeriod:9,basePeriod:26,spanPeriod:52,displacement:26},e),t=new Z(2*r.conversionPeriod,!0,!0,!1),l=new Z(2*r.basePeriod,!0,!0,!1),o=new Z(2*r.spanPeriod,!0,!0,!1);this.generator=function*(){let e,a,n=X(r.conversionPeriod,r.basePeriod,r.spanPeriod,r.displacement),s=1;for(a=yield;;){if(t.push(a.high),t.push(a.low),l.push(a.high),l.push(a.low),o.push(a.high),o.push(a.low),s<n)s++;else{let r=(t.periodHigh+t.periodLow)/2,a=(l.periodHigh+l.periodLow)/2,n=(o.periodHigh+o.periodLow)/2;e={conversion:r,base:a,spanA:(r+a)/2,spanB:n}}a=yield e}}(),this.generator.next(),e.low.forEach((r,t)=>{var l=this.generator.next({high:e.high[t],low:e.low[t]});l.value&&this.result.push(l.value)})}nextValue(e){return this.generator.next(e).value}}Sr.calculate=y;class Vr extends te{constructor(e){super(e);var r,t=e.useSMA?le:oe,l=new t({period:e.maPeriod,values:[],format:(e)=>e}),o=new fe({period:e.atrPeriod,high:[],low:[],close:[],format:(e)=>e});this.result=[],this.generator=function*(){var t;for(r=yield;;){var{close:a}=r,n=l.nextValue(a),s=o.nextValue(r);n!=void 0&&s!=void 0&&(t={middle:n,upper:n+e.multiplier*s,lower:n-e.multiplier*s}),r=yield t}}(),this.generator.next();var a=e.high;a.forEach((r,t)=>{var l={high:r,low:e.low[t],close:e.close[t]},o=this.generator.next(l);o.value!=void 0&&this.result.push(o.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}Vr.calculate=F;class kr extends te{constructor(e){super(e);var r=e.high,t=e.low,l=e.close;this.result=[];var o=new fe({period:e.period,high:[],low:[],close:[],format:(e)=>e}),a=new Z(2*e.period,!0,!0,!1);this.generator=function*(){for(var r,t,l=yield;;){var{high:n,low:s}=l;a.push(n),a.push(s),t=o.nextValue(l),a.totalPushed>=2*e.period&&t!=void 0&&(r={exitLong:a.periodHigh-t*e.multiplier,exitShort:a.periodLow+t*e.multiplier}),l=yield r}}(),this.generator.next(),r.forEach((e,r)=>{var o={high:e,low:t[r],close:l[r]},a=this.generator.next(o);a.value!=void 0&&this.result.push(a.value)})}nextValue(e){var r=this.generator.next(e);if(r.value!=void 0)return r.value}}kr.calculate=U;class Ar extends te{constructor(e){super(e),this.lineA=e.lineA,this.lineB=e.lineB;var r=[],t=[];this.generator=function*(){for(var e=yield,l=!1;;){r.unshift(e.valueA),t.unshift(e.valueB),l=e.valueA>e.valueB;for(var o=1;!0==l&&r[o]>=t[o];)r[o]>t[o]?l=!1:r[o]<t[o]?l=!0:r[o]===t[o]&&(o+=1);!0==l&&(r=[e.valueA],t=[e.valueB]),e=yield l}}(),this.generator.next(),this.result=[],this.lineA.forEach((e,r)=>{var t=this.generator.next({valueA:this.lineA[r],valueB:this.lineB[r]});t.value!==void 0&&this.result.push(t.value)})}static reverseInputs(e){e.reversedInput&&(e.lineA?e.lineA.reverse():void 0,e.lineB?e.lineB.reverse():void 0)}nextValue(e,r){return this.generator.next({valueA:e,valueB:r}).value}}Ar.calculate=W;class Br extends te{constructor(e){super(e),this.lineA=e.lineA,this.lineB=e.lineB;var r=[],t=[];this.generator=function*(){for(var e=yield,l=!1;;){r.unshift(e.valueA),t.unshift(e.valueB),l=e.valueA<e.valueB;for(var o=1;!0==l&&r[o]<=t[o];)r[o]<t[o]?l=!1:r[o]>t[o]?l=!0:r[o]===t[o]&&(o+=1);!0==l&&(r=[e.valueA],t=[e.valueB]),e=yield l}}(),this.generator.next(),this.result=[],this.lineA.forEach((e,r)