ohlcv-indicators 3.5.51 → 3.5.52
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.52",
|
|
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",
|
|
@@ -147,7 +147,7 @@ export const crossPairs = (main, index, crossPairsList) => {
|
|
|
147
147
|
|
|
148
148
|
const col = slow.toString()
|
|
149
149
|
verticalOhlcvTempCols.add(col)
|
|
150
|
-
verticalOhlcv[col] = buildArray('Int16Array', len)
|
|
150
|
+
verticalOhlcv[col] = buildArray('Int16Array', len, slow)
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
if(!instances.hasOwnProperty('crossPairs'))
|
|
@@ -164,7 +164,7 @@ export const crossPairs = (main, index, crossPairsList) => {
|
|
|
164
164
|
|
|
165
165
|
const crossArrType = 'Int16Array'
|
|
166
166
|
|
|
167
|
-
verticalOhlcv[crossName] = buildArray(crossArrType, len)
|
|
167
|
+
verticalOhlcv[crossName] = buildArray(crossArrType, len, 0)
|
|
168
168
|
|
|
169
169
|
} else if(index + 1 === len) {
|
|
170
170
|
// sanity checks
|
|
@@ -3,7 +3,7 @@ import { selectDateFormatter } from "./dateUtilities.js";
|
|
|
3
3
|
|
|
4
4
|
const numberKeys = new Set(['open', 'high', 'low', 'close'])
|
|
5
5
|
|
|
6
|
-
export const buildArray = (arrayType, len) => {
|
|
6
|
+
export const buildArray = (arrayType, len, fallbackValue) => {
|
|
7
7
|
const ctorMap = {
|
|
8
8
|
Array: Array,
|
|
9
9
|
Float64Array: Float64Array,
|
|
@@ -14,14 +14,24 @@ export const buildArray = (arrayType, len) => {
|
|
|
14
14
|
Int16Array: Int16Array,
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const Ctor = ctorMap[arrayType]
|
|
17
|
+
const Ctor = ctorMap[arrayType]
|
|
18
18
|
if (!Ctor || typeof Ctor.from !== 'function') {
|
|
19
|
-
throw new Error(`Unsupported array type: ${arrayType}`)
|
|
19
|
+
throw new Error(`Unsupported array type: ${arrayType}`)
|
|
20
20
|
}
|
|
21
21
|
// Arrays get nulls, typed-arrays get NaNs
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
let fillValue
|
|
24
|
+
|
|
25
|
+
if(typeof fallbackValue !== 'undefined')
|
|
26
|
+
{
|
|
27
|
+
fillValue = fallbackValue
|
|
28
|
+
} else {
|
|
29
|
+
fillValue = arrayType === 'Array' ? null : NaN
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
23
33
|
// Ctor.from({ length }, mapFn) works for Array *and* all TypedArrays
|
|
24
|
-
return Ctor.from({ length: len }, () => fillValue)
|
|
34
|
+
return Ctor.from({ length: len }, () => fillValue)
|
|
25
35
|
}
|
|
26
36
|
|
|
27
37
|
export const assignTypes = main => {
|