ohlcv-indicators 3.3.4 → 3.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ohlcv-indicators.min.js +1165 -1079
- package/index.js +63 -63
- package/package.json +1 -1
- package/src/core-functions/mainLoop.js +26 -41
- package/src/moving-averages/bollingerBands.js +10 -3
- package/src/moving-averages/donchianChannel.js +11 -3
- package/src/moving-averages/macd.js +9 -2
- package/src/moving-averages/movingAverages.js +2 -1
- package/src/studies/findCrosses.js +14 -7
- package/src/studies/lag.js +8 -5
- package/src/studies/scaler.js +1 -1
- package/src/utilities/assignTypes.js +2 -2
- package/src/utilities/numberUtilities.js +1 -1
- package/src/utilities/precisionMultiplier.js +1 -1
- package/src/utilities/validators.js +27 -2
- package/src/utilities/verticalToHorizontal.js +20 -23
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
export const verticalToHorizontal = (
|
|
2
|
-
obj,
|
|
3
2
|
skipNull = false,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
priceBased,
|
|
7
|
-
invalidValueIndex = 0
|
|
3
|
+
main,
|
|
4
|
+
startIndex = 0
|
|
8
5
|
) => {
|
|
9
|
-
const keys = Object.keys(obj);
|
|
10
|
-
if (keys.length === 0) return [];
|
|
11
|
-
|
|
12
|
-
const startIndex = skipNull && invalidValueIndex >= 0 ? invalidValueIndex + 1 : 0
|
|
13
|
-
const endIndex = obj[keys[0]].length
|
|
14
|
-
const len = endIndex - startIndex
|
|
15
|
-
const result = new Array(len)
|
|
16
6
|
|
|
7
|
+
const {precisionMultiplier, priceBased, precision, verticalOhlcv, invalidValueIndex, len, verticalOhlcvKeyNames, verticalOhlcvTempCols} = main
|
|
8
|
+
|
|
9
|
+
if (verticalOhlcvKeyNames.length === 0) return []
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const value = obj[key][i]
|
|
11
|
+
const skipNullIndex = skipNull && invalidValueIndex >= 0 ? invalidValueIndex + 1 : 0
|
|
12
|
+
const maxStartIndex = Math.max(skipNullIndex, startIndex)
|
|
13
|
+
const diffLen = len - maxStartIndex
|
|
14
|
+
const result = Array.from({ length: diffLen }, () => ({}))
|
|
23
15
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
for(const [key, arr] of Object.entries(verticalOhlcv)){
|
|
17
|
+
if(verticalOhlcvTempCols.has(key)) continue
|
|
18
|
+
const shouldApplyPrecision = priceBased.has(key) && precision
|
|
27
19
|
|
|
28
|
-
|
|
20
|
+
for (let i = maxStartIndex; i < len; i++)
|
|
21
|
+
{
|
|
22
|
+
result[i - maxStartIndex][key] = (shouldApplyPrecision)
|
|
23
|
+
? arr[i] / precisionMultiplier
|
|
24
|
+
: arr[i]
|
|
25
|
+
}
|
|
29
26
|
}
|
|
30
|
-
|
|
27
|
+
|
|
31
28
|
return result
|
|
32
|
-
}
|
|
29
|
+
}
|