ohlcv-indicators 3.5.46 → 3.5.48
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/index.js +3 -3
- package/package.json +1 -1
- package/src/studies/findCrosses.js +11 -16
package/index.js
CHANGED
|
@@ -355,14 +355,14 @@ export default class OHLCV_INDICATORS {
|
|
|
355
355
|
return this
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
vidya(size = 14,
|
|
358
|
+
vidya(size = 14, momentum = 20, options = {}) {
|
|
359
359
|
|
|
360
360
|
const methodName = 'vidya'
|
|
361
361
|
|
|
362
362
|
isAlreadyComputed(this)
|
|
363
363
|
|
|
364
364
|
validateNumber(size, {min: 2, max: this.len, allowDecimals: false}, 'size', methodName)
|
|
365
|
-
validateNumber(
|
|
365
|
+
validateNumber(momentum, {min: 1, max: this.len, allowDecimals: false}, 'momentum', methodName)
|
|
366
366
|
validateObject(options, 'options', methodName)
|
|
367
367
|
|
|
368
368
|
const {target = 'close', lag = 0, atrLength = 200, bandDistance = 2, liquidityLookback = 20} = options
|
|
@@ -375,7 +375,7 @@ export default class OHLCV_INDICATORS {
|
|
|
375
375
|
|
|
376
376
|
const order = getOrderFromArray([target], methodName)
|
|
377
377
|
|
|
378
|
-
this.inputParams.push({key: methodName, order, params: [size,
|
|
378
|
+
this.inputParams.push({key: methodName, order, params: [size, momentum, {target, lag}]})
|
|
379
379
|
|
|
380
380
|
return this
|
|
381
381
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohlcv-indicators",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.48",
|
|
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,18 +147,7 @@ export const crossPairs = (main, index, crossPairsList, {limit, oneHot}) => {
|
|
|
147
147
|
|
|
148
148
|
const col = slow.toString()
|
|
149
149
|
verticalOhlcvTempCols.add(col)
|
|
150
|
-
|
|
151
|
-
let slowNumArrType = 'Int16Array'
|
|
152
|
-
|
|
153
|
-
if(slow === 0 || slow === 1)
|
|
154
|
-
{
|
|
155
|
-
slowNumArrType = 'Uint8Array'
|
|
156
|
-
} else if(slow >= -125 && slow <= 125)
|
|
157
|
-
{
|
|
158
|
-
slowNumArrType = 'Int8Array'
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
verticalOhlcv[col] = buildArray(slowNumArrType, len)
|
|
150
|
+
verticalOhlcv[col] = buildArray('Int16Array', len)
|
|
162
151
|
}
|
|
163
152
|
|
|
164
153
|
if(!instances.hasOwnProperty('crossPairs'))
|
|
@@ -220,15 +209,21 @@ export const crossPairs = (main, index, crossPairsList, {limit, oneHot}) => {
|
|
|
220
209
|
|
|
221
210
|
const rawValue = run.getResult()
|
|
222
211
|
|
|
223
|
-
const value = Math.max(-limit, Math.min(limit, rawValue))
|
|
212
|
+
const value = rawValue//Math.max(-limit, Math.min(limit, rawValue))
|
|
224
213
|
|
|
225
214
|
main.pushToMain({index, key: crossName, value})
|
|
226
215
|
|
|
227
216
|
if(oneHot)
|
|
228
217
|
{
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
|
|
218
|
+
// clamp _just_ for the one-hot index
|
|
219
|
+
const clamped = Math.max(-limit, Math.min(limit, rawValue));
|
|
220
|
+
const oneHotIdx = clamped + limit;
|
|
221
|
+
const oneHotSize = 2 * limit + 1;
|
|
222
|
+
main.pushToMain({
|
|
223
|
+
index,
|
|
224
|
+
key: `one_hot_${crossName}`,
|
|
225
|
+
value: oneHotEncode(oneHotIdx, oneHotSize)
|
|
226
|
+
});
|
|
232
227
|
}
|
|
233
228
|
|
|
234
229
|
}
|