ohlcv-indicators 1.5.9 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ohlcv-indicators.min.js +1 -1
- package/index.js +7 -46
- package/knn-model.json +1 -0
- package/package.json +1 -1
- package/src/utilities/parsing-utilities.js +1 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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",
|
|
@@ -66,33 +66,4 @@ export const parseOhlcvToVertical = (input, len) => {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
return verticalOhlcv
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Memory-efficient and fast normalize function with zero-division handling
|
|
73
|
-
export const normalize = values => {
|
|
74
|
-
let min = Infinity;
|
|
75
|
-
let max = -Infinity;
|
|
76
|
-
|
|
77
|
-
// Single pass to find min and max
|
|
78
|
-
for (let value of values) {
|
|
79
|
-
if (value < min) min = value;
|
|
80
|
-
if (value > max) max = value;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const range = max - min;
|
|
84
|
-
|
|
85
|
-
// If range is 0, return an array of 0s (all values are the same)
|
|
86
|
-
return {
|
|
87
|
-
normalizedDataset: range === 0 ? values.map(() => 0) : values.map(value => (value - min) / range),
|
|
88
|
-
min,
|
|
89
|
-
max
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// Memory-efficient and fast denormalize function
|
|
94
|
-
export const denormalize = (normalizedDataset, min, max) => {
|
|
95
|
-
const range = max - min;
|
|
96
|
-
// If range is 0, return the original min value (all values were the same)
|
|
97
|
-
return range === 0 ? normalizedDataset.map(() => min) : normalizedDataset.map(value => value * range + min);
|
|
98
|
-
};
|
|
69
|
+
}
|