ferro-ta-wasm 1.0.2 → 1.0.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ npm install ferro-ta-wasm
11
11
  ```
12
12
 
13
13
  ```javascript
14
- const { sma, ema, rsi, bbands, atr, obv, macd } = require('ferro-ta-wasm');
14
+ const { sma, ema, wma, rsi, adx, mfi, bbands, atr, obv, macd } = require('ferro-ta-wasm');
15
15
 
16
16
  const close = new Float64Array([44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.10]);
17
17
  const smaOut = sma(close, 3);
@@ -28,20 +28,23 @@ console.log('SMA:', Array.from(smaOut));
28
28
  |------------|---------------|----------------------------------------------------|---------|
29
29
  | Overlap | `sma` | `close: Float64Array, timeperiod: number` | `Float64Array` |
30
30
  | Overlap | `ema` | `close: Float64Array, timeperiod: number` | `Float64Array` |
31
+ | Overlap | `wma` | `close: Float64Array, timeperiod: number` | `Float64Array` |
31
32
  | Overlap | `bbands` | `close, timeperiod, nbdevup, nbdevdn` | `Array[upper, middle, lower]` |
32
33
  | Momentum | `rsi` | `close: Float64Array, timeperiod: number` | `Float64Array` |
34
+ | Momentum | `adx` | `high, low, close: Float64Array, timeperiod` | `Float64Array` |
33
35
  | Momentum | `macd` | `close, fastperiod, slowperiod, signalperiod` | `Array[macd, signal, hist]` |
34
36
  | Momentum | `mom` | `close: Float64Array, timeperiod: number` | `Float64Array` |
35
37
  | Momentum | `stochf` | `high, low, close, fastk_period, fastd_period` | `Array[fastk, fastd]` |
36
38
  | Volatility | `atr` | `high, low, close: Float64Array, timeperiod` | `Float64Array` |
37
39
  | Volume | `obv` | `close: Float64Array, volume: Float64Array` | `Float64Array` |
40
+ | Volume | `mfi` | `high, low, close, volume: Float64Array, timeperiod` | `Float64Array` |
38
41
 
39
42
  ### Adding more indicators
40
43
 
41
- All implementations are self-contained in `src/lib.rs` no external crate dependency needed.
44
+ WASM exports live in `src/lib.rs` and can either implement logic directly or delegate to `ferro_ta_core`.
42
45
  To add a new indicator:
43
46
 
44
- 1. Implement the algorithm in a `#[wasm_bindgen]` function in `src/lib.rs`.
47
+ 1. Add a `#[wasm_bindgen]` export in `src/lib.rs` (prefer delegating to `ferro_ta_core` where possible).
45
48
  2. Add at least two `#[wasm_bindgen_test]` tests covering output length and a known value.
46
49
  3. Update this README table.
47
50
  4. Run `wasm-pack test --node` to verify.
@@ -79,7 +82,7 @@ wasm-pack build --target web --out-dir pkg-web
79
82
  ## Usage (Node.js)
80
83
 
81
84
  ```javascript
82
- const { sma, ema, rsi, bbands, atr, obv, macd } = require('./pkg/ferro_ta_wasm.js');
85
+ const { sma, ema, wma, rsi, adx, mfi, bbands, atr, obv, macd } = require('./pkg/ferro_ta_wasm.js');
83
86
 
84
87
  const close = new Float64Array([44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.10]);
85
88
 
@@ -91,6 +94,10 @@ console.log('SMA:', Array.from(smaOut)); // [ NaN, NaN, 44.193, ... ]
91
94
  const rsiOut = rsi(close, 5);
92
95
  console.log('RSI:', Array.from(rsiOut));
93
96
 
97
+ // WMA (period 5)
98
+ const wmaOut = wma(close, 5);
99
+ console.log('WMA:', Array.from(wmaOut));
100
+
94
101
  // Bollinger Bands (period 5, ±2σ) — returns [upper, middle, lower]
95
102
  const [upper, middle, lower] = bbands(close, 5, 2.0, 2.0);
96
103
  console.log('BBANDS upper:', Array.from(upper));
@@ -107,10 +114,18 @@ const low = new Float64Array([43.0, 44.0, 45.0, 44.0, 43.0, 42.0, 43.0]);
107
114
  const atrOut = atr(high, low, close, 3);
108
115
  console.log('ATR:', Array.from(atrOut));
109
116
 
117
+ // ADX (period 3)
118
+ const adxOut = adx(high, low, close, 3);
119
+ console.log('ADX:', Array.from(adxOut));
120
+
110
121
  // OBV
111
122
  const volume = new Float64Array([1000, 1200, 900, 1500, 800, 600, 700]);
112
123
  const obvOut = obv(close, volume);
113
124
  console.log('OBV:', Array.from(obvOut));
125
+
126
+ // MFI (period 3)
127
+ const mfiOut = mfi(high, low, close, volume, 3);
128
+ console.log('MFI:', Array.from(mfiOut));
114
129
  ```
115
130
 
116
131
  ## Usage (Browser)
@@ -150,7 +165,7 @@ from source:
150
165
 
151
166
  ## Limitations
152
167
 
153
- - Only 9 indicators are currently exposed (SMA, EMA, BBANDS, RSI, MACD, MOM, STOCHF, ATR, OBV).
168
+ - Only 12 indicators are currently exposed (SMA, EMA, WMA, BBANDS, RSI, ADX, MACD, MOM, STOCHF, ATR, OBV, MFI).
154
169
  Additional indicators will be added following the same pattern in `src/lib.rs`.
155
170
  - Large arrays (> 10M bars) may be slow due to JS↔WASM memory copies. For high-throughput
156
171
  use cases prefer the Python (PyO3) binding.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ferro-ta-wasm",
3
- "version": "1.0.2",
3
+ "version": "1.0.6",
4
4
  "description": "WebAssembly bindings for ferro-ta technical analysis indicators",
5
5
  "main": "pkg/ferro_ta_wasm.js",
6
6
  "types": "pkg/ferro_ta_wasm.d.ts",
package/pkg/README.md CHANGED
@@ -11,7 +11,7 @@ npm install ferro-ta-wasm
11
11
  ```
12
12
 
13
13
  ```javascript
14
- const { sma, ema, rsi, bbands, atr, obv, macd } = require('ferro-ta-wasm');
14
+ const { sma, ema, wma, rsi, adx, mfi, bbands, atr, obv, macd } = require('ferro-ta-wasm');
15
15
 
16
16
  const close = new Float64Array([44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.10]);
17
17
  const smaOut = sma(close, 3);
@@ -28,20 +28,23 @@ console.log('SMA:', Array.from(smaOut));
28
28
  |------------|---------------|----------------------------------------------------|---------|
29
29
  | Overlap | `sma` | `close: Float64Array, timeperiod: number` | `Float64Array` |
30
30
  | Overlap | `ema` | `close: Float64Array, timeperiod: number` | `Float64Array` |
31
+ | Overlap | `wma` | `close: Float64Array, timeperiod: number` | `Float64Array` |
31
32
  | Overlap | `bbands` | `close, timeperiod, nbdevup, nbdevdn` | `Array[upper, middle, lower]` |
32
33
  | Momentum | `rsi` | `close: Float64Array, timeperiod: number` | `Float64Array` |
34
+ | Momentum | `adx` | `high, low, close: Float64Array, timeperiod` | `Float64Array` |
33
35
  | Momentum | `macd` | `close, fastperiod, slowperiod, signalperiod` | `Array[macd, signal, hist]` |
34
36
  | Momentum | `mom` | `close: Float64Array, timeperiod: number` | `Float64Array` |
35
37
  | Momentum | `stochf` | `high, low, close, fastk_period, fastd_period` | `Array[fastk, fastd]` |
36
38
  | Volatility | `atr` | `high, low, close: Float64Array, timeperiod` | `Float64Array` |
37
39
  | Volume | `obv` | `close: Float64Array, volume: Float64Array` | `Float64Array` |
40
+ | Volume | `mfi` | `high, low, close, volume: Float64Array, timeperiod` | `Float64Array` |
38
41
 
39
42
  ### Adding more indicators
40
43
 
41
- All implementations are self-contained in `src/lib.rs` no external crate dependency needed.
44
+ WASM exports live in `src/lib.rs` and can either implement logic directly or delegate to `ferro_ta_core`.
42
45
  To add a new indicator:
43
46
 
44
- 1. Implement the algorithm in a `#[wasm_bindgen]` function in `src/lib.rs`.
47
+ 1. Add a `#[wasm_bindgen]` export in `src/lib.rs` (prefer delegating to `ferro_ta_core` where possible).
45
48
  2. Add at least two `#[wasm_bindgen_test]` tests covering output length and a known value.
46
49
  3. Update this README table.
47
50
  4. Run `wasm-pack test --node` to verify.
@@ -79,7 +82,7 @@ wasm-pack build --target web --out-dir pkg-web
79
82
  ## Usage (Node.js)
80
83
 
81
84
  ```javascript
82
- const { sma, ema, rsi, bbands, atr, obv, macd } = require('./pkg/ferro_ta_wasm.js');
85
+ const { sma, ema, wma, rsi, adx, mfi, bbands, atr, obv, macd } = require('./pkg/ferro_ta_wasm.js');
83
86
 
84
87
  const close = new Float64Array([44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.10]);
85
88
 
@@ -91,6 +94,10 @@ console.log('SMA:', Array.from(smaOut)); // [ NaN, NaN, 44.193, ... ]
91
94
  const rsiOut = rsi(close, 5);
92
95
  console.log('RSI:', Array.from(rsiOut));
93
96
 
97
+ // WMA (period 5)
98
+ const wmaOut = wma(close, 5);
99
+ console.log('WMA:', Array.from(wmaOut));
100
+
94
101
  // Bollinger Bands (period 5, ±2σ) — returns [upper, middle, lower]
95
102
  const [upper, middle, lower] = bbands(close, 5, 2.0, 2.0);
96
103
  console.log('BBANDS upper:', Array.from(upper));
@@ -107,10 +114,18 @@ const low = new Float64Array([43.0, 44.0, 45.0, 44.0, 43.0, 42.0, 43.0]);
107
114
  const atrOut = atr(high, low, close, 3);
108
115
  console.log('ATR:', Array.from(atrOut));
109
116
 
117
+ // ADX (period 3)
118
+ const adxOut = adx(high, low, close, 3);
119
+ console.log('ADX:', Array.from(adxOut));
120
+
110
121
  // OBV
111
122
  const volume = new Float64Array([1000, 1200, 900, 1500, 800, 600, 700]);
112
123
  const obvOut = obv(close, volume);
113
124
  console.log('OBV:', Array.from(obvOut));
125
+
126
+ // MFI (period 3)
127
+ const mfiOut = mfi(high, low, close, volume, 3);
128
+ console.log('MFI:', Array.from(mfiOut));
114
129
  ```
115
130
 
116
131
  ## Usage (Browser)
@@ -150,7 +165,7 @@ from source:
150
165
 
151
166
  ## Limitations
152
167
 
153
- - Only 9 indicators are currently exposed (SMA, EMA, BBANDS, RSI, MACD, MOM, STOCHF, ATR, OBV).
168
+ - Only 12 indicators are currently exposed (SMA, EMA, WMA, BBANDS, RSI, ADX, MACD, MOM, STOCHF, ATR, OBV, MFI).
154
169
  Additional indicators will be added following the same pattern in `src/lib.rs`.
155
170
  - Large arrays (> 10M bars) may be slow due to JS↔WASM memory copies. For high-throughput
156
171
  use cases prefer the Python (PyO3) binding.
@@ -1,6 +1,20 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * Average Directional Movement Index (Wilder smoothing).
6
+ *
7
+ * # Arguments
8
+ * - `high` – `Float64Array` of high prices.
9
+ * - `low` – `Float64Array` of low prices.
10
+ * - `close` – `Float64Array` of close prices.
11
+ * - `timeperiod` – look-back period (default 14, minimum 1).
12
+ *
13
+ * # Returns
14
+ * `Float64Array`; warm-up values are `NaN`.
15
+ */
16
+ export function adx(high: Float64Array, low: Float64Array, close: Float64Array, timeperiod: number): Float64Array;
17
+
4
18
  /**
5
19
  * Average True Range (Wilder smoothing, TA-Lib compatible).
6
20
  *
@@ -57,6 +71,21 @@ export function ema(close: Float64Array, timeperiod: number): Float64Array;
57
71
  */
58
72
  export function macd(close: Float64Array, fastperiod: number, slowperiod: number, signalperiod: number): Array<any>;
59
73
 
74
+ /**
75
+ * Money Flow Index.
76
+ *
77
+ * # Arguments
78
+ * - `high` – `Float64Array` of high prices.
79
+ * - `low` – `Float64Array` of low prices.
80
+ * - `close` – `Float64Array` of close prices.
81
+ * - `volume` – `Float64Array` of volume values.
82
+ * - `timeperiod` – look-back period (default 14, minimum 1).
83
+ *
84
+ * # Returns
85
+ * `Float64Array`; warm-up values are `NaN`.
86
+ */
87
+ export function mfi(high: Float64Array, low: Float64Array, close: Float64Array, volume: Float64Array, timeperiod: number): Float64Array;
88
+
60
89
  /**
61
90
  * Momentum — difference between current close and close *timeperiod* bars ago.
62
91
  *
@@ -119,3 +148,15 @@ export function sma(close: Float64Array, timeperiod: number): Float64Array;
119
148
  * A `js_sys::Array` containing two `Float64Array` elements: `[fastk, fastd]`.
120
149
  */
121
150
  export function stochf(high: Float64Array, low: Float64Array, close: Float64Array, fastk_period: number, fastd_period: number): Array<any>;
151
+
152
+ /**
153
+ * Weighted Moving Average.
154
+ *
155
+ * # Arguments
156
+ * - `close` – `Float64Array` of close prices.
157
+ * - `timeperiod` – look-back window (default 30, minimum 1).
158
+ *
159
+ * # Returns
160
+ * `Float64Array` with the first `timeperiod - 1` values set to `NaN`.
161
+ */
162
+ export function wma(close: Float64Array, timeperiod: number): Float64Array;
@@ -1,5 +1,28 @@
1
1
  /* @ts-self-types="./ferro_ta_wasm.d.ts" */
2
2
 
3
+ /**
4
+ * Average Directional Movement Index (Wilder smoothing).
5
+ *
6
+ * # Arguments
7
+ * - `high` – `Float64Array` of high prices.
8
+ * - `low` – `Float64Array` of low prices.
9
+ * - `close` – `Float64Array` of close prices.
10
+ * - `timeperiod` – look-back period (default 14, minimum 1).
11
+ *
12
+ * # Returns
13
+ * `Float64Array`; warm-up values are `NaN`.
14
+ * @param {Float64Array} high
15
+ * @param {Float64Array} low
16
+ * @param {Float64Array} close
17
+ * @param {number} timeperiod
18
+ * @returns {Float64Array}
19
+ */
20
+ function adx(high, low, close, timeperiod) {
21
+ const ret = wasm.adx(high, low, close, timeperiod);
22
+ return ret;
23
+ }
24
+ exports.adx = adx;
25
+
3
26
  /**
4
27
  * Average True Range (Wilder smoothing, TA-Lib compatible).
5
28
  *
@@ -90,6 +113,31 @@ function macd(close, fastperiod, slowperiod, signalperiod) {
90
113
  }
91
114
  exports.macd = macd;
92
115
 
116
+ /**
117
+ * Money Flow Index.
118
+ *
119
+ * # Arguments
120
+ * - `high` – `Float64Array` of high prices.
121
+ * - `low` – `Float64Array` of low prices.
122
+ * - `close` – `Float64Array` of close prices.
123
+ * - `volume` – `Float64Array` of volume values.
124
+ * - `timeperiod` – look-back period (default 14, minimum 1).
125
+ *
126
+ * # Returns
127
+ * `Float64Array`; warm-up values are `NaN`.
128
+ * @param {Float64Array} high
129
+ * @param {Float64Array} low
130
+ * @param {Float64Array} close
131
+ * @param {Float64Array} volume
132
+ * @param {number} timeperiod
133
+ * @returns {Float64Array}
134
+ */
135
+ function mfi(high, low, close, volume, timeperiod) {
136
+ const ret = wasm.mfi(high, low, close, volume, timeperiod);
137
+ return ret;
138
+ }
139
+ exports.mfi = mfi;
140
+
93
141
  /**
94
142
  * Momentum — difference between current close and close *timeperiod* bars ago.
95
143
  *
@@ -191,6 +239,25 @@ function stochf(high, low, close, fastk_period, fastd_period) {
191
239
  }
192
240
  exports.stochf = stochf;
193
241
 
242
+ /**
243
+ * Weighted Moving Average.
244
+ *
245
+ * # Arguments
246
+ * - `close` – `Float64Array` of close prices.
247
+ * - `timeperiod` – look-back window (default 30, minimum 1).
248
+ *
249
+ * # Returns
250
+ * `Float64Array` with the first `timeperiod - 1` values set to `NaN`.
251
+ * @param {Float64Array} close
252
+ * @param {number} timeperiod
253
+ * @returns {Float64Array}
254
+ */
255
+ function wma(close, timeperiod) {
256
+ const ret = wasm.wma(close, timeperiod);
257
+ return ret;
258
+ }
259
+ exports.wma = wma;
260
+
194
261
  function __wbg_get_imports() {
195
262
  const import0 = {
196
263
  __proto__: null,
Binary file
@@ -1,14 +1,17 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const adx: (a: any, b: any, c: any, d: number) => any;
4
5
  export const atr: (a: any, b: any, c: any, d: number) => any;
5
6
  export const bbands: (a: any, b: number, c: number, d: number) => any;
6
7
  export const ema: (a: any, b: number) => any;
7
8
  export const macd: (a: any, b: number, c: number, d: number) => any;
9
+ export const mfi: (a: any, b: any, c: any, d: any, e: number) => any;
8
10
  export const mom: (a: any, b: number) => any;
9
11
  export const obv: (a: any, b: any) => any;
10
12
  export const rsi: (a: any, b: number) => any;
11
13
  export const sma: (a: any, b: number) => any;
12
14
  export const stochf: (a: any, b: any, c: any, d: number, e: number) => any;
15
+ export const wma: (a: any, b: number) => any;
13
16
  export const __wbindgen_externrefs: WebAssembly.Table;
14
17
  export const __wbindgen_start: () => void;
package/pkg/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ferro_ta_wasm",
3
3
  "description": "WebAssembly bindings for ferro-ta technical analysis indicators",
4
- "version": "1.0.2",
4
+ "version": "1.0.6",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "ferro_ta_wasm_bg.wasm",