qntjs-lib 1.0.0
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/LICENSE +695 -0
- package/README.md +60 -0
- package/dist/arr/arr.d.ts +81 -0
- package/dist/bundle/index.d.ts +1573 -0
- package/dist/bundle/index.js +3169 -0
- package/dist/index.d.ts +4 -0
- package/dist/math/basic.d.ts +174 -0
- package/dist/math/index.d.ts +11 -0
- package/dist/math/linalg.d.ts +36 -0
- package/dist/math/minmax.d.ts +81 -0
- package/dist/math/prod.d.ts +20 -0
- package/dist/math/random.d.ts +22 -0
- package/dist/math/sum.d.ts +26 -0
- package/dist/stats/index.d.ts +10 -0
- package/dist/stats/mean.d.ts +53 -0
- package/dist/stats/quantile.d.ts +42 -0
- package/dist/stats/sampling.d.ts +23 -0
- package/dist/stats/skew.d.ts +26 -0
- package/dist/stats/transforms.d.ts +48 -0
- package/dist/stats/var.d.ts +42 -0
- package/dist/ta/index.d.ts +13 -0
- package/dist/ta/momentum-oscillators/ao.d.ts +11 -0
- package/dist/ta/momentum-oscillators/apo.d.ts +11 -0
- package/dist/ta/momentum-oscillators/aroon.d.ts +11 -0
- package/dist/ta/momentum-oscillators/cmo.d.ts +10 -0
- package/dist/ta/momentum-oscillators/index.d.ts +14 -0
- package/dist/ta/momentum-oscillators/kst.d.ts +29 -0
- package/dist/ta/momentum-oscillators/macd.d.ts +12 -0
- package/dist/ta/momentum-oscillators/mom.d.ts +9 -0
- package/dist/ta/momentum-oscillators/ppo.d.ts +11 -0
- package/dist/ta/momentum-oscillators/roc.d.ts +18 -0
- package/dist/ta/momentum-oscillators/rsi.d.ts +14 -0
- package/dist/ta/momentum-oscillators/stoch.d.ts +14 -0
- package/dist/ta/momentum-oscillators/stochrsi.d.ts +9 -0
- package/dist/ta/momentum-oscillators/ultosc.d.ts +17 -0
- package/dist/ta/momentum-oscillators/wpr.d.ts +12 -0
- package/dist/ta/moving-averages/dema.d.ts +10 -0
- package/dist/ta/moving-averages/ema.d.ts +10 -0
- package/dist/ta/moving-averages/hma.d.ts +10 -0
- package/dist/ta/moving-averages/index.d.ts +11 -0
- package/dist/ta/moving-averages/kama.d.ts +14 -0
- package/dist/ta/moving-averages/rma.d.ts +11 -0
- package/dist/ta/moving-averages/sma.d.ts +11 -0
- package/dist/ta/moving-averages/t3.d.ts +24 -0
- package/dist/ta/moving-averages/tema.d.ts +10 -0
- package/dist/ta/moving-averages/trima.d.ts +9 -0
- package/dist/ta/moving-averages/vwma.d.ts +17 -0
- package/dist/ta/moving-averages/wma.d.ts +11 -0
- package/dist/ta/trend/cci.d.ts +13 -0
- package/dist/ta/trend/di.d.ts +36 -0
- package/dist/ta/trend/dpo.d.ts +10 -0
- package/dist/ta/trend/ichimoku.d.ts +20 -0
- package/dist/ta/trend/index.d.ts +6 -0
- package/dist/ta/trend/psar.d.ts +10 -0
- package/dist/ta/trend/supertrend.d.ts +14 -0
- package/dist/ta/util.d.ts +53 -0
- package/dist/ta/volatility/atr.d.ts +23 -0
- package/dist/ta/volatility/bb.d.ts +11 -0
- package/dist/ta/volatility/bbw.d.ts +10 -0
- package/dist/ta/volatility/donchian.d.ts +11 -0
- package/dist/ta/volatility/index.d.ts +5 -0
- package/dist/ta/volatility/keltner.d.ts +12 -0
- package/dist/ta/volume-money-flow/ad.d.ts +12 -0
- package/dist/ta/volume-money-flow/adosc.d.ts +15 -0
- package/dist/ta/volume-money-flow/index.d.ts +6 -0
- package/dist/ta/volume-money-flow/mfi.d.ts +12 -0
- package/dist/ta/volume-money-flow/obv.d.ts +9 -0
- package/dist/ta/volume-money-flow/pnvi.d.ts +10 -0
- package/dist/ta/volume-money-flow/wad.d.ts +11 -0
- package/dist/untyped/index.d.ts +1194 -0
- package/dist/untyped/index.js +29 -0
- package/package.json +58 -0
|
@@ -0,0 +1,1573 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element-wise addition.
|
|
3
|
+
* - If `b` is a number, returns `a + b` for each element.
|
|
4
|
+
* - If `b` is an array, returns element-wise sum up to the shorter length.
|
|
5
|
+
* @param a Left operand array
|
|
6
|
+
* @param b Right operand array or scalar
|
|
7
|
+
* @returns Float64Array of sums
|
|
8
|
+
*/
|
|
9
|
+
declare function add(a: ArrayLike<number>, b: ArrayLike<number> | number): Float64Array;
|
|
10
|
+
/**
|
|
11
|
+
* Element-wise subtraction.
|
|
12
|
+
* - If `b` is a number, returns `a - b` for each element.
|
|
13
|
+
* - If `b` is an array, returns element-wise difference up to the shorter length.
|
|
14
|
+
* @param a Left operand array
|
|
15
|
+
* @param b Right operand array or scalar
|
|
16
|
+
* @returns Float64Array of differences
|
|
17
|
+
*/
|
|
18
|
+
declare function sub(a: ArrayLike<number>, b: ArrayLike<number> | number): Float64Array;
|
|
19
|
+
/**
|
|
20
|
+
* Element-wise multiplication.
|
|
21
|
+
* - If `b` is a number, scales each element of `a` by `b`.
|
|
22
|
+
* - If `b` is an array, returns element-wise products up to the shorter length.
|
|
23
|
+
* @param a Left operand array
|
|
24
|
+
* @param b Right operand array or scalar
|
|
25
|
+
* @returns Float64Array of products
|
|
26
|
+
*/
|
|
27
|
+
declare function mul(a: ArrayLike<number>, b: ArrayLike<number> | number): Float64Array;
|
|
28
|
+
/**
|
|
29
|
+
* Element-wise division.
|
|
30
|
+
* - If `b` is a number, divides each element of `a` by `b`.
|
|
31
|
+
* - If `b` is an array, returns element-wise quotients up to the shorter length.
|
|
32
|
+
* @param a Numerator array
|
|
33
|
+
* @param b Denominator array or scalar
|
|
34
|
+
* @returns Float64Array of quotients
|
|
35
|
+
*/
|
|
36
|
+
declare function div(a: ArrayLike<number>, b: ArrayLike<number> | number): Float64Array;
|
|
37
|
+
/**
|
|
38
|
+
* Element-wise average: (a + b) / 2.
|
|
39
|
+
* Computes the average without allocating temporaries.
|
|
40
|
+
* @param a First array
|
|
41
|
+
* @param b Second array or scalar
|
|
42
|
+
* @returns Float64Array of averages
|
|
43
|
+
*/
|
|
44
|
+
declare function avg(a: ArrayLike<number>, b: ArrayLike<number> | number): Float64Array;
|
|
45
|
+
/**
|
|
46
|
+
* Scale an array by a scalar: `source * s`.
|
|
47
|
+
* @param source Input array
|
|
48
|
+
* @param s Scale factor
|
|
49
|
+
* @returns Float64Array scaled values
|
|
50
|
+
*/
|
|
51
|
+
declare function scale(source: ArrayLike<number>, s: number): Float64Array;
|
|
52
|
+
/**
|
|
53
|
+
* Clamp values to the inclusive range [lo, hi]. Preserves NaN entries.
|
|
54
|
+
* @param source Input array
|
|
55
|
+
* @param lo Lower bound
|
|
56
|
+
* @param hi Upper bound
|
|
57
|
+
* @returns Float64Array with values clamped or NaN preserved
|
|
58
|
+
*/
|
|
59
|
+
declare function clamp(source: ArrayLike<number>, lo: number, hi: number): Float64Array;
|
|
60
|
+
/**
|
|
61
|
+
* Element-wise absolute value.
|
|
62
|
+
* @param source Input array
|
|
63
|
+
* @returns Float64Array of absolute values
|
|
64
|
+
*/
|
|
65
|
+
declare function abs(source: ArrayLike<number>): Float64Array;
|
|
66
|
+
/**
|
|
67
|
+
* Element-wise sign (-1, 0, 1) for each entry.
|
|
68
|
+
* @param source Input array
|
|
69
|
+
* @returns Float64Array of sign values
|
|
70
|
+
*/
|
|
71
|
+
declare function sign(source: ArrayLike<number>): Float64Array;
|
|
72
|
+
/**
|
|
73
|
+
* Round values to nearest integer. Ties are rounded away from zero.
|
|
74
|
+
* @param source Input array
|
|
75
|
+
* @returns Float64Array of rounded integers
|
|
76
|
+
*/
|
|
77
|
+
declare function round(source: ArrayLike<number>): Float64Array;
|
|
78
|
+
/**
|
|
79
|
+
* Element-wise floor operation.
|
|
80
|
+
* @param source Input array
|
|
81
|
+
* @returns Float64Array of floored values
|
|
82
|
+
*/
|
|
83
|
+
declare function floor(source: ArrayLike<number>): Float64Array;
|
|
84
|
+
/**
|
|
85
|
+
* Element-wise ceil operation.
|
|
86
|
+
* @param source Input array
|
|
87
|
+
* @returns Float64Array of ceiled values
|
|
88
|
+
*/
|
|
89
|
+
declare function ceil(source: ArrayLike<number>): Float64Array;
|
|
90
|
+
/**
|
|
91
|
+
* First difference: output[i] = source[i] - source[i-1].
|
|
92
|
+
* The first element is NaN (no previous value).
|
|
93
|
+
* @param source Input array
|
|
94
|
+
* @returns Float64Array of differences (first element NaN)
|
|
95
|
+
*/
|
|
96
|
+
declare function diff(source: ArrayLike<number>): Float64Array;
|
|
97
|
+
/**
|
|
98
|
+
* Element-wise less-than comparison. Returns `Uint8Array` mask with 1 where true.
|
|
99
|
+
* @param a Left operand
|
|
100
|
+
* @param b Right operand or scalar
|
|
101
|
+
* @returns Uint8Array mask of comparisons
|
|
102
|
+
*/
|
|
103
|
+
declare function lt(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
|
|
104
|
+
/**
|
|
105
|
+
* Element-wise less-than-or-equal comparison (with epsilon tolerance).
|
|
106
|
+
* @param a Left operand
|
|
107
|
+
* @param b Right operand or scalar
|
|
108
|
+
* @returns Uint8Array mask of comparisons
|
|
109
|
+
*/
|
|
110
|
+
declare function lte(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
|
|
111
|
+
/**
|
|
112
|
+
* Element-wise greater-than comparison. Returns `Uint8Array` mask with 1 where true.
|
|
113
|
+
* @param a Left operand
|
|
114
|
+
* @param b Right operand or scalar
|
|
115
|
+
* @returns Uint8Array mask of comparisons
|
|
116
|
+
*/
|
|
117
|
+
declare function gt(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
|
|
118
|
+
/**
|
|
119
|
+
* Element-wise greater-than-or-equal comparison (with epsilon tolerance).
|
|
120
|
+
* @param a Left operand
|
|
121
|
+
* @param b Right operand or scalar
|
|
122
|
+
* @returns Uint8Array mask of comparisons
|
|
123
|
+
*/
|
|
124
|
+
declare function gte(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
|
|
125
|
+
/**
|
|
126
|
+
* Element-wise equality comparison using `Number.EPSILON` tolerance.
|
|
127
|
+
* @param a Left operand
|
|
128
|
+
* @param b Right operand or scalar
|
|
129
|
+
* @returns Uint8Array mask of equality tests
|
|
130
|
+
*/
|
|
131
|
+
declare function eq(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
|
|
132
|
+
/**
|
|
133
|
+
* Element-wise inequality comparison.
|
|
134
|
+
* @param a Left operand
|
|
135
|
+
* @param b Right operand or scalar
|
|
136
|
+
* @returns Uint8Array mask where elements are not equal
|
|
137
|
+
*/
|
|
138
|
+
declare function neq(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
|
|
139
|
+
/**
|
|
140
|
+
* Logical AND for boolean masks (Uint8Array) or with a scalar.
|
|
141
|
+
* Returns a Uint8Array of 1/0 values.
|
|
142
|
+
* @param a Left boolean mask
|
|
143
|
+
* @param b Right boolean mask or scalar
|
|
144
|
+
* @returns Uint8Array mask result
|
|
145
|
+
*/
|
|
146
|
+
declare function and(a: Uint8Array, b: Uint8Array | number): Uint8Array;
|
|
147
|
+
/**
|
|
148
|
+
* Logical OR for boolean masks (Uint8Array) or with a scalar.
|
|
149
|
+
* Returns a Uint8Array of 1/0 values.
|
|
150
|
+
* @param a Left boolean mask
|
|
151
|
+
* @param b Right boolean mask or scalar
|
|
152
|
+
* @returns Uint8Array mask result
|
|
153
|
+
*/
|
|
154
|
+
declare function or(a: Uint8Array, b: Uint8Array | number): Uint8Array;
|
|
155
|
+
/**
|
|
156
|
+
* Logical NOT for a boolean mask (Uint8Array).
|
|
157
|
+
* @param a Input boolean mask
|
|
158
|
+
* @returns Uint8Array mask with bits inverted
|
|
159
|
+
*/
|
|
160
|
+
declare function not(a: Uint8Array): Uint8Array;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Product of array elements, ignoring NaNs. Returns NaN if no valid entries.
|
|
164
|
+
* @param source Input array
|
|
165
|
+
* @returns Product of values or NaN
|
|
166
|
+
*/
|
|
167
|
+
declare function prod(source: ArrayLike<number>): number;
|
|
168
|
+
/**
|
|
169
|
+
* Cumulative product (NaN-preserving). At each index the product of all prior valid elements.
|
|
170
|
+
* @param source Input array
|
|
171
|
+
* @returns Float64Array of cumulative products (NaN where input was NaN)
|
|
172
|
+
*/
|
|
173
|
+
declare function cumprod(source: ArrayLike<number>): Float64Array;
|
|
174
|
+
/**
|
|
175
|
+
* Rolling product over a window. NaN-aware: windows with no valid entries produce NaN.
|
|
176
|
+
* Zeros are handled efficiently by tracking counts.
|
|
177
|
+
* @param source Input array
|
|
178
|
+
* @param period Window length (must be > 0)
|
|
179
|
+
* @returns Float64Array of rolling products (NaN for positions before window fills)
|
|
180
|
+
*/
|
|
181
|
+
declare function rollprod(source: ArrayLike<number>, period: number): Float64Array;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Sum of array elements with optional NaN-skipping.
|
|
185
|
+
* When `skipna` is true (default) NaNs are ignored; returns NaN if no valid samples.
|
|
186
|
+
* Uses a fast dense path when global optimization allows it.
|
|
187
|
+
* @param source Input array
|
|
188
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
189
|
+
* @returns Sum or NaN
|
|
190
|
+
*/
|
|
191
|
+
declare function sum(source: ArrayLike<number>, skipna?: boolean): number;
|
|
192
|
+
/**
|
|
193
|
+
* Cumulative sum preserving NaNs: NaN entries do not increase the running sum
|
|
194
|
+
* but are represented as the running total up to that point.
|
|
195
|
+
* @param source Input array
|
|
196
|
+
* @returns Float64Array of cumulative sums
|
|
197
|
+
*/
|
|
198
|
+
declare function cumsum(source: ArrayLike<number>): Float64Array;
|
|
199
|
+
/**
|
|
200
|
+
* Rolling sum over a window with optional NaN-skipping.
|
|
201
|
+
* If `skipna` is true, windows with no valid values produce NaN.
|
|
202
|
+
* Supports a fast dense path when inputs contain no NaNs.
|
|
203
|
+
* @param source Input array
|
|
204
|
+
* @param period Window length (must be > 0)
|
|
205
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
206
|
+
* @returns Float64Array of rolling sums (NaN for positions before window fills)
|
|
207
|
+
*/
|
|
208
|
+
declare function rollsum(source: ArrayLike<number>, period: number, skipna?: boolean): Float64Array;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Rolling minimum over a window. NaN-aware: windows containing only NaNs produce NaN.
|
|
212
|
+
* @param source Input values
|
|
213
|
+
* @param period Window length (must be > 0)
|
|
214
|
+
* @returns Float64Array of rolling minima (NaN for positions before the window fills)
|
|
215
|
+
*/
|
|
216
|
+
declare function rollmin(source: ArrayLike<number>, period: number): Float64Array;
|
|
217
|
+
/**
|
|
218
|
+
* Rolling maximum over a window. NaN-aware: windows containing only NaNs produce NaN.
|
|
219
|
+
* @param source Input values
|
|
220
|
+
* @param period Window length (must be > 0)
|
|
221
|
+
* @returns Float64Array of rolling maxima (NaN for positions before the window fills)
|
|
222
|
+
*/
|
|
223
|
+
declare function rollmax(source: ArrayLike<number>, period: number): Float64Array;
|
|
224
|
+
/**
|
|
225
|
+
* Compute rolling minima and maxima pairwise over two input series.
|
|
226
|
+
* Optional callback `cb(minVal, maxVal, i)` is invoked for each computed window.
|
|
227
|
+
* @param minSource Input for minima
|
|
228
|
+
* @param maxSource Input for maxima
|
|
229
|
+
* @param period Window length (must be > 0)
|
|
230
|
+
* @param cb Optional callback invoked per window
|
|
231
|
+
* @returns Object with `min` and `max` Float64Array results
|
|
232
|
+
*/
|
|
233
|
+
declare function rollminmax(minSource: ArrayLike<number>, maxSource: ArrayLike<number>, period: number, cb?: (minVal: number, maxVal: number, i: number) => void): {
|
|
234
|
+
min: Float64Array;
|
|
235
|
+
max: Float64Array;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Minimum of an array, ignoring NaNs. Returns NaN if no valid entries.
|
|
239
|
+
* @param source Input array
|
|
240
|
+
* @returns Minimum value or NaN
|
|
241
|
+
*/
|
|
242
|
+
declare function min(source: ArrayLike<number>): number;
|
|
243
|
+
/**
|
|
244
|
+
* Maximum of an array, ignoring NaNs. Returns NaN if no valid entries.
|
|
245
|
+
* @param source Input array
|
|
246
|
+
* @returns Maximum value or NaN
|
|
247
|
+
*/
|
|
248
|
+
declare function max(source: ArrayLike<number>): number;
|
|
249
|
+
/**
|
|
250
|
+
* Index of the first minimum value (ignores NaNs). Returns -1 if none found.
|
|
251
|
+
* @param source Input array
|
|
252
|
+
* @returns Index of minimum or -1
|
|
253
|
+
*/
|
|
254
|
+
declare function argmin(source: ArrayLike<number>): number;
|
|
255
|
+
/**
|
|
256
|
+
* Index of the first maximum value (ignores NaNs). Returns -1 if none found.
|
|
257
|
+
* @param source Input array
|
|
258
|
+
* @returns Index of maximum or -1
|
|
259
|
+
*/
|
|
260
|
+
declare function argmax(source: ArrayLike<number>): number;
|
|
261
|
+
/**
|
|
262
|
+
* Cumulative maximum: at each index the maximum over all prior valid elements.
|
|
263
|
+
* NaNs are preserved in the output at positions where input is NaN.
|
|
264
|
+
* @param source Input array
|
|
265
|
+
* @returns Float64Array of cumulative maxima
|
|
266
|
+
*/
|
|
267
|
+
declare function cummax(source: ArrayLike<number>): Float64Array;
|
|
268
|
+
/**
|
|
269
|
+
* Cumulative minimum: at each index the minimum over all prior valid elements.
|
|
270
|
+
* NaNs are preserved in the output at positions where input is NaN.
|
|
271
|
+
* @param source Input array
|
|
272
|
+
* @returns Float64Array of cumulative minima
|
|
273
|
+
*/
|
|
274
|
+
declare function cummin(source: ArrayLike<number>): Float64Array;
|
|
275
|
+
/**
|
|
276
|
+
* Rolling argmin: returns the index (into `source`) of the minimum value in each window.
|
|
277
|
+
* Positions before the window fills are NaN.
|
|
278
|
+
* @param source Input array
|
|
279
|
+
* @param period Window length
|
|
280
|
+
* @returns Float64Array of argmin indices (NaN when not available)
|
|
281
|
+
*/
|
|
282
|
+
declare function rollargmin(source: ArrayLike<number>, period: number): Float64Array;
|
|
283
|
+
/**
|
|
284
|
+
* Rolling argmax: returns the index (into `source`) of the maximum value in each window.
|
|
285
|
+
* Positions before the window fills are NaN.
|
|
286
|
+
* @param source Input array
|
|
287
|
+
* @param period Window length
|
|
288
|
+
* @returns Float64Array of argmax indices (NaN when not available)
|
|
289
|
+
*/
|
|
290
|
+
declare function rollargmax(source: ArrayLike<number>, period: number): Float64Array;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Generate `n` uniform random values in [lo, hi).
|
|
294
|
+
* Uses `Math.random()`; tests should stub `Math.random` for determinism.
|
|
295
|
+
* @param n Number of samples to generate
|
|
296
|
+
* @param options Optional `{ lo, hi }` bounds (defaults to 0..1)
|
|
297
|
+
* @returns Float64Array of length `n`
|
|
298
|
+
*/
|
|
299
|
+
declare function randuniform(n: number, options?: {
|
|
300
|
+
lo?: number;
|
|
301
|
+
hi?: number;
|
|
302
|
+
}): Float64Array;
|
|
303
|
+
/**
|
|
304
|
+
* Generate `n` standard normal samples using the Box-Muller transform.
|
|
305
|
+
* Uses `Math.random()`; tests should stub `Math.random` for determinism.
|
|
306
|
+
* @param n Number of samples to generate
|
|
307
|
+
* @param options Optional `{ mean, sd }` to shift/scale samples
|
|
308
|
+
* @returns Float64Array of length `n`
|
|
309
|
+
*/
|
|
310
|
+
declare function randnormal(n: number, options?: {
|
|
311
|
+
mean?: number;
|
|
312
|
+
sd?: number;
|
|
313
|
+
}): Float64Array;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Dot product of two vectors: sum_i x[i] * y[i].
|
|
317
|
+
* Operates up to the shorter length of the inputs.
|
|
318
|
+
* @param x First vector
|
|
319
|
+
* @param y Second vector
|
|
320
|
+
* @returns Scalar dot product
|
|
321
|
+
*/
|
|
322
|
+
declare function dot(x: ArrayLike<number>, y: ArrayLike<number>): number;
|
|
323
|
+
/**
|
|
324
|
+
* Vector p-norm. Supports common p values (1, 2, Infinity) with a fast dense path.
|
|
325
|
+
* When `skipna` is true the implementation ignores NaNs and returns NaN if no valid entries exist.
|
|
326
|
+
* @param x Input vector
|
|
327
|
+
* @param p Norm order (default 2)
|
|
328
|
+
* @param skipna Whether to ignore NaNs (default true)
|
|
329
|
+
* @returns Norm value or NaN
|
|
330
|
+
*/
|
|
331
|
+
declare function norm(x: ArrayLike<number>, p?: number, skipna?: boolean): number;
|
|
332
|
+
/**
|
|
333
|
+
* Ordinary least squares for a simple linear model y = intercept + slope * x.
|
|
334
|
+
* Ignores paired NaN entries and returns NaN coefficients if no valid pairs or singular design.
|
|
335
|
+
* @param x Predictor values
|
|
336
|
+
* @param y Response values
|
|
337
|
+
* @returns Object with `intercept` and `slope` or NaNs on failure
|
|
338
|
+
*/
|
|
339
|
+
declare function ols(x: ArrayLike<number>, y: ArrayLike<number>): {
|
|
340
|
+
intercept: number;
|
|
341
|
+
slope: number;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Multiple linear regression using normal equations (adds intercept column internally).
|
|
345
|
+
* Returns coefficient vector or null if the normal matrix is singular or inputs are empty.
|
|
346
|
+
* @param X Design matrix (rows = observations, cols = features)
|
|
347
|
+
* @param y Response vector
|
|
348
|
+
* @returns Coefficient array [intercept, beta1, beta2, ...] or null
|
|
349
|
+
*/
|
|
350
|
+
declare function olsMulti(X: number[][], y: number[]): number[] | null;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Barrel exports for math helpers. Re-exports individual functions from
|
|
354
|
+
* the `src/math` submodules for convenient imports.
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
declare const index_d$2_abs: typeof abs;
|
|
358
|
+
declare const index_d$2_add: typeof add;
|
|
359
|
+
declare const index_d$2_and: typeof and;
|
|
360
|
+
declare const index_d$2_argmax: typeof argmax;
|
|
361
|
+
declare const index_d$2_argmin: typeof argmin;
|
|
362
|
+
declare const index_d$2_avg: typeof avg;
|
|
363
|
+
declare const index_d$2_ceil: typeof ceil;
|
|
364
|
+
declare const index_d$2_clamp: typeof clamp;
|
|
365
|
+
declare const index_d$2_cummax: typeof cummax;
|
|
366
|
+
declare const index_d$2_cummin: typeof cummin;
|
|
367
|
+
declare const index_d$2_cumprod: typeof cumprod;
|
|
368
|
+
declare const index_d$2_cumsum: typeof cumsum;
|
|
369
|
+
declare const index_d$2_diff: typeof diff;
|
|
370
|
+
declare const index_d$2_div: typeof div;
|
|
371
|
+
declare const index_d$2_dot: typeof dot;
|
|
372
|
+
declare const index_d$2_eq: typeof eq;
|
|
373
|
+
declare const index_d$2_floor: typeof floor;
|
|
374
|
+
declare const index_d$2_gt: typeof gt;
|
|
375
|
+
declare const index_d$2_gte: typeof gte;
|
|
376
|
+
declare const index_d$2_lt: typeof lt;
|
|
377
|
+
declare const index_d$2_lte: typeof lte;
|
|
378
|
+
declare const index_d$2_max: typeof max;
|
|
379
|
+
declare const index_d$2_min: typeof min;
|
|
380
|
+
declare const index_d$2_mul: typeof mul;
|
|
381
|
+
declare const index_d$2_neq: typeof neq;
|
|
382
|
+
declare const index_d$2_norm: typeof norm;
|
|
383
|
+
declare const index_d$2_not: typeof not;
|
|
384
|
+
declare const index_d$2_ols: typeof ols;
|
|
385
|
+
declare const index_d$2_olsMulti: typeof olsMulti;
|
|
386
|
+
declare const index_d$2_or: typeof or;
|
|
387
|
+
declare const index_d$2_prod: typeof prod;
|
|
388
|
+
declare const index_d$2_randnormal: typeof randnormal;
|
|
389
|
+
declare const index_d$2_randuniform: typeof randuniform;
|
|
390
|
+
declare const index_d$2_rollargmax: typeof rollargmax;
|
|
391
|
+
declare const index_d$2_rollargmin: typeof rollargmin;
|
|
392
|
+
declare const index_d$2_rollmax: typeof rollmax;
|
|
393
|
+
declare const index_d$2_rollmin: typeof rollmin;
|
|
394
|
+
declare const index_d$2_rollminmax: typeof rollminmax;
|
|
395
|
+
declare const index_d$2_rollprod: typeof rollprod;
|
|
396
|
+
declare const index_d$2_rollsum: typeof rollsum;
|
|
397
|
+
declare const index_d$2_round: typeof round;
|
|
398
|
+
declare const index_d$2_scale: typeof scale;
|
|
399
|
+
declare const index_d$2_sign: typeof sign;
|
|
400
|
+
declare const index_d$2_sub: typeof sub;
|
|
401
|
+
declare const index_d$2_sum: typeof sum;
|
|
402
|
+
declare namespace index_d$2 {
|
|
403
|
+
export {
|
|
404
|
+
index_d$2_abs as abs,
|
|
405
|
+
index_d$2_add as add,
|
|
406
|
+
index_d$2_and as and,
|
|
407
|
+
index_d$2_argmax as argmax,
|
|
408
|
+
index_d$2_argmin as argmin,
|
|
409
|
+
index_d$2_avg as avg,
|
|
410
|
+
index_d$2_ceil as ceil,
|
|
411
|
+
index_d$2_clamp as clamp,
|
|
412
|
+
index_d$2_cummax as cummax,
|
|
413
|
+
index_d$2_cummin as cummin,
|
|
414
|
+
index_d$2_cumprod as cumprod,
|
|
415
|
+
index_d$2_cumsum as cumsum,
|
|
416
|
+
index_d$2_diff as diff,
|
|
417
|
+
index_d$2_div as div,
|
|
418
|
+
index_d$2_dot as dot,
|
|
419
|
+
index_d$2_eq as eq,
|
|
420
|
+
index_d$2_floor as floor,
|
|
421
|
+
index_d$2_gt as gt,
|
|
422
|
+
index_d$2_gte as gte,
|
|
423
|
+
index_d$2_lt as lt,
|
|
424
|
+
index_d$2_lte as lte,
|
|
425
|
+
index_d$2_max as max,
|
|
426
|
+
index_d$2_min as min,
|
|
427
|
+
index_d$2_mul as mul,
|
|
428
|
+
index_d$2_neq as neq,
|
|
429
|
+
index_d$2_norm as norm,
|
|
430
|
+
index_d$2_not as not,
|
|
431
|
+
index_d$2_ols as ols,
|
|
432
|
+
index_d$2_olsMulti as olsMulti,
|
|
433
|
+
index_d$2_or as or,
|
|
434
|
+
index_d$2_prod as prod,
|
|
435
|
+
index_d$2_randnormal as randnormal,
|
|
436
|
+
index_d$2_randuniform as randuniform,
|
|
437
|
+
index_d$2_rollargmax as rollargmax,
|
|
438
|
+
index_d$2_rollargmin as rollargmin,
|
|
439
|
+
index_d$2_rollmax as rollmax,
|
|
440
|
+
index_d$2_rollmin as rollmin,
|
|
441
|
+
index_d$2_rollminmax as rollminmax,
|
|
442
|
+
index_d$2_rollprod as rollprod,
|
|
443
|
+
index_d$2_rollsum as rollsum,
|
|
444
|
+
index_d$2_round as round,
|
|
445
|
+
index_d$2_scale as scale,
|
|
446
|
+
index_d$2_sign as sign,
|
|
447
|
+
index_d$2_sub as sub,
|
|
448
|
+
index_d$2_sum as sum,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Simple Moving Average (SMA).
|
|
454
|
+
* Computes the arithmetic mean over a sliding window.
|
|
455
|
+
* When `skipna` is true, NaNs inside the window are ignored; when false
|
|
456
|
+
* a dense fast-path is used (assumes no NaNs).
|
|
457
|
+
* @param source Input series
|
|
458
|
+
* @param period Window length (must be > 0)
|
|
459
|
+
* @param skipna Whether to ignore NaNs inside windows (default: true)
|
|
460
|
+
* @returns Float64Array of SMA values (NaN before window fills)
|
|
461
|
+
*/
|
|
462
|
+
declare function sma(source: ArrayLike<number>, period: number, skipna?: boolean): Float64Array;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Exponential Moving Average (EMA).
|
|
466
|
+
* Seeds on the first non-NaN value and uses the standard EMA recurrence.
|
|
467
|
+
* Preserves NaN gaps in the input: outputs are NaN until enough valid samples
|
|
468
|
+
* have been seen to initialize the EMA.
|
|
469
|
+
* @param source Input series
|
|
470
|
+
* @param period Smoothing period (must be > 0)
|
|
471
|
+
* @returns Float64Array of EMA values (NaN where undefined)
|
|
472
|
+
*/
|
|
473
|
+
declare function ema(source: ArrayLike<number>, period: number): Float64Array;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Weighted Moving Average (WMA).
|
|
477
|
+
* Computes a linearly-weighted average over a sliding window with weights
|
|
478
|
+
* 1..period (oldest..newest). When `skipna` is true NaNs are ignored
|
|
479
|
+
* within the window; when false a dense fast-path is used.
|
|
480
|
+
* @param source Input series
|
|
481
|
+
* @param period Window length (must be > 0)
|
|
482
|
+
* @param skipna Whether to ignore NaNs inside windows (default: true)
|
|
483
|
+
* @returns Float64Array of WMA values (NaN before window fills)
|
|
484
|
+
*/
|
|
485
|
+
declare function wma(source: ArrayLike<number>, period: number, skipna?: boolean): Float64Array;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Volume Weighted Moving Average (VWMA).
|
|
489
|
+
* Computes pvSum / vSum over a sliding window, NaN-aware. When `skipna` is
|
|
490
|
+
* true NaNs in either series are ignored within the window; when false a
|
|
491
|
+
* dense fast-path is used (assumes no NaNs).
|
|
492
|
+
* @param price Price series
|
|
493
|
+
* @param volume Volume series
|
|
494
|
+
* @param period Window length (>0)
|
|
495
|
+
* @param skipna Whether to ignore NaNs inside windows (default: true)
|
|
496
|
+
* @returns Float64Array of VWMA values (NaN before window fills)
|
|
497
|
+
*/
|
|
498
|
+
declare function vwma(price: ArrayLike<number>, volume: ArrayLike<number>, period: number, skipna?: boolean): Float64Array;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Double Exponential Moving Average (DEMA).
|
|
502
|
+
* DEMA reduces lag by combining a single EMA and a double-smoothed EMA:
|
|
503
|
+
* DEMA = 2 * EMA(source, period) - EMA(EMA(source, period), period).
|
|
504
|
+
* Preserves NaN gaps and follows the same seeding semantics as `ema`.
|
|
505
|
+
* @param source Input series
|
|
506
|
+
* @param period Smoothing period (must be > 0)
|
|
507
|
+
* @returns Float64Array of DEMA values (NaN where undefined)
|
|
508
|
+
*/
|
|
509
|
+
declare function dema(source: ArrayLike<number>, period: number): Float64Array;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Triangular Moving Average (TRIMA).
|
|
513
|
+
* A triangular-weighted moving average implemented via two `sma` passes.
|
|
514
|
+
* Preserves NaN handling by delegating to `sma` implementations.
|
|
515
|
+
* @param source Input series
|
|
516
|
+
* @param period Window length (must be > 0)
|
|
517
|
+
* @returns Float64Array of TRIMA values (NaN where undefined)
|
|
518
|
+
*/
|
|
519
|
+
declare function trima(source: ArrayLike<number>, period: number): Float64Array;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Triple Exponential Moving Average (TEMA).
|
|
523
|
+
* Combines three nested EMAs to reduce lag while smoothing:
|
|
524
|
+
* TEMA = 3*EMA1 - 3*EMA2 + EMA3. Preserves NaN gaps and seeds
|
|
525
|
+
* each EMA before emitting values.
|
|
526
|
+
* @param source Input series
|
|
527
|
+
* @param period Smoothing period (must be > 0)
|
|
528
|
+
* @returns Float64Array of TEMA values (NaN where undefined)
|
|
529
|
+
*/
|
|
530
|
+
declare function tema(source: ArrayLike<number>, period: number): Float64Array;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Hull Moving Average (HMA).
|
|
534
|
+
* Computes a lower-lag smoothing by combining WMAs at different lengths
|
|
535
|
+
* and then applying a final WMA on the derived series. Pine-compatible
|
|
536
|
+
* and NaN-aware: NaNs propagate where insufficient valid samples exist.
|
|
537
|
+
* @param source Input series
|
|
538
|
+
* @param period Window length (must be > 0)
|
|
539
|
+
* @returns Float64Array of HMA values (NaN where undefined)
|
|
540
|
+
*/
|
|
541
|
+
declare function hma(source: ArrayLike<number>, period: number): Float64Array;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Kaufman Adaptive Moving Average (KAMA).
|
|
545
|
+
* Adapts smoothing based on the efficiency ratio (market noise vs direction).
|
|
546
|
+
* This implementation supports NaN-aware and dense fast-paths; when NaNs are
|
|
547
|
+
* present the compacting + mapping strategy is used, otherwise an O(n)
|
|
548
|
+
* incremental volatility approach is used for speed.
|
|
549
|
+
* @param source Input series
|
|
550
|
+
* @param period Efficiency smoothing lookback (must be > 0)
|
|
551
|
+
* @param fastPeriod Fast smoothing period (default: 2)
|
|
552
|
+
* @param slowPeriod Slow smoothing period (default: 30)
|
|
553
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
554
|
+
* @returns Float64Array of KAMA values (NaN where undefined)
|
|
555
|
+
*/
|
|
556
|
+
declare function kama(source: ArrayLike<number>, period: number, fastPeriod?: number, slowPeriod?: number, skipna?: boolean): Float64Array;
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Wilder's Moving Average / RMA.
|
|
560
|
+
* Implements the Wilder smoothing recurrence (rma = (rma*(period-1) + x)/period).
|
|
561
|
+
* When `skipna` is true NaNs are ignored during seeding and updates; otherwise
|
|
562
|
+
* a dense fast-path is used for NaN-free inputs.
|
|
563
|
+
* @param source Input series
|
|
564
|
+
* @param period Smoothing period (must be > 0)
|
|
565
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
566
|
+
* @returns Float64Array of RMA values (NaN before window fills)
|
|
567
|
+
*/
|
|
568
|
+
declare function rma(source: ArrayLike<number>, period: number, skipna?: boolean): Float64Array;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Triple Exponential Moving Average (T3)
|
|
572
|
+
*
|
|
573
|
+
* T3 is a triple-smoothed moving average developed by Tim Tillson that reduces lag
|
|
574
|
+
* and smoothing compared to traditional EMAs while maintaining responsiveness to price changes.
|
|
575
|
+
*
|
|
576
|
+
* @param source - Input data array
|
|
577
|
+
* @param period - Smoothing period (default: 5)
|
|
578
|
+
* @param volumeFactor - Volume factor for smoothing (default: 0.7)
|
|
579
|
+
* @returns T3 values
|
|
580
|
+
*/
|
|
581
|
+
/**
|
|
582
|
+
* Triple Exponential Moving Average (T3)
|
|
583
|
+
*
|
|
584
|
+
* Implemented following TA‑Lib's algorithm (see TA_T3 C implementation).
|
|
585
|
+
* This inlines the nested EMA seeding (e1..e6) and performs a single-pass
|
|
586
|
+
* update, which is significantly faster than calling `ema()` six times.
|
|
587
|
+
*
|
|
588
|
+
* Notes:
|
|
589
|
+
* - Lookback = 6 * (period - 1)
|
|
590
|
+
* - For inputs containing NaNs we propagate NaN outputs where we cannot
|
|
591
|
+
* compute valid seeds or updates.
|
|
592
|
+
*/
|
|
593
|
+
declare function t3(source: ArrayLike<number>, period: number, volumeFactor: number): Float64Array;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Awesome Oscillator (AO): difference between short and long simple moving averages
|
|
597
|
+
* of the median price ((high + low)/2). Supports NaN-aware and dense fast-paths.
|
|
598
|
+
* @param high High price series
|
|
599
|
+
* @param low Low price series
|
|
600
|
+
* @param shortPeriod Short SMA period (default 5)
|
|
601
|
+
* @param longPeriod Long SMA period (default 34)
|
|
602
|
+
* @param skipna When true, ignore NaNs inside windows; false forces dense path
|
|
603
|
+
* @returns Float64Array AO series (NaN where undefined)
|
|
604
|
+
*/
|
|
605
|
+
declare function ao(high: ArrayLike<number>, low: ArrayLike<number>, shortPeriod?: number, longPeriod?: number, skipna?: boolean): Float64Array;
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Absolute Price Oscillator (APO).
|
|
609
|
+
* Computes the difference between a short and a long EMA of `src`.
|
|
610
|
+
* Skips NaNs and seeds EMAs on the first valid value; returns NaN
|
|
611
|
+
* for indices before both EMAs have filled.
|
|
612
|
+
* @param src Input series
|
|
613
|
+
* @param shortPeriod Short EMA period
|
|
614
|
+
* @param longPeriod Long EMA period
|
|
615
|
+
* @returns Float64Array of APO values (NaN where undefined)
|
|
616
|
+
*/
|
|
617
|
+
declare function apo(src: ArrayLike<number>, shortPeriod: number, longPeriod: number): Float64Array;
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Chande Momentum Oscillator (CMO).
|
|
621
|
+
* Computes CMO over `period` using percent scaling in [-100, 100].
|
|
622
|
+
* Ignores NaNs in the input deltas; positions before the first
|
|
623
|
+
* computable value are NaN.
|
|
624
|
+
* @param src Input series
|
|
625
|
+
* @param period Period over which to compute the oscillator
|
|
626
|
+
* @returns Float64Array of CMO values (NaN where undefined)
|
|
627
|
+
*/
|
|
628
|
+
declare function cmo(src: ArrayLike<number>, period: number): Float64Array;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Moving Average Convergence Divergence (MACD).
|
|
632
|
+
* Produces the MACD line (short EMA - long EMA), the signal line (EMA of MACD),
|
|
633
|
+
* and the histogram (MACD - signal). Skips NaNs and seeds EMAs on first valid
|
|
634
|
+
* value; outputs are NaN until the EMAs and signal have seeded.
|
|
635
|
+
* @param src Input series
|
|
636
|
+
* @param shortPeriod Short EMA period
|
|
637
|
+
* @param longPeriod Long EMA period
|
|
638
|
+
* @param signalPeriod Signal EMA period
|
|
639
|
+
* @returns Tuple `[macdLine, signalLine, histogram]` as Float64Array
|
|
640
|
+
*/
|
|
641
|
+
declare function macd(src: ArrayLike<number>, shortPeriod: number, longPeriod: number, signalPeriod: number): [Float64Array, Float64Array, Float64Array];
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Momentum (difference) indicator.
|
|
645
|
+
* Computes `src[i] - src[i - period]` for each index; positions where
|
|
646
|
+
* the lagged value is not available are NaN.
|
|
647
|
+
* @param src Input series
|
|
648
|
+
* @param period Lag period (must be > 0)
|
|
649
|
+
* @returns Float64Array of momentum values (NaN where undefined)
|
|
650
|
+
*/
|
|
651
|
+
declare function mom(src: ArrayLike<number>, period: number): Float64Array;
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Percentage Price Oscillator (PPO).
|
|
655
|
+
* PPO = 100 * (EMA_short - EMA_long) / EMA_long.
|
|
656
|
+
* Skips NaNs and seeds EMAs on first valid value; outputs are NaN until the
|
|
657
|
+
* long EMA has enough data. When EMA_long is zero, returns 0 to avoid division.
|
|
658
|
+
* @param src Input series
|
|
659
|
+
* @param shortPeriod Short EMA period
|
|
660
|
+
* @param longPeriod Long EMA period
|
|
661
|
+
* @returns Float64Array of PPO values (NaN where undefined)
|
|
662
|
+
*/
|
|
663
|
+
declare function ppo(src: ArrayLike<number>, shortPeriod: number, longPeriod: number): Float64Array;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Simple change over `period`.
|
|
667
|
+
* Computes `src[i] - src[i-period]` for each index `i >= period`.
|
|
668
|
+
* Outputs NaN for indices before `period` and propagates NaNs for invalid pairs.
|
|
669
|
+
* @param src Input series
|
|
670
|
+
* @param period Lookback period (must be > 0)
|
|
671
|
+
* @returns Float64Array of simple change values (NaN where undefined)
|
|
672
|
+
*/
|
|
673
|
+
declare function change(src: ArrayLike<number>, period: number): Float64Array;
|
|
674
|
+
/**
|
|
675
|
+
* Percentage Rate-of-Change (ROC).
|
|
676
|
+
* Returns 100 * (src[i] - src[i-period]) / src[i-period]. NaN is returned
|
|
677
|
+
* for indices before `period` or when a denominator is NaN/zero.
|
|
678
|
+
* @param src Input series
|
|
679
|
+
* @param period Lookback period (must be > 0)
|
|
680
|
+
* @returns Float64Array of ROC values (NaN where undefined)
|
|
681
|
+
*/
|
|
682
|
+
declare function roc(src: ArrayLike<number>, period: number): Float64Array;
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Relative Strength Index (RSI) with optional NaN-aware behavior.
|
|
686
|
+
* - `skipna=false` (dense path): assumes inputs contain no NaNs or that NaN
|
|
687
|
+
* propagation is desired; uses a dense fast-path implementation.
|
|
688
|
+
* - `skipna=true` (NaN-aware): skips NaNs when computing deltas and preserves
|
|
689
|
+
* gaps in the output where insufficient valid data exists.
|
|
690
|
+
* Seeding: the implementation seeds on the first valid value and uses Wilder
|
|
691
|
+
* smoothing once the initial window is filled.
|
|
692
|
+
* @param src Input series
|
|
693
|
+
* @param period Lookback period for RSI (must be > 0)
|
|
694
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
695
|
+
* @returns Float64Array of RSI values (NaN where undefined)
|
|
696
|
+
*/
|
|
697
|
+
declare function rsi(src: ArrayLike<number>, period: number, skipna?: boolean): Float64Array;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Stochastic oscillator (fast %K and %D smoothed outputs).
|
|
701
|
+
* Computes fast %K based on rolling highest/lowest over `kPeriod`, then
|
|
702
|
+
* smooths with `kSlow` and `dPeriod` using dense SMA. Assumes input series
|
|
703
|
+
* length equality and returns NaN when insufficient data exists.
|
|
704
|
+
* @param high High price series
|
|
705
|
+
* @param low Low price series
|
|
706
|
+
* @param close Close price series
|
|
707
|
+
* @param kPeriod %K lookback period
|
|
708
|
+
* @param kSlow Smoothing period for %K
|
|
709
|
+
* @param dPeriod Smoothing period for %D
|
|
710
|
+
* @returns Tuple `[slowK, slowD]` as Float64Array
|
|
711
|
+
*/
|
|
712
|
+
declare function stoch(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, kPeriod: number, kSlow: number, dPeriod: number): [Float64Array, Float64Array];
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Stochastic RSI.
|
|
716
|
+
* Applies a stochastic calculation to the RSI series, producing values in [0,1].
|
|
717
|
+
* This implementation is NaN-aware and maintains deques over valid RSI samples.
|
|
718
|
+
* @param close Close price series
|
|
719
|
+
* @param period RSI lookback period
|
|
720
|
+
* @returns Float64Array of StochRSI values (NaN where undefined)
|
|
721
|
+
*/
|
|
722
|
+
declare function stochrsi(close: ArrayLike<number>, period: number): Float64Array;
|
|
723
|
+
|
|
724
|
+
type UltoscOptions = {
|
|
725
|
+
s1?: number;
|
|
726
|
+
s2?: number;
|
|
727
|
+
s3?: number;
|
|
728
|
+
};
|
|
729
|
+
/**
|
|
730
|
+
* Ultimate Oscillator (ULTOSC).
|
|
731
|
+
* Combines short-, mid-, and long-term averages of the buying pressure / true range
|
|
732
|
+
* to produce a bounded oscillator in [0,100]. Preserves NaN inputs and returns
|
|
733
|
+
* NaN for indices before the longest lookback has sufficient data.
|
|
734
|
+
* @param high High price series
|
|
735
|
+
* @param low Low price series
|
|
736
|
+
* @param close Close price series
|
|
737
|
+
* @param options Optional periods for short/mid/long (s1,s2,s3)
|
|
738
|
+
* @returns Float64Array of Ultimate Oscillator values (NaN where undefined)
|
|
739
|
+
*/
|
|
740
|
+
declare function ultosc(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, options?: UltoscOptions): Float64Array;
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Williams %R (WPR).
|
|
744
|
+
* Computes %R = (highestHigh - close) / (highestHigh - lowestLow) * -100
|
|
745
|
+
* over a rolling `period`. Uses `rollminmax` to compute window extrema and
|
|
746
|
+
* returns NaN for indices before `period` or when the range is zero.
|
|
747
|
+
* @param high High price series
|
|
748
|
+
* @param low Low price series
|
|
749
|
+
* @param close Close price series
|
|
750
|
+
* @param period Lookback period (must be > 0)
|
|
751
|
+
* @returns Float64Array of %R values (NaN where undefined)
|
|
752
|
+
*/
|
|
753
|
+
declare function wpr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): Float64Array;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Aroon indicator: returns `[up, down]` arrays in percentage form (0-100)
|
|
757
|
+
* describing the time since the highest/lowest value within the lookback
|
|
758
|
+
* `period`. Supports NaN-aware and dense fast-paths.
|
|
759
|
+
* @param high High price series
|
|
760
|
+
* @param low Low price series
|
|
761
|
+
* @param period Lookback period (>0)
|
|
762
|
+
* @param skipna When true ignore NaNs in windows; false forces dense path
|
|
763
|
+
* @returns Tuple `[up, down]` Float64Array indicators
|
|
764
|
+
*/
|
|
765
|
+
declare function aroon(high: ArrayLike<number>, low: ArrayLike<number>, period: number, skipna?: boolean): [Float64Array, Float64Array];
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Know Sure Thing (KST) momentum oscillator
|
|
769
|
+
* Default parameters match common KST configuration
|
|
770
|
+
*/
|
|
771
|
+
type KstOptions = {
|
|
772
|
+
r1?: number;
|
|
773
|
+
r2?: number;
|
|
774
|
+
r3?: number;
|
|
775
|
+
r4?: number;
|
|
776
|
+
n1?: number;
|
|
777
|
+
n2?: number;
|
|
778
|
+
n3?: number;
|
|
779
|
+
n4?: number;
|
|
780
|
+
w1?: number;
|
|
781
|
+
w2?: number;
|
|
782
|
+
w3?: number;
|
|
783
|
+
w4?: number;
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* Know Sure Thing (KST) momentum oscillator.
|
|
787
|
+
* Computes a weighted sum of smoothed rate-of-change series.
|
|
788
|
+
* Parameters may be supplied via the `options` object or defaults are used.
|
|
789
|
+
* The output length equals `src.length`; positions before the required
|
|
790
|
+
* lookback periods are NaN.
|
|
791
|
+
* @param src Input series
|
|
792
|
+
* @param options Optional parameters for ROC and smoothing windows
|
|
793
|
+
* @returns Float64Array of KST values (NaN where insufficient data)
|
|
794
|
+
*/
|
|
795
|
+
declare function kst(src: ArrayLike<number>, options?: KstOptions): Float64Array;
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Commodity Channel Index (CCI).
|
|
799
|
+
* Computes the typical price (TP) and compares to a moving average and
|
|
800
|
+
* mean absolute deviation (MAD) scaled by 0.015. Positions before the
|
|
801
|
+
* full lookback or with invalid inputs are NaN.
|
|
802
|
+
* Performance: O(n*p) due to MAD recomputation per window.
|
|
803
|
+
* @param high High price series
|
|
804
|
+
* @param low Low price series
|
|
805
|
+
* @param close Close price series
|
|
806
|
+
* @param period Lookback period (must be > 0)
|
|
807
|
+
* @returns Float64Array of CCI values (NaN where undefined)
|
|
808
|
+
*/
|
|
809
|
+
declare function cci(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): Float64Array;
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Directional Indicators (DI+ and DI-).
|
|
813
|
+
* @param high High price series
|
|
814
|
+
* @param low Low price series
|
|
815
|
+
* @param close Close price series
|
|
816
|
+
* @param period Lookback period (must be > 0)
|
|
817
|
+
* @returns Tuple `[diplus, diminus]` as Float64Array
|
|
818
|
+
*/
|
|
819
|
+
declare function di(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): [Float64Array, Float64Array];
|
|
820
|
+
/**
|
|
821
|
+
* DX (Directional Movement Index).
|
|
822
|
+
* @param high High price series
|
|
823
|
+
* @param low Low price series
|
|
824
|
+
* @param close Close price series
|
|
825
|
+
* @param period Lookback period (must be > 0)
|
|
826
|
+
* @returns Float64Array of DX values (NaN where undefined)
|
|
827
|
+
*/
|
|
828
|
+
declare function dx(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): Float64Array;
|
|
829
|
+
/**
|
|
830
|
+
* Average Directional Index (ADX).
|
|
831
|
+
* @param high High price series
|
|
832
|
+
* @param low Low price series
|
|
833
|
+
* @param close Close price series
|
|
834
|
+
* @param period Lookback period (must be > 0)
|
|
835
|
+
* @returns Float64Array of ADX values (NaN where undefined)
|
|
836
|
+
*/
|
|
837
|
+
declare function adx(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): Float64Array;
|
|
838
|
+
/**
|
|
839
|
+
* ADXR (Average DX Rating) - smoothed ADX.
|
|
840
|
+
* @param high High price series
|
|
841
|
+
* @param low Low price series
|
|
842
|
+
* @param close Close price series
|
|
843
|
+
* @param period Lookback period (must be > 0)
|
|
844
|
+
* @returns Float64Array of ADXR values (NaN where undefined)
|
|
845
|
+
*/
|
|
846
|
+
declare function adxr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): Float64Array;
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Detrended Price Oscillator (DPO).
|
|
850
|
+
* Computes DPO[i] = source[i - shift] - SMA(source, period)[i], where
|
|
851
|
+
* shift = floor(period/2) + 1. Outputs are NaN for indices before the
|
|
852
|
+
* shift or when insufficient data exists.
|
|
853
|
+
* @param source Input series
|
|
854
|
+
* @param period Lookback period (must be > 0)
|
|
855
|
+
* @returns Float64Array of DPO values (NaN where undefined)
|
|
856
|
+
*/
|
|
857
|
+
declare function dpo(source: ArrayLike<number>, period: number): Float64Array;
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Parabolic SAR (PSAR) indicator.
|
|
861
|
+
* @param high High price series
|
|
862
|
+
* @param low Low price series
|
|
863
|
+
* @param step Acceleration step increment (>0)
|
|
864
|
+
* @param maxStep Maximum acceleration value (>= step)
|
|
865
|
+
* @param skipna When true ignore NaNs; when false use dense fast-path
|
|
866
|
+
* @returns Float64Array PSAR values (NaN for undefined positions)
|
|
867
|
+
*/
|
|
868
|
+
declare function psar(high: ArrayLike<number>, low: ArrayLike<number>, step: number, maxStep: number, skipna?: boolean): Float64Array;
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Supertrend indicator.
|
|
872
|
+
* Returns `[supertrend, finalUpper, finalLower, isUpMask]`.
|
|
873
|
+
* `supertrend` contains the plotted trend line (either finalLower when up or finalUpper when down),
|
|
874
|
+
* `finalUpper`/`finalLower` are the band values, and `isUpMask` is a Uint8Array mask (1 when up).
|
|
875
|
+
* NaNs are preserved for invalid inputs or before enough data is available.
|
|
876
|
+
* @param high High price series
|
|
877
|
+
* @param low Low price series
|
|
878
|
+
* @param close Close price series
|
|
879
|
+
* @param period ATR lookback period
|
|
880
|
+
* @param mult Multiplier applied to ATR to form bands
|
|
881
|
+
* @returns Tuple `[supertrend, finalUpper, finalLower, isUpMask]`
|
|
882
|
+
*/
|
|
883
|
+
declare function supertrend(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number, mult: number): [Float64Array, Float64Array, Float64Array, Uint8Array];
|
|
884
|
+
|
|
885
|
+
type IchimokuOptions = {
|
|
886
|
+
tenkan?: number;
|
|
887
|
+
kijun?: number;
|
|
888
|
+
senkouB?: number;
|
|
889
|
+
};
|
|
890
|
+
/**
|
|
891
|
+
* Ichimoku Kinko Hyo indicator components.
|
|
892
|
+
* Returns `[tenkan, kijun, senkouA, senkouB, chikou]` where senkou lines
|
|
893
|
+
* are shifted forward by the `kijun` displacement and chikou is the close
|
|
894
|
+
* shifted backward. NaN is produced where rolling inputs are invalid.
|
|
895
|
+
* @param high High price series
|
|
896
|
+
* @param low Low price series
|
|
897
|
+
* @param close Close price series
|
|
898
|
+
* @param options Optional periods `{ tenkan, kijun, senkouB }`
|
|
899
|
+
* @returns Tuple of Float64Array: `[tenkan, kijun, senkouA, senkouB, chikou]`
|
|
900
|
+
*/
|
|
901
|
+
declare function ichimoku(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, options?: IchimokuOptions): [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array];
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* True Range (TR).
|
|
905
|
+
* TR[i] = max(high[i]-low[i], |high[i]-close[i-1]|, |low[i]-close[i-1]|).
|
|
906
|
+
* Preserves NaNs and returns NaN where inputs are invalid.
|
|
907
|
+
* @param high High price series
|
|
908
|
+
* @param low Low price series
|
|
909
|
+
* @param close Close price series
|
|
910
|
+
* @returns Float64Array of TR values
|
|
911
|
+
*/
|
|
912
|
+
declare function tr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>): Float64Array;
|
|
913
|
+
/**
|
|
914
|
+
* Average True Range (ATR).
|
|
915
|
+
* Computes ATR using Wilder's RMA over the true-range series. Handles NaNs
|
|
916
|
+
* via the `rma` NaN-aware implementation; returns NaN for indices before the
|
|
917
|
+
* lookback is filled.
|
|
918
|
+
* @param high High price series
|
|
919
|
+
* @param low Low price series
|
|
920
|
+
* @param close Close price series
|
|
921
|
+
* @param period Lookback period (must be > 0)
|
|
922
|
+
* @returns Float64Array of ATR values
|
|
923
|
+
*/
|
|
924
|
+
declare function atr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): Float64Array;
|
|
925
|
+
declare function natr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): Float64Array;
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Bollinger Bands (BB).
|
|
929
|
+
* Returns `[middle, upper, lower]` where `middle` is the SMA, and `upper`/`lower`
|
|
930
|
+
* are `middle ± mult * stddev`. Uses a NaN-aware or dense `rollstdev` depending
|
|
931
|
+
* on input; positions before the window fills are NaN.
|
|
932
|
+
* @param source Input series
|
|
933
|
+
* @param period Window length (must be > 0)
|
|
934
|
+
* @param mult Standard-deviation multiplier
|
|
935
|
+
* @returns Tuple `[middle, upper, lower]` as Float64Array
|
|
936
|
+
*/
|
|
937
|
+
declare function bb(source: ArrayLike<number>, period: number, mult: number): [Float64Array, Float64Array, Float64Array];
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Bollinger Band Width (BBW).
|
|
941
|
+
* Returns the normalized width of the Bollinger Bands as percentage: `100*(upper-lower)/middle`.
|
|
942
|
+
* NaNs propagate and positions with `middle === 0` leave the output unchanged (NaN or 0).
|
|
943
|
+
* @param source Input series
|
|
944
|
+
* @param period Window length
|
|
945
|
+
* @param mult Standard-deviation multiplier used for BB
|
|
946
|
+
* @returns Float64Array of BB width percentages
|
|
947
|
+
*/
|
|
948
|
+
declare function bbw(source: ArrayLike<number>, period: number, mult: number): Float64Array;
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Donchian Channels.
|
|
952
|
+
* Returns `[upper, lower, middle]` where `upper` is the highest high
|
|
953
|
+
* and `lower` the lowest low over the lookback `period`. `middle` is the
|
|
954
|
+
* midpoint. NaNs propagate when inputs are invalid.
|
|
955
|
+
* @param high High price series
|
|
956
|
+
* @param low Low price series
|
|
957
|
+
* @param period Lookback period (must be > 0)
|
|
958
|
+
* @returns Tuple `[upper, lower, middle]` as Float64Array
|
|
959
|
+
*/
|
|
960
|
+
declare function donchian(high: ArrayLike<number>, low: ArrayLike<number>, period: number): [Float64Array, Float64Array, Float64Array];
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Keltner Channels.
|
|
964
|
+
* Returns `[middle(EMA of typical price), upper, lower]` where upper/lower are `middle ± mult * ATR`.
|
|
965
|
+
* Preserves NaNs when inputs are invalid.
|
|
966
|
+
* @param high High price series
|
|
967
|
+
* @param low Low price series
|
|
968
|
+
* @param close Close price series
|
|
969
|
+
* @param period Lookback period (must be > 0)
|
|
970
|
+
* @param mult Multiplier applied to ATR
|
|
971
|
+
* @returns Tuple `[middle, upper, lower]` as Float64Array
|
|
972
|
+
*/
|
|
973
|
+
declare function keltner(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number, mult: number): [Float64Array, Float64Array, Float64Array];
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Accumulation/Distribution (AD) line.
|
|
977
|
+
* Computes the cumulative money flow: AD[i] = AD[i-1] + MFM[i] * volume[i],
|
|
978
|
+
* where MFM = ((close - low) - (high - close)) / (high - low).
|
|
979
|
+
* NaNs propagate for invalid input tuples and the accumulator only updates on finite values.
|
|
980
|
+
* @param high High price series
|
|
981
|
+
* @param low Low price series
|
|
982
|
+
* @param close Close price series
|
|
983
|
+
* @param volume Volume series
|
|
984
|
+
* @returns Float64Array of AD values
|
|
985
|
+
*/
|
|
986
|
+
declare function ad(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, volume: ArrayLike<number>): Float64Array;
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Accumulation/Distribution Oscillator (ADOSC).
|
|
990
|
+
* Computes the difference between short- and long-term EMAs of the cumulative
|
|
991
|
+
* money flow (AD). Supports NaN-aware and dense fast-paths; outputs are NaN
|
|
992
|
+
* until the long EMA seeding is complete.
|
|
993
|
+
* @param high High price series
|
|
994
|
+
* @param low Low price series
|
|
995
|
+
* @param close Close price series
|
|
996
|
+
* @param volume Volume series
|
|
997
|
+
* @param shortPeriod Short EMA period
|
|
998
|
+
* @param longPeriod Long EMA period
|
|
999
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
1000
|
+
* @returns Float64Array of ADOSC values (NaN where undefined)
|
|
1001
|
+
*/
|
|
1002
|
+
declare function adosc(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, volume: ArrayLike<number>, shortPeriod: number, longPeriod: number, skipna?: boolean): Float64Array;
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Money Flow Index (MFI).
|
|
1006
|
+
* Computes MFI over `period` using typical price and money flow; NaN-aware
|
|
1007
|
+
* sliding-window implementation that emits NaN where insufficient valid data exists.
|
|
1008
|
+
* @param high High price series
|
|
1009
|
+
* @param low Low price series
|
|
1010
|
+
* @param close Close price series
|
|
1011
|
+
* @param volume Volume series
|
|
1012
|
+
* @param period Lookback period (must be > 0)
|
|
1013
|
+
* @returns Float64Array of MFI values in [0,100]
|
|
1014
|
+
*/
|
|
1015
|
+
declare function mfi(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, volume: ArrayLike<number>, period: number): Float64Array;
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* On-Balance Volume (OBV).
|
|
1019
|
+
* Accumulates volume by sign of price change: add volume when price rises,
|
|
1020
|
+
* subtract when price falls; NaNs in inputs yield NaN outputs for that index.
|
|
1021
|
+
* @param price Price series
|
|
1022
|
+
* @param volume Volume series
|
|
1023
|
+
* @returns Float64Array of OBV values
|
|
1024
|
+
*/
|
|
1025
|
+
declare function obv(price: ArrayLike<number>, volume: ArrayLike<number>): Float64Array;
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Positive/Negative Volume Index (PNVI).
|
|
1029
|
+
* Returns `[pvi, nvi]` series tracking separate indices when volume increases
|
|
1030
|
+
* (PVI) or decreases (NVI). Preserves NaNs and treats zero close as missing.
|
|
1031
|
+
* @param close Close price series
|
|
1032
|
+
* @param volume Volume series
|
|
1033
|
+
* @param start Initial index value (default: 1000)
|
|
1034
|
+
* @returns Tuple `[pvi, nvi]` as Float64Array
|
|
1035
|
+
*/
|
|
1036
|
+
declare function pnvi(close: ArrayLike<number>, volume: ArrayLike<number>, start?: number): [Float64Array, Float64Array];
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Williams Accumulation/Distribution (WAD).
|
|
1040
|
+
* Accumulates the money flow based on price movement using either a dense
|
|
1041
|
+
* fast-path or a NaN-aware path depending on `skipna` and input contents.
|
|
1042
|
+
* @param high High price series
|
|
1043
|
+
* @param low Low price series
|
|
1044
|
+
* @param close Close price series
|
|
1045
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
1046
|
+
* @returns Float64Array of WAD values (NaN where undefined)
|
|
1047
|
+
*/
|
|
1048
|
+
declare function wad(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, skipna?: boolean): Float64Array;
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* Rising mask: returns a Uint8Array where `1` indicates `source[i]` is
|
|
1052
|
+
* strictly greater than the value `length` periods ago (NaN-aware).
|
|
1053
|
+
* When `skipna` is true, NaNs are tolerated and preserved; when false a
|
|
1054
|
+
* dense fast-path is used (assumes no NaNs).
|
|
1055
|
+
* @param source Input numeric series
|
|
1056
|
+
* @param length Lookback length (>0)
|
|
1057
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
1058
|
+
* @returns Uint8Array mask with 0/1 values
|
|
1059
|
+
*/
|
|
1060
|
+
declare function rising(source: ArrayLike<number>, length: number, skipna?: boolean): Uint8Array;
|
|
1061
|
+
/**
|
|
1062
|
+
* Falling mask: returns a Uint8Array where `1` indicates `source[i]` is
|
|
1063
|
+
* strictly less than the value `length` periods ago (NaN-aware).
|
|
1064
|
+
* When `skipna` is true, NaNs are tolerated and preserved; when false a
|
|
1065
|
+
* dense fast-path is used (assumes no NaNs).
|
|
1066
|
+
* @param source Input numeric series
|
|
1067
|
+
* @param length Lookback length (>0)
|
|
1068
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
1069
|
+
* @returns Uint8Array mask with 0/1 values
|
|
1070
|
+
*/
|
|
1071
|
+
declare function falling(source: ArrayLike<number>, length: number, skipna?: boolean): Uint8Array;
|
|
1072
|
+
/**
|
|
1073
|
+
* Test whether series `a` crosses `b` (or a scalar) between the previous and
|
|
1074
|
+
* current index. By default uses a symmetric cross test that detects both
|
|
1075
|
+
* upward and downward crossings. Comparisons are strict and require non-NaN
|
|
1076
|
+
* current and previous values for both operands.
|
|
1077
|
+
* @param a Left series
|
|
1078
|
+
* @param b Right series or scalar
|
|
1079
|
+
* @param test Optional custom comparator receiving (ai, aim1, bi, bim1)
|
|
1080
|
+
* @returns Uint8Array mask where 1 indicates a crossing at that index
|
|
1081
|
+
*/
|
|
1082
|
+
declare function cross(a: ArrayLike<number>, b: ArrayLike<number> | number, test?: (ai: number, aim1: number, bi: number, bim1: number) => boolean): Uint8Array;
|
|
1083
|
+
/**
|
|
1084
|
+
* Detect an upward crossover (a crosses above b).
|
|
1085
|
+
*/
|
|
1086
|
+
declare function crossover(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
|
|
1087
|
+
/**
|
|
1088
|
+
* Detect a downward crossunder (a crosses below b).
|
|
1089
|
+
*/
|
|
1090
|
+
declare function crossunder(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* Technical indicators barrel: re-export grouped TA modules for convenient imports.
|
|
1094
|
+
* This file collects moving averages, momentum oscillators, trend and
|
|
1095
|
+
* volatility indicators, as well as utility helpers.
|
|
1096
|
+
*/
|
|
1097
|
+
|
|
1098
|
+
type index_d$1_IchimokuOptions = IchimokuOptions;
|
|
1099
|
+
type index_d$1_KstOptions = KstOptions;
|
|
1100
|
+
type index_d$1_UltoscOptions = UltoscOptions;
|
|
1101
|
+
declare const index_d$1_ad: typeof ad;
|
|
1102
|
+
declare const index_d$1_adosc: typeof adosc;
|
|
1103
|
+
declare const index_d$1_adx: typeof adx;
|
|
1104
|
+
declare const index_d$1_adxr: typeof adxr;
|
|
1105
|
+
declare const index_d$1_ao: typeof ao;
|
|
1106
|
+
declare const index_d$1_apo: typeof apo;
|
|
1107
|
+
declare const index_d$1_aroon: typeof aroon;
|
|
1108
|
+
declare const index_d$1_atr: typeof atr;
|
|
1109
|
+
declare const index_d$1_bb: typeof bb;
|
|
1110
|
+
declare const index_d$1_bbw: typeof bbw;
|
|
1111
|
+
declare const index_d$1_cci: typeof cci;
|
|
1112
|
+
declare const index_d$1_change: typeof change;
|
|
1113
|
+
declare const index_d$1_cmo: typeof cmo;
|
|
1114
|
+
declare const index_d$1_cross: typeof cross;
|
|
1115
|
+
declare const index_d$1_crossover: typeof crossover;
|
|
1116
|
+
declare const index_d$1_crossunder: typeof crossunder;
|
|
1117
|
+
declare const index_d$1_dema: typeof dema;
|
|
1118
|
+
declare const index_d$1_di: typeof di;
|
|
1119
|
+
declare const index_d$1_donchian: typeof donchian;
|
|
1120
|
+
declare const index_d$1_dpo: typeof dpo;
|
|
1121
|
+
declare const index_d$1_dx: typeof dx;
|
|
1122
|
+
declare const index_d$1_ema: typeof ema;
|
|
1123
|
+
declare const index_d$1_falling: typeof falling;
|
|
1124
|
+
declare const index_d$1_hma: typeof hma;
|
|
1125
|
+
declare const index_d$1_ichimoku: typeof ichimoku;
|
|
1126
|
+
declare const index_d$1_kama: typeof kama;
|
|
1127
|
+
declare const index_d$1_keltner: typeof keltner;
|
|
1128
|
+
declare const index_d$1_kst: typeof kst;
|
|
1129
|
+
declare const index_d$1_macd: typeof macd;
|
|
1130
|
+
declare const index_d$1_mfi: typeof mfi;
|
|
1131
|
+
declare const index_d$1_mom: typeof mom;
|
|
1132
|
+
declare const index_d$1_natr: typeof natr;
|
|
1133
|
+
declare const index_d$1_obv: typeof obv;
|
|
1134
|
+
declare const index_d$1_pnvi: typeof pnvi;
|
|
1135
|
+
declare const index_d$1_ppo: typeof ppo;
|
|
1136
|
+
declare const index_d$1_psar: typeof psar;
|
|
1137
|
+
declare const index_d$1_rising: typeof rising;
|
|
1138
|
+
declare const index_d$1_rma: typeof rma;
|
|
1139
|
+
declare const index_d$1_roc: typeof roc;
|
|
1140
|
+
declare const index_d$1_rsi: typeof rsi;
|
|
1141
|
+
declare const index_d$1_sma: typeof sma;
|
|
1142
|
+
declare const index_d$1_stoch: typeof stoch;
|
|
1143
|
+
declare const index_d$1_stochrsi: typeof stochrsi;
|
|
1144
|
+
declare const index_d$1_supertrend: typeof supertrend;
|
|
1145
|
+
declare const index_d$1_t3: typeof t3;
|
|
1146
|
+
declare const index_d$1_tema: typeof tema;
|
|
1147
|
+
declare const index_d$1_tr: typeof tr;
|
|
1148
|
+
declare const index_d$1_trima: typeof trima;
|
|
1149
|
+
declare const index_d$1_ultosc: typeof ultosc;
|
|
1150
|
+
declare const index_d$1_vwma: typeof vwma;
|
|
1151
|
+
declare const index_d$1_wad: typeof wad;
|
|
1152
|
+
declare const index_d$1_wma: typeof wma;
|
|
1153
|
+
declare const index_d$1_wpr: typeof wpr;
|
|
1154
|
+
declare namespace index_d$1 {
|
|
1155
|
+
export { index_d$1_ad as ad, index_d$1_adosc as adosc, index_d$1_adx as adx, index_d$1_adxr as adxr, index_d$1_ao as ao, index_d$1_apo as apo, index_d$1_aroon as aroon, index_d$1_atr as atr, index_d$1_bb as bb, index_d$1_bbw as bbw, index_d$1_cci as cci, index_d$1_change as change, index_d$1_cmo as cmo, index_d$1_cross as cross, index_d$1_crossover as crossover, index_d$1_crossunder as crossunder, index_d$1_dema as dema, index_d$1_di as di, index_d$1_donchian as donchian, index_d$1_dpo as dpo, index_d$1_dx as dx, index_d$1_ema as ema, index_d$1_falling as falling, index_d$1_hma as hma, index_d$1_ichimoku as ichimoku, index_d$1_kama as kama, index_d$1_keltner as keltner, index_d$1_kst as kst, index_d$1_macd as macd, index_d$1_mfi as mfi, index_d$1_mom as mom, index_d$1_natr as natr, index_d$1_obv as obv, index_d$1_pnvi as pnvi, index_d$1_ppo as ppo, index_d$1_psar as psar, index_d$1_rising as rising, index_d$1_rma as rma, index_d$1_roc as roc, index_d$1_rsi as rsi, index_d$1_sma as sma, index_d$1_stoch as stoch, index_d$1_stochrsi as stochrsi, index_d$1_supertrend as supertrend, index_d$1_t3 as t3, index_d$1_tema as tema, index_d$1_tr as tr, index_d$1_trima as trima, index_d$1_ultosc as ultosc, index_d$1_vwma as vwma, index_d$1_wad as wad, index_d$1_wma as wma, index_d$1_wpr as wpr };
|
|
1156
|
+
export type { index_d$1_IchimokuOptions as IchimokuOptions, index_d$1_KstOptions as KstOptions, index_d$1_UltoscOptions as UltoscOptions };
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Elementwise equality comparison of two arrays, treating NaNs as equal.
|
|
1161
|
+
* If `precision` is provided, numeric comparison uses a tolerance of 10^-precision.
|
|
1162
|
+
* @param source1 First input array
|
|
1163
|
+
* @param source2 Second input array
|
|
1164
|
+
* @param precision Optional decimal precision for fuzzy equality
|
|
1165
|
+
* @returns `true` if arrays are equal, `false` otherwise
|
|
1166
|
+
*/
|
|
1167
|
+
declare function equals(source1: ArrayLike<number>, source2: ArrayLike<number>, precision?: number): boolean;
|
|
1168
|
+
/**
|
|
1169
|
+
* Return true if all elements are NaN.
|
|
1170
|
+
* @param source Input array
|
|
1171
|
+
* @returns `true` when every entry is NaN
|
|
1172
|
+
*/
|
|
1173
|
+
declare function allna(source: ArrayLike<number>): boolean;
|
|
1174
|
+
/**
|
|
1175
|
+
* Count NaN entries in `source`.
|
|
1176
|
+
* @param source Input array
|
|
1177
|
+
* @returns Number of NaNs in the array
|
|
1178
|
+
*/
|
|
1179
|
+
declare function countna(source: ArrayLike<number>): number;
|
|
1180
|
+
/**
|
|
1181
|
+
* Test whether any of the provided arrays contains a NaN at the same index.
|
|
1182
|
+
* Performs a single-pass scan across arrays and exits early on the first NaN.
|
|
1183
|
+
* @param sources One or more input arrays
|
|
1184
|
+
* @returns `true` if any NaN is found, otherwise `false`
|
|
1185
|
+
*/
|
|
1186
|
+
declare function havena(...sources: ArrayLike<number>[]): boolean;
|
|
1187
|
+
/**
|
|
1188
|
+
* Return a mask indicating NaN positions: 1 for NaN, 0 otherwise.
|
|
1189
|
+
* @param source Input array
|
|
1190
|
+
* @returns Float64Array mask of 0/1 values
|
|
1191
|
+
*/
|
|
1192
|
+
declare function isna(source: ArrayLike<number>): Float64Array;
|
|
1193
|
+
/**
|
|
1194
|
+
* Inverse of `isna`: mask with 1 for valid numbers and 0 for NaNs.
|
|
1195
|
+
* @param source Input array
|
|
1196
|
+
* @returns Float64Array mask of 0/1 values
|
|
1197
|
+
*/
|
|
1198
|
+
declare function notna(source: ArrayLike<number>): Float64Array;
|
|
1199
|
+
/**
|
|
1200
|
+
* Replace NaNs with `value`. When `inplace=true` and `source` is a Float64Array,
|
|
1201
|
+
* the original buffer is mutated.
|
|
1202
|
+
* @param source Input array
|
|
1203
|
+
* @param value Replacement value for NaNs
|
|
1204
|
+
* @param inplace Whether to mutate the input when possible
|
|
1205
|
+
* @returns Float64Array with NaNs replaced
|
|
1206
|
+
*/
|
|
1207
|
+
declare function fillna(source: ArrayLike<number>, value: number, inplace?: boolean): Float64Array;
|
|
1208
|
+
/**
|
|
1209
|
+
* Forward-fill NaNs: propagate the last valid value forward. Leading NaNs remain NaN.
|
|
1210
|
+
* @param source Input array
|
|
1211
|
+
* @param inplace Whether to mutate the input when possible
|
|
1212
|
+
* @returns Float64Array with forward-filled values
|
|
1213
|
+
*/
|
|
1214
|
+
declare function ffill(source: ArrayLike<number>, inplace?: boolean): Float64Array;
|
|
1215
|
+
/**
|
|
1216
|
+
* Backward-fill NaNs: propagate the next valid value backward. Trailing NaNs remain NaN.
|
|
1217
|
+
* @param source Input array
|
|
1218
|
+
* @param inplace Whether to mutate the input when possible
|
|
1219
|
+
* @returns Float64Array with backward-filled values
|
|
1220
|
+
*/
|
|
1221
|
+
declare function bfill(source: ArrayLike<number>, inplace?: boolean): Float64Array;
|
|
1222
|
+
declare function lag(source: ArrayLike<number>, shift?: number): Float64Array;
|
|
1223
|
+
/**
|
|
1224
|
+
* Replace occurrences of `fromValue` with `toValue`. If `fromValue` is NaN,
|
|
1225
|
+
* NaN entries are replaced.
|
|
1226
|
+
* @param source Input array
|
|
1227
|
+
* @param fromValue Value to replace (may be NaN)
|
|
1228
|
+
* @param toValue Replacement value
|
|
1229
|
+
* @param inplace Whether to mutate the input when possible
|
|
1230
|
+
* @returns Float64Array with replacements applied
|
|
1231
|
+
*/
|
|
1232
|
+
declare function replace(source: ArrayLike<number>, fromValue: number, toValue: number, inplace?: boolean): Float64Array;
|
|
1233
|
+
/**
|
|
1234
|
+
* Remove NaN entries from `source` and return a compacted Float64Array.
|
|
1235
|
+
* @param source Input array
|
|
1236
|
+
* @returns New Float64Array containing only the non-NaN values
|
|
1237
|
+
*/
|
|
1238
|
+
declare function dropna(source: ArrayLike<number>): Float64Array;
|
|
1239
|
+
|
|
1240
|
+
declare const arr_d_allna: typeof allna;
|
|
1241
|
+
declare const arr_d_bfill: typeof bfill;
|
|
1242
|
+
declare const arr_d_countna: typeof countna;
|
|
1243
|
+
declare const arr_d_dropna: typeof dropna;
|
|
1244
|
+
declare const arr_d_equals: typeof equals;
|
|
1245
|
+
declare const arr_d_ffill: typeof ffill;
|
|
1246
|
+
declare const arr_d_fillna: typeof fillna;
|
|
1247
|
+
declare const arr_d_havena: typeof havena;
|
|
1248
|
+
declare const arr_d_isna: typeof isna;
|
|
1249
|
+
declare const arr_d_lag: typeof lag;
|
|
1250
|
+
declare const arr_d_notna: typeof notna;
|
|
1251
|
+
declare const arr_d_replace: typeof replace;
|
|
1252
|
+
declare namespace arr_d {
|
|
1253
|
+
export {
|
|
1254
|
+
arr_d_allna as allna,
|
|
1255
|
+
arr_d_bfill as bfill,
|
|
1256
|
+
arr_d_countna as countna,
|
|
1257
|
+
arr_d_dropna as dropna,
|
|
1258
|
+
arr_d_equals as equals,
|
|
1259
|
+
arr_d_ffill as ffill,
|
|
1260
|
+
arr_d_fillna as fillna,
|
|
1261
|
+
arr_d_havena as havena,
|
|
1262
|
+
arr_d_isna as isna,
|
|
1263
|
+
arr_d_lag as lag,
|
|
1264
|
+
arr_d_notna as notna,
|
|
1265
|
+
arr_d_replace as replace,
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* Variance: compute a single variance over the whole series, dropping NaNs.
|
|
1271
|
+
* Uses `ddof` (delta degrees of freedom) like NumPy/pandas: denominator = N - ddof.
|
|
1272
|
+
* Default pandas behavior is sample variance (ddof=1), so the default here is ddof=1.
|
|
1273
|
+
*/
|
|
1274
|
+
declare function variance(source: ArrayLike<number>, options?: {
|
|
1275
|
+
ddof?: number;
|
|
1276
|
+
skipna?: boolean;
|
|
1277
|
+
}): number;
|
|
1278
|
+
/**
|
|
1279
|
+
* Standard deviation: compute a single standard deviation over the whole series, dropping NaNs.
|
|
1280
|
+
* Uses `ddof` (delta degrees of freedom) like NumPy/pandas: denominator = N - ddof.
|
|
1281
|
+
* Default pandas behavior is sample standard deviation (ddof=1), so the default here is ddof=1.
|
|
1282
|
+
*/
|
|
1283
|
+
declare function stdev(source: ArrayLike<number>, options?: {
|
|
1284
|
+
ddof?: number;
|
|
1285
|
+
skipna?: boolean;
|
|
1286
|
+
}): number;
|
|
1287
|
+
/**
|
|
1288
|
+
* Pairwise covariance: cov(X,Y) = E[XY] - E[X]E[Y]
|
|
1289
|
+
*/
|
|
1290
|
+
declare function covar(x: ArrayLike<number>, y: ArrayLike<number>, options?: {
|
|
1291
|
+
ddof?: number;
|
|
1292
|
+
}): number;
|
|
1293
|
+
/**
|
|
1294
|
+
* Rolling variance over a sliding window. Accepts `{ skipna?, ddof? }`.
|
|
1295
|
+
* @param source Input array
|
|
1296
|
+
* @param period Window length (>0)
|
|
1297
|
+
* @param options Optional `{ skipna?, ddof? }`
|
|
1298
|
+
* @returns Float64Array of rolling variances
|
|
1299
|
+
*/
|
|
1300
|
+
declare function rollvar(source: ArrayLike<number>, period: number, options?: {
|
|
1301
|
+
skipna?: boolean;
|
|
1302
|
+
ddof?: number;
|
|
1303
|
+
}): Float64Array;
|
|
1304
|
+
declare function rollcovar(x: ArrayLike<number>, y: ArrayLike<number>, period: number, options?: {
|
|
1305
|
+
ddof?: number;
|
|
1306
|
+
}): Float64Array;
|
|
1307
|
+
declare function rollstdev(source: ArrayLike<number>, period: number, options?: {
|
|
1308
|
+
skipna?: boolean;
|
|
1309
|
+
ddof?: number;
|
|
1310
|
+
}): Float64Array;
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Compute z-scores for `source`: (x - mean) / std (ddof=1). NaNs preserved.
|
|
1314
|
+
* @param source Input array
|
|
1315
|
+
* @param options Optional `{ skipna? }` to ignore NaNs
|
|
1316
|
+
* @returns Float64Array of z-scores
|
|
1317
|
+
*/
|
|
1318
|
+
declare function zscore(source: ArrayLike<number>, skipna?: boolean): Float64Array;
|
|
1319
|
+
/**
|
|
1320
|
+
* Normalize to [0,1] by min/max scaling. Preserves NaNs when `skipna` is true.
|
|
1321
|
+
* @param source Input array
|
|
1322
|
+
* @param options Optional `{ skipna? }`
|
|
1323
|
+
* @returns Float64Array of normalized values
|
|
1324
|
+
*/
|
|
1325
|
+
declare function norminmax(source: ArrayLike<number>, skipna?: boolean): Float64Array;
|
|
1326
|
+
/**
|
|
1327
|
+
* Pearson correlation between `x` and `y`. When `skipna` is true only
|
|
1328
|
+
* pairwise-valid entries are used; otherwise a dense fast-path is taken.
|
|
1329
|
+
* @param x First input array
|
|
1330
|
+
* @param y Second input array
|
|
1331
|
+
* @param options Optional `{ skipna? }`
|
|
1332
|
+
* @returns Correlation coefficient or NaN
|
|
1333
|
+
*/
|
|
1334
|
+
declare function corr(x: ArrayLike<number>, y: ArrayLike<number>, skipna?: boolean): number;
|
|
1335
|
+
/**
|
|
1336
|
+
* Rolling Pearson correlation computed from rolling covariance and stddev.
|
|
1337
|
+
* Supports alignment modes via `options.outLength` ('min' or 'max').
|
|
1338
|
+
* @param x First input array
|
|
1339
|
+
* @param y Second input array
|
|
1340
|
+
* @param period Window length
|
|
1341
|
+
* @param options Optional `{ skipna?, outLength? }`
|
|
1342
|
+
* @returns Float64Array of rolling correlations
|
|
1343
|
+
*/
|
|
1344
|
+
declare function rollcorr(x: ArrayLike<number>, y: ArrayLike<number>, period: number, options?: {
|
|
1345
|
+
skipna?: boolean;
|
|
1346
|
+
outLength?: 'min' | 'max';
|
|
1347
|
+
}): Float64Array;
|
|
1348
|
+
/**
|
|
1349
|
+
* Winsorize values to the given lower and upper quantile bounds.
|
|
1350
|
+
* Preserves NaNs when `skipna` is true.
|
|
1351
|
+
* @param source Input array
|
|
1352
|
+
* @param options Optional `{ lower?, upper?, skipna? }` where bounds are in [0,1]
|
|
1353
|
+
* @returns Float64Array of winsorized values
|
|
1354
|
+
*/
|
|
1355
|
+
declare function winsorize(source: ArrayLike<number>, options?: {
|
|
1356
|
+
lower?: number;
|
|
1357
|
+
upper?: number;
|
|
1358
|
+
skipna?: boolean;
|
|
1359
|
+
}): Float64Array;
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Compute the (possibly weighted) mean of `source`.
|
|
1363
|
+
* By default NaNs are skipped (`skipna=true`). When `weights` are provided they
|
|
1364
|
+
* must match `source` length and the function computes the weighted mean.
|
|
1365
|
+
* A dense fast-path is used when the global optimization allows it.
|
|
1366
|
+
* @param source Input array
|
|
1367
|
+
* @param options Optional `{ weights?, skipna? }`
|
|
1368
|
+
* @returns Mean value or NaN when undefined
|
|
1369
|
+
*/
|
|
1370
|
+
declare function mean(source: ArrayLike<number>, options?: {
|
|
1371
|
+
weights?: ArrayLike<number>;
|
|
1372
|
+
skipna?: boolean;
|
|
1373
|
+
}): number;
|
|
1374
|
+
/**
|
|
1375
|
+
* Rolling mean (moving average) over a sliding window of length `period`.
|
|
1376
|
+
* When `skipna` is true, NaNs inside windows are ignored; windows with no
|
|
1377
|
+
* valid values produce NaN. A fast dense path is used when no NaNs.
|
|
1378
|
+
* @param source Input array
|
|
1379
|
+
* @param period Window length (>0)
|
|
1380
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
1381
|
+
* @returns Float64Array of rolling means
|
|
1382
|
+
*/
|
|
1383
|
+
declare function rollmean(source: ArrayLike<number>, period: number, skipna?: boolean): Float64Array;
|
|
1384
|
+
/**
|
|
1385
|
+
* Harmonic mean (optionally weighted). Values must be positive; NaNs are
|
|
1386
|
+
* ignored when `skipna` is true. Returns NaN when no valid values.
|
|
1387
|
+
* @param source Input array
|
|
1388
|
+
* @param options Optional `{ weights?, skipna? }`
|
|
1389
|
+
* @returns Harmonic mean or NaN
|
|
1390
|
+
*/
|
|
1391
|
+
declare function hmean(source: ArrayLike<number>, options?: {
|
|
1392
|
+
weights?: ArrayLike<number>;
|
|
1393
|
+
skipna?: boolean;
|
|
1394
|
+
}): number;
|
|
1395
|
+
/**
|
|
1396
|
+
* Geometric mean (optionally weighted). Values must be positive; NaNs are
|
|
1397
|
+
* ignored when `skipna` is true. Returns NaN when no valid values.
|
|
1398
|
+
* @param source Input array
|
|
1399
|
+
* @param options Optional `{ weights?, skipna? }`
|
|
1400
|
+
* @returns Geometric mean or NaN
|
|
1401
|
+
*/
|
|
1402
|
+
declare function gmean(source: ArrayLike<number>, options?: {
|
|
1403
|
+
weights?: ArrayLike<number>;
|
|
1404
|
+
skipna?: boolean;
|
|
1405
|
+
}): number;
|
|
1406
|
+
/**
|
|
1407
|
+
* Mean absolute deviation from the mean. When `skipna` is true NaNs are
|
|
1408
|
+
* ignored. Returns NaN when the input contains no valid values.
|
|
1409
|
+
* @param source Input array
|
|
1410
|
+
* @param options Optional `{ skipna? }`
|
|
1411
|
+
* @returns Mean absolute deviation or NaN
|
|
1412
|
+
*/
|
|
1413
|
+
declare function mad(source: ArrayLike<number>, skipna?: boolean): number;
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* Median of `source` (ignores NaNs). Implemented via `quantile(source, 0.5)`.
|
|
1417
|
+
* @param source Input array
|
|
1418
|
+
* @returns Median value or NaN
|
|
1419
|
+
*/
|
|
1420
|
+
declare function median(source: ArrayLike<number>): number;
|
|
1421
|
+
/**
|
|
1422
|
+
* Compute the rolling median over a sliding window.
|
|
1423
|
+
* Ignores NaNs and validates `period`.
|
|
1424
|
+
* Returns a Float64Array with NaN entries for positions before the window fills.
|
|
1425
|
+
* @param source Input array
|
|
1426
|
+
* @param period Window length
|
|
1427
|
+
* @returns Float64Array of rolling medians
|
|
1428
|
+
*/
|
|
1429
|
+
declare function rollmedian(source: ArrayLike<number>, period: number): Float64Array;
|
|
1430
|
+
/**
|
|
1431
|
+
* Compute the quantile `q` of `source`, ignoring NaNs. Implements a
|
|
1432
|
+
* selection-based algorithm using quickselect for expected linear time.
|
|
1433
|
+
* @param source Input array
|
|
1434
|
+
* @param q Quantile in [0,1]
|
|
1435
|
+
* @returns Quantile value or NaN
|
|
1436
|
+
*/
|
|
1437
|
+
declare function quantile(source: ArrayLike<number>, q: number): number;
|
|
1438
|
+
/**
|
|
1439
|
+
* Compute multiple percentiles (quantiles) for `source`. When `qs.length`
|
|
1440
|
+
* is small, selection is used for each quantile; otherwise the data are
|
|
1441
|
+
* sorted once for efficiency.
|
|
1442
|
+
* @param source Input array
|
|
1443
|
+
* @param qs Array of quantiles in [0,1]
|
|
1444
|
+
* @returns Array of quantile values
|
|
1445
|
+
*/
|
|
1446
|
+
declare function percentiles(source: ArrayLike<number>, qs: number[]): number[];
|
|
1447
|
+
/**
|
|
1448
|
+
* Compute the rolling quantile over a sliding window.
|
|
1449
|
+
* Ignores NaNs and validates `period` and `q`.
|
|
1450
|
+
* Returns a Float64Array with NaN entries for positions before the window fills.
|
|
1451
|
+
* @param source Input array
|
|
1452
|
+
* @param period Window length
|
|
1453
|
+
* @param q Quantile in [0,1]
|
|
1454
|
+
* @returns Float64Array of rolling quantiles
|
|
1455
|
+
*/
|
|
1456
|
+
declare function rollquantile(source: ArrayLike<number>, period: number, q: number): Float64Array;
|
|
1457
|
+
|
|
1458
|
+
/**
|
|
1459
|
+
* Fisher-Pearson sample skewness (ignores NaNs). Returns NaN when insufficient data.
|
|
1460
|
+
* @param source Input array
|
|
1461
|
+
* @returns Skewness or NaN
|
|
1462
|
+
*/
|
|
1463
|
+
declare function skew(source: ArrayLike<number>): number;
|
|
1464
|
+
/**
|
|
1465
|
+
* Excess kurtosis (kurtosis - 3) for `source` (ignores NaNs). Returns NaN when insufficient data.
|
|
1466
|
+
* @param source Input array
|
|
1467
|
+
* @returns Excess kurtosis or NaN
|
|
1468
|
+
*/
|
|
1469
|
+
declare function kurtosis(source: ArrayLike<number>): number;
|
|
1470
|
+
/**
|
|
1471
|
+
* Rolling skewness over a sliding window of length `period`.
|
|
1472
|
+
* @param source Input array
|
|
1473
|
+
* @param period Window length
|
|
1474
|
+
* @returns Float64Array of rolling skewness values
|
|
1475
|
+
*/
|
|
1476
|
+
declare function rollskew(source: ArrayLike<number>, period: number): Float64Array;
|
|
1477
|
+
/**
|
|
1478
|
+
* Rolling excess kurtosis over a sliding window of length `period`.
|
|
1479
|
+
* @param source Input array
|
|
1480
|
+
* @param period Window length
|
|
1481
|
+
* @returns Float64Array of rolling kurtosis values
|
|
1482
|
+
*/
|
|
1483
|
+
declare function rollkurtosis(source: ArrayLike<number>, period: number): Float64Array;
|
|
1484
|
+
|
|
1485
|
+
/**
|
|
1486
|
+
* In-place Fisher–Yates shuffle of `arr`.
|
|
1487
|
+
* Uses `Math.random()`; tests should stub `Math.random` for determinism.
|
|
1488
|
+
* @param arr Array to shuffle (mutated)
|
|
1489
|
+
* @returns The shuffled array (same reference)
|
|
1490
|
+
*/
|
|
1491
|
+
declare function shuffle<T>(arr: T[]): T[];
|
|
1492
|
+
/**
|
|
1493
|
+
* Draw `k` unique samples without replacement from `arr`.
|
|
1494
|
+
* If `k` >= arr.length a shallow copy is returned. Uses `Math.random()`.
|
|
1495
|
+
* @param arr Source array
|
|
1496
|
+
* @param k Number of samples to draw
|
|
1497
|
+
* @returns Array of sampled elements
|
|
1498
|
+
*/
|
|
1499
|
+
declare function sample<T>(arr: T[], k: number): T[];
|
|
1500
|
+
/**
|
|
1501
|
+
* Draw `k` bootstrap samples (with replacement) from `arr`.
|
|
1502
|
+
* Uses `Math.random()`; tests should stub `Math.random` for determinism.
|
|
1503
|
+
* @param arr Source array
|
|
1504
|
+
* @param k Number of draws
|
|
1505
|
+
* @returns Array of sampled elements (with replacement)
|
|
1506
|
+
*/
|
|
1507
|
+
declare function bootstrap<T>(arr: T[], k: number): T[];
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* Stats barrel: re-export statistical helpers for convenient imports.
|
|
1511
|
+
*/
|
|
1512
|
+
|
|
1513
|
+
declare const index_d_bootstrap: typeof bootstrap;
|
|
1514
|
+
declare const index_d_corr: typeof corr;
|
|
1515
|
+
declare const index_d_covar: typeof covar;
|
|
1516
|
+
declare const index_d_gmean: typeof gmean;
|
|
1517
|
+
declare const index_d_hmean: typeof hmean;
|
|
1518
|
+
declare const index_d_kurtosis: typeof kurtosis;
|
|
1519
|
+
declare const index_d_mad: typeof mad;
|
|
1520
|
+
declare const index_d_mean: typeof mean;
|
|
1521
|
+
declare const index_d_median: typeof median;
|
|
1522
|
+
declare const index_d_norminmax: typeof norminmax;
|
|
1523
|
+
declare const index_d_percentiles: typeof percentiles;
|
|
1524
|
+
declare const index_d_quantile: typeof quantile;
|
|
1525
|
+
declare const index_d_rollcorr: typeof rollcorr;
|
|
1526
|
+
declare const index_d_rollcovar: typeof rollcovar;
|
|
1527
|
+
declare const index_d_rollkurtosis: typeof rollkurtosis;
|
|
1528
|
+
declare const index_d_rollmean: typeof rollmean;
|
|
1529
|
+
declare const index_d_rollmedian: typeof rollmedian;
|
|
1530
|
+
declare const index_d_rollquantile: typeof rollquantile;
|
|
1531
|
+
declare const index_d_rollskew: typeof rollskew;
|
|
1532
|
+
declare const index_d_rollstdev: typeof rollstdev;
|
|
1533
|
+
declare const index_d_rollvar: typeof rollvar;
|
|
1534
|
+
declare const index_d_sample: typeof sample;
|
|
1535
|
+
declare const index_d_shuffle: typeof shuffle;
|
|
1536
|
+
declare const index_d_skew: typeof skew;
|
|
1537
|
+
declare const index_d_stdev: typeof stdev;
|
|
1538
|
+
declare const index_d_winsorize: typeof winsorize;
|
|
1539
|
+
declare const index_d_zscore: typeof zscore;
|
|
1540
|
+
declare namespace index_d {
|
|
1541
|
+
export {
|
|
1542
|
+
index_d_bootstrap as bootstrap,
|
|
1543
|
+
index_d_corr as corr,
|
|
1544
|
+
index_d_covar as covar,
|
|
1545
|
+
index_d_gmean as gmean,
|
|
1546
|
+
index_d_hmean as hmean,
|
|
1547
|
+
index_d_kurtosis as kurtosis,
|
|
1548
|
+
index_d_mad as mad,
|
|
1549
|
+
index_d_mean as mean,
|
|
1550
|
+
index_d_median as median,
|
|
1551
|
+
index_d_norminmax as norminmax,
|
|
1552
|
+
index_d_percentiles as percentiles,
|
|
1553
|
+
index_d_quantile as quantile,
|
|
1554
|
+
index_d_rollcorr as rollcorr,
|
|
1555
|
+
index_d_rollcovar as rollcovar,
|
|
1556
|
+
index_d_rollkurtosis as rollkurtosis,
|
|
1557
|
+
index_d_rollmean as rollmean,
|
|
1558
|
+
index_d_rollmedian as rollmedian,
|
|
1559
|
+
index_d_rollquantile as rollquantile,
|
|
1560
|
+
index_d_rollskew as rollskew,
|
|
1561
|
+
index_d_rollstdev as rollstdev,
|
|
1562
|
+
index_d_rollvar as rollvar,
|
|
1563
|
+
index_d_sample as sample,
|
|
1564
|
+
index_d_shuffle as shuffle,
|
|
1565
|
+
index_d_skew as skew,
|
|
1566
|
+
index_d_stdev as stdev,
|
|
1567
|
+
variance as var,
|
|
1568
|
+
index_d_winsorize as winsorize,
|
|
1569
|
+
index_d_zscore as zscore,
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
export { arr_d as arr, index_d$2 as math, index_d as stats, index_d$1 as ta };
|