ohlcv-indicators 3.5.70 → 3.5.71

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.70",
3
+ "version": "3.5.71",
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",
@@ -3,14 +3,14 @@
3
3
  const isBadNumber = (v) => v == null || !Number.isFinite(v)
4
4
 
5
5
  export const priceFeatures = (main, index, {lag, colKeys, retLogs}) => {
6
- const { verticalOhlcv } = main
6
+ const { verticalOhlcv, priceBased, scaledGroups } = main
7
7
 
8
8
  const getRet = (next, prev) => (retLogs) ? Math.log(next / prev) : (next - prev) / prev
9
9
  const prefix = (retLogs) ? 'ret_log_' : 'ret_'
10
10
 
11
11
  if(index === 0) {
12
12
  const {len} = main
13
-
13
+
14
14
  const newCols = {
15
15
  [`${prefix}change`]: new Float64Array(len).fill(NaN),
16
16
  [`${prefix}mid_price_change`]: new Float64Array(len).fill(NaN),
@@ -24,15 +24,23 @@ export const priceFeatures = (main, index, {lag, colKeys, retLogs}) => {
24
24
  for(const target of colKeys) {
25
25
  if(!verticalOhlcv.hasOwnProperty(target)) {
26
26
  throw new Error(
27
- `Target property ${target} not found in verticalOhlcv for "priceFeatures".`
27
+ `Target property in "options.colKey" array "${target}" not found in verticalOhlcv for "priceFeatures".`
28
28
  );
29
29
  }
30
30
 
31
+ else if(!priceBased.has(target)) {
32
+ throw new Error(
33
+ `Target property in "options.colKey" array "${target}" not found in priceBased for "priceFeatures".`
34
+ );
35
+ }
36
+
31
37
  newCols[`${prefix}${target}`] = new Float64Array(len).fill(NaN)
32
38
  }
33
39
 
34
40
  Object.assign(verticalOhlcv, newCols)
35
41
 
42
+ scaledGroups.priceFeatures = Object.keys(newCols)
43
+
36
44
  if(lag) {
37
45
  main.lag(Object.keys(newCols), lag)
38
46
  }