ohlcv-indicators 3.5.45 → 3.5.47
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 +10 -19
- package/package.json +1 -1
- package/src/core-functions/mainLoop.js +1 -8
- package/src/machine-learning/balancing.js +65 -0
- package/src/machine-learning/classifier.js +4 -3
- package/src/machine-learning/ml-utilities.js +0 -18
- package/src/machine-learning/pca.js +0 -1
- package/src/machine-learning/scaler.js +2 -3
- package/src/moving-averages/bollingerBands.js +1 -6
- package/src/moving-averages/donchianChannel.js +2 -5
- package/src/moving-averages/macd.js +1 -6
- package/src/moving-averages/movingAverages.js +1 -3
- package/src/moving-averages/relativeVolume.js +2 -3
- package/src/moving-averages/vidya.js +5 -5
- package/src/oscillators/rsi.js +2 -8
- package/src/oscillators/stochastic.js +2 -8
- package/src/oscillators/volumeOscillator.js +1 -3
- package/src/studies/dateTime.js +3 -9
- package/src/studies/findCrosses.js +12 -24
- package/src/studies/lag.js +7 -6
- package/src/studies/mapCols.js +1 -2
- package/src/utilities/assignTypes.js +9 -9
- package/src/utilities/verticalToHorizontal.js +2 -8
- package/src/volatility/atr.js +1 -2
|
@@ -25,7 +25,7 @@ export const buildArray = (arrayType, len) => {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export const assignTypes = main => {
|
|
28
|
-
const {firstRow
|
|
28
|
+
const {firstRow} = main
|
|
29
29
|
const inputTypes = {}
|
|
30
30
|
const arrayTypes = {}
|
|
31
31
|
|
|
@@ -34,13 +34,11 @@ export const assignTypes = main => {
|
|
|
34
34
|
if (colName === 'date') {
|
|
35
35
|
inputTypes[colName] = selectDateFormatter(cellValue, true)
|
|
36
36
|
arrayTypes[colName] = 'Array'
|
|
37
|
-
notNumberKeys.add(colName)
|
|
38
37
|
}
|
|
39
38
|
else if(colName === 'volume')
|
|
40
39
|
{
|
|
41
40
|
inputTypes[colName] = classifyNum(cellValue, true)
|
|
42
41
|
arrayTypes[colName] = 'Int32Array'
|
|
43
|
-
notNumberKeys.add(colName)
|
|
44
42
|
}
|
|
45
43
|
else if(numberKeys.has(colName))
|
|
46
44
|
{
|
|
@@ -50,14 +48,16 @@ export const assignTypes = main => {
|
|
|
50
48
|
const thisType = classifyNum(cellValue, false)
|
|
51
49
|
inputTypes[colName] = thisType
|
|
52
50
|
arrayTypes[colName] = (thisType === 'number') ? 'Float64Array' : 'Array'
|
|
53
|
-
|
|
54
|
-
if(!thisType.startsWith('number'))
|
|
55
|
-
{
|
|
56
|
-
notNumberKeys.add(colName)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
53
|
|
|
62
54
|
return { inputTypes, arrayTypes }
|
|
63
55
|
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export const getArrayType = (key, arr) => {
|
|
59
|
+
if (!arr || typeof arr !== 'object') {
|
|
60
|
+
throw new TypeError(`Invalid array type: "${key}"`);
|
|
61
|
+
}
|
|
62
|
+
return arr.constructor.name;
|
|
63
|
+
}
|
|
@@ -2,7 +2,7 @@ import { dateOutputFormaters } from "./dateUtilities.js"
|
|
|
2
2
|
|
|
3
3
|
export const verticalToHorizontal = ({main, skipNull = false, startIndex = 0, dateFormat}) => {
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const {verticalOhlcv, invalidValueIndex, len, verticalOhlcvKeyNames, verticalOhlcvTempCols} = main
|
|
6
6
|
|
|
7
7
|
if (verticalOhlcvKeyNames.length === 0) return []
|
|
8
8
|
|
|
@@ -13,16 +13,10 @@ export const verticalToHorizontal = ({main, skipNull = false, startIndex = 0, da
|
|
|
13
13
|
|
|
14
14
|
for(const [key, arr] of Object.entries(verticalOhlcv)){
|
|
15
15
|
if(verticalOhlcvTempCols.has(key)) continue
|
|
16
|
-
const shouldApplyPrecision = precision && !notNumberKeys.has(key)
|
|
17
16
|
|
|
18
17
|
for (let i = maxStartIndex; i < len; i++)
|
|
19
18
|
{
|
|
20
|
-
if(
|
|
21
|
-
{
|
|
22
|
-
result[i - maxStartIndex][key] = arr[i] / precisionMultiplier
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
else if(key === 'date')
|
|
19
|
+
if(key === 'date')
|
|
26
20
|
{
|
|
27
21
|
result[i - maxStartIndex][key] = dateOutputFormaters[dateFormat](arr[i])
|
|
28
22
|
}
|
package/src/volatility/atr.js
CHANGED
|
@@ -7,7 +7,7 @@ export const atr = (main, index, size, {lag, percentage, upper, lower}) => {
|
|
|
7
7
|
|
|
8
8
|
if (index === 0) {
|
|
9
9
|
|
|
10
|
-
const {instances, verticalOhlcv,
|
|
10
|
+
const {instances, verticalOhlcv, len} = main
|
|
11
11
|
|
|
12
12
|
instances[baseKeyName] = new FasterATR(size, FasterWSMA)
|
|
13
13
|
|
|
@@ -20,7 +20,6 @@ export const atr = (main, index, size, {lag, percentage, upper, lower}) => {
|
|
|
20
20
|
for(const k of keyNames)
|
|
21
21
|
{
|
|
22
22
|
verticalOhlcv[k] = new Float64Array(len).fill(NaN)
|
|
23
|
-
arrayTypes[k] = 'Float64Array'
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
if(lag > 0)
|