ohlcv-indicators 3.3.6 → 3.3.8
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.
|
@@ -2455,7 +2455,7 @@ var OHLCV_INDICATORS;
|
|
|
2455
2455
|
return function(t) {
|
|
2456
2456
|
if (Array.isArray(t)) return t;
|
|
2457
2457
|
}
|
|
2458
|
-
/* General
|
|
2458
|
+
/* General scaler: supports "minmax" and "zscore" types */ (t) || function(t, e) {
|
|
2459
2459
|
var r = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
|
|
2460
2460
|
if (null != r) {
|
|
2461
2461
|
var n, o, i, a, u = [], l = !0, c = !1;
|
|
@@ -3074,7 +3074,7 @@ var OHLCV_INDICATORS;
|
|
|
3074
3074
|
value: b
|
|
3075
3075
|
}), !0;
|
|
3076
3076
|
},
|
|
3077
|
-
|
|
3077
|
+
scaler: function(t, e, r, n, o, i, a,
|
|
3078
3078
|
// used for minmax: [validMin, validMax]
|
|
3079
3079
|
u) {
|
|
3080
3080
|
var l = t.verticalOhlcv, c = t.instances, s = t.arrayTypes, f = "".concat(o, "_").concat(r), y = "";
|
|
@@ -3095,15 +3095,15 @@ var OHLCV_INDICATORS;
|
|
|
3095
3095
|
var r = "".concat(f, "_").concat(e);
|
|
3096
3096
|
l[r] = new Float64Array(h).fill(NaN), s[r] = "Float64Array";
|
|
3097
3097
|
var n = i ? y : e;
|
|
3098
|
-
if (c.scaler.windows[n] = [], i && (t.
|
|
3099
|
-
t.
|
|
3098
|
+
if (c.scaler.windows[n] = [], i && (t.scaledGroups[y] || (t.scaledGroups[y] = []),
|
|
3099
|
+
t.scaledGroups[y].push(r)), u > 0) {
|
|
3100
3100
|
if (i) {
|
|
3101
3101
|
var o, a = Array.from({
|
|
3102
3102
|
length: u
|
|
3103
3103
|
}).map((function(t, e) {
|
|
3104
3104
|
return "".concat(r, "_lag_").concat(e + 1);
|
|
3105
3105
|
}));
|
|
3106
|
-
(o = t.
|
|
3106
|
+
(o = t.scaledGroups[y]).push.apply(o, tr(a));
|
|
3107
3107
|
}
|
|
3108
3108
|
t.lag([ r ], u);
|
|
3109
3109
|
}
|
|
@@ -3540,7 +3540,7 @@ var OHLCV_INDICATORS;
|
|
|
3540
3540
|
this.verticalOhlcvTempCols = new Set, this.utilities = {
|
|
3541
3541
|
correlation: hr
|
|
3542
3542
|
}, this.invalidValueIndex = -1, this.precision = u, this.precisionMultiplier = wr(this, this.firstRow),
|
|
3543
|
-
this.
|
|
3543
|
+
this.scaledGroups = {}, null !== f && (validateInputParams(f, this.len), this.inputParams = f,
|
|
3544
3544
|
this.compute()), this.inputParams = [], this.pushToMain = function(t) {
|
|
3545
3545
|
var e = t.index, n = t.key, o = t.value;
|
|
3546
3546
|
return function(t) {
|
|
@@ -3891,9 +3891,9 @@ var OHLCV_INDICATORS;
|
|
|
3891
3891
|
}), this;
|
|
3892
3892
|
}
|
|
3893
3893
|
}, {
|
|
3894
|
-
key: "
|
|
3894
|
+
key: "scaler",
|
|
3895
3895
|
value: function(t, e, n) {
|
|
3896
|
-
var o = "
|
|
3896
|
+
var o = "scaler";
|
|
3897
3897
|
u(this), f(t, {
|
|
3898
3898
|
min: 1,
|
|
3899
3899
|
max: this.len,
|
package/index.js
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
validateArrayOptions,
|
|
8
8
|
validateBoolean,
|
|
9
9
|
validateNumber,
|
|
10
|
-
validateArrayOfRanges
|
|
10
|
+
validateArrayOfRanges,
|
|
11
|
+
validateInputParams
|
|
11
12
|
} from './src/utilities/validators.js'
|
|
12
13
|
import { verticalToHorizontal } from './src/utilities/verticalToHorizontal.js'
|
|
13
14
|
import { pushToMain } from './src/core-functions/pushToMain.js'
|
|
@@ -58,7 +59,7 @@ export default class OHLCV_INDICATORS {
|
|
|
58
59
|
this.invalidValueIndex = -1
|
|
59
60
|
this.precision = precision
|
|
60
61
|
this.precisionMultiplier = calcPrecisionMultiplier(this, this.firstRow)
|
|
61
|
-
this.
|
|
62
|
+
this.scaledGroups = {}
|
|
62
63
|
|
|
63
64
|
if(inputParams !== null)
|
|
64
65
|
{
|
|
@@ -375,9 +376,9 @@ export default class OHLCV_INDICATORS {
|
|
|
375
376
|
return this
|
|
376
377
|
}
|
|
377
378
|
|
|
378
|
-
|
|
379
|
+
scaler(size, colKeys, options)
|
|
379
380
|
{
|
|
380
|
-
const methodName = '
|
|
381
|
+
const methodName = 'scaler'
|
|
381
382
|
|
|
382
383
|
isAlreadyComputed(this)
|
|
383
384
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.8",
|
|
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",
|
|
@@ -9,7 +9,7 @@ import { volumeOscillator } from "../oscillators/volumeOscillator.js";
|
|
|
9
9
|
import { lag } from "../studies/lag.js";
|
|
10
10
|
import { crossPairs } from "../studies/findCrosses.js";
|
|
11
11
|
import { dateTime } from "../studies/dateTime.js";
|
|
12
|
-
import {
|
|
12
|
+
import { scaler } from "../studies/scaler.js";
|
|
13
13
|
|
|
14
14
|
import { buildArray } from "../utilities/assignTypes.js";
|
|
15
15
|
import { numberFormater } from "../utilities/numberUtilities.js";
|
|
@@ -26,7 +26,7 @@ const indicatorFunctions = {
|
|
|
26
26
|
donchianChannels,
|
|
27
27
|
bollingerBands,
|
|
28
28
|
volumeOscillator,
|
|
29
|
-
|
|
29
|
+
scaler
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
|
package/src/studies/scaler.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* General
|
|
1
|
+
/* General scaler: supports "minmax" and "zscore" types */
|
|
2
2
|
|
|
3
3
|
const normalizeMinMax = (value, min, max, [validMin, validMax]) => {
|
|
4
4
|
const clamped = Math.min(Math.max(value, min), max);
|
|
@@ -9,7 +9,7 @@ const normalizeMinMax = (value, min, max, [validMin, validMax]) => {
|
|
|
9
9
|
return std === 0 ? 0 : (value - mean) / std;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const scaler = (
|
|
13
13
|
main,
|
|
14
14
|
index,
|
|
15
15
|
size,
|
|
@@ -49,14 +49,14 @@ export const Scaler = (
|
|
|
49
49
|
instances.scaler.windows[winKey] = [];
|
|
50
50
|
|
|
51
51
|
if (group) {
|
|
52
|
-
if (!main.
|
|
53
|
-
main.
|
|
52
|
+
if (!main.scaledGroups[groupKey]) main.scaledGroups[groupKey] = [];
|
|
53
|
+
main.scaledGroups[groupKey].push(key);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (lag > 0) {
|
|
57
57
|
if (group) {
|
|
58
58
|
const lags = Array.from({ length: lag }).map((_, i) => `${key}_lag_${i + 1}`);
|
|
59
|
-
main.
|
|
59
|
+
main.scaledGroups[groupKey].push(...lags);
|
|
60
60
|
}
|
|
61
61
|
main.lag([key], lag);
|
|
62
62
|
}
|