ferro-ta-wasm 1.0.2 → 1.1.1

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.1.1",
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.