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.
@@ -1,32 +1,29 @@
1
1
  export const verticalToHorizontal = (
2
- obj,
3
2
  skipNull = false,
4
- precision,
5
- precisionMultiplier,
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
- for (let i = startIndex; i < endIndex; i++) {
19
- const row = {};
20
- for (let j = 0; j < keys.length; j++) {
21
- const key = keys[j]
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
- row[key] = (precision && priceBased.includes(key)) ? value / precisionMultiplier : value
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
- result[i - startIndex] = row
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
+ }