ohlcv-indicators 3.5.80 → 3.5.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -2
- package/README.md +1 -16
- package/dist/ohlcv-indicators.min.js +1 -2
- package/index.js +24 -3
- package/package.json +5 -12
- package/src/core-functions/mainLoop.js +2 -0
- package/src/core-indicators/README.md +1 -19
- package/src/core-indicators/indicator.js +11 -29
- package/src/moving-averages/heikenAshi.js +75 -85
- package/src/moving-averages/movingAverages.js +38 -13
- package/src/oscillators/cmf.js +78 -0
- package/src/oscillators/volumeOscillator.js +3 -0
- package/src/studies/findCrosses.js +0 -10
- package/src/utilities/assignTypes.js +1 -1
- package/src/utilities/validators.js +1 -1
- package/webpack.config.js +2 -31
- package/dist/ohlcv-indicators.min.js.LICENSE.txt +0 -22
- package/test/test.js +0 -1230
package/AGENTS.md
CHANGED
|
@@ -109,5 +109,4 @@ Input rows normally contain `open`, `high`, `low`, `close`, and `volume`; `date`
|
|
|
109
109
|
|
|
110
110
|
- Preserve unrelated working-tree changes; indicator files are frequently edited together.
|
|
111
111
|
- Do not edit `dist/ohlcv-indicators.min.js` manually. Run `npm run build` after source changes that should ship in the browser bundle.
|
|
112
|
-
- Use deterministic local OHLCV arrays to test warm-up boundaries, zero/invalid inputs, lagged columns, multiple configurations, `retLogs`, `precision: true`, and both `getData()` modes.
|
|
113
|
-
- Run `git diff --check`, `npm test`, and `npm run build`. `test/test.js` runs deterministic local regression checks by default; `npm test -- --live` runs the optional integration demo against its configured market-data service.
|
|
112
|
+
- Use deterministic local OHLCV arrays to test warm-up boundaries, zero/invalid inputs, lagged columns, multiple configurations, `retLogs`, `precision: true`, and both `getData()` modes.
|
package/README.md
CHANGED
|
@@ -438,19 +438,4 @@ Use this section as a compact implementation contract, alongside [AGENTS.md](./A
|
|
|
438
438
|
- `src/core-indicators/` contains the local numeric indicator classes used at runtime, with no external indicator dependency. Self-contained tests cover known results and fixed behavior traces. Preserve warm-up, arithmetic order, and intentional zero/NaN behavior when changing these classes.
|
|
439
439
|
- Full output storage grows with both row count and column count. Each `Float64Array` column uses approximately `8 * input.length` bytes, excluding other overhead. Lags add full columns; `getData()` allocates row objects on each call. Request only needed features, or use `getLastValues()` when you only need the final row.
|
|
440
440
|
- `chunkProcess` does not turn the API into asynchronous, streaming, or bounded-memory processing. Create a new instance for each independent run and retain the input separately if you need replay.
|
|
441
|
-
- Read the implementation for exact output naming and formulas; do not assume every third-party indicator convention or parameter combination is supported.
|
|
442
|
-
|
|
443
|
-
### Development checks
|
|
444
|
-
|
|
445
|
-
From a checkout with dependencies installed:
|
|
446
|
-
|
|
447
|
-
```sh
|
|
448
|
-
npm test
|
|
449
|
-
npm test -- --benchmark --rows 20000 --repeats 9
|
|
450
|
-
npm run build
|
|
451
|
-
git diff --check
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
`test/test.js` runs deterministic local regressions by default, including indicator behavior, configuration replay, known-value core checks, and fixed behavior traces. The tests do not require a third-party indicator oracle. `npm test -- --live` is an optional integration demo requiring its configured market-data service. Build the browser bundle with `npm run build`; do not edit the minified file manually.
|
|
455
|
-
|
|
456
|
-
The package declares the ISC license. Adapted core indicator code retains its upstream MIT notice; preserve that notice when redistributing it and the generated bundle's accompanying license file.
|
|
441
|
+
- Read the implementation for exact output naming and formulas; do not assume every third-party indicator convention or parameter combination is supported.
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
/*! For license information please see ohlcv-indicators.min.js.LICENSE.txt */
|
|
2
|
-
var OHLCV_INDICATORS;(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{t.r(e),t.d(e,{default:()=>Je});var r=function(t,e){if(0===t.length)return!1;for(var r=0;r<t.length;r++){var n=t[r][e];if(null==n||Number.isNaN(n))return!1}return!0};function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return o(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var i=function(t,e){if(!Array.isArray(t))throw new Error('Property "inputParams" must be an "Array" or "Set".');var r,o=n(t);try{for(o.s();!(r=o.n()).done;){var i=r.value;if(!i||"string"!=typeof i.key||!Array.isArray(i.params))throw new TypeError("Each inputParams entry must have an indicator key and a params array.");if(void 0!==i.order&&!Number.isFinite(i.order))throw new TypeError("Indicator order must be a finite number when provided.");var a,u=n(i.params);try{for(u.s();!(a=u.n()).done;){var c=a.value;if("number"==typeof c&&c>e)throw console.log(c,e),new Error("At least one of the params of the indicator is greater than the input OHLCV length. Make sure to have enough datapoints in the input OHLCV.")}}catch(t){u.e(t)}finally{u.f()}}}catch(t){o.e(t)}finally{o.f()}},a=function(t){if(!0===t.isComputing)throw Error("You cannot add indicators while computation is in progress.");if(!0===t.isComputed)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" or "getData" methods are called.')},u=function(t,e,r){if(!Array.isArray(t))throw new Error('Param "'.concat(e,'" must be an array in "').concat(r,'".'));return!0},c=function(t,e,r){if(t instanceof Object==0)throw new Error('Param "'.concat(e,'" must be an object in "').concat(r,'".'));return!0},l=function(t,e,r,n){if(u(t,"arrayOptions","".concat(n,".").concat(r,".validateArrayOptions")),!t.includes(e.toString()))throw new Error('Param "'.concat(r,'" must be any of the following values [').concat(t.join(", "),'] in "').concat(n,'".'));return!0},s=function(t,e,r){if("boolean"!=typeof t)throw new Error('Param "'.concat(e,'" must be an boolean in "').concat(r,'".'));return!0},f=function(t,e,r,n){c(e,"options","".concat(n,".").concat(r,".validateNumber"));var o=e.allowDecimals,i=void 0!==o&&o,a=e.min,u=e.max,l=i?"number":"integer";if("number"!=typeof t||!1===i&&!Number.isInteger(t))throw new Error('Param "'.concat(r,'" must be an ').concat(l,' in "').concat(n,'".'));if(void 0!==a&&"number"!=typeof a)throw new Error('Param "min" must be a valid '.concat(l,' (if provided) in "').concat(n,".").concat(r,'.validateNumber".'));if(void 0!==u&&"number"!=typeof u)throw new Error('Param "max" must be a valid '.concat(l,' (if provided) in "').concat(n,".").concat(r,'.validateNumber".'));if(void 0!==a&&void 0!==u&&a>=u)throw new Error('Param "min" must be less than "max" in "'.concat(n,".").concat(r,'.validateNumber".'));if(void 0!==a&&t<a)throw new Error('Param "'.concat(r,'" must be an ').concat(l," ≥ ").concat(a,' in "').concat(n,'".'));if(void 0!==u&&t>u)throw new Error('Param "'.concat(r,'" must be an ').concat(l," ≤ ").concat(u,' in "').concat(n,'".'));return!0},h=function(t,e,r){if("string"!=typeof t||!t.length)throw new Error('Invalid "'.concat(e,'" property in "').concat(r,'". Only strings are accepted.'));return!0},v=function(t,e,r,n){if(0!==r)return!0;for(var o=[],i=0,a=Object.keys(t);i<a.length;i++){var u,c=a[i],l=null===(u=e[c])||void 0===u?void 0:u[r];("volume"===c?Number.isInteger(l)&&l>=0:Number.isFinite(l)&&l>0)||o.push(c)}if(o.length>0)throw new TypeError("Invalid or missing input value(s) [".concat(o.join(", "),"] ")+"at index ".concat(r,' in "').concat(n,'".'));return!0};function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function y(t,e,r){return(e=b(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,b(n.key),n)}}function d(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function b(t){var e=function(t,e){if("object"!=p(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==p(e)?e:e+""}function g(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function w(t,e,r){return e=P(e),function(t,e){if(e&&("object"==p(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_()?Reflect.construct(e,r||[],P(t).constructor):e.apply(t,r))}function S(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&j(t,e)}function O(t){var e="function"==typeof Map?new Map:void 0;return O=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(_())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&j(o,r.prototype),o}(t,arguments,P(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),j(r,t)},O(t)}function _(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_=function(){return!!t})()}function j(t,e){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},j(t,e)}function P(t){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},P(t)}var k=function(t){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not enough data";return g(this,e),(t=w(this,e,[r])).name="NotEnoughDataError",t}return S(e,t),d(e)}(O(Error)),N=function(){return d((function t(){g(this,t),y(this,"result",void 0)}),[{key:"isStable",get:function(){return void 0!==this.result}},{key:"getResult",value:function(){if(!this.isStable)throw new k;return this.result}}])}(),A=function(t){function e(){var t;g(this,e);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return y(t=w(this,e,[].concat(n)),"previousResult",void 0),y(t,"highest",void 0),y(t,"lowest",void 0),y(t,"previousHighest",void 0),y(t,"previousLowest",void 0),t}return S(e,t),d(e,[{key:"setResult",value:function(t){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=t:(this.previousHighest=this.highest,t>this.highest&&(this.highest=t)),void 0===this.lowest?this.lowest=t:(this.previousLowest=this.lowest,t<this.lowest&&(this.lowest=t)),this.previousResult=this.result,this.result=t,t}},{key:"replace",value:function(t){return this.update(t,!0)}},{key:"updates",value:function(t){var e=this;return t.forEach((function(t){return e.update(t)})),this.result}}])}(N);function x(t){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(t)}function T(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function E(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,M(n.key),n)}}function I(t,e,r){return e&&E(t.prototype,e),r&&E(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function M(t){var e=function(t,e){if("object"!=x(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=x(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==x(e)?e:e+""}function C(t,e,r){return e=F(e),function(t,e){if(e&&("object"==x(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,D()?Reflect.construct(e,r||[],F(t).constructor):e.apply(t,r))}function D(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(D=function(){return!!t})()}function F(t){return F=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},F(t)}function L(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}var U=function(t){function e(t){var r;return T(this,e),(r=C(this,e)).interval=t,r.pricesCounter=0,r.weightFactor=2/(t+1),r}return L(e,t),I(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e&&0!==this.pricesCounter||this.pricesCounter++;var r=e&&void 0!==this.previousResult?this.previousResult:void 0!==this.result?this.result:t;return this.setResult(t*this.weightFactor+r*(1-this.weightFactor),e)}},{key:"isStable",get:function(){return this.pricesCounter>=this.interval}}])}(A),B=function(t){function e(t){var r;return T(this,e),(r=C(this,e)).interval=t,r.prices=new Float64Array(t),r.count=0,r.head=0,r}return L(e,t),I(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"number"==typeof t||Array.isArray(this.prices)||(this.prices=Array.from(this.prices));var r=this.interval,n=this.prices;if(e&&this.count){var o=this.head+this.count-1;o>=r&&(o-=r),n[o]=t}else this.count<r?n[this.count++]=t:(n[this.head]=t,++this.head===r&&(this.head=0));if(this.count===r){for(var i=0,a=this.head;a<r;a++)i+=n[a];for(var u=0;u<this.head;u++)i+=n[u];return this.setResult(i/r,e)}}}])}(A),H=function(t){function e(t){var r;return T(this,e),(r=C(this,e)).interval=t,r.indicator=new B(t),r.smoothingFactor=1/t,r}return L(e,t),I(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0===this.result){var r=this.indicator.update(t);if(void 0!==r)return this.indicator=void 0,this.setResult(r,e)}else{if(e&&void 0!==this.previousResult){var n=(t-this.previousResult)*this.smoothingFactor;return this.setResult(n+this.previousResult,e)}if(!e){var o=(t-this.result)*this.smoothingFactor;return this.setResult(o+this.result,e)}}}}])}(A);function V(t){return V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},V(t)}function K(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,$(n.key),n)}}function $(t){var e=function(t,e){if("object"!=V(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=V(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==V(e)?e:e+""}function z(t,e,r){return e=G(e),function(t,e){if(e&&("object"==V(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Z()?Reflect.construct(e,r||[],G(t).constructor):e.apply(t,r))}function Z(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Z=function(){return!!t})()}function G(t){return G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},G(t)}function Y(t,e){return Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Y(t,e)}var q=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:H;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(r=z(this,e)).interval=t,r.avgGain=new n(t),r.avgLoss=new n(t),r.maxValue=100,r.priceCount=0,r.previousPrice=void 0,r.currentPrice=void 0,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Y(t,e)}(e,t),r=e,n=[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e&&0!==this.priceCount||(this.previousPrice=this.currentPrice,this.priceCount<2&&this.priceCount++),this.currentPrice=t,!(this.priceCount<2)){var r=this.previousPrice;if(t>r?(this.avgLoss.update(0,e),this.avgGain.update(t-r,e)):(this.avgLoss.update(r-t,e),this.avgGain.update(0,e)),this.avgGain.isStable){var n=this.avgLoss.getResult();if(0===n)return this.setResult(100,e);var o=this.avgGain.getResult()/n;return this.setResult(this.maxValue-this.maxValue/(o+1),e)}}}}],n&&K(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(A),J=function(t,e){if(0===t&&(t=.001),0===e&&(e=.001),Math.sign(t)!==Math.sign(e))throw new Error("[BUG] Params must have the same sign in mathLog a=".concat(t," b=").concat(e,"."));t<0&&(t=-t,e=-e);var r,n=Math.log(t/e);if(null==(r=n)||!Number.isFinite(r))throw new Error("[BUG] Invalid params passed to mathLog a=".concat(t," b=").concat(e,"."));return n};function W(t){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(t)}function Q(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return X(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?X(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function X(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var tt=function(t){var e=String(t);return 1===t?0:e.length-1},et=function(t,e,r){if("string"!=typeof t)throw new Error("addPrecisionExact expects a string when precision=true");var n="-"===t.charAt(0),o=Q((n?t.slice(1):t).split("."),2),i=o[0],a=o[1],u=void 0===a?"":a,c=void 0===r?tt(e):r,l=u.padEnd(c,"0").slice(0,c),s=parseInt(i+l||"0",10);return n&&(s=-s),s};function rt(t){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rt(t)}var nt={number:function(t){return t},numberCleanString:function(t){return Number(t)},precisionNumberCleanString:function(t,e,r){return et(t,e,r)}},ot=function(t,e,r){return function(t,e,r){if("number"!=typeof t||!Number.isFinite(t))throw new Error("revertPrecisionAsNumber expects a finite number");var n=t<0,o=Math.abs(t);o=Math.trunc(o);var i=void 0===r?tt(e):r;if(0===i)return n?-o:o;var a=Math.trunc(o/e),u=String(o%e).padStart(i,"0"),c=0===(u=u.replace(/0+$/,"")).length?String(a):"".concat(a,".").concat(u);return Number(n?"-".concat(c):c)}(t,e,r)},it=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n="number"==typeof t&&!Number.isNaN(t),o="string"==typeof t&&/^-?\d+(\.\d+)?$/.test(t);if(!0===r){if(o)return"precisionNumberCleanString";if(e)throw new Error("Invalid number forma");return rt(t)}if(n)return"number";if(o)return"numberCleanString";if(e)throw new TypeError("Invalid input: expected a number or numeric string");return rt(t)};function at(t){return at="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},at(t)}var ut={toString:function(t){return t.toString()},string:function(t){return t.toString()},toISOString:function(t){return t.toISOString()},iso:function(t){return t.toISOString()},toUTCString:function(t){return t.toUTCString()},milliseconds:function(t){return t.getTime()},seconds:function(t){return t.getTime()/1e3},object:function(t){return t}},ct={dateObject:function(t){return t},dateMilliseconds:function(t){return new Date(t)},dateSeconds:function(t){return new Date(1e3*t)},dateIncompleteDayString:function(t){return new Date("".concat(t," 00:00:00"))},dateCompleteDateString:function(t){return new Date(t)}},lt=function(t){var e=["Date -> object","Milliseconds Timestamp -> integer","Seconds Timestamp -> integer","UTC Time Format (ISO 8601) -> string","Including a Timezone Offset (ISO 8601) -> string","Local Time Format (ISO 8601) -> string","YYYY/MM/DD or YYYY-MM-DD -> string"],r=function(){throw new Error('Invalid "'.concat(at(t),'" date value passed in selectDateFormatter. Supported formats: \n-').concat(e.join("\n- ")))};if("object"===at(t)){if(t instanceof Date&&!isNaN(t.valueOf()))return"dateObject";r()}else{if("number"==typeof t)return Math.abs(t)<1e11?"dateSeconds":"dateMillseconds";if("string"==typeof t){if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/i.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?([+-]\d{2}:\d{2})$/.test(t)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(t)&&t.length>10||/^\d{4}\/\d{2}\/\d{2}$/.test(t))return"dateCompleteDateString";if(/^\d{4}-\d{2}-\d{2}$/.test(t))return"dateIncompleteDayString";r()}else r()}};function st(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||ft(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ft(t,e){if(t){if("string"==typeof t)return ht(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ht(t,e):void 0}}function ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var vt=function(t,e,r){var n,o={Array,Float64Array,Float32Array,Int32Array,Uint8Array,Int8Array,Int16Array}[t];if(!o||"function"!=typeof o.from)throw new Error("Unsupported array type: ".concat(t));return n=void 0!==r?r:"Array"===t?null:NaN,new o(e).fill(n)};function pt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var yt=function(t,e){var r,n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).lag,o=void 0===n?0:n,i=[],a=[],u=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return pt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(e);try{for(u.s();!(r=u.n()).done;){var c=r.value,l=c.key,s=c.type,h=void 0===s?"Float64Array":s,v=c.fill,p=c.enabled,y=void 0===p||p,m=c.priceBased,d=void 0!==m&&m,b=c.includeInLag,g=void 0===b||b;if(y){if(Object.prototype.hasOwnProperty.call(t.verticalOhlcv,l))throw new Error('Output column "'.concat(l,'" already exists in verticalOhlcv.'));if(/^(?:Int|Uint)/.test(h)&&void 0===v)throw new Error('Integer output column "'.concat(l,'" requires an explicit fill value.'));t.verticalOhlcv[l]=vt(h,t.len,v),d&&t.priceBased.add(l),i.push(l),g&&a.push(l)}}}catch(t){u.e(t)}finally{u.f()}return o>0&&a.length>0&&(f(o,{min:1,max:t.len},"lag","initializeColumns"),t.executionParams.push({key:"lag",params:[a,o]})),i};function mt(t){return mt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mt(t)}function dt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=mt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=mt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function bt(t){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bt(t)}function gt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function wt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ot(n.key),n)}}function St(t,e,r){return e&&wt(t.prototype,e),r&&wt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ot(t){var e=function(t,e){if("object"!=bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bt(e)?e:e+""}function _t(t,e,r){return e=Pt(e),function(t,e){if(e&&("object"==bt(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,jt()?Reflect.construct(e,r||[],Pt(t).constructor):e.apply(t,r))}function jt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(jt=function(){return!!t})()}function Pt(t){return Pt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Pt(t)}function kt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Nt(t,e)}function Nt(t,e){return Nt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Nt(t,e)}var At=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return gt(this,e),(r=_t(this,e)).interval=t,r.deviationMultiplier=n,r.prices=new Float64Array(t),r.count=0,r.head=0,r}return kt(e,t),St(e,[{key:"update",value:function(t){if("number"==typeof t||Array.isArray(this.prices)||(this.prices=Array.from(this.prices)),!(this.count<this.interval)){this.prices[this.head]=t,this.head=(this.head+1)%this.interval;for(var e=0,r=this.head,n=0;n<this.count;n++)e+=this.prices[r],++r===this.interval&&(r=0);var o=this.count?e/this.count:0,i=o;if(!i&&Array.isArray(this.prices)){e=0,r=this.head;for(var a=0;a<this.count;a++)e+=this.prices[r],++r===this.interval&&(r=0);i=this.count?e/this.count:0}var u=0;r=this.head;for(var c=0;c<this.count;c++){var l=this.prices[r]-i;u+=l*l,++r===this.interval&&(r=0)}var s=Math.sqrt(this.count?u/this.count:0);return this.result={lower:o-s*this.deviationMultiplier,middle:o,upper:o+s*this.deviationMultiplier}}this.prices[this.count++]=t}}])}(N),xt=function(t){function e(t,r,n){var o;return gt(this,e),(o=_t(this,e)).short=t,o.long=r,o.signal=n,o.pricesCounter=0,o}return kt(e,t),St(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e&&0!==this.pricesCounter||this.pricesCounter++;var r=this.short.update(t,e),n=this.long.update(t,e);if(this.pricesCounter>this.long.interval&&this.pricesCounter--,this.pricesCounter===this.long.interval){var o=r-n,i=this.signal.update(o,e);return this.result={histogram:o-i,macd:o,signal:i}}}}])}(N),Tt=function(t){function e(t,r,n){var o;return gt(this,e),(o=_t(this,e)).n=t,o.m=r,o.p=n,o.periodM=new B(r),o.periodP=new B(n),o.candles=new Array(t),o.count=0,o.head=0,o}return kt(e,t),St(e,[{key:"update",value:function(t){if(this.count<this.n?this.candles[this.count++]=t:(this.candles[this.head]=t,this.head=(this.head+1)%this.n),this.count===this.n){for(var e=-1/0,r=1/0,n=this.head,o=0;o<this.count;o++)e=Math.max(e,this.candles[n].high),++n===this.n&&(n=0);n=this.head;for(var i=0;i<this.count;i++)r=Math.min(r,this.candles[n].low),++n===this.n&&(n=0);var a=e-r,u=100*(t.close-r)/(0===a?1:a),c=this.periodM.update(u),l=c&&this.periodP.update(c);if(void 0!==c&&void 0!==l)return this.result={stochD:l,stochK:c}}}}])}(N);function Et(t){return Et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Et(t)}function It(t){return It="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},It(t)}var Mt={ema:U,sma:B},Ct=function(t,e,r,n,o){var i,a,u,c=o.target,l=o.lag,s=o.retLogs,f=void 0!==s&&s,h=t.verticalOhlcv,p=t.instances,y=t.priceBased,m="close"!==c?"_".concat(c):"",d="".concat(f?"ret_log_":"").concat(r,"_").concat(n).concat(m);if(0===e){if(v((i={},u=!0,(a=function(t){var e=function(t,e){if("object"!=It(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=It(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==It(e)?e:e+""}(a=c))in i?Object.defineProperty(i,a,{value:u,enumerable:!0,configurable:!0,writable:!0}):i[a]=u,i),h,e,r),!h.hasOwnProperty(c))throw new Error("Target property ".concat(c," not found in verticalOhlcv for ").concat(r,"."));p[d]=new Mt[r](n),yt(t,[{key:d,priceBased:!f&&y.has(c)}],{lag:l})}var b=h[c][e],g=p[d];g.update(b);var w=g.isStable?g.getResult():NaN,S=w;if(f){var O=b/w;S=b>0&&w>0&&O>0&&Number.isFinite(O)?J(O,1):NaN}t.pushToMain({index:e,key:d,value:S})};function Dt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ft=function(t){return null==t||!Number.isFinite(t)};function Lt(t){return Lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lt(t)}function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ut="close";function Bt(t){return Bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bt(t)}function Ht(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Vt(t){return Vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vt(t)}function Kt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return $t(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$t(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function $t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var zt=Symbol("lagColumns"),Zt=function(t,e){var r=new Uint8Array(e);return r[t]=1,r};function Gt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Yt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Gt(Object(r),!0).forEach((function(e){qt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Gt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function qt(t,e,r){return(e=Xt(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Jt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Wt(t){return Wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wt(t)}function Qt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Xt(n.key),n)}}function Xt(t){var e=function(t,e){if("object"!=Wt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Wt(e)?e:e+""}var te=function(t,e){return t>e},ee=function(t,e){return t<e},re=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Object.assign(this,{interval:0,prevState:.5,prevFast:NaN,prevSlow:NaN,prevHigh:NaN,prevLow:NaN,areHighAndLowUndefined:!1})},(e=[{key:"update",value:function(t,e){var r=e.fast,n=e.high,o=e.slow,i=e.low,a=this.prevState;this.areHighAndLowUndefined||void 0!==n&&void 0!==i||(this.areHighAndLowUndefined=!0),Number.isNaN(r)||Number.isNaN(o)||function(t,e){return t===e}(r,o)?a=.5:te(r,o)?a=this.areHighAndLowUndefined?1:[i,o,this.prevLow,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&ee(i,o)&&te(this.prevLow,this.prevSlow)?0:1:ee(r,o)&&(a=this.areHighAndLowUndefined?0:[n,o,this.prevHigh,this.prevSlow].every((function(t){return!Number.isNaN(t)}))&&te(n,o)&&ee(this.prevHigh,this.prevSlow)?1:0),.5===a?this.interval=0:1===a?this.prevState<=.5?this.interval=1:this.interval++:0===a&&(this.prevState>=.5?this.interval=-1:this.interval--),Object.assign(this,{prevState:a,prevFast:r,prevSlow:o,prevHigh:n,prevLow:i})}},{key:"getResult",value:function(){return this.interval}}])&&Qt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function ne(t){return ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ne(t)}function oe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ie(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?oe(Object(r),!0).forEach((function(e){ae(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ae(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=ne(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ne(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ne(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ue(t,e){if(t){if("string"==typeof t)return ce(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ce(t,e):void 0}}function ce(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var le=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function se(t){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},se(t)}function fe(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function he(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,pe(n.key),n)}}function ve(t,e,r){return e&&he(t.prototype,e),r&&he(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function pe(t){var e=function(t,e){if("object"!=se(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=se(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==se(e)?e:e+""}function ye(t,e,r){return e=de(e),function(t,e){if(e&&("object"==se(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,me()?Reflect.construct(e,r||[],de(t).constructor):e.apply(t,r))}function me(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(me=function(){return!!t})()}function de(t){return de=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},de(t)}function be(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ge(t,e)}function ge(t,e){return ge=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ge(t,e)}var we=function(t){function e(){var t;return fe(this,e),(t=ye(this,e)).previousCandle=void 0,t.twoPreviousCandle=void 0,t}return be(e,t),ve(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.high,n=t.low,o=r-n;if(this.previousCandle&&e&&(this.previousCandle=this.twoPreviousCandle),this.previousCandle){var i=Math.abs(r-this.previousCandle.close),a=Math.abs(n-this.previousCandle.close);return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(Math.max(o,i,a),e)}return this.twoPreviousCandle=this.previousCandle,this.previousCandle=t,this.setResult(o,e)}}])}(A),Se=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:H;return fe(this,e),(r=ye(this,e)).interval=t,r.tr=new we,r.smoothing=new n(t),r}return be(e,t),ve(e,[{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.tr.update(t,e);if(this.smoothing.update(r,e),this.smoothing.isStable)return this.setResult(this.smoothing.getResult(),e)}}])}(A),Oe=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:H;return fe(this,e),(r=ye(this,e)).interval=t,r.atr=new Se(t,n),r.movesDown=new n(t),r.movesUp=new n(t),r.previousCandle=void 0,r.mdi=void 0,r.pdi=void 0,r}return be(e,t),ve(e,[{key:"updateState",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.atr.update(t),this.movesUp.update(e),this.movesDown.update(r),this.previousCandle=t}},{key:"update",value:function(t){if(this.previousCandle){var e=t.high-this.previousCandle.high,r=this.previousCandle.low-t.low,n=e<0||e<r?0:e,o=r<0||r<e?0:r;if(this.updateState(t,n,o),this.movesUp.isStable){var i=this.atr.getResult();this.pdi=this.movesUp.getResult()/i,this.mdi=this.movesDown.getResult()/i;var a=Math.abs(this.pdi-this.mdi),u=this.pdi+this.mdi;return 0===u?this.setResult(0,!1):this.setResult(a/u*100,!1)}}else this.updateState(t)}}])}(A),_e=function(t){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:H;return fe(this,e),(r=ye(this,e)).interval=t,r.adx=new n(t),r.dx=new Oe(t,n),r}return be(e,t),ve(e,[{key:"mdi",get:function(){return this.dx.mdi}},{key:"pdi",get:function(){return this.dx.pdi}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.dx.update(t);if(void 0!==r&&this.adx.update(r),this.adx.isStable)return this.setResult(this.adx.getResult(),e)}}])}(A);function je(t){return je="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},je(t)}function Pe(t){return Pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pe(t)}function ke(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=Pe(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Pe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pe(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ne(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ae(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Ae(t,e){if(t){if("string"==typeof t)return xe(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?xe(t,e):void 0}}function xe(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Te(t){return function(t){if(Array.isArray(t))return Me(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ie(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ee(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ie(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function Ie(t,e){if(t){if("string"==typeof t)return Me(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Me(t,e):void 0}}function Me(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Ce={candleFeatures:function(t,e,r){var n=r.lag,o=r.colKeys,i=r.retLogs,a=t.verticalOhlcv,u=t.priceBased,c=t.scaledGroups,l=function(t,e){return i?Math.log(t/e):(t-e)/e},s=i?"ret_log_":"ret_";if(0===e){v({open:!0,high:!0,low:!0,close:!0},a,e,"candleFeatures");var f,h=["change","mid_price_change","upper_wick","lower_wick","gap","body","range"].map((function(t){return{key:"".concat(s).concat(t)}})),p=Ne(o);try{for(p.s();!(f=p.n()).done;){var y=f.value;if(v(ke({},y,!0),a,e,"candleFeatures"),!a.hasOwnProperty(y))throw new Error('Target property in "options.colKey" array "'.concat(y,'" not found in verticalOhlcv for "candleFeatures".'));if(!u.has(y))throw new Error('Target property in "options.colKey" array "'.concat(y,'" not found in priceBased for "candleFeatures".'));h.push({key:"".concat(s).concat(y)})}}catch(t){p.e(t)}finally{p.f()}c.candleFeatures=yt(t,h,{lag:n})}var m,d,b=a.close[e-1],g=a.open[e-1];if(void 0!==b){var w=a.open[e],S=a.high[e],O=a.low[e],_=a.close[e],j=(b+g)/2,P=(w+_)/2,k=Math.max(w,_),N=Math.min(w,_),A=l(_,b),x=l(P,j),T=l(S,k),E=l(N,O),I=l(w,b),M=l(_,w),C=l(S,O);if(0===o.length)return t.pushToMain({index:e,key:"".concat(s,"change"),value:A}),t.pushToMain({index:e,key:"".concat(s,"mid_price_change"),value:x}),t.pushToMain({index:e,key:"".concat(s,"upper_wick"),value:T}),t.pushToMain({index:e,key:"".concat(s,"lower_wick"),value:E}),t.pushToMain({index:e,key:"".concat(s,"gap"),value:I}),t.pushToMain({index:e,key:"".concat(s,"body"),value:M}),void t.pushToMain({index:e,key:"".concat(s,"range"),value:C});var D,F,L=ke(ke(ke(ke(ke(ke(ke({},"".concat(s,"change"),A),"".concat(s,"mid_price_change"),x),"".concat(s,"upper_wick"),T),"".concat(s,"lower_wick"),E),"".concat(s,"gap"),I),"".concat(s,"body"),M),"".concat(s,"range"),C),R=!1,U=Ne(o);try{for(U.s();!(D=U.n()).done;){var B=D.value,H=a[B][e];if(null==(F=H)||!Number.isFinite(F)){R=!0;break}var V=l(_,H);L["".concat(s).concat(B)]=V}}catch(t){U.e(t)}finally{U.f()}if(!R)for(var K=0,$=Object.entries(L);K<$.length;K++){var z=(m=$[K],d=2,function(t){if(Array.isArray(t))return t}(m)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(m,d)||Ae(m,d)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),Z=z[0],G=z[1];t.pushToMain({index:e,key:Z,value:G})}}},dateTime:function(t,e,r){var n,o=r.lag,i=r.oneHot,a=r.precompute,u=t.instances,c=t.verticalOhlcv,l=a.prefix;if(0===e){if(!t.dateType)throw Error('dateTime method found and invalid "date" in input ohlcv');Object.assign(u,{dateTime:{formatter:new Intl.DateTimeFormat("en-US-u-ca-gregory-nu-latn",{timeZone:t.timeZone,year:"numeric",month:"numeric",day:"numeric",weekday:"short",hour:"numeric",minute:"numeric",hourCycle:"h23"}),colKeys:[].concat((n=a.colKeys,function(t){if(Array.isArray(t))return ce(t)}(n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||ue(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),["".concat(l,"year")]).filter((function(t){return"one_hot_year"!==t})),colKeySizes:ie({},a.colKeySizes)}});var s=u.dateTime.colKeys;yt(t,s.map((function(t){return{key:t,type:i?"Array":"Int16Array",fill:i?null:0}})),{lag:o})}var f,h,v,p,y,m,d,b=u.dateTime,g=b.colKeySizes,w=b.formatter,S=c.date[e],O=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ue(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(w.formatToParts(S));try{for(O.s();!(d=O.n()).done;){var _=d.value;switch(_.type){case"year":f=_.value;break;case"month":h=_.value;break;case"hour":v=_.value;break;case"minute":p=_.value;break;case"weekday":y=_.value;break;case"day":m=_.value}}}catch(t){O.e(t)}finally{O.f()}var j=Number(f),P=Number(h)-1,k=Number(v),N=Number(p),A=le.indexOf(y),x=Number(m)-1;if(!i)return t.pushToMain({index:e,key:"year",value:j}),t.pushToMain({index:e,key:"month",value:P+1}),t.pushToMain({index:e,key:"hour",value:k}),t.pushToMain({index:e,key:"minute",value:N}),t.pushToMain({index:e,key:"day_of_the_week",value:(A+6)%7+1}),void t.pushToMain({index:e,key:"day_of_the_month",value:x+1});var T=Zt(P,g.one_hot_month),E=Zt(k,g.one_hot_hour),I=Zt(N,g.one_hot_minute),M=Zt(A,g.one_hot_day_of_the_week),C=Zt(x,g.one_hot_day_of_the_month);t.pushToMain({index:e,key:"one_hot_month",value:T}),t.pushToMain({index:e,key:"one_hot_hour",value:E}),t.pushToMain({index:e,key:"one_hot_minute",value:I}),t.pushToMain({index:e,key:"one_hot_day_of_the_week",value:M}),t.pushToMain({index:e,key:"one_hot_day_of_the_month",value:C})},heikenAshi:function(t,e,r,n){var o,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},a=i.lag,u=void 0===a?0:a,c=i.bothNull,l=void 0!==c&&c,s=i.retLogs,f=void 0===s||s,h=t.verticalOhlcv,p=t.instances,y=t.scaledGroups,m="".concat(r,"_").concat(n),d=function(t,e){return f?Math.log(t/e):(t-e)/e},b=f?"ret_log_":"ret_",g=l?"":"_".concat(m),w=function(t){return"".concat(b,"heiken_ashi_").concat(t).concat(g)},S=l?"heiken_ashi_cross":"heiken_ashi_cross_".concat(m),O=l?"heiken_ashi":"heiken_ashi_".concat(m);if(0===e){v({open:!0,high:!0,low:!0,close:!0},h,e,"heikenAshi");var _=["open","high","low","close"];p[O]={emaPre:l?null:Object.fromEntries(_.map((function(t){return[t,new U(r)]}))),emaPost:l?null:Object.fromEntries(_.map((function(t){return[t,new U(n)]}))),prevHaOpen:NaN,prevHaClose:NaN,prevSmOpen:NaN,prevSmClose:NaN,isTrendUp:!1};var j=["body","upper_wick","lower_wick","range"].map(w);yt(t,[].concat((o=j,function(t){if(Array.isArray(t))return Dt(t)}(o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return Dt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Dt(t,e):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),[S]).map((function(t){return{key:t}})),{lag:u}),y&&(y.heikenAshi=j)}var P=h.open[e],k=h.high[e],N=h.low[e],A=h.close[e],x=p[O];if(!(Ft(P)||Ft(k)||Ft(N)||Ft(A))){var T,E,I,M;if(l)T=P,E=k,I=N,M=A;else{if(x.emaPre.open.update(P),x.emaPre.high.update(k),x.emaPre.low.update(N),x.emaPre.close.update(A),!(x.emaPre.open.isStable&&x.emaPre.high.isStable&&x.emaPre.low.isStable&&x.emaPre.close.isStable))return;T=x.emaPre.open.getResult(),E=x.emaPre.high.getResult(),I=x.emaPre.low.getResult(),M=x.emaPre.close.getResult()}if(!(Ft(T)||Ft(E)||Ft(I)||Ft(M))){var C,D,F,L,R=(T+E+I+M)/4,B=Number.isNaN(x.prevHaOpen)||Number.isNaN(x.prevHaClose)?(T+M)/2:(x.prevHaOpen+x.prevHaClose)/2,H=Math.max(E,B,R),V=Math.min(I,B,R);if(x.prevHaOpen=B,x.prevHaClose=R,l)C=B,D=H,F=V,L=R;else{if(x.emaPost.open.update(B),x.emaPost.high.update(H),x.emaPost.low.update(V),x.emaPost.close.update(R),!(x.emaPost.open.isStable&&x.emaPost.high.isStable&&x.emaPost.low.isStable&&x.emaPost.close.isStable))return;C=x.emaPost.open.getResult(),D=x.emaPost.high.getResult(),F=x.emaPost.low.getResult(),L=x.emaPost.close.getResult()}if(!(Ft(C)||Ft(D)||Ft(F)||Ft(L)||C<=0||D<=0||F<=0||L<=0)){var K=e>0?h[S][e-1]:0,$=x.prevSmOpen,z=x.prevSmClose,Z=Number.isFinite($)&&Number.isFinite(z)&&z<=$&&L>C,G=Number.isFinite($)&&Number.isFinite(z)&&z>=$&&L<C;Z&&(x.isTrendUp=!0),G&&(x.isTrendUp=!1);var Y=0;e>0&&(Y=x.isTrendUp?K>0?K+1:1:K<0?K-1:-1),x.prevSmOpen=C,x.prevSmClose=L;var q=Math.max(C,L),J=Math.min(C,L),W=d(L,C),Q=d(D,q),X=d(J,F),tt=d(D,F);Ft(W)||t.pushToMain({index:e,key:w("body"),value:W}),Ft(Q)||t.pushToMain({index:e,key:w("upper_wick"),value:Q}),Ft(X)||t.pushToMain({index:e,key:w("lower_wick"),value:X}),Ft(tt)||t.pushToMain({index:e,key:w("range"),value:tt}),t.pushToMain({index:e,key:S,value:Y})}}}},rsi:function(t,e,r,n){var o=n.target,i=n.lag,a=n.retLogs,u=t.verticalOhlcv,c=t.instances,l="close"===o?"":"_".concat(o),s=a?"ret_log_rsi_".concat(r).concat(l):"rsi_".concat(r).concat(l),f=a?"ret_log_rsi_sma_".concat(r).concat(l):"rsi_sma_".concat(r).concat(l);if(0===e){if(v(dt({},o,!0),u,e,"rsi"),!u.hasOwnProperty(o))throw new Error("Target property ".concat(o," not found in verticalOhlcv for rsi."));Object.assign(c,dt(dt({},s,new q(r)),f,new B(r))),yt(t,[{key:s},{key:f}],{lag:i})}var h=u[o][e];c[s].update(h);var p=c[s].isStable?c[s].getResult():NaN,y=Number.isNaN(p)?NaN:a?J(p,50):p;t.pushToMain({index:e,key:s,value:y}),Number.isNaN(p)||c[f].update(p);var m=c[f].isStable?c[f].getResult():NaN,d=Number.isNaN(m)?NaN:a?J(m,50):m;t.pushToMain({index:e,key:f,value:d})},mfi:function(t,e,r,n){var o=n.lag,i=n.retLogs,a=t.verticalOhlcv,u=t.instances,c="".concat(i?"ret_log_":"","mfi_").concat(r);0===e&&(v({high:!0,low:!0,close:!0,volume:!0},a,e,"mfi"),yt(t,[{key:c}],{lag:o}),u[c]={flows:new Float64Array(r),next:0,count:0,previousTypical:NaN});var l=u[c],s=(a.high[e]+a.low[e]+a.close[e])/3,f=s-l.previousTypical;if(l.previousTypical=s,0!==e){var h=s*a.volume[e];if(l.flows[l.next]=Number.isFinite(f)&&Number.isFinite(h)&&h>=0?Math.sign(f)*h:NaN,l.next=(l.next+1)%r,l.count<r&&l.count++,!(l.count<r)){for(var p=0,y=0,m=l.next,d=0;d<r;d++){var b=l.flows[m];if(Number.isNaN(b))return;b>0?p+=b:b<0&&(y-=b),++m===r&&(m=0)}if(Number.isFinite(p)&&Number.isFinite(y)){var g=0===p&&0===y?NaN:100-100/(1+p/y);t.pushToMain({index:e,key:c,value:Number.isNaN(g)?NaN:i?J(g,50):g})}}}},stochastic:function(t,e,r,n,o,i){var a,u,c,l=i.lag,s=i.retLogs,f=t.verticalOhlcv,h=t.instances,p=t.useFullNames,y=14!==r||3!==n||3!==o||p?"_".concat(r,"_").concat(n,"_").concat(o):"",m=s?"ret_log_stochastic_d".concat(y):"stochastic_d".concat(y),d=s?"ret_log_stochastic_k".concat(y):"stochastic_k".concat(y),b=y;0===e&&(v({high:!0,low:!0,close:!0},f,e,"stochastic"),Object.assign(h,(a={},u=b,c=new Tt(r,n,o),(u=function(t){var e=function(t,e){if("object"!=Et(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Et(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Et(e)?e:e+""}(u))in a?Object.defineProperty(a,u,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[u]=c,a)),yt(t,[{key:m},{key:d}],{lag:l}));var g=f.close[e],w=f.low[e],S=f.high[e];h[b].update({close:g,low:w,high:S});var O=h[b].isStable?h[b].getResult():null,_=O?s?J(O.stochK,50):O.stochK:NaN,j=O?s?J(O.stochD,50):O.stochD:NaN;t.pushToMain({index:e,key:d,value:_}),t.pushToMain({index:e,key:m,value:j})},atr:function(t,e,r,n){var o=n.lag,i=n.retLogs,a=t.verticalOhlcv,u=t.instances,c=i?"ret_log_atr_".concat(r):"atr_".concat(r);if(0===e){var l=t.instances,s=t.verticalOhlcv;v({high:!0,low:!0,close:!0},s,e,"atr"),l[c]=new Se(r,H),yt(t,[{key:c,priceBased:!i}],{lag:o})}var f={high:a.high[e],low:a.low[e],close:a.close[e]},h=u[c];h.update(f);var p=h.isStable?h.getResult():NaN;t.pushToMain({index:e,key:c,value:Number.isNaN(p)?NaN:i?J(p,f.close):p})},adx:function(t,e,r,n){var o,i,a,u=n.lag,c=n.retLogs,l=t.verticalOhlcv,s=t.instances,f=(t.useFullNames,c?"ret_log_adx_".concat(r):"adx_".concat(r)),h="adx_".concat(r);if(0===e){if(v({high:!0,low:!0,close:!0},l,e,"adx"),!l.hasOwnProperty("high"))throw new Error("Property high not found in verticalOhlcv for adx.");if(!l.hasOwnProperty("low"))throw new Error("Property low not found in verticalOhlcv for adx.");if(!l.hasOwnProperty("close"))throw new Error("Property close not found in verticalOhlcv for adx.");Object.assign(s,(o={},i=h,a=new _e(r),(i=function(t){var e=function(t,e){if("object"!=je(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=je(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==je(e)?e:e+""}(i))in o?Object.defineProperty(o,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[i]=a,o)),yt(t,[{key:f}],{lag:u})}var p=l.high[e],y=l.low[e],m=l.close[e];s[h].update({high:p,low:y,close:m});var d=s[h].isStable?s[h].getResult():NaN,b=Number.isNaN(d)?NaN:c?J(d,20):d;t.pushToMain({index:e,key:f,value:b})},ema:Ct,sma:Ct,macd:function(t,e,r,n,o,i){var a,u,c,l=i.target,s=i.lag,f=i.precomputed,h=t.verticalOhlcv,p=t.instances,y=t.useFullNames,m=f.instanceKey;if(0===e){v((a={},c=!0,(u=function(t){var e=function(t,e){if("object"!=Lt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Lt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lt(e)?e:e+""}(u=l))in a?Object.defineProperty(a,u,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[u]=c,a),h,e,"macd");var d=t.inputParams;if(!h.hasOwnProperty(l))throw new Error("Target property ".concat(l," not found in verticalOhlcv for macd."));var b,g=0,w=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(d);try{for(w.s();!(b=w.n()).done;)"macd"===b.value.key&&g++}catch(t){w.e(t)}finally{w.f()}var S=g>1||y,O="".concat(r,"_").concat(n,"_").concat(o),_=function(t){return l===Ut?S?"macd_".concat(t,"_").concat(O):"macd_".concat(t):S?"macd_".concat(t,"_").concat(l,"_").concat(O):"macd_".concat(t,"_").concat(l)},j=_("diff"),P=_("dea"),k=_("histogram");p.hasOwnProperty("macd")||(p.macd={numberOfIndicators:g,settings:{}}),p.macd.settings[m]=new xt(new U(r),new U(n),new U(o)),yt(t,[j,P,k].map((function(t){return{key:t,priceBased:!0}})),{lag:s})}var N=p.macd,A=N.numberOfIndicators,x=N.settings,T=A>1||y,E="".concat(r,"_").concat(n,"_").concat(o),I=function(t){return l===Ut?T?"macd_".concat(t,"_").concat(E):"macd_".concat(t):T?"macd_".concat(t,"_").concat(l,"_").concat(E):"macd_".concat(t,"_").concat(l)},M=I("diff"),C=I("dea"),D=I("histogram"),F=x[m],L=h[l][e];F.update(L);var R=F.isStable?F.getResult():null;t.pushToMain({index:e,key:M,value:R?R.macd:NaN}),t.pushToMain({index:e,key:C,value:R?R.signal:NaN}),t.pushToMain({index:e,key:D,value:R?R.histogram:NaN})},volumeDelta:function(t,e,r){var n=r.lag,o=void 0===n?0:n,i=t.verticalOhlcv,a=t.instances,u="volume_delta";if(0===e){v({open:!0,close:!0,volume:!0},i,e,"volumeDelta"),a[u]||(a[u]={isBuyVolume:!0,cross:0});var c=["".concat(u,"_high"),"".concat(u,"_low"),"".concat(u,"_close"),"".concat(u,"_cross")];yt(t,c.map((function(t){return{key:t}})),{lag:o})}var l=a[u],s=(l.hasInvalidInputValue,i.volume[e]);if(0!==s){var f=i.open[e],h=i.close[e],p=e>0?i.close[e-1]:NaN,y=l.isBuyVolume;h>f?y=!0:h<f?y=!1:h>p?y=!0:h<p&&(y=!1),l.isBuyVolume=y,e<1?l.cross=y?1:-1:y?l.cross>0?l.cross=l.cross+1:l.cross=1:l.cross>0?l.cross=-1:l.cross=l.cross-1;var m=y?s:-s,d=m,b=Math.max(m,0),g=Math.min(m,0);t.pushToMain({index:e,key:"".concat(u,"_high"),value:b}),t.pushToMain({index:e,key:"".concat(u,"_low"),value:g}),t.pushToMain({index:e,key:"".concat(u,"_close"),value:d}),t.pushToMain({index:e,key:"".concat(u,"_cross"),value:l.cross})}},relativeVolume:function(t,e,r,n){var o=n.lag,i=n.retLogs,a=void 0!==i&&i,u="".concat(a?"ret_log_":"","relative_volume_").concat(r),c=t.instances,l=t.verticalOhlcv;0===e&&(v({volume:!0},l,e,"relativeVolume"),c[u]={instance:new B(r),prevRelativeVolumeSma:NaN},yt(t,[{key:u}],{lag:o}));var s=l.volume[e];if(0!==s){var f=c[u].instance;f.update(s);var h=f.isStable?f.getResult():NaN,p=c[u].prevRelativeVolumeSma;if(c[u].prevRelativeVolumeSma=h,!Number.isNaN(h)&&!Number.isNaN(p)){var y=s/p,m=a?s>0&&p>0&&y>0&&Number.isFinite(y)?J(y,1):NaN:y;t.pushToMain({index:e,key:u,value:m})}}},donchianChannels:function(t,e,r,n,o){var i=t.verticalOhlcv,a=t.instances,u=t.len,c=t.inputParams,l=t.useFullNames,s=o.lag,f=void 0===s?0:s,h=o.retLogs,p=void 0!==h&&h,y="".concat(r,"_").concat(n),m="".concat(p?"ret_log_":"").concat(y),d="".concat(p?"ret_log_":"","donchian_channel");if(0===e){v({high:!0,low:!0},i,e,"donchianChannels"),p&&v({close:!0},i,e,"donchianChannels");var b=c.filter((function(t){return"donchianChannels"===t.key})).length,g=b>1||l,w=(p?["width","position"]:["upper","basis","lower"]).map((function(t){return g?"".concat(d,"_").concat(t,"_").concat(y):"".concat(d,"_").concat(t)}));a.donchian_channel||(a.donchian_channel={numberOfIndicators:b,settings:{}}),a.donchian_channel.numberOfIndicators=b,a.donchian_channel.settings[m]={maxDeque:{indices:[],head:0,length:0},minDeque:{indices:[],head:0,length:0}},yt(t,w.map((function(t){return{key:t,priceBased:!p}})),{lag:f})}var S=a.donchian_channel,O=S.numberOfIndicators,_=S.settings,j=O>1||l,P=function(t){return j?"".concat(d,"_").concat(t,"_").concat(y):"".concat(d,"_").concat(t)},k=_[m],N=k.maxDeque,A=k.minDeque,x=e-n,T=x-r+1;if(!(x<0||x>=u)){var E=i.high,I=i.low,M=function(t,e,n){for(var o=t.indices;t.length&&o[t.head]<T;)t.head=(t.head+1)%r,t.length--;for(;t.length&&n(e[o[(t.head+t.length-1)%r]],e[x]);)t.length--;o[(t.head+t.length)%r]=x,t.length++};if(M(N,E,(function(t,e){return t<=e})),M(A,I,(function(t,e){return t>=e})),!(T<0)){var C=N.length&&A.length,D=C?E[N.indices[N.head]]:NaN,F=C?I[A.indices[A.head]]:NaN;if(p){var L=NaN,R=NaN,U=D/F;if(F>0&&D>=F&&Number.isFinite(D)&&Number.isFinite(U)){var B=J(U,1);L=B/2;var H=i.close[e],V=H/F;if(B>0&&H>0&&V>0&&Number.isFinite(V)){var K=2*J(V,1)/B-1;Number.isFinite(K)&&(R=K)}}return t.pushToMain({index:e,key:P("width"),value:L}),void t.pushToMain({index:e,key:P("position"),value:R})}var $=C?(D+F)/2:NaN;t.pushToMain({index:e,key:P("upper"),value:D}),t.pushToMain({index:e,key:P("basis"),value:$}),t.pushToMain({index:e,key:P("lower"),value:F})}}},bollingerBands:function(t,e,r,n){var o,i,a,u,c,l,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},f=s.lag,h=s.retLogs,p=void 0!==h&&h,y=t.verticalOhlcv,m=t.instances,d=t.useFullNames,b="".concat(r,"_").concat(n),g="".concat(p?"ret_log_":"").concat(b),w="".concat(p?"ret_log_":"","bollinger_bands"),S="close";if(0===e){var O=t.inputParams,_=t.verticalOhlcv,j=t.priceBased;if(v((u={},l=!0,(c=function(t){var e=function(t,e){if("object"!=Bt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Bt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bt(e)?e:e+""}(c=S))in u?Object.defineProperty(u,c,{value:l,enumerable:!0,configurable:!0,writable:!0}):u[c]=l,u),_,e,"bollingerBands"),!(S in _))throw new Error('bollingerBands could not find target "'.concat(S,'"'));var P,k=0,N=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Ht(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ht(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(O);try{for(N.s();!(P=N.n()).done;)"bollingerBands"===P.value.key&&k++}catch(t){N.e(t)}finally{N.f()}m.bollinger_bands||(m.bollinger_bands={numberOfIndicators:k,settings:{}}),m.bollinger_bands.settings[g]=new At(r,n);var A=k>1||d?"_".concat(b):"",x=p?["".concat(w,"_width").concat(A),"".concat(w,"_position").concat(A)]:["".concat(w,"_upper").concat(A),"".concat(w,"_middle").concat(A),"".concat(w,"_lower").concat(A)];yt(t,x.map((function(t){return{key:t,priceBased:!p&&j.has(S)}})),{lag:f})}var T=m.bollinger_bands.numberOfIndicators>1||d?"_".concat(b):"",E=m.bollinger_bands.settings[g],I=y[S][e];E.update(I);var M=E.isStable?E.getResult():null,C=null!==(o=null==M?void 0:M.upper)&&void 0!==o?o:NaN,D=null!==(i=null==M?void 0:M.middle)&&void 0!==i?i:NaN,F=null!==(a=null==M?void 0:M.lower)&&void 0!==a?a:NaN;if(p){var L=NaN,R=NaN,U=C/F;if(F>0&&C>=F&&Number.isFinite(C)&&Number.isFinite(U)){var B=J(U,1);L=B/2;var H=I/F;if(B>0&&I>0&&H>0&&Number.isFinite(H)){var V=2*J(H,1)/B-1;Number.isFinite(V)&&(R=V)}}return t.pushToMain({index:e,key:"".concat(w,"_width").concat(T),value:L}),void t.pushToMain({index:e,key:"".concat(w,"_position").concat(T),value:R})}t.pushToMain({index:e,key:"".concat(w,"_upper").concat(T),value:C}),t.pushToMain({index:e,key:"".concat(w,"_middle").concat(T),value:D}),t.pushToMain({index:e,key:"".concat(w,"_lower").concat(T),value:F})},volumeOscillator:function(t,e,r,n,o){var i,a,u,c=o.lag,l=o.retLogs,s=t.verticalOhlcv,f=t.instances,h=l?"ret_log_volume_oscillator_".concat(r,"_").concat(n):"volume_oscillator_".concat(r,"_").concat(n);0===e&&(v({volume:!0},s,e,"volumeOscillator"),Object.assign(f,(i={},a=h,u={fastEMA:new U(r),slowEMA:new U(n)},(a=function(t){var e=function(t,e){if("object"!=Vt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Vt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Vt(e)?e:e+""}(a))in i?Object.defineProperty(i,a,{value:u,enumerable:!0,configurable:!0,writable:!0}):i[a]=u,i)),yt(t,[{key:h}],{lag:c}));var p=f[h],y=p.fastEMA,m=p.slowEMA,d=s.volume[e];if(0!==d){y.update(d),m.update(d);var b,g=y.isStable?y.getResult():NaN,w=m.isStable?m.getResult():NaN;Number.isNaN(g)||Number.isNaN(w)||(b=l?J(g,w):100*(g-w)/w,t.pushToMain({index:e,key:h,value:b}))}},crossPairs:function(t,e,r,n){var o,i=n.oneHot,a=n.limit,u=t.verticalOhlcv,c=t.verticalOhlcvTempCols,l=t.instances,s=t.len,f=t.precision,h=t.precisionMultiplier,p=t.priceBased,y=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Jt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Jt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(r);try{for(y.s();!(o=y.n()).done;){var m=o.value,d=m.fast,b=m.slow,g="".concat(d,"_x_").concat(b);if(0===e){if(v(Yt(Yt({},"price"===d?{high:!0,low:!0,close:!0}:qt({},d,!0)),"number"==typeof b?{}:qt({},b,!0)),u,e,"crossPairs"),"number"==typeof b){var w=b.toString();c.add(w);var S=f&&("price"===d||p.has(d)),O=S?et(w,h):b,_=b>=-125&&b<=125&&!1===S?"Int8Array":"Float64Array";u[w]=vt(_,s,O)}l.hasOwnProperty("crossPairs")||(l.crossPairs={}),l.crossPairs[g]={run:new re,min:1/0,max:-1/0},yt(t,[{key:g,type:null!==a&&a<=125?"Int8Array":"Float64Array",fill:0},{key:"one_hot_".concat(g),type:"Array",enabled:i}])}else if(e+1===s){if("price"!==d&&!u.hasOwnProperty(d))throw new Error('crossPairs invalid param: fast "'.concat(d,'" not found in "verticalOhlcv": ').concat(JSON.stringify(Object.keys(u))));if(!u.hasOwnProperty(b))throw new Error('crossPairs invalid param: slow "'.concat(b,'" not found in "verticalOhlcv": ').concat(JSON.stringify(Object.keys(u))))}if("price"!==d&&!u.hasOwnProperty(d))return;if(!u.hasOwnProperty(b))return;var j=l.crossPairs[g].run;if("price"===d){var P=u.close[e],k=u[b][e];j.update(e,{fast:P,slow:k,high:u.high[e],low:u.low[e]})}else{var N=u[d][e],A=u[b][e];j.update(e,{fast:N,slow:A})}var x=j.getResult(),T=null!==a?Math.min(Math.max(x,-a),a):x;if(t.pushToMain({index:e,key:g,value:T}),i){var E=T+a,I=2*a+1;t.pushToMain({index:e,key:"one_hot_".concat(g),value:Zt(E,I)})}}}catch(t){y.e(t)}finally{y.f()}},lag:function(t,e,r,n){var o,i=t.verticalOhlcv,a=t.priceBased,u=t.instances;if(0===e){var c,l=new Map,s=Kt(r);try{for(s.s();!(c=s.n()).done;){var f=c.value;if(!i.hasOwnProperty(f))throw new Error('Lag processing invoked by col "'.concat(f,'" was not found in "verticalOhlcv".'));for(var h=a.has(f),v=Array.isArray(i[f])?"Array":"Float64Array",p=[],y=[],m=1;m<=n;m++){var d="".concat(f,"_lag_").concat(m);p.push({key:d,type:v,priceBased:h,includeInLag:!1}),y.push(d)}yt(t,p),l.set(f,y)}}catch(t){s.e(t)}finally{s.f()}u[zt]||(u[zt]=new WeakMap),u[zt].set(r,l)}var b,g=null===(o=u[zt])||void 0===o?void 0:o.get(r),w=Kt(r);try{for(w.s();!(b=w.n()).done;)for(var S=b.value,O=null==g?void 0:g.get(S),_=i[S],j=Array.isArray(_)?null:NaN,P=1;P<=n;P++){var k,N=null!==(k=null==O?void 0:O[P-1])&&void 0!==k?k:"".concat(S,"_lag_").concat(P),A=e-P,x=A<0||null==_[A]?j:_[A];t.pushToMain({index:e,key:N,value:x})}}catch(t){w.e(t)}finally{w.f()}}};function De(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var Fe=function(t){var e,r,n=t.main,o=t.skipNull,i=void 0!==o&&o,a=t.startIndex,u=void 0===a?0:a,c=t.dateFormat,l=n.verticalOhlcv,s=n.invalidValueIndex,f=n.len,h=n.verticalOhlcvKeyNames,v=n.verticalOhlcvTempCols,p=n.priceBased,y=n.precision,m=n.precisionMultiplier;if(0===h.length)return[];for(var d=y&&"number"==typeof m?tt(m):void 0,b=i&&s>=0?s+1:0,g=Math.max(b,u),w=f-g,S=Array.from({length:w},(function(){return{}})),O=0,_=Object.entries(l);O<_.length;O++){var j=(e=_[O],r=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(e,r)||function(t,e){if(t){if("string"==typeof t)return De(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?De(t,e):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),P=j[0],k=j[1];if(!v.has(P))if("date"===P)for(var N=ut[c],A=g;A<f;A++)S[A-g][P]=N(k[A]);else if(y&&p.has(P))for(var x=ot,T=g;T<f;T++){var E=k[T];S[T-g][P]=null==E||Number.isNaN(E)?E:x(E,m,d)}else for(var I=g;I<f;I++)S[I-g][P]=k[I]}return S};function Le(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Re(t){return Re="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Re(t)}var Ue=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(null===t||"string"==typeof t||"boolean"==typeof t)return t;if("number"==typeof t&&Number.isFinite(t))return t;if("object"!==Re(t)||null===t)throw new TypeError("Configuration values must be JSON-safe: no undefined, non-finite numbers, or functions.");if(e.has(t))throw new TypeError("Configuration must not contain circular references.");var r=Object.getPrototypeOf(t);if(!Array.isArray(t)&&r!==Object.prototype&&null!==r)throw new TypeError("Configuration must contain only plain objects and arrays.");if(Object.getOwnPropertySymbols(t).length)throw new TypeError("Configuration must not contain symbol keys.");e.add(t);var n=Array.isArray(t)?Array.from(t,(function(t){return Ue(t,e)})):Object.fromEntries(Object.entries(t).map((function(t){var r,n,o=(n=2,function(t){if(Array.isArray(t))return t}(r=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r,n)||function(t,e){if(t){if("string"==typeof t)return Le(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Le(t,e):void 0}}(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1];return[i,Ue(a,e)]})));return e.delete(t),n},Be=function(t){if(null!==t&&"object"===Re(t)){for(var e=0,r=Object.values(t);e<r.length;e++){var n=r[e];Be(n)}Object.freeze(t)}return t};function He(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ve(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?He(Object(r),!0).forEach((function(e){Ke(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):He(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Ke(t,e,r){return(e=qe(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $e(t){return function(t){if(Array.isArray(t))return Ze(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ze(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ze(t,e){if(t){if("string"==typeof t)return Ze(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ze(t,e):void 0}}function Ze(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ge(t){return Ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ge(t)}function Ye(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qe(n.key),n)}}function qe(t){var e=function(t,e){if("object"!=Ge(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Ge(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ge(e)?e:e+""}var Je=function(){return t=function t(e){var r=this,n=e.input,o=e.ticker,a=void 0===o?null:o,c=e.chunkProcess,v=void 0===c?2e3:c,p=e.config,y=void 0===p?{}:p;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),null===y||Array.isArray(y)||"object"!==Ge(y))throw new TypeError('Constructor "config" must be a plain object.');for(var m=Ue(y),d=["schemaVersion","precision","useFullNames","inputParams","dateFormat","skipNull","timeZone"],b=0,g=Object.keys(m);b<g.length;b++){var w=g[b];if(!d.includes(w))throw new Error('Unknown configuration option "'.concat(w,'".'))}var S=m.schemaVersion,O=void 0===S?1:S,_=m.precision,j=void 0!==_&&_,P=m.useFullNames,k=void 0!==P&&P,N=m.inputParams,A=void 0===N?null:N,x=m.dateFormat,T=void 0===x?"milliseconds":x,E=m.skipNull,I=void 0===E||E,M=m.timeZone,C=void 0===M?Intl.DateTimeFormat().resolvedOptions().timeZone:M;if(1!==O)throw new Error("Unsupported configuration schemaVersion: ".concat(O,"."));s(I,"config.skipNull","constructor"),h(T,"config.dateFormat","constructor"),l(Object.keys(ut),T,"config.dateFormat","constructor"),h(C,"config.timeZone","constructor");var D=new Intl.DateTimeFormat("en-US",{timeZone:C}).resolvedOptions().timeZone;if(this.config=Object.freeze({schemaVersion:O,precision:j,useFullNames:k,dateFormat:T,skipNull:I,timeZone:D}),this.timeZone=D,u(n,"input",null!==a?"contructor ".concat(a):"constuctor"),0===n.length)throw Error("input OHLCV must not be empty: "+a);f(v,{min:100,max:5e4,allowDecimals:!1},"chunkProcess","constructor"),s(j,"precision","contructor"),s(k,"config.useFullNames","constructor"),this.chunkProcess=v,this.input=$e(n),this.len=this.input.length,this.firstRow=this.input[0],this.precision=j,this.useFullNames=k;var F=["open","high","low","close","mid_price"];this.initialPriceBased=new Set(F),this.priceBased=new Set(F),this.precisionMultiplier=function(t){var e=t.precision,r=t.firstRow,n=t.initialPriceBased;if(!1===e)return 1;for(var o=1,i=0,a=Object.entries(r);i<a.length;i++){var u=Q(a[i],2),c=u[0],l=u[1];if(n.has(c)){if("string"!=typeof l||!/^\d+(\.\d+)?$/.test(l))throw new Error('If "precision" is set to true all the "open", "high", "low" and "close" values must be numeric strings like "123.45" with no commas or currency symbols. Property "'.concat(c,'" had the value "').concat(l,'" type ').concat(W(l),"."));var s=Q(l.split("."),2),f=s[0],h=s[1],v=void 0===h?"":h,p=Number(f),y=4;if(0===Math.abs(p)){var m=v.length,d=Math.max(4,m),b=v.search(/[1-9]/);if(-1===b)y=d;else{var g=b+1+5;y=Math.max(d,g)}}var w=Math.pow(10,y);w>o&&(o=w)}}return o}(this);var L=function(t){for(var e=t.firstRow,r=t.precision,n=t.initialPriceBased,o={},i={},a=new Map,u=0,c=Object.entries(e);u<c.length;u++){var l=st(c[u],2),s=l[0],f=l[1];if("date"===s)o[s]=lt(f),i[s]="Array";else if("volume"===s)o[s]=it(f,!0),i[s]="Int32Array";else if(n.has(s))o[s]=it(f,!0,r),i[s]="Float64Array",a.set(s,o[s]);else{var h=it(f,!1,r);o[s]=h,i[s]="number"===h?"Float64Array":"Array"}}if(new Set(a.values()).size>1){var v=function(t){return function(t){if(Array.isArray(t))return ht(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ft(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(a.entries()).map((function(t){var e=st(t,2),r=e[0],n=e[1];return"".concat(r,': "').concat(n,'"')})).join(", ");throw new Error("Inconsistent types among price-based columns — ".concat(v,". ")+"All initialPriceBased columns must share the same numeric type.")}return i.hasOwnProperty("open")&&i.hasOwnProperty("close")&&(i.mid_price=i.open,o.mid_price=o.open),{inputTypes:o,arrayTypes:i}}(this),R=L.inputTypes,U=L.arrayTypes;if(this.inputTypes=R,this.arrayTypes=U,!this.firstRow.hasOwnProperty("close"))throw Error('input OHLCV array objects require at least "close" property: '.concat(a));return this.dateType=this.inputTypes.date?this.inputTypes.date:null,this.isComputed=!1,this.isComputing=!1,this.executionParams=[],this.instances={},this.verticalOhlcv={},this.verticalOhlcvKeyNames=[],this.verticalOhlcvTempCols=new Set,this.utilities={},this.invalidValueIndex=-1,this.scaledGroups={},this.isAlreadyComputed=new Set,this.pushToMain=function(t){var e=t.index,n=t.key,o=t.value;r.verticalOhlcv[n][e]=o},null!==A?(i(A,this.len),this.inputParams=Be(Ue(A)),this.compute()):this.inputParams=Object.freeze([]),this},e=[{key:"exportConfig",value:function(){return Ve(Ve({},this.config),{},{inputParams:Ue(this.inputParams)})}},{key:"_registerIndicator",value:function(t){return a(this),this.inputParams=Object.freeze([].concat($e(this.inputParams),[Be(Ue(t))])),this}},{key:"getData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.skipNull,r=void 0===e?this.config.skipNull:e,n=t.dateFormat,o=void 0===n?this.config.dateFormat:n;return l(Object.keys(ut),o,"dateFormat","getData"),c(t,"options","getData"),Fe({main:this,skipNull:r,startIndex:0,dateFormat:o})}},{key:"getLastValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.compute();var e=t.dateFormat,r=void 0===e?this.config.dateFormat:e;return l(Object.keys(ut),r,"dateFormat","getData"),Fe({skipNull:!1,main:this,startIndex:this.len-1,dateFormat:r})[0]}},{key:"compute",value:function(){if(this.isComputed)return this;if(this.isComputing)throw new Error("Computation is already in progress.");if(this.executionParams=Ue(this.inputParams).sort((function(t,e){var r,n;return(null!==(r=t.order)&&void 0!==r?r:0)-(null!==(n=e.order)&&void 0!==n?n:0)})),this.isComputed=!1,this.len>0){this.isComputing=!0;try{!function(t,e){var n=e.len,o=e.arrayTypes,a=e.verticalOhlcv,u=e.verticalOhlcvKeyNames,c=e.inputTypes,l=e.chunkProcess,s=e.precisionMultiplier,f=e.executionParams;i(f,n);var h,v=Ee(f);try{for(v.s();!(h=v.n()).done;){var p=h.value.key;if(!Object.prototype.hasOwnProperty.call(Ce,p))throw new Error('Unknown indicator "'.concat(p,'" in configuration.'))}}catch(t){v.e(t)}finally{v.f()}for(var y=0,m=Object.keys(c);y<m.length;y++){var d=m[y];a[d]=vt(o[d],n)}for(var b=Object.entries(c).map((function(t){var e=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||Ie(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),r=e[0],n=e[1],o=nt.hasOwnProperty(n);return{key:r,formatter:o?nt[n]:ct.hasOwnProperty(n)?ct[n]:null,numeric:o}})),g="number"==typeof s?tt(s):void 0,w=null,S=0;S<n;S+=l)for(var O=Math.min(S+l,n),_=S;_<O;_++){var j,P=t[_],k=Ee(b);try{for(k.s();!(j=k.n()).done;){var N=j.value,A=N.key,x=N.formatter,T=N.numeric,E=P[A];if(void 0!==E){var I=null===x?E:T?x(E,s,g):x(E);e.pushToMain({index:_,key:A,value:I})}}}catch(t){k.e(t)}finally{k.f()}var M=(a.open[_]+a.close[_])/2;e.pushToMain({index:_,key:"mid_price",value:M});var C,D=Ee(f);try{for(D.s();!(C=D.n()).done;){var F=C.value,L=F.key,R=F.params;Ce[L].apply(Ce,[e,_].concat(Te(R)))}}catch(t){D.e(t)}finally{D.f()}t[_]=null,null===w&&(w=Object.values(a)),r(w,_)||(e.invalidValueIndex=_)}u.push.apply(u,Te(Object.keys(a)))}(this.input,this)}finally{this.isComputing=!1}this.isComputed=!0,this.input=[],this.instances={},this.firstRow=[]}return this}},{key:"crossPairs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="crossPairs";a(this),u(t,"arr",r),c(e,"options",r);var n=e.limit,o=void 0===n?null:n,i=e.oneHot,l=void 0!==i&&i;null!==o&&f(o,{min:2,max:this.len},"options.limit",r),s(l,"options.oneHot",r);var h,v=[],p=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ze(t))){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(t);try{for(p.s();!(h=p.n()).done;){var y=h.value,m=y.fast,d=void 0===m?"":m,b=y.slow,g=void 0===b?"":b;if(""===d||""===g)throw new Error("Invalid crossPairs[".concat(d,"_").concat(g,"]: Object property “fast” must be a non-null column name and “slow” must be a non-null column name or integer."));v.push(d.toString(),g.toString())}}catch(t){p.e(t)}finally{p.f()}if(this.isAlreadyComputed.has(r))throw new Error('You can only call the "'.concat(r,'" method once.'));return this.isAlreadyComputed.add(r),this._registerIndicator({key:r,params:[t,{limit:o,oneHot:l}]}),this}},{key:"lag",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["close"],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r="lag";a(this),u(t,"colKeys",r);var n=t.find((function(t){return"string"!=typeof t||""===t}));if(void 0!==n)throw new Error('Invalid item "'.concat(n,'" (column name) in "colKeys" array param of "').concat(r,'()".'));return f(e,{min:1,max:this.len,allowDecimals:!1},"lookback",r),this._registerIndicator({key:r,params:[t,e]}),this}},{key:"relativeVolume",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="relativeVolume";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.lag,o=void 0===n?0:n,i=e.retLogs,u=void 0!==i&&i;return f(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),s(u,"options.retLogs",r),this._registerIndicator({key:r,order:0,params:[t,{lag:o,retLogs:u}]}),this}},{key:"volumeDelta",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="volumeDelta";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeDelta" is called the input ohlcv must contain valid volume properties.');a(this),c(t,"options",e);var r=t.lag,n=void 0===r?0:r;return f(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),this._registerIndicator({key:e,order:0,params:[{lag:n}]}),this}},{key:"atr",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="atr";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.lag,o=void 0===n?0:n,i=e.retLogs,u=void 0!==i&&i;return f(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),s(u,"options.retLogs",r),this._registerIndicator({key:r,order:0,params:[t,{lag:o,retLogs:u}]}),this}},{key:"adx",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="adx";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.lag,o=void 0===n?0:n,i=e.retLogs,u=void 0!==i&&i;return f(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),s(u,"options.retLogs",r),this._registerIndicator({key:r,order:0,params:[t,{lag:o,retLogs:u}]}),this}},{key:"ema",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="ema";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,u=void 0===i?0:i,l=e.retLogs,v=void 0!==l&&l;return h(o,"options.target",r),f(u,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),s(v,"options.retLogs",r),this._registerIndicator({key:r,params:[r,t,{target:o,lag:u,retLogs:v}]}),this}},{key:"sma",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="sma";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,u=void 0===i?0:i,l=e.retLogs,v=void 0!==l&&l;return h(o,"options.target",r),f(u,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),s(v,"options.retLogs",r),this._registerIndicator({key:r,params:[r,t,{target:o,lag:u,retLogs:v}]}),this}},{key:"heikenAshi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="heikenAshi";a(this);var o=null===t&&null===e;!1===o&&(f(t,{min:1,max:this.len,allowDecimals:!1},"smoothLength",n),f(e,{min:1,max:this.len,allowDecimals:!1},"afterSmoothLength",n)),c(r,"options",n);var i=r.lag,u=void 0===i?0:i,l=r.retLogs,h=void 0!==l&&l;return f(u,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),s(h,"option.retLogs",n),this._registerIndicator({key:n,order:0,params:[t,e,{lag:u,bothNull:o,retLogs:h}]}),this}},{key:"stochastic",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="stochastic";a(this);var i=this.len;f(t,{min:1,max:i,allowDecimals:!1},"kPeriod",o),f(e,{min:1,max:i,allowDecimals:!1},"kSlowingPeriod",o),f(r,{min:1,max:i,allowDecimals:!1},"dPeriod",o),c(n,"options",o);var u=n.lag,l=void 0===u?0:u,h=n.retLogs;return f(l,{min:0,max:i,allowDecimals:!1},"options.lag",o),s(h,"retLogs",o),this._registerIndicator({key:o,params:[t,e,r,{lag:l,retLogs:h}]}),this}},{key:"macd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:26,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o="macd";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"fast",o),f(e,{min:1,max:this.len,allowDecimals:!1},"slow",o),f(r,{min:1,max:this.len,allowDecimals:!1},"signal",o),c(n,"options",o);var i=n.target,u=void 0===i?"close":i,l=n.lag,s=void 0===l?0:l;h(u,"options.target",o),f(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",o);var v={instanceKey:"".concat(t,"_").concat(e,"_").concat(r).concat("close"===u?"":"_".concat(u))};return this._registerIndicator({key:o,params:[t,e,r,{target:u,lag:s,precomputed:v}]}),this}},{key:"bollingerBands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="bollingerBands";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",n),f(e,{min:.01,max:50,allowDecimals:!0},"stdDev",n),c(r,"options",n);var o=r.lag,i=void 0===o?0:o,u=r.retLogs,l=void 0!==u&&u;return f(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),s(l,"options.retLogs",n),this._registerIndicator({key:n,params:[t,e,{lag:i,retLogs:l}]}),this}},{key:"rsi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="rsi";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.target,o=void 0===n?"close":n,i=e.lag,u=void 0===i?0:i,l=e.retLogs,v=void 0!==l&&l;return h(o,"options.target",r),f(u,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),s(v,"retLogs",r),this._registerIndicator({key:r,params:[t,{target:o,lag:u,retLogs:v}]}),this}},{key:"mfi",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:14,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="mfi";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",r),c(e,"options",r);var n=e.lag,o=void 0===n?0:n,i=e.retLogs,u=void 0!==i&&i;return f(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",r),s(u,"options.retLogs",r),this._registerIndicator({key:r,params:[t,{lag:o,retLogs:u}]}),this}},{key:"donchianChannels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="donchianChannels";a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"size",n),f(e,{min:0,max:this.len,allowDecimals:!1},"offset",n),c(r,"options",n);var o=r.lag,i=void 0===o?0:o,u=r.retLogs,l=void 0!==u&&u;return f(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),s(l,"options.retLogs",n),this._registerIndicator({key:n,order:0,params:[t,e,{lag:i,retLogs:l}]}),this}},{key:"volumeOscillator",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="volumeOscillator";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');a(this),f(t,{min:1,max:this.len,allowDecimals:!1},"fastsize",n),f(e,{min:t,max:this.len,allowDecimals:!1},"slowsize",n),c(r,"options",n);var o=r.lag,i=void 0===o?0:o,u=r.retLogs,l=void 0!==u&&u;return f(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",n),s(l,"retLogs",n),this._registerIndicator({key:n,order:0,params:[t,e,{lag:i,retLogs:l}]}),this}},{key:"dateTime",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="dateTime";a(this),c(t,"options",e);var r=t.lag,n=void 0===r?0:r,o=t.oneHot,i=void 0!==o&&o;f(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),s(i,"options.oneHot",e);var u=i?"one_hot_":"",l=Ke(Ke(Ke(Ke(Ke({},"".concat(u,"month"),12),"".concat(u,"day_of_the_month"),31),"".concat(u,"day_of_the_week"),7),"".concat(u,"hour"),24),"".concat(u,"minute"),60),h={prefix:u,colKeySizes:l,colKeys:Object.keys(l)};return this._registerIndicator({key:e,order:0,params:[{lag:n,oneHot:i,precompute:h}]}),this}},{key:"candleFeatures",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e="candleFeatures";a(this),c(t,"options",e);var r=t.lag,n=void 0===r?0:r,o=t.colKeys,i=void 0===o?[]:o,l=t.retLogs,h=void 0!==l&&l;return f(n,{min:0,max:this.len,allowDecimals:!1},"options.lag",e),u(i,"options.colKeys",e),s(h,"retLogs",e),this._registerIndicator({key:e,params:[{lag:n,colKeys:i,retLogs:h}]}),this}}],e&&Ye(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()})(),OHLCV_INDICATORS=e})();
|
|
1
|
+
var OHLCV_INDICATORS;(()=>{"use strict";const e={d:(t,i)=>{for(var s in i)e.o(i,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:i[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};(()=>{e.d(t,{default:()=>ee});const i=(e,t)=>{if(0===e.length)return!1;for(let i=0;i<e.length;i++){const s=e[i][t];if(null==s||Number.isNaN(s))return!1}return!0},s=(e,t)=>{if(!Array.isArray(e))throw new Error('Property "inputParams" must be an "Array" or "Set".');for(const i of e){if(!i||"string"!=typeof i.key||!Array.isArray(i.params))throw new TypeError("Each inputParams entry must have an indicator key and a params array.");if(void 0!==i.order&&!Number.isFinite(i.order))throw new TypeError("Indicator order must be a finite number when provided.");const{params:e}=i;for(const i of e)if("number"==typeof i&&i>t)throw console.log(i,t),new Error("At least one of the params of the indicator is greater than the input OHLCV length. Make sure to have enough datapoints in the input OHLCV.")}},n=e=>{if(!0===e.isComputing)throw Error("You cannot add indicators while computation is in progress.");if(!0===e.isComputed)throw Error('ohlcv is already computed, you can not add new indicators after "compute", "getLastValues" or "getData" methods are called.')},o=(e,t,i)=>{if(!Array.isArray(e))throw new Error(`Param "${t}" must be an array in "${i}".`);return!0},r=(e,t,i)=>{if(e instanceof Object==0)throw new Error(`Param "${t}" must be an object in "${i}".`);return!0},a=(e,t,i,s)=>{if(o(e,"arrayOptions",`${s}.${i}.validateArrayOptions`),!e.includes(t.toString()))throw new Error(`Param "${i}" must be any of the following values [${e.join(", ")}] in "${s}".`);return!0},l=(e,t,i)=>{if("boolean"!=typeof e)throw new Error(`Param "${t}" must be an boolean in "${i}".`);return!0},c=(e,t,i,s)=>{r(t,"options",`${s}.${i}.validateNumber`);const{allowDecimals:n=!1,min:o,max:a}=t,l=n?"number":"integer";if("number"!=typeof e||!1===n&&!Number.isInteger(e))throw new Error(`Param "${i}" must be an ${l} in "${s}".`);if(void 0!==o&&"number"!=typeof o)throw new Error(`Param "min" must be a valid ${l} (if provided) in "${s}.${i}.validateNumber".`);if(void 0!==a&&"number"!=typeof a)throw new Error(`Param "max" must be a valid ${l} (if provided) in "${s}.${i}.validateNumber".`);if(void 0!==o&&void 0!==a&&o>=a)throw new Error(`Param "min" must be less than "max" in "${s}.${i}.validateNumber".`);if(void 0!==o&&e<o)throw new Error(`Param "${i}" must be an ${l} ≥ ${o} in "${s}".`);if(void 0!==a&&e>a)throw new Error(`Param "${i}" must be an ${l} ≤ ${a} in "${s}".`);return!0},h=(e,t,i)=>{if("string"!=typeof e||!e.length)throw new Error(`Invalid "${t}" property in "${i}". Only strings are accepted.`);return!0},u=(e,t,i,s)=>{if(0!==i)return!0;const n=[];for(const s of Object.keys(e)){const e=t[s]?.[i];("volume"===s?Number.isFinite(e)&&e>=0:Number.isFinite(e)&&e>0)||n.push(s)}if(n.length>0)throw new TypeError(`Invalid or missing input value(s) [${n.join(", ")}] at index ${i} in "${s}".`);return!0};class p extends Error{constructor(e="Not enough data"){super(e),this.name="NotEnoughDataError"}}class m{constructor(){this.result=void 0}get isStable(){return void 0!==this.result}getResult(){if(!this.isStable)throw new p;return this.result}}class d extends m{constructor(){super(),this.previousResult=void 0,this.highest=void 0,this.lowest=void 0,this.previousHighest=void 0,this.previousLowest=void 0}setResult(e,t=!1){return t&&(this.highest=this.previousHighest,this.lowest=this.previousLowest,this.result=this.previousResult),void 0===this.highest?this.highest=e:(this.previousHighest=this.highest,e>this.highest&&(this.highest=e)),void 0===this.lowest?this.lowest=e:(this.previousLowest=this.lowest,e<this.lowest&&(this.lowest=e)),this.previousResult=this.result,this.result=e,e}replace(e){return this.update(e,!0)}updates(e){return e.forEach(e=>this.update(e)),this.result}}class g extends d{constructor(e){super(),this.interval=e,this.pricesCounter=0,this.weightFactor=2/(e+1)}update(e,t=!1){t&&0!==this.pricesCounter||this.pricesCounter++;const i=t&&void 0!==this.previousResult?this.previousResult:void 0!==this.result?this.result:e;return this.setResult(e*this.weightFactor+i*(1-this.weightFactor),t)}get isStable(){return this.pricesCounter>=this.interval}}class f extends d{constructor(e){super(),this.interval=e,this.prices=new Float64Array(e),this.count=0,this.head=0}update(e,t=!1){"number"==typeof e||Array.isArray(this.prices)||(this.prices=Array.from(this.prices));const{interval:i,prices:s}=this;if(t&&this.count){let t=this.head+this.count-1;t>=i&&(t-=i),s[t]=e}else this.count<i?s[this.count++]=e:(s[this.head]=e,++this.head===i&&(this.head=0));if(this.count===i){let e=0;for(let t=this.head;t<i;t++)e+=s[t];for(let t=0;t<this.head;t++)e+=s[t];return this.setResult(e/i,t)}}}class v extends d{constructor(e){super(),this.interval=e,this.indicator=new f(e),this.smoothingFactor=1/e}update(e,t=!1){if(void 0===this.result){const i=this.indicator.update(e);if(void 0!==i)return this.indicator=void 0,this.setResult(i,t)}else{if(t&&void 0!==this.previousResult){const i=(e-this.previousResult)*this.smoothingFactor;return this.setResult(i+this.previousResult,t)}if(!t){const i=(e-this.result)*this.smoothingFactor;return this.setResult(i+this.result,t)}}}}class y extends d{constructor(e,t=v){super(),this.interval=e,this.avgGain=new t(e),this.avgLoss=new t(e),this.maxValue=100,this.priceCount=0,this.previousPrice=void 0,this.currentPrice=void 0}update(e,t=!1){if(t&&0!==this.priceCount||(this.previousPrice=this.currentPrice,this.priceCount<2&&this.priceCount++),this.currentPrice=e,this.priceCount<2)return;const i=this.previousPrice;if(e>i?(this.avgLoss.update(0,t),this.avgGain.update(e-i,t)):(this.avgLoss.update(i-e,t),this.avgGain.update(0,t)),this.avgGain.isStable){const e=this.avgLoss.getResult();if(0===e)return this.setResult(100,t);const i=this.avgGain.getResult()/e;return this.setResult(this.maxValue-this.maxValue/(i+1),t)}}}class w extends d{constructor(){super(),this.previousCandle=void 0,this.twoPreviousCandle=void 0}update(e,t=!1){const{high:i,low:s}=e,n=i-s;if(this.previousCandle&&t&&(this.previousCandle=this.twoPreviousCandle),this.previousCandle){const o=Math.abs(i-this.previousCandle.close),r=Math.abs(s-this.previousCandle.close);return this.twoPreviousCandle=this.previousCandle,this.previousCandle=e,this.setResult(Math.max(n,o,r),t)}return this.twoPreviousCandle=this.previousCandle,this.previousCandle=e,this.setResult(n,t)}}class b extends d{constructor(e,t=v){super(),this.interval=e,this.tr=new w,this.smoothing=new t(e)}update(e,t=!1){const i=this.tr.update(e,t);if(this.smoothing.update(i,t),this.smoothing.isStable)return this.setResult(this.smoothing.getResult(),t)}}class $ extends d{constructor(e,t=v){super(),this.interval=e,this.atr=new b(e,t),this.movesDown=new t(e),this.movesUp=new t(e),this.previousCandle=void 0,this.mdi=void 0,this.pdi=void 0}updateState(e,t=0,i=0){this.atr.update(e),this.movesUp.update(t),this.movesDown.update(i),this.previousCandle=e}update(e){if(!this.previousCandle)return void this.updateState(e);const t=e.high-this.previousCandle.high,i=this.previousCandle.low-e.low,s=t<0||t<i?0:t,n=i<0||i<t?0:i;if(this.updateState(e,s,n),this.movesUp.isStable){const e=this.atr.getResult();this.pdi=this.movesUp.getResult()/e,this.mdi=this.movesDown.getResult()/e;const t=Math.abs(this.pdi-this.mdi),i=this.pdi+this.mdi;return 0===i?this.setResult(0,!1):this.setResult(t/i*100,!1)}}}class _ extends d{constructor(e,t=v){super(),this.interval=e,this.adx=new t(e),this.dx=new $(e,t)}get mdi(){return this.dx.mdi}get pdi(){return this.dx.pdi}update(e,t=!1){const i=this.dx.update(e);if(void 0!==i&&this.adx.update(i),this.adx.isStable)return this.setResult(this.adx.getResult(),t)}}class N extends m{constructor(e,t=2){super(),this.interval=e,this.deviationMultiplier=t,this.prices=new Float64Array(e),this.count=0,this.head=0}update(e){if("number"==typeof e||Array.isArray(this.prices)||(this.prices=Array.from(this.prices)),this.count<this.interval)return void(this.prices[this.count++]=e);this.prices[this.head]=e,this.head=(this.head+1)%this.interval;let t=0,i=this.head;for(let e=0;e<this.count;e++)t+=this.prices[i],++i===this.interval&&(i=0);const s=this.count?t/this.count:0;let n=s;if(!n&&Array.isArray(this.prices)){t=0,i=this.head;for(let e=0;e<this.count;e++)t+=this.prices[i],++i===this.interval&&(i=0);n=this.count?t/this.count:0}let o=0;i=this.head;for(let e=0;e<this.count;e++){const e=this.prices[i]-n;o+=e*e,++i===this.interval&&(i=0)}const r=Math.sqrt(this.count?o/this.count:0);return this.result={lower:s-r*this.deviationMultiplier,middle:s,upper:s+r*this.deviationMultiplier}}}class x extends m{constructor(e,t,i){super(),this.short=e,this.long=t,this.signal=i,this.pricesCounter=0}update(e,t=!1){t&&0!==this.pricesCounter||this.pricesCounter++;const i=this.short.update(e,t),s=this.long.update(e,t);if(this.pricesCounter>this.long.interval&&this.pricesCounter--,this.pricesCounter===this.long.interval){const e=i-s,n=this.signal.update(e,t);return this.result={histogram:e-n,macd:e,signal:n}}}}class k extends m{constructor(e,t,i){super(),this.n=e,this.m=t,this.p=i,this.periodM=new f(t),this.periodP=new f(i),this.candles=new Array(e),this.count=0,this.head=0}update(e){if(this.count<this.n?this.candles[this.count++]=e:(this.candles[this.head]=e,this.head=(this.head+1)%this.n),this.count===this.n){let t=-1/0,i=1/0,s=this.head;for(let e=0;e<this.count;e++)t=Math.max(t,this.candles[s].high),++s===this.n&&(s=0);s=this.head;for(let e=0;e<this.count;e++)i=Math.min(i,this.candles[s].low),++s===this.n&&(s=0);const n=t-i,o=100*(e.close-i)/(0===n?1:n),r=this.periodM.update(o),a=r&&this.periodP.update(r);if(void 0!==r&&void 0!==a)return this.result={stochD:a,stochK:r}}}}const O=(e,t)=>{if(0===e&&(e=.001),0===t&&(t=.001),Math.sign(e)!==Math.sign(t))throw new Error(`[BUG] Params must have the same sign in mathLog a=${e} b=${t}.`);e<0&&(e=-e,t=-t);const i=Math.log(e/t);if(null==(s=i)||!Number.isFinite(s))throw new Error(`[BUG] Invalid params passed to mathLog a=${e} b=${t}.`);var s;return i},T=e=>{const t=String(e);return 1===e?0:t.length-1},M=(e,t,i)=>{if("string"!=typeof e)throw new Error("addPrecisionExact expects a string when precision=true");const s="-"===e.charAt(0),n=s?e.slice(1):e,[o,r=""]=n.split("."),a=void 0===i?T(t):i,l=r.padEnd(a,"0").slice(0,a);let c=parseInt(o+l||"0",10);return s&&(c=-c),c},S={number:e=>e,numberCleanString:e=>Number(e),precisionNumberCleanString:(e,t,i)=>M(e,t,i)},F=(e,t,i)=>((e,t,i)=>{if("number"!=typeof e||!Number.isFinite(e))throw new Error("revertPrecisionAsNumber expects a finite number");const s=e<0;let n=Math.abs(e);n=Math.trunc(n);const o=void 0===i?T(t):i;if(0===o)return s?-n:n;const r=Math.trunc(n/t);let a=String(n%t).padStart(o,"0");a=a.replace(/0+$/,"");const l=0===a.length?String(r):`${r}.${a}`;return Number(s?`-${l}`:l)})(e,t,i),P=(e,t=!1,i=!1)=>{const s="number"==typeof e&&!Number.isNaN(e),n="string"==typeof e&&/^-?\d+(\.\d+)?$/.test(e);if(!0===i){if(n)return"precisionNumberCleanString";if(t)throw new Error("Invalid number forma");return typeof e}if(s)return"number";if(n)return"numberCleanString";if(t)throw new TypeError("Invalid input: expected a number or numeric string");return typeof e},C={toString:e=>e.toString(),string:e=>e.toString(),toISOString:e=>e.toISOString(),iso:e=>e.toISOString(),toUTCString:e=>e.toUTCString(),milliseconds:e=>e.getTime(),seconds:e=>e.getTime()/1e3,object:e=>e},A={dateObject:e=>e,dateMilliseconds:e=>new Date(e),dateSeconds:e=>new Date(1e3*e),dateIncompleteDayString:e=>new Date(`${e} 00:00:00`),dateCompleteDateString:e=>new Date(e)},D=e=>{const t=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/i,i=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?([+-]\d{2}:\d{2})$/,s=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/,n=/^\d{4}-\d{2}-\d{2}$/,o=/^\d{4}\/\d{2}\/\d{2}$/,r=["Date -> object","Milliseconds Timestamp -> integer","Seconds Timestamp -> integer","UTC Time Format (ISO 8601) -> string","Including a Timezone Offset (ISO 8601) -> string","Local Time Format (ISO 8601) -> string","YYYY/MM/DD or YYYY-MM-DD -> string"],a=()=>{throw new Error(`Invalid "${typeof e}" date value passed in selectDateFormatter. Supported formats: \n-${r.join("\n- ")}`)};if("object"==typeof e){if(e instanceof Date&&!isNaN(e.valueOf()))return"dateObject";a()}else{if("number"==typeof e)return Math.abs(e)<1e11?"dateSeconds":"dateMillseconds";if("string"==typeof e){if(t.test(e)||i.test(e)||s.test(e)&&e.length>10||o.test(e))return"dateCompleteDateString";if(n.test(e))return"dateIncompleteDayString";a()}else a()}},L=(e,t,i)=>{const s={Array,Float64Array,Float32Array,Int32Array,Uint8Array,Int8Array,Int16Array}[e];if(!s||"function"!=typeof s.from)throw new Error(`Unsupported array type: ${e}`);let n;return n=void 0!==i?i:"Array"===e?null:NaN,new s(t).fill(n)},I=(e,t,{lag:i=0}={})=>{const s=[],n=[];for(const{key:i,type:o="Float64Array",fill:r,enabled:a=!0,priceBased:l=!1,includeInLag:c=!0}of t)if(a){if(Object.prototype.hasOwnProperty.call(e.verticalOhlcv,i))throw new Error(`Output column "${i}" already exists in verticalOhlcv.`);if(/^(?:Int|Uint)/.test(o)&&void 0===r)throw new Error(`Integer output column "${i}" requires an explicit fill value.`);e.verticalOhlcv[i]=L(o,e.len,r),l&&e.priceBased.add(i),s.push(i),c&&n.push(i)}return i>0&&n.length>0&&(c(i,{min:1,max:e.len},"lag","initializeColumns"),e.executionParams.push({key:"lag",params:[n,i]})),s},E=e=>null==e||!Number.isFinite(e),R={ema:g,sma:f},j=(e,t,i,s,{target:n,lag:o,retLogs:r=!1})=>{const{verticalOhlcv:a,instances:l,priceBased:c}=e,h=`${r?"ret_log_":""}${i}_${s}${"close"!==n?`_${n}`:""}`;if(0===t){if(u({[n]:!0},a,t,i),!a.hasOwnProperty(n))throw new Error(`Target property ${n} not found in verticalOhlcv for ${i}.`);l[h]=new R[i](s),I(e,r?[{key:`${h}_distance`,priceBased:!1},{key:`${h}_change`,priceBased:!1}]:[{key:h,priceBased:c.has(n)}],{lag:o})}const p=a[n][t];if(E(p))return;const m=l[h],d=m.isStable?m.getResult():NaN;m.update(p);const g=m.isStable?m.getResult():NaN;if(!E(g))if(r){const i=O(p,g);if(e.pushToMain({index:t,key:`${h}_distance`,value:i}),E(d))return;const s=O(g,d);e.pushToMain({index:t,key:`${h}_change`,value:s})}else e.pushToMain({index:t,key:h,value:g})},H=e=>null==e||!Number.isFinite(e),B=(e,t)=>(e-t)/t,V="close",K=Symbol("lagColumns"),U=(e,t)=>{const i=new Uint8Array(t);return i[e]=1,i},z=(e,t)=>e>t,Z=(e,t)=>e<t;class G{constructor(){Object.assign(this,{interval:0,prevState:.5,prevFast:NaN,prevSlow:NaN,prevHigh:NaN,prevLow:NaN,areHighAndLowUndefined:!1})}update(e,{fast:t,high:i,slow:s,low:n}){let o=this.prevState;this.areHighAndLowUndefined||void 0!==i&&void 0!==n||(this.areHighAndLowUndefined=!0),Number.isNaN(t)||Number.isNaN(s)||((e,t)=>e===t)(t,s)?o=.5:z(t,s)?o=this.areHighAndLowUndefined?1:[n,s,this.prevLow,this.prevSlow].every(e=>!Number.isNaN(e))&&Z(n,s)&&z(this.prevLow,this.prevSlow)?0:1:Z(t,s)&&(o=this.areHighAndLowUndefined?0:[i,s,this.prevHigh,this.prevSlow].every(e=>!Number.isNaN(e))&&z(i,s)&&Z(this.prevHigh,this.prevSlow)?1:0),.5===o?this.interval=0:1===o?this.prevState<=.5?this.interval=1:this.interval++:0===o&&(this.prevState>=.5?this.interval=-1:this.interval--),Object.assign(this,{prevState:o,prevFast:t,prevSlow:s,prevHigh:i,prevLow:n})}getResult(){return this.interval}}const Y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],q=e=>null==e||!Number.isFinite(e),J={candleFeatures:(e,t,{lag:i,colKeys:s,retLogs:n})=>{const{verticalOhlcv:o,priceBased:r,scaledGroups:a}=e,l=(e,t)=>n?Math.log(e/t):(e-t)/t,c=n?"ret_log_":"ret_";if(0===t){u({open:!0,high:!0,low:!0,close:!0},o,t,"candleFeatures");const n=["change","mid_price_change","upper_wick","lower_wick","gap","body","range"].map(e=>({key:`${c}${e}`}));for(const e of s){if(u({[e]:!0},o,t,"candleFeatures"),!o.hasOwnProperty(e))throw new Error(`Target property in "options.colKey" array "${e}" not found in verticalOhlcv for "candleFeatures".`);if(!r.has(e))throw new Error(`Target property in "options.colKey" array "${e}" not found in priceBased for "candleFeatures".`);n.push({key:`${c}${e}`})}a.candleFeatures=I(e,n,{lag:i})}const h=o.close[t-1],p=o.open[t-1];if(void 0===h)return;const m=o.open[t],d=o.high[t],g=o.low[t],f=o.close[t],v=(h+p)/2,y=(m+f)/2,w=Math.max(m,f),b=Math.min(m,f),$=l(f,h),_=l(y,v),N=l(d,w),x=l(b,g),k=l(m,h),O=l(f,m),T=l(d,g);if(0===s.length)return e.pushToMain({index:t,key:`${c}change`,value:$}),e.pushToMain({index:t,key:`${c}mid_price_change`,value:_}),e.pushToMain({index:t,key:`${c}upper_wick`,value:N}),e.pushToMain({index:t,key:`${c}lower_wick`,value:x}),e.pushToMain({index:t,key:`${c}gap`,value:k}),e.pushToMain({index:t,key:`${c}body`,value:O}),void e.pushToMain({index:t,key:`${c}range`,value:T});const M={[`${c}change`]:$,[`${c}mid_price_change`]:_,[`${c}upper_wick`]:N,[`${c}lower_wick`]:x,[`${c}gap`]:k,[`${c}body`]:O,[`${c}range`]:T};let S=!1;for(const e of s){const i=o[e][t];if(q(i)){S=!0;break}const s=l(f,i);M[`${c}${e}`]=s}if(!S)for(const[i,s]of Object.entries(M))e.pushToMain({index:t,key:i,value:s})},dateTime:(e,t,{lag:i,oneHot:s,precompute:n})=>{const{instances:o,verticalOhlcv:r}=e,{prefix:a}=n;if(0===t){const{dateType:t}=e;if(!t)throw Error('dateTime method found and invalid "date" in input ohlcv');Object.assign(o,{dateTime:{formatter:new Intl.DateTimeFormat("en-US-u-ca-gregory-nu-latn",{timeZone:e.timeZone,year:"numeric",month:"numeric",day:"numeric",weekday:"short",hour:"numeric",minute:"numeric",hourCycle:"h23"}),colKeys:[...n.colKeys,`${a}year`].filter(e=>"one_hot_year"!==e),colKeySizes:{...n.colKeySizes}}});const{colKeys:r}=o.dateTime;I(e,r.map(e=>({key:e,type:s?"Array":"Int16Array",fill:s?null:0})),{lag:i})}const{colKeySizes:l,formatter:c}=o.dateTime,h=r.date[t];let u,p,m,d,g,f;for(const e of c.formatToParts(h))switch(e.type){case"year":u=e.value;break;case"month":p=e.value;break;case"hour":m=e.value;break;case"minute":d=e.value;break;case"weekday":g=e.value;break;case"day":f=e.value}const v=Number(u),y=Number(p)-1,w=Number(m),b=Number(d),$=Y.indexOf(g),_=Number(f)-1;if(!s)return e.pushToMain({index:t,key:"year",value:v}),e.pushToMain({index:t,key:"month",value:y+1}),e.pushToMain({index:t,key:"hour",value:w}),e.pushToMain({index:t,key:"minute",value:b}),e.pushToMain({index:t,key:"day_of_the_week",value:($+6)%7+1}),void e.pushToMain({index:t,key:"day_of_the_month",value:_+1});const N=U(y,l.one_hot_month),x=U(w,l.one_hot_hour),k=U(b,l.one_hot_minute),O=U($,l.one_hot_day_of_the_week),T=U(_,l.one_hot_day_of_the_month);e.pushToMain({index:t,key:"one_hot_month",value:N}),e.pushToMain({index:t,key:"one_hot_hour",value:x}),e.pushToMain({index:t,key:"one_hot_minute",value:k}),e.pushToMain({index:t,key:"one_hot_day_of_the_week",value:O}),e.pushToMain({index:t,key:"one_hot_day_of_the_month",value:T})},heikenAshi:(e,t,i,s,{lag:n=0,noSmoothing:o=!1,retLogs:r=!1}={})=>{const{verticalOhlcv:a,instances:l,scaledGroups:c}=e,h=o?"heiken_ashi":`heiken_ashi_${i}_${s}`;if(0===t){u({open:!0,high:!0,low:!0,close:!0},a,t,"heikenAshi");const p=["open","high","low","close"],m=["body","upper_wick","lower_wick","range"],d=o?"":`_${i}_${s}`,f=r?"ret_log_":"ret_",v=Object.fromEntries(m.map(e=>[e,`${f}heiken_ashi_${e}${d}`])),y=`heiken_ashi_cross${d}`,w=Object.values(v);l[h]={emaPre:o?null:Object.fromEntries(p.map(e=>[e,new g(i)])),emaPost:o?null:Object.fromEntries(p.map(e=>[e,new g(s)])),prevHaOpen:NaN,prevHaClose:NaN,prevSmOpen:NaN,prevSmClose:NaN,trendDirection:0,getRet:r?O:B,outputKeys:v,crossKey:y},I(e,[...w,y].map(e=>({key:e})),{lag:n}),c&&(c.heikenAshi=w)}const p=a.open[t],m=a.high[t],d=a.low[t],f=a.close[t],v=l[h],{crossKey:y,emaPre:w,emaPost:b,getRet:$,outputKeys:_}=v;if(H(p)||H(m)||H(d)||H(f))return;let N,x,k,T;if(null!==w){if(w.open.update(p),w.high.update(m),w.low.update(d),w.close.update(f),!(w.open.isStable&&w.high.isStable&&w.low.isStable&&w.close.isStable))return;N=w.open.getResult(),x=w.high.getResult(),k=w.low.getResult(),T=w.close.getResult()}else N=p,x=m,k=d,T=f;if(H(N)||H(x)||H(k)||H(T))return;const M=(N+x+k+T)/4,S=Number.isNaN(v.prevHaOpen)||Number.isNaN(v.prevHaClose)?(N+T)/2:(v.prevHaOpen+v.prevHaClose)/2,F=Math.max(x,S,M),P=Math.min(k,S,M);let C,A,D,L;if(v.prevHaOpen=S,v.prevHaClose=M,null!==b){if(b.open.update(S),b.high.update(F),b.low.update(P),b.close.update(M),!(b.open.isStable&&b.high.isStable&&b.low.isStable&&b.close.isStable))return;C=b.open.getResult(),A=b.high.getResult(),D=b.low.getResult(),L=b.close.getResult()}else C=S,A=F,D=P,L=M;if(H(C)||H(A)||H(D)||H(L)||C<=0||A<=0||D<=0||L<=0)return;const E=Number.isFinite(v.prevSmOpen)&&Number.isFinite(v.prevSmClose),R=t>0?a[y][t-1]:NaN,j=L>C?1:L<C?-1:v.trendDirection;let V=0;E&&0!==j&&(V=Number.isFinite(R)&&Math.sign(R)===j?R+j:j),v.trendDirection=j,v.prevSmOpen=C,v.prevSmClose=L;const K=Math.max(C,L),U=Math.min(C,L),z=$(L,C),Z=$(A,K),G=$(U,D),Y=$(A,D);H(z)||e.pushToMain({index:t,key:_.body,value:z}),H(Z)||e.pushToMain({index:t,key:_.upper_wick,value:Z}),H(G)||e.pushToMain({index:t,key:_.lower_wick,value:G}),H(Y)||e.pushToMain({index:t,key:_.range,value:Y}),e.pushToMain({index:t,key:y,value:V})},rsi:(e,t,i,{target:s,lag:n,retLogs:o})=>{const{verticalOhlcv:r,instances:a}=e,l="close"===s?"":`_${s}`,c=o?`ret_log_rsi_${i}${l}`:`rsi_${i}${l}`,h=o?`ret_log_rsi_sma_${i}${l}`:`rsi_sma_${i}${l}`;if(0===t){if(u({[s]:!0},r,t,"rsi"),!r.hasOwnProperty(s))throw new Error(`Target property ${s} not found in verticalOhlcv for rsi.`);Object.assign(a,{[c]:new y(i),[h]:new f(i)}),I(e,[{key:c},{key:h}],{lag:n})}const p=r[s][t];a[c].update(p);const m=a[c].isStable?a[c].getResult():NaN,d=Number.isNaN(m)?NaN:o?O(m,50):m;e.pushToMain({index:t,key:c,value:d}),Number.isNaN(m)||a[h].update(m);const g=a[h].isStable?a[h].getResult():NaN,v=Number.isNaN(g)?NaN:o?O(g,50):g;e.pushToMain({index:t,key:h,value:v})},mfi:(e,t,i,{lag:s,retLogs:n})=>{const{verticalOhlcv:o,instances:r}=e,a=`${n?"ret_log_":""}mfi_${i}`;0===t&&(u({high:!0,low:!0,close:!0,volume:!0},o,t,"mfi"),I(e,[{key:a}],{lag:s}),r[a]={flows:new Float64Array(i),next:0,count:0,previousTypical:NaN});const l=r[a],c=(o.high[t]+o.low[t]+o.close[t])/3,h=c-l.previousTypical;if(l.previousTypical=c,0===t)return;const p=c*o.volume[t];if(l.flows[l.next]=Number.isFinite(h)&&Number.isFinite(p)&&p>=0?Math.sign(h)*p:NaN,l.next=(l.next+1)%i,l.count<i&&l.count++,l.count<i)return;let m=0,d=0,g=l.next;for(let e=0;e<i;e++){const e=l.flows[g];if(Number.isNaN(e))return;e>0?m+=e:e<0&&(d-=e),++g===i&&(g=0)}if(!Number.isFinite(m)||!Number.isFinite(d))return;const f=0===m&&0===d?NaN:100-100/(1+m/d);e.pushToMain({index:t,key:a,value:Number.isNaN(f)?NaN:n?O(f,50):f})},cmf:(e,t,i,s={})=>{const{verticalOhlcv:n,instances:o}=e,{lag:r=0}=s,a=`cmf_${i}`;if(0===t){const l=Object.keys(s).find(e=>"lag"!==e);if(l)throw new Error(`Unsupported option "${l}" in "cmf"; only "lag" is available.`);u({high:!0,low:!0,close:!0,volume:!0},n,t,"cmf"),I(e,[{key:a}],{lag:r}),o[a]={moneyFlowVolumes:new Float64Array(i),volumes:new Float64Array(i),next:0,count:0}}const l=o[a],c=n.high[t],h=n.low[t],p=n.close[t],m=n.volume[t],d=c-h;let g=NaN,f=NaN;if(Number.isFinite(c)&&Number.isFinite(h)&&Number.isFinite(p)&&Number.isFinite(m)&&m>=0&&c>=h&&p>=h&&p<=c&&Number.isFinite(d)){const e=0===d?0:(p-h-(c-p))/d,t=e*m;Number.isFinite(e)&&Number.isFinite(t)&&(g=t,f=m)}if(l.moneyFlowVolumes[l.next]=g,l.volumes[l.next]=f,l.next=(l.next+1)%i,l.count<i&&l.count++,l.count<i)return;let v=0,y=0,w=l.next;for(let e=0;e<i;e++){const e=l.moneyFlowVolumes[w],t=l.volumes[w];if(!Number.isFinite(e)||!Number.isFinite(t))return;v+=e,y+=t,++w===i&&(w=0)}if(!Number.isFinite(v)||!Number.isFinite(y)||0===y)return;const b=v/y;Number.isFinite(b)&&e.pushToMain({index:t,key:a,value:b})},stochastic:(e,t,i,s,n,{lag:o,retLogs:r})=>{const{verticalOhlcv:a,instances:l,useFullNames:c}=e,h=14!==i||3!==s||3!==n||c?`_${i}_${s}_${n}`:"",p=r?`ret_log_stochastic_d${h}`:`stochastic_d${h}`,m=r?`ret_log_stochastic_k${h}`:`stochastic_k${h}`,d=h;0===t&&(u({high:!0,low:!0,close:!0},a,t,"stochastic"),Object.assign(l,{[d]:new k(i,s,n)}),I(e,[{key:p},{key:m}],{lag:o}));const g=a.close[t],f=a.low[t],v=a.high[t];l[d].update({close:g,low:f,high:v});const y=l[d].isStable?l[d].getResult():null,w=y?r?O(y.stochK,50):y.stochK:NaN,b=y?r?O(y.stochD,50):y.stochD:NaN;e.pushToMain({index:t,key:m,value:w}),e.pushToMain({index:t,key:p,value:b})},atr:(e,t,i,{lag:s,retLogs:n})=>{const{verticalOhlcv:o,instances:r}=e,a=n?`ret_log_atr_${i}`:`atr_${i}`;if(0===t){const{instances:o,verticalOhlcv:r}=e;u({high:!0,low:!0,close:!0},r,t,"atr"),o[a]=new b(i,v),I(e,[{key:a,priceBased:!n}],{lag:s})}const l={high:o.high[t],low:o.low[t],close:o.close[t]},c=r[a];c.update(l);const h=c.isStable?c.getResult():NaN;e.pushToMain({index:t,key:a,value:Number.isNaN(h)?NaN:n?O(h,l.close):h})},adx:(e,t,i,{lag:s,retLogs:n})=>{const{verticalOhlcv:o,instances:r,useFullNames:a}=e,l=n?`ret_log_adx_${i}`:`adx_${i}`,c=`adx_${i}`;if(0===t){if(u({high:!0,low:!0,close:!0},o,t,"adx"),!o.hasOwnProperty("high"))throw new Error("Property high not found in verticalOhlcv for adx.");if(!o.hasOwnProperty("low"))throw new Error("Property low not found in verticalOhlcv for adx.");if(!o.hasOwnProperty("close"))throw new Error("Property close not found in verticalOhlcv for adx.");Object.assign(r,{[c]:new _(i)}),I(e,[{key:l}],{lag:s})}const h=o.high[t],p=o.low[t],m=o.close[t];r[c].update({high:h,low:p,close:m});const d=r[c].isStable?r[c].getResult():NaN,g=Number.isNaN(d)?NaN:n?O(d,20):d;e.pushToMain({index:t,key:l,value:g})},ema:j,sma:j,macd:(e,t,i,s,n,{target:o,lag:r,precomputed:a})=>{const{verticalOhlcv:l,instances:c,useFullNames:h}=e,{instanceKey:p}=a;if(0===t){u({[o]:!0},l,t,"macd");const{inputParams:a}=e;if(!l.hasOwnProperty(o))throw new Error(`Target property ${o} not found in verticalOhlcv for macd.`);let m=0;for(const e of a)"macd"===e.key&&m++;const d=m>1||h,f=`${i}_${s}_${n}`,v=e=>o===V?d?`macd_${e}_${f}`:`macd_${e}`:d?`macd_${e}_${o}_${f}`:`macd_${e}_${o}`,y=v("diff"),w=v("dea"),b=v("histogram");c.hasOwnProperty("macd")||(c.macd={numberOfIndicators:m,settings:{}}),c.macd.settings[p]=new x(new g(i),new g(s),new g(n)),I(e,[y,w,b].map(e=>({key:e,priceBased:!0})),{lag:r})}const{numberOfIndicators:m,settings:d}=c.macd,f=m>1||h,v=`${i}_${s}_${n}`,y=e=>o===V?f?`macd_${e}_${v}`:`macd_${e}`:f?`macd_${e}_${o}_${v}`:`macd_${e}_${o}`,w=y("diff"),b=y("dea"),$=y("histogram"),_=d[p],N=l[o][t];_.update(N);const k=_.isStable?_.getResult():null;e.pushToMain({index:t,key:w,value:k?k.macd:NaN}),e.pushToMain({index:t,key:b,value:k?k.signal:NaN}),e.pushToMain({index:t,key:$,value:k?k.histogram:NaN})},volumeDelta:(e,t,{lag:i=0})=>{const{verticalOhlcv:s,instances:n}=e,o="volume_delta";0===t&&(u({open:!0,close:!0,volume:!0},s,t,"volumeDelta"),n[o]||(n[o]={isBuyVolume:!0,cross:0}),I(e,[`${o}_high`,`${o}_low`,`${o}_close`,`${o}_cross`].map(e=>({key:e})),{lag:i}));const r=n[o],{hasInvalidInputValue:a}=r,l=s.volume[t];if(0===l)return;const c=s.open[t],h=s.close[t],p=t>0?s.close[t-1]:NaN;let m=r.isBuyVolume;h>c?m=!0:h<c?m=!1:h>p?m=!0:h<p&&(m=!1),r.isBuyVolume=m,t<1?r.cross=m?1:-1:m?r.cross>0?r.cross=r.cross+1:r.cross=1:r.cross>0?r.cross=-1:r.cross=r.cross-1;const d=m?l:-l,g=d,f=Math.max(d,0),v=Math.min(d,0);e.pushToMain({index:t,key:`${o}_high`,value:f}),e.pushToMain({index:t,key:`${o}_low`,value:v}),e.pushToMain({index:t,key:`${o}_close`,value:g}),e.pushToMain({index:t,key:`${o}_cross`,value:r.cross})},relativeVolume:(e,t,i,{lag:s,retLogs:n=!1})=>{const o=`${n?"ret_log_":""}relative_volume_${i}`,{instances:r,verticalOhlcv:a}=e;0===t&&(u({volume:!0},a,t,"relativeVolume"),r[o]={instance:new f(i),prevRelativeVolumeSma:NaN},I(e,[{key:o}],{lag:s}));const l=a.volume[t];if(0===l)return;const c=r[o].instance;c.update(l);const h=c.isStable?c.getResult():NaN,p=r[o].prevRelativeVolumeSma;if(r[o].prevRelativeVolumeSma=h,Number.isNaN(h)||Number.isNaN(p))return;const m=l/p,d=n?l>0&&p>0&&m>0&&Number.isFinite(m)?O(m,1):NaN:m;e.pushToMain({index:t,key:o,value:d})},donchianChannels:(e,t,i,s,n)=>{const{verticalOhlcv:o,instances:r,len:a,inputParams:l,useFullNames:c}=e,{lag:h=0,retLogs:p=!1}=n,m=`${i}_${s}`,d=`${p?"ret_log_":""}${m}`,g=(p?"ret_log_":"")+"donchian_channel";if(0===t){u({high:!0,low:!0},o,t,"donchianChannels"),p&&u({close:!0},o,t,"donchianChannels");const i=l.filter(e=>"donchianChannels"===e.key).length,s=i>1||c,n=(p?["width","position"]:["upper","basis","lower"]).map(e=>s?`${g}_${e}_${m}`:`${g}_${e}`);r.donchian_channel||(r.donchian_channel={numberOfIndicators:i,settings:{}}),r.donchian_channel.numberOfIndicators=i,r.donchian_channel.settings[d]={maxDeque:{indices:[],head:0,length:0},minDeque:{indices:[],head:0,length:0}},I(e,n.map(e=>({key:e,priceBased:!p})),{lag:h})}const{numberOfIndicators:f,settings:v}=r.donchian_channel,y=f>1||c,w=e=>y?`${g}_${e}_${m}`:`${g}_${e}`,{maxDeque:b,minDeque:$}=v[d],_=t-s,N=_-i+1;if(_<0||_>=a)return;const{high:x,low:k}=o,T=(e,t,s)=>{const{indices:n}=e;for(;e.length&&n[e.head]<N;)e.head=(e.head+1)%i,e.length--;for(;e.length&&s(t[n[(e.head+e.length-1)%i]],t[_]);)e.length--;n[(e.head+e.length)%i]=_,e.length++};if(T(b,x,(e,t)=>e<=t),T($,k,(e,t)=>e>=t),N<0)return;const M=b.length&&$.length,S=M?x[b.indices[b.head]]:NaN,F=M?k[$.indices[$.head]]:NaN;if(p){let i=NaN,s=NaN;const n=S/F;if(F>0&&S>=F&&Number.isFinite(S)&&Number.isFinite(n)){const e=O(n,1);i=e/2;const r=o.close[t],a=r/F;if(e>0&&r>0&&a>0&&Number.isFinite(a)){const t=2*O(a,1)/e-1;Number.isFinite(t)&&(s=t)}}return e.pushToMain({index:t,key:w("width"),value:i}),void e.pushToMain({index:t,key:w("position"),value:s})}const P=M?(S+F)/2:NaN;e.pushToMain({index:t,key:w("upper"),value:S}),e.pushToMain({index:t,key:w("basis"),value:P}),e.pushToMain({index:t,key:w("lower"),value:F})},bollingerBands:(e,t,i,s,{lag:n,retLogs:o=!1}={})=>{const{verticalOhlcv:r,instances:a,useFullNames:l}=e,c=`${i}_${s}`,h=`${o?"ret_log_":""}${c}`,p=(o?"ret_log_":"")+"bollinger_bands",m="close";if(0===t){const{inputParams:r,verticalOhlcv:d,priceBased:g}=e;if(u({[m]:!0},d,t,"bollingerBands"),!(m in d))throw new Error(`bollingerBands could not find target "${m}"`);let f=0;for(const e of r)"bollingerBands"===e.key&&f++;a.bollinger_bands||(a.bollinger_bands={numberOfIndicators:f,settings:{}}),a.bollinger_bands.settings[h]=new N(i,s);const v=f>1||l?`_${c}`:"";I(e,(o?[`${p}_width${v}`,`${p}_position${v}`]:[`${p}_upper${v}`,`${p}_middle${v}`,`${p}_lower${v}`]).map(e=>({key:e,priceBased:!o&&g.has(m)})),{lag:n})}const{numberOfIndicators:d}=a.bollinger_bands,g=d>1||l?`_${c}`:"",f=a.bollinger_bands.settings[h],v=r[m][t];f.update(v);const y=f.isStable?f.getResult():null,w=y?.upper??NaN,b=y?.middle??NaN,$=y?.lower??NaN;if(o){let i=NaN,s=NaN;const n=w/$;if($>0&&w>=$&&Number.isFinite(w)&&Number.isFinite(n)){const e=O(n,1);i=e/2;const t=v/$;if(e>0&&v>0&&t>0&&Number.isFinite(t)){const i=2*O(t,1)/e-1;Number.isFinite(i)&&(s=i)}}return e.pushToMain({index:t,key:`${p}_width${g}`,value:i}),void e.pushToMain({index:t,key:`${p}_position${g}`,value:s})}e.pushToMain({index:t,key:`${p}_upper${g}`,value:w}),e.pushToMain({index:t,key:`${p}_middle${g}`,value:b}),e.pushToMain({index:t,key:`${p}_lower${g}`,value:$})},volumeOscillator:(e,t,i,s,{lag:n,retLogs:o})=>{const{verticalOhlcv:r,instances:a}=e,l=o?`ret_log_volume_oscillator_${i}_${s}`:`volume_oscillator_${i}_${s}`;0===t&&(u({volume:!0},r,t,"volumeOscillator"),Object.assign(a,{[l]:{fastEMA:new g(i),slowEMA:new g(s)}}),I(e,[{key:l}],{lag:n}));const{fastEMA:c,slowEMA:h}=a[l],p=r.volume[t];if(0===p)return;c.update(p),h.update(p);const m=c.isStable?c.getResult():NaN,d=h.isStable?h.getResult():NaN;let f=NaN;Number.isNaN(m)||Number.isNaN(d)||(f=o?O(m,d):100*(m-d)/d,e.pushToMain({index:t,key:l,value:f}))},crossPairs:(e,t,i,{oneHot:s,limit:n})=>{const{verticalOhlcv:o,verticalOhlcvTempCols:r,instances:a,len:l,precision:c,precisionMultiplier:h,priceBased:u}=e;for(const{fast:p,slow:m}of i){const i=`${p}_x_${m}`;if(0===t){if("number"==typeof m){const e=m.toString();r.add(e);const t=c&&("price"===p||u.has(p)),i=t?M(e,h):m,s=m>=-125&&m<=125&&!1===t?"Int8Array":"Float64Array";o[e]=L(s,l,i)}a.hasOwnProperty("crossPairs")||(a.crossPairs={}),a.crossPairs[i]={run:new G,min:1/0,max:-1/0},I(e,[{key:i,type:null!==n&&n<=125?"Int8Array":"Float64Array",fill:0},{key:`one_hot_${i}`,type:"Array",enabled:s}])}else if(t+1===l){if("price"!==p&&!o.hasOwnProperty(p))throw new Error(`crossPairs invalid param: fast "${p}" not found in "verticalOhlcv": ${JSON.stringify(Object.keys(o))}`);if(!o.hasOwnProperty(m))throw new Error(`crossPairs invalid param: slow "${m}" not found in "verticalOhlcv": ${JSON.stringify(Object.keys(o))}`)}if("price"!==p&&!o.hasOwnProperty(p))return;if(!o.hasOwnProperty(m))return;const{run:d}=a.crossPairs[i];if("price"===p){const e=o.close[t],i=o[m][t];d.update(t,{fast:e,slow:i,high:o.high[t],low:o.low[t]})}else{const e=o[p][t],i=o[m][t];d.update(t,{fast:e,slow:i})}const g=d.getResult(),f=null!==n?Math.min(Math.max(g,-n),n):g;if(e.pushToMain({index:t,key:i,value:f}),s){const s=f+n,o=2*n+1;e.pushToMain({index:t,key:`one_hot_${i}`,value:U(s,o)})}}},lag:(e,t,i,s)=>{const{verticalOhlcv:n,priceBased:o,instances:r}=e;if(0===t){const t=new Map;for(const r of i){if(!n.hasOwnProperty(r))throw new Error(`Lag processing invoked by col "${r}" was not found in "verticalOhlcv".`);const i=o.has(r),a=Array.isArray(n[r])?"Array":"Float64Array",l=[],c=[];for(let e=1;e<=s;e++){const t=`${r}_lag_${e}`;l.push({key:t,type:a,priceBased:i,includeInLag:!1}),c.push(t)}I(e,l),t.set(r,c)}r[K]||(r[K]=new WeakMap),r[K].set(i,t)}const a=r[K]?.get(i);for(const o of i){const i=a?.get(o),r=n[o],l=Array.isArray(r)?null:NaN;for(let n=1;n<=s;n++){const s=i?.[n-1]??`${o}_lag_${n}`,a=t-n,c=a<0||null==r[a]?l:r[a];e.pushToMain({index:t,key:s,value:c})}}}},W=({main:e,skipNull:t=!1,startIndex:i=0,dateFormat:s})=>{const{verticalOhlcv:n,invalidValueIndex:o,len:r,verticalOhlcvKeyNames:a,verticalOhlcvTempCols:l,priceBased:c,precision:h,precisionMultiplier:u}=e;if(0===a.length)return[];const p=h&&"number"==typeof u?T(u):void 0,m=t&&o>=0?o+1:0,d=Math.max(m,i),g=r-d,f=Array.from({length:g},()=>({}));for(const[e,t]of Object.entries(n))if(!l.has(e))if("date"===e){const i=C[s];for(let s=d;s<r;s++)f[s-d][e]=i(t[s])}else if(h&&c.has(e)){const i=F;for(let s=d;s<r;s++){const n=t[s];f[s-d][e]=null==n||Number.isNaN(n)?n:i(n,u,p)}}else for(let i=d;i<r;i++)f[i-d][e]=t[i];return f},Q=(e,t=new Set)=>{if(null===e||"string"==typeof e||"boolean"==typeof e)return e;if("number"==typeof e&&Number.isFinite(e))return e;if("object"!=typeof e||null===e)throw new TypeError("Configuration values must be JSON-safe: no undefined, non-finite numbers, or functions.");if(t.has(e))throw new TypeError("Configuration must not contain circular references.");const i=Object.getPrototypeOf(e);if(!Array.isArray(e)&&i!==Object.prototype&&null!==i)throw new TypeError("Configuration must contain only plain objects and arrays.");if(Object.getOwnPropertySymbols(e).length)throw new TypeError("Configuration must not contain symbol keys.");t.add(e);const s=Array.isArray(e)?Array.from(e,e=>Q(e,t)):Object.fromEntries(Object.entries(e).map(([e,i])=>[e,Q(i,t)]));return t.delete(e),s},X=e=>{if(null!==e&&"object"==typeof e){for(const t of Object.values(e))X(t);Object.freeze(e)}return e};class ee{constructor({input:e,ticker:t=null,chunkProcess:i=2e3,config:n={}}){if(null===n||Array.isArray(n)||"object"!=typeof n)throw new TypeError('Constructor "config" must be a plain object.');const r=Q(n),u=["schemaVersion","precision","useFullNames","inputParams","dateFormat","skipNull","timeZone"];for(const e of Object.keys(r))if(!u.includes(e))throw new Error(`Unknown configuration option "${e}".`);const{schemaVersion:p=1,precision:m=!1,useFullNames:d=!1,inputParams:g=null,dateFormat:f="milliseconds",skipNull:v=!0,timeZone:y=Intl.DateTimeFormat().resolvedOptions().timeZone}=r;if(1!==p)throw new Error(`Unsupported configuration schemaVersion: ${p}.`);l(v,"config.skipNull","constructor"),h(f,"config.dateFormat","constructor"),a(Object.keys(C),f,"config.dateFormat","constructor"),h(y,"config.timeZone","constructor");const w=new Intl.DateTimeFormat("en-US",{timeZone:y}).resolvedOptions().timeZone;if(this.config=Object.freeze({schemaVersion:p,precision:m,useFullNames:d,dateFormat:f,skipNull:v,timeZone:w}),this.timeZone=w,o(e,"input",null!==t?`contructor ${t}`:"constuctor"),0===e.length)throw Error("input OHLCV must not be empty: "+t);c(i,{min:100,max:5e4,allowDecimals:!1},"chunkProcess","constructor"),l(m,"precision","contructor"),l(d,"config.useFullNames","constructor"),this.chunkProcess=i,this.input=[...e],this.len=this.input.length,this.firstRow=this.input[0],this.precision=m,this.useFullNames=d;const b=["open","high","low","close","mid_price"];this.initialPriceBased=new Set(b),this.priceBased=new Set(b),this.precisionMultiplier=(e=>{const{precision:t,firstRow:i,initialPriceBased:s}=e;if(!1===t)return 1;let n=1;for(const[e,t]of Object.entries(i)){if(!s.has(e))continue;if("string"!=typeof t||!/^\d+(\.\d+)?$/.test(t))throw new Error(`If "precision" is set to true all the "open", "high", "low" and "close" values must be numeric strings like "123.45" with no commas or currency symbols. Property "${e}" had the value "${t}" type ${typeof t}.`);const[i,o=""]=t.split("."),r=Number(i);let a=4;if(0===Math.abs(r)){const e=o.length,t=Math.max(4,e),i=o.search(/[1-9]/);if(-1===i)a=t;else{const e=i+1+5;a=Math.max(t,e)}}const l=10**a;l>n&&(n=l)}return n})(this);const{inputTypes:$,arrayTypes:_}=(e=>{const{firstRow:t,precision:i,initialPriceBased:s}=e,n={},o={},r=new Map;for(const[e,a]of Object.entries(t))if("date"===e)n[e]=D(a),o[e]="Array";else if("volume"===e)n[e]=P(a,!0),o[e]="Float64Array";else if(s.has(e))n[e]=P(a,!0,i),o[e]="Float64Array",r.set(e,n[e]);else{const t=P(a,!1,i);n[e]=t,o[e]="number"===t?"Float64Array":"Array"}if(new Set(r.values()).size>1){const e=[...r.entries()].map(([e,t])=>`${e}: "${t}"`).join(", ");throw new Error(`Inconsistent types among price-based columns — ${e}. All initialPriceBased columns must share the same numeric type.`)}return o.hasOwnProperty("open")&&o.hasOwnProperty("close")&&(o.mid_price=o.open,n.mid_price=n.open),{inputTypes:n,arrayTypes:o}})(this);if(this.inputTypes=$,this.arrayTypes=_,!this.firstRow.hasOwnProperty("close"))throw Error(`input OHLCV array objects require at least "close" property: ${t}`);return this.dateType=this.inputTypes.date?this.inputTypes.date:null,this.isComputed=!1,this.isComputing=!1,this.executionParams=[],this.instances={},this.verticalOhlcv={},this.verticalOhlcvKeyNames=[],this.verticalOhlcvTempCols=new Set,this.utilities={},this.invalidValueIndex=-1,this.scaledGroups={},this.isAlreadyComputed=new Set,this.pushToMain=({index:e,key:t,value:i})=>{this.verticalOhlcv[t][e]=i},null!==g?(s(g,this.len),this.inputParams=X(Q(g)),this.compute()):this.inputParams=Object.freeze([]),this}exportConfig(){return{...this.config,inputParams:Q(this.inputParams)}}_registerIndicator(e){return n(this),this.inputParams=Object.freeze([...this.inputParams,X(Q(e))]),this}getData(e={}){this.compute();const{skipNull:t=this.config.skipNull,dateFormat:i=this.config.dateFormat}=e;return a(Object.keys(C),i,"dateFormat","getData"),r(e,"options","getData"),W({main:this,skipNull:t,startIndex:0,dateFormat:i})}getLastValues(e={}){this.compute();const{dateFormat:t=this.config.dateFormat}=e;return a(Object.keys(C),t,"dateFormat","getData"),W({skipNull:!1,main:this,startIndex:this.len-1,dateFormat:t})[0]}compute(){if(this.isComputed)return this;if(this.isComputing)throw new Error("Computation is already in progress.");if(this.executionParams=Q(this.inputParams).sort((e,t)=>(e.order??0)-(t.order??0)),this.isComputed=!1,this.len>0){this.isComputing=!0;try{((e,t)=>{const{len:n,arrayTypes:o,verticalOhlcv:r,verticalOhlcvKeyNames:a,inputTypes:l,chunkProcess:c,precisionMultiplier:h,executionParams:u}=t;s(u,n);for(const{key:e}of u)if(!Object.prototype.hasOwnProperty.call(J,e))throw new Error(`Unknown indicator "${e}" in configuration.`);for(const e of Object.keys(l))r[e]=L(o[e],n);const p=Object.entries(l).map(([e,t])=>{const i=S.hasOwnProperty(t);return{key:e,formatter:i?S[t]:A.hasOwnProperty(t)?A[t]:null,numeric:i}}),m="number"==typeof h?T(h):void 0;let d=null;for(let s=0;s<n;s+=c){const o=Math.min(s+c,n);for(let n=s;n<o;n++){const s=e[n];for(const{key:e,formatter:i,numeric:o}of p){const r=s[e];if(void 0===r)continue;const a=null===i?r:o?i(r,h,m):i(r);t.pushToMain({index:n,key:e,value:a})}const o=(r.open[n]+r.close[n])/2;t.pushToMain({index:n,key:"mid_price",value:o});for(const{key:e,params:i}of u)J[e](t,n,...i);e[n]=null,null===d&&(d=Object.values(r)),i(d,n)||(t.invalidValueIndex=n)}}a.push(...Object.keys(r))})(this.input,this)}finally{this.isComputing=!1}this.isComputed=!0,this.input=[],this.instances={},this.firstRow=[]}return this}crossPairs(e=[],t={}){const i="crossPairs";n(this),o(e,"arr",i),r(t,"options",i);const{limit:s=null,oneHot:a=!1}=t;null!==s&&c(s,{min:2,max:this.len},"options.limit",i),l(a,"options.oneHot",i);const h=[];for(const{fast:t="",slow:i=""}of e){if(""===t||""===i)throw new Error(`Invalid crossPairs[${t}_${i}]: Object property “fast” must be a non-null column name and “slow” must be a non-null column name or integer.`);h.push(t.toString(),i.toString())}if(this.isAlreadyComputed.has(i))throw new Error(`You can only call the "${i}" method once.`);return this.isAlreadyComputed.add(i),this._registerIndicator({key:i,params:[e,{limit:s,oneHot:a}]}),this}lag(e=["close"],t=1){const i="lag";n(this),o(e,"colKeys",i);const s=e.find(e=>"string"!=typeof e||""===e);if(void 0!==s)throw new Error(`Invalid item "${s}" (column name) in "colKeys" array param of "${i}()".`);return c(t,{min:1,max:this.len,allowDecimals:!1},"lookback",i),this._registerIndicator({key:i,params:[e,t]}),this}relativeVolume(e=10,t={}){const i="relativeVolume";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "relativeVolume" is called the input ohlcv must contain valid volume properties.');n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",i),r(t,"options",i);const{lag:s=0,retLogs:o=!1}=t;return c(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",i),l(o,"options.retLogs",i),this._registerIndicator({key:i,order:0,params:[e,{lag:s,retLogs:o}]}),this}volumeDelta(e={}){const t="volumeDelta";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeDelta" is called the input ohlcv must contain valid volume properties.');n(this),r(e,"options",t);const{lag:i=0}=e;return c(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",t),this._registerIndicator({key:t,order:0,params:[{lag:i}]}),this}atr(e=14,t={}){const i="atr";n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",i),r(t,"options",i);const{lag:s=0,retLogs:o=!1}=t;return c(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",i),l(o,"options.retLogs",i),this._registerIndicator({key:i,order:0,params:[e,{lag:s,retLogs:o}]}),this}adx(e=14,t={}){const i="adx";n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",i),r(t,"options",i);const{lag:s=0,retLogs:o=!1}=t;return c(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",i),l(o,"options.retLogs",i),this._registerIndicator({key:i,order:0,params:[e,{lag:s,retLogs:o}]}),this}ema(e=5,t={}){const i="ema";n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",i),r(t,"options",i);const{target:s="close",lag:o=0,retLogs:a=!1}=t;return h(s,"options.target",i),c(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",i),l(a,"options.retLogs",i),this._registerIndicator({key:i,params:[i,e,{target:s,lag:o,retLogs:a}]}),this}sma(e=5,t={}){const i="sma";n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",i),r(t,"options",i);const{target:s="close",lag:o=0,retLogs:a=!1}=t;return h(s,"options.target",i),c(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",i),l(a,"options.retLogs",i),this._registerIndicator({key:i,params:[i,e,{target:s,lag:o,retLogs:a}]}),this}heikenAshi(e=null,t=null,i={}){const s="heikenAshi";n(this);const o=null===e&&null===t;!1===o&&(c(e,{min:1,max:this.len,allowDecimals:!1},"smoothLength",s),c(t,{min:1,max:this.len,allowDecimals:!1},"afterSmoothLength",s)),r(i,"options",s);const{lag:a=0,retLogs:h=!1}=i;return c(a,{min:0,max:this.len,allowDecimals:!1},"options.lag",s),l(h,"option.retLogs",s),this._registerIndicator({key:s,order:0,params:[e,t,{lag:a,noSmoothing:o,retLogs:h}]}),this}stochastic(e=14,t=3,i=3,s={}){const o="stochastic";n(this);const{len:a}=this;c(e,{min:1,max:a,allowDecimals:!1},"kPeriod",o),c(t,{min:1,max:a,allowDecimals:!1},"kSlowingPeriod",o),c(i,{min:1,max:a,allowDecimals:!1},"dPeriod",o),r(s,"options",o);const{lag:h=0,retLogs:u}=s;return c(h,{min:0,max:a,allowDecimals:!1},"options.lag",o),l(u,"retLogs",o),this._registerIndicator({key:o,params:[e,t,i,{lag:h,retLogs:u}]}),this}macd(e=12,t=26,i=9,s={}){const o="macd";n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"fast",o),c(t,{min:1,max:this.len,allowDecimals:!1},"slow",o),c(i,{min:1,max:this.len,allowDecimals:!1},"signal",o),r(s,"options",o);const{target:a="close",lag:l=0}=s;h(a,"options.target",o),c(l,{min:0,max:this.len,allowDecimals:!1},"options.lag",o);const u={instanceKey:`${e}_${t}_${i}${"close"===a?"":`_${a}`}`};return this._registerIndicator({key:o,params:[e,t,i,{target:a,lag:l,precomputed:u}]}),this}bollingerBands(e=20,t=2,i={}){const s="bollingerBands";n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",s),c(t,{min:.01,max:50,allowDecimals:!0},"stdDev",s),r(i,"options",s);const{lag:o=0,retLogs:a=!1}=i;return c(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",s),l(a,"options.retLogs",s),this._registerIndicator({key:s,params:[e,t,{lag:o,retLogs:a}]}),this}rsi(e=14,t={}){const i="rsi";n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",i),r(t,"options",i);const{target:s="close",lag:o=0,retLogs:a=!1}=t;return h(s,"options.target",i),c(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",i),l(a,"retLogs",i),this._registerIndicator({key:i,params:[e,{target:s,lag:o,retLogs:a}]}),this}mfi(e=14,t={}){const i="mfi";n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",i),r(t,"options",i);const{lag:s=0,retLogs:o=!1}=t;return c(s,{min:0,max:this.len,allowDecimals:!1},"options.lag",i),l(o,"options.retLogs",i),this._registerIndicator({key:i,params:[e,{lag:s,retLogs:o}]}),this}cmf(e=20,t={}){const i="cmf";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "cmf" is called the input ohlcv must contain valid volume properties.');n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",i),r(t,"options",i);const s=Object.keys(t).find(e=>"lag"!==e);if(s)throw new Error(`Unsupported option "${s}" in "cmf"; only "lag" is available.`);const{lag:o=0}=t;return c(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",i),this._registerIndicator({key:i,params:[e,{lag:o}]}),this}donchianChannels(e=20,t=0,i={}){const s="donchianChannels";n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"size",s),c(t,{min:0,max:this.len,allowDecimals:!1},"offset",s),r(i,"options",s);const{lag:o=0,retLogs:a=!1}=i;return c(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",s),l(a,"options.retLogs",s),this._registerIndicator({key:s,order:0,params:[e,t,{lag:o,retLogs:a}]}),this}volumeOscillator(e=5,t=10,i={}){const s="volumeOscillator";if(!this.inputTypes.hasOwnProperty("volume"))throw new Error('If "volumeOscillator" is called the input ohlcv must contain valid volume properties.');n(this),c(e,{min:1,max:this.len,allowDecimals:!1},"fastsize",s),c(t,{min:e,max:this.len,allowDecimals:!1},"slowsize",s),r(i,"options",s);const{lag:o=0,retLogs:a=!1}=i;return c(o,{min:0,max:this.len,allowDecimals:!1},"options.lag",s),l(a,"retLogs",s),this._registerIndicator({key:s,order:0,params:[e,t,{lag:o,retLogs:a}]}),this}dateTime(e={}){const t="dateTime";n(this),r(e,"options",t);const{lag:i=0,oneHot:s=!1}=e;c(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",t),l(s,"options.oneHot",t);const o=s?"one_hot_":"",a={[`${o}month`]:12,[`${o}day_of_the_month`]:31,[`${o}day_of_the_week`]:7,[`${o}hour`]:24,[`${o}minute`]:60},h={prefix:o,colKeySizes:a,colKeys:Object.keys(a)};return this._registerIndicator({key:t,order:0,params:[{lag:i,oneHot:s,precompute:h}]}),this}candleFeatures(e={}){let t="candleFeatures";n(this),r(e,"options",t);const{lag:i=0,colKeys:s=[],retLogs:a=!1}=e;return c(i,{min:0,max:this.len,allowDecimals:!1},"options.lag",t),o(s,"options.colKeys",t),l(a,"retLogs",t),this._registerIndicator({key:t,params:[{lag:i,colKeys:s,retLogs:a}]}),this}}})(),OHLCV_INDICATORS=t.default})();
|
package/index.js
CHANGED
|
@@ -389,9 +389,9 @@ export default class OHLCV_INDICATORS {
|
|
|
389
389
|
|
|
390
390
|
isAlreadyComputed(this)
|
|
391
391
|
|
|
392
|
-
const
|
|
392
|
+
const noSmoothing = smoothLength === null && afterSmoothLength === null;
|
|
393
393
|
|
|
394
|
-
if(
|
|
394
|
+
if(noSmoothing === false) {
|
|
395
395
|
validateNumber(smoothLength, {min: 1, max: this.len, allowDecimals: false}, 'smoothLength', methodName)
|
|
396
396
|
validateNumber(afterSmoothLength, {min: 1, max: this.len, allowDecimals: false}, 'afterSmoothLength', methodName)
|
|
397
397
|
}
|
|
@@ -405,7 +405,7 @@ export default class OHLCV_INDICATORS {
|
|
|
405
405
|
|
|
406
406
|
const order = 0
|
|
407
407
|
|
|
408
|
-
this._registerIndicator({key: methodName, order, params: [smoothLength, afterSmoothLength, {lag,
|
|
408
|
+
this._registerIndicator({key: methodName, order, params: [smoothLength, afterSmoothLength, {lag, noSmoothing, retLogs}]})
|
|
409
409
|
|
|
410
410
|
return this
|
|
411
411
|
}
|
|
@@ -510,6 +510,27 @@ export default class OHLCV_INDICATORS {
|
|
|
510
510
|
return this
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
+
cmf(size = 20, options = {}) {
|
|
514
|
+
const methodName = 'cmf'
|
|
515
|
+
|
|
516
|
+
if(!this.inputTypes.hasOwnProperty('volume')) {
|
|
517
|
+
throw new Error('If "cmf" is called the input ohlcv must contain valid volume properties.')
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
isAlreadyComputed(this)
|
|
521
|
+
validateNumber(size, {min: 1, max: this.len, allowDecimals: false}, 'size', methodName)
|
|
522
|
+
validateObject(options, 'options', methodName)
|
|
523
|
+
|
|
524
|
+
const unsupportedOption = Object.keys(options).find(key => key !== 'lag')
|
|
525
|
+
if (unsupportedOption) throw new Error(`Unsupported option "${unsupportedOption}" in "cmf"; only "lag" is available.`)
|
|
526
|
+
|
|
527
|
+
const {lag = 0} = options
|
|
528
|
+
validateNumber(lag, {min: 0, max: this.len, allowDecimals: false}, 'options.lag', methodName)
|
|
529
|
+
|
|
530
|
+
this._registerIndicator({key: methodName, params: [size, {lag}]})
|
|
531
|
+
return this
|
|
532
|
+
}
|
|
533
|
+
|
|
513
534
|
donchianChannels(size = 20, offset = 0, options = {}) {
|
|
514
535
|
|
|
515
536
|
const methodName = 'donchianChannels'
|
package/package.json
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.84",
|
|
4
4
|
"description": "A JavaScript library featuring optimized trading indicators for OHLCV arrays [{open, high, low, close, value}]. This library is optimized for backtesting and trading bot development.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "node test/test.js",
|
|
9
|
-
"test-benchmark": "npm test -- --benchmark --rows 20000 --repeats 9",
|
|
10
8
|
"build": "npx webpack",
|
|
11
|
-
"
|
|
9
|
+
"test": "node test/test.js"
|
|
12
10
|
},
|
|
13
11
|
"author": "https://jaimelias.com/",
|
|
14
12
|
"license": "ISC",
|
|
15
13
|
"devDependencies": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"babel-loader": "^9.1.3",
|
|
20
|
-
"dotenv": "^16.4.5",
|
|
21
|
-
"terser-webpack-plugin": "^5.3.14",
|
|
22
|
-
"webpack": "^5.93.0",
|
|
23
|
-
"webpack-cli": "^5.1.4"
|
|
14
|
+
"dotenv": "^16.6.1",
|
|
15
|
+
"webpack": "^5.111.1",
|
|
16
|
+
"webpack-cli": "^7.2.3"
|
|
24
17
|
}
|
|
25
18
|
}
|
|
@@ -2,6 +2,7 @@ import { areKeyValuesValid } from "./pushToMain.js";
|
|
|
2
2
|
import { validateInputParams } from "../utilities/validators.js";
|
|
3
3
|
import { rsi } from "../oscillators/rsi.js";
|
|
4
4
|
import { mfi } from "../oscillators/mfi.js";
|
|
5
|
+
import { cmf } from "../oscillators/cmf.js";
|
|
5
6
|
import { stochastic } from "../oscillators/stochastic.js";
|
|
6
7
|
import { movingAverages } from "../moving-averages/movingAverages.js";
|
|
7
8
|
import { heikenAshi } from "../moving-averages/heikenAshi.js";
|
|
@@ -31,6 +32,7 @@ const mainFunctions = {
|
|
|
31
32
|
heikenAshi,
|
|
32
33
|
rsi,
|
|
33
34
|
mfi,
|
|
35
|
+
cmf,
|
|
34
36
|
stochastic,
|
|
35
37
|
atr,
|
|
36
38
|
adx,
|
|
@@ -39,22 +39,4 @@ provided. This preserves existing JavaScript coercion for custom mapped
|
|
|
39
39
|
columns without adding object storage for normal numeric input. NaN and
|
|
40
40
|
Infinity remain numeric values and do not trigger this fallback. Candle
|
|
41
41
|
references are retained where the reference implementation observes mutations
|
|
42
|
-
of previously supplied objects. Private buffer layouts intentionally differ.
|
|
43
|
-
|
|
44
|
-
## Verification
|
|
45
|
-
|
|
46
|
-
`npm test` checks known core results and fixed behavior traces captured before
|
|
47
|
-
runtime optimizations, checks bounded retained storage, and exercises all
|
|
48
|
-
public indicators, precision/log modes, lags, and config replay.
|
|
49
|
-
These checks are self-contained: no third-party indicator library or test
|
|
50
|
-
oracle is installed. Preserve the trace expectations unless intentionally
|
|
51
|
-
changing the corresponding behavior.
|
|
52
|
-
|
|
53
|
-
`node test/test.js --baseline /path/to/original/index.js --benchmark` also
|
|
54
|
-
compares the full pipeline with a pre-change checkout. Benchmarks report
|
|
55
|
-
local timings and retained array slots/buffer bytes, not total heap usage or
|
|
56
|
-
performance guarantees. Results must remain exact; changing summation order,
|
|
57
|
-
warm-up, or quirks is a separate behavior change.
|
|
58
|
-
|
|
59
|
-
Adapted portions retain the upstream MIT notice in `indicator.js`, also
|
|
60
|
-
preserved in the generated distribution's license notice.
|
|
42
|
+
of previously supplied objects. Private buffer layouts intentionally differ.
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* MIT License
|
|
3
|
-
* Copyright (c) 2020 Benny Neugebauer
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
* in the Software without restriction, including without limitation the rights
|
|
8
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
* furnished to do so, subject to the following conditions:
|
|
11
|
-
*
|
|
12
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
* copies or substantial portions of the Software.
|
|
14
|
-
*
|
|
15
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
* SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
1
|
export class NotEnoughDataError extends Error {
|
|
25
2
|
constructor(message = 'Not enough data') {
|
|
26
3
|
super(message)
|
|
@@ -29,7 +6,9 @@ export class NotEnoughDataError extends Error {
|
|
|
29
6
|
}
|
|
30
7
|
|
|
31
8
|
export class Indicator {
|
|
32
|
-
|
|
9
|
+
constructor() {
|
|
10
|
+
this.result = undefined
|
|
11
|
+
}
|
|
33
12
|
|
|
34
13
|
get isStable() {
|
|
35
14
|
return this.result !== undefined
|
|
@@ -43,11 +22,14 @@ export class Indicator {
|
|
|
43
22
|
|
|
44
23
|
// Keep the public result/extrema and replacement semantics without price history.
|
|
45
24
|
export class NumberIndicator extends Indicator {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
25
|
+
constructor() {
|
|
26
|
+
super()
|
|
27
|
+
this.previousResult = undefined
|
|
28
|
+
this.highest = undefined
|
|
29
|
+
this.lowest = undefined
|
|
30
|
+
this.previousHighest = undefined
|
|
31
|
+
this.previousLowest = undefined
|
|
32
|
+
}
|
|
51
33
|
|
|
52
34
|
setResult(value, replace = false) {
|
|
53
35
|
if (replace) {
|