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,1194 @@
|
|
|
1
|
+
// Generated untyped declarations with JSDoc preserved
|
|
2
|
+
|
|
3
|
+
export type UltoscOptions = {
|
|
4
|
+
s1?: number;
|
|
5
|
+
s2?: number;
|
|
6
|
+
s3?: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Know Sure Thing (KST) momentum oscillator
|
|
11
|
+
* Default parameters match common KST configuration
|
|
12
|
+
*/
|
|
13
|
+
export type KstOptions = {
|
|
14
|
+
r1?: number;
|
|
15
|
+
r2?: number;
|
|
16
|
+
r3?: number;
|
|
17
|
+
r4?: number;
|
|
18
|
+
n1?: number;
|
|
19
|
+
n2?: number;
|
|
20
|
+
n3?: number;
|
|
21
|
+
n4?: number;
|
|
22
|
+
w1?: number;
|
|
23
|
+
w2?: number;
|
|
24
|
+
w3?: number;
|
|
25
|
+
w4?: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type IchimokuOptions = {
|
|
29
|
+
tenkan?: number;
|
|
30
|
+
kijun?: number;
|
|
31
|
+
senkouB?: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
declare namespace math {
|
|
35
|
+
/**
|
|
36
|
+
* Element-wise absolute value.
|
|
37
|
+
* @param source Input array
|
|
38
|
+
* @returns Float64Array of absolute values
|
|
39
|
+
*/
|
|
40
|
+
export function abs(source: ArrayLike<number>): number[];
|
|
41
|
+
/**
|
|
42
|
+
* Element-wise addition.
|
|
43
|
+
* - If `b` is a number, returns `a + b` for each element.
|
|
44
|
+
* - If `b` is an array, returns element-wise sum up to the shorter length.
|
|
45
|
+
* @param a Left operand array
|
|
46
|
+
* @param b Right operand array or scalar
|
|
47
|
+
* @returns Float64Array of sums
|
|
48
|
+
*/
|
|
49
|
+
export function add(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
50
|
+
/**
|
|
51
|
+
* Logical AND for boolean masks (Uint8Array) or with a scalar.
|
|
52
|
+
* Returns a Uint8Array of 1/0 values.
|
|
53
|
+
* @param a Left boolean mask
|
|
54
|
+
* @param b Right boolean mask or scalar
|
|
55
|
+
* @returns Uint8Array mask result
|
|
56
|
+
*/
|
|
57
|
+
export function and(a: Uint8Array, b: Uint8Array | number): number[];
|
|
58
|
+
/**
|
|
59
|
+
* Index of the first maximum value (ignores NaNs). Returns -1 if none found.
|
|
60
|
+
* @param source Input array
|
|
61
|
+
* @returns Index of maximum or -1
|
|
62
|
+
*/
|
|
63
|
+
export function argmax(source: ArrayLike<number>): number;
|
|
64
|
+
/**
|
|
65
|
+
* Index of the first minimum value (ignores NaNs). Returns -1 if none found.
|
|
66
|
+
* @param source Input array
|
|
67
|
+
* @returns Index of minimum or -1
|
|
68
|
+
*/
|
|
69
|
+
export function argmin(source: ArrayLike<number>): number;
|
|
70
|
+
/**
|
|
71
|
+
* Element-wise average: (a + b) / 2.
|
|
72
|
+
* Computes the average without allocating temporaries.
|
|
73
|
+
* @param a First array
|
|
74
|
+
* @param b Second array or scalar
|
|
75
|
+
* @returns Float64Array of averages
|
|
76
|
+
*/
|
|
77
|
+
export function avg(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
78
|
+
/**
|
|
79
|
+
* Element-wise ceil operation.
|
|
80
|
+
* @param source Input array
|
|
81
|
+
* @returns Float64Array of ceiled values
|
|
82
|
+
*/
|
|
83
|
+
export function ceil(source: ArrayLike<number>): number[];
|
|
84
|
+
/**
|
|
85
|
+
* Clamp values to the inclusive range [lo, hi]. Preserves NaN entries.
|
|
86
|
+
* @param source Input array
|
|
87
|
+
* @param lo Lower bound
|
|
88
|
+
* @param hi Upper bound
|
|
89
|
+
* @returns Float64Array with values clamped or NaN preserved
|
|
90
|
+
*/
|
|
91
|
+
export function clamp(source: ArrayLike<number>, lo: number, hi: number): number[];
|
|
92
|
+
/**
|
|
93
|
+
* Cumulative maximum: at each index the maximum over all prior valid elements.
|
|
94
|
+
* NaNs are preserved in the output at positions where input is NaN.
|
|
95
|
+
* @param source Input array
|
|
96
|
+
* @returns Float64Array of cumulative maxima
|
|
97
|
+
*/
|
|
98
|
+
export function cummax(source: ArrayLike<number>): number[];
|
|
99
|
+
/**
|
|
100
|
+
* Cumulative minimum: at each index the minimum over all prior valid elements.
|
|
101
|
+
* NaNs are preserved in the output at positions where input is NaN.
|
|
102
|
+
* @param source Input array
|
|
103
|
+
* @returns Float64Array of cumulative minima
|
|
104
|
+
*/
|
|
105
|
+
export function cummin(source: ArrayLike<number>): number[];
|
|
106
|
+
/**
|
|
107
|
+
* Cumulative product (NaN-preserving). At each index the product of all prior valid elements.
|
|
108
|
+
* @param source Input array
|
|
109
|
+
* @returns Float64Array of cumulative products (NaN where input was NaN)
|
|
110
|
+
*/
|
|
111
|
+
export function cumprod(source: ArrayLike<number>): number[];
|
|
112
|
+
/**
|
|
113
|
+
* Cumulative sum preserving NaNs: NaN entries do not increase the running sum
|
|
114
|
+
* but are represented as the running total up to that point.
|
|
115
|
+
* @param source Input array
|
|
116
|
+
* @returns Float64Array of cumulative sums
|
|
117
|
+
*/
|
|
118
|
+
export function cumsum(source: ArrayLike<number>): number[];
|
|
119
|
+
/**
|
|
120
|
+
* First difference: output[i] = source[i] - source[i-1].
|
|
121
|
+
* The first element is NaN (no previous value).
|
|
122
|
+
* @param source Input array
|
|
123
|
+
* @returns Float64Array of differences (first element NaN)
|
|
124
|
+
*/
|
|
125
|
+
export function diff(source: ArrayLike<number>): number[];
|
|
126
|
+
/**
|
|
127
|
+
* Element-wise division.
|
|
128
|
+
* - If `b` is a number, divides each element of `a` by `b`.
|
|
129
|
+
* - If `b` is an array, returns element-wise quotients up to the shorter length.
|
|
130
|
+
* @param a Numerator array
|
|
131
|
+
* @param b Denominator array or scalar
|
|
132
|
+
* @returns Float64Array of quotients
|
|
133
|
+
*/
|
|
134
|
+
export function div(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
135
|
+
/**
|
|
136
|
+
* Dot product of two vectors: sum_i x[i] * y[i].
|
|
137
|
+
* Operates up to the shorter length of the inputs.
|
|
138
|
+
* @param x First vector
|
|
139
|
+
* @param y Second vector
|
|
140
|
+
* @returns Scalar dot product
|
|
141
|
+
*/
|
|
142
|
+
export function dot(x: ArrayLike<number>, y: ArrayLike<number>): number;
|
|
143
|
+
/**
|
|
144
|
+
* Element-wise equality comparison using `Number.EPSILON` tolerance.
|
|
145
|
+
* @param a Left operand
|
|
146
|
+
* @param b Right operand or scalar
|
|
147
|
+
* @returns Uint8Array mask of equality tests
|
|
148
|
+
*/
|
|
149
|
+
export function eq(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
150
|
+
/**
|
|
151
|
+
* Element-wise floor operation.
|
|
152
|
+
* @param source Input array
|
|
153
|
+
* @returns Float64Array of floored values
|
|
154
|
+
*/
|
|
155
|
+
export function floor(source: ArrayLike<number>): number[];
|
|
156
|
+
/**
|
|
157
|
+
* Element-wise greater-than comparison. Returns `Uint8Array` mask with 1 where true.
|
|
158
|
+
* @param a Left operand
|
|
159
|
+
* @param b Right operand or scalar
|
|
160
|
+
* @returns Uint8Array mask of comparisons
|
|
161
|
+
*/
|
|
162
|
+
export function gt(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
163
|
+
/**
|
|
164
|
+
* Element-wise greater-than-or-equal comparison (with epsilon tolerance).
|
|
165
|
+
* @param a Left operand
|
|
166
|
+
* @param b Right operand or scalar
|
|
167
|
+
* @returns Uint8Array mask of comparisons
|
|
168
|
+
*/
|
|
169
|
+
export function gte(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
170
|
+
/**
|
|
171
|
+
* Element-wise less-than comparison. Returns `Uint8Array` mask with 1 where true.
|
|
172
|
+
* @param a Left operand
|
|
173
|
+
* @param b Right operand or scalar
|
|
174
|
+
* @returns Uint8Array mask of comparisons
|
|
175
|
+
*/
|
|
176
|
+
export function lt(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
177
|
+
/**
|
|
178
|
+
* Element-wise less-than-or-equal comparison (with epsilon tolerance).
|
|
179
|
+
* @param a Left operand
|
|
180
|
+
* @param b Right operand or scalar
|
|
181
|
+
* @returns Uint8Array mask of comparisons
|
|
182
|
+
*/
|
|
183
|
+
export function lte(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
184
|
+
/**
|
|
185
|
+
* Maximum of an array, ignoring NaNs. Returns NaN if no valid entries.
|
|
186
|
+
* @param source Input array
|
|
187
|
+
* @returns Maximum value or NaN
|
|
188
|
+
*/
|
|
189
|
+
export function max(source: ArrayLike<number>): number;
|
|
190
|
+
/**
|
|
191
|
+
* Minimum of an array, ignoring NaNs. Returns NaN if no valid entries.
|
|
192
|
+
* @param source Input array
|
|
193
|
+
* @returns Minimum value or NaN
|
|
194
|
+
*/
|
|
195
|
+
export function min(source: ArrayLike<number>): number;
|
|
196
|
+
/**
|
|
197
|
+
* Element-wise multiplication.
|
|
198
|
+
* - If `b` is a number, scales each element of `a` by `b`.
|
|
199
|
+
* - If `b` is an array, returns element-wise products up to the shorter length.
|
|
200
|
+
* @param a Left operand array
|
|
201
|
+
* @param b Right operand array or scalar
|
|
202
|
+
* @returns Float64Array of products
|
|
203
|
+
*/
|
|
204
|
+
export function mul(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
205
|
+
/**
|
|
206
|
+
* Element-wise inequality comparison.
|
|
207
|
+
* @param a Left operand
|
|
208
|
+
* @param b Right operand or scalar
|
|
209
|
+
* @returns Uint8Array mask where elements are not equal
|
|
210
|
+
*/
|
|
211
|
+
export function neq(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
212
|
+
/**
|
|
213
|
+
* Vector p-norm. Supports common p values (1, 2, Infinity) with a fast dense path.
|
|
214
|
+
* When `skipna` is true the implementation ignores NaNs and returns NaN if no valid entries exist.
|
|
215
|
+
* @param x Input vector
|
|
216
|
+
* @param p Norm order (default 2)
|
|
217
|
+
* @param skipna Whether to ignore NaNs (default true)
|
|
218
|
+
* @returns Norm value or NaN
|
|
219
|
+
*/
|
|
220
|
+
export function norm(x: ArrayLike<number>, p?: number, skipna?: boolean): number;
|
|
221
|
+
/**
|
|
222
|
+
* Logical NOT for a boolean mask (Uint8Array).
|
|
223
|
+
* @param a Input boolean mask
|
|
224
|
+
* @returns Uint8Array mask with bits inverted
|
|
225
|
+
*/
|
|
226
|
+
export function not(a: Uint8Array): number[];
|
|
227
|
+
/**
|
|
228
|
+
* Ordinary least squares for a simple linear model y = intercept + slope * x.
|
|
229
|
+
* Ignores paired NaN entries and returns NaN coefficients if no valid pairs or singular design.
|
|
230
|
+
* @param x Predictor values
|
|
231
|
+
* @param y Response values
|
|
232
|
+
* @returns Object with `intercept` and `slope` or NaNs on failure
|
|
233
|
+
*/
|
|
234
|
+
export function ols(x: ArrayLike<number>, y: ArrayLike<number>): {
|
|
235
|
+
intercept: number;
|
|
236
|
+
slope: number;
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Multiple linear regression using normal equations (adds intercept column internally).
|
|
240
|
+
* Returns coefficient vector or null if the normal matrix is singular or inputs are empty.
|
|
241
|
+
* @param X Design matrix (rows = observations, cols = features)
|
|
242
|
+
* @param y Response vector
|
|
243
|
+
* @returns Coefficient array [intercept, beta1, beta2, ...] or null
|
|
244
|
+
*/
|
|
245
|
+
export function olsMulti(X: number[][], y: number[]): number[] | null;
|
|
246
|
+
/**
|
|
247
|
+
* Logical OR for boolean masks (Uint8Array) or with a scalar.
|
|
248
|
+
* Returns a Uint8Array of 1/0 values.
|
|
249
|
+
* @param a Left boolean mask
|
|
250
|
+
* @param b Right boolean mask or scalar
|
|
251
|
+
* @returns Uint8Array mask result
|
|
252
|
+
*/
|
|
253
|
+
export function or(a: Uint8Array, b: Uint8Array | number): number[];
|
|
254
|
+
/**
|
|
255
|
+
* Product of array elements, ignoring NaNs. Returns NaN if no valid entries.
|
|
256
|
+
* @param source Input array
|
|
257
|
+
* @returns Product of values or NaN
|
|
258
|
+
*/
|
|
259
|
+
export function prod(source: ArrayLike<number>): number;
|
|
260
|
+
/**
|
|
261
|
+
* Generate `n` standard normal samples using the Box-Muller transform.
|
|
262
|
+
* Uses `Math.random()`; tests should stub `Math.random` for determinism.
|
|
263
|
+
* @param n Number of samples to generate
|
|
264
|
+
* @param options Optional `{ mean, sd }` to shift/scale samples
|
|
265
|
+
* @returns Float64Array of length `n`
|
|
266
|
+
*/
|
|
267
|
+
export function randnormal(n: number, options?: {
|
|
268
|
+
mean?: number;
|
|
269
|
+
sd?: number;
|
|
270
|
+
}): number[];
|
|
271
|
+
/**
|
|
272
|
+
* Generate `n` uniform random values in [lo, hi).
|
|
273
|
+
* Uses `Math.random()`; tests should stub `Math.random` for determinism.
|
|
274
|
+
* @param n Number of samples to generate
|
|
275
|
+
* @param options Optional `{ lo, hi }` bounds (defaults to 0..1)
|
|
276
|
+
* @returns Float64Array of length `n`
|
|
277
|
+
*/
|
|
278
|
+
export function randuniform(n: number, options?: {
|
|
279
|
+
lo?: number;
|
|
280
|
+
hi?: number;
|
|
281
|
+
}): number[];
|
|
282
|
+
/**
|
|
283
|
+
* Rolling argmax: returns the index (into `source`) of the maximum value in each window.
|
|
284
|
+
* Positions before the window fills are NaN.
|
|
285
|
+
* @param source Input array
|
|
286
|
+
* @param period Window length
|
|
287
|
+
* @returns Float64Array of argmax indices (NaN when not available)
|
|
288
|
+
*/
|
|
289
|
+
export function rollargmax(source: ArrayLike<number>, period: number): number[];
|
|
290
|
+
/**
|
|
291
|
+
* Rolling argmin: returns the index (into `source`) of the minimum value in each window.
|
|
292
|
+
* Positions before the window fills are NaN.
|
|
293
|
+
* @param source Input array
|
|
294
|
+
* @param period Window length
|
|
295
|
+
* @returns Float64Array of argmin indices (NaN when not available)
|
|
296
|
+
*/
|
|
297
|
+
export function rollargmin(source: ArrayLike<number>, period: number): number[];
|
|
298
|
+
/**
|
|
299
|
+
* Rolling maximum over a window. NaN-aware: windows containing only NaNs produce NaN.
|
|
300
|
+
* @param source Input values
|
|
301
|
+
* @param period Window length (must be > 0)
|
|
302
|
+
* @returns Float64Array of rolling maxima (NaN for positions before the window fills)
|
|
303
|
+
*/
|
|
304
|
+
export function rollmax(source: ArrayLike<number>, period: number): number[];
|
|
305
|
+
/**
|
|
306
|
+
* Rolling minimum over a window. NaN-aware: windows containing only NaNs produce NaN.
|
|
307
|
+
* @param source Input values
|
|
308
|
+
* @param period Window length (must be > 0)
|
|
309
|
+
* @returns Float64Array of rolling minima (NaN for positions before the window fills)
|
|
310
|
+
*/
|
|
311
|
+
export function rollmin(source: ArrayLike<number>, period: number): number[];
|
|
312
|
+
/**
|
|
313
|
+
* Compute rolling minima and maxima pairwise over two input series.
|
|
314
|
+
* Optional callback `cb(minVal, maxVal, i)` is invoked for each computed window.
|
|
315
|
+
* @param minSource Input for minima
|
|
316
|
+
* @param maxSource Input for maxima
|
|
317
|
+
* @param period Window length (must be > 0)
|
|
318
|
+
* @param cb Optional callback invoked per window
|
|
319
|
+
* @returns Object with `min` and `max` Float64Array results
|
|
320
|
+
*/
|
|
321
|
+
export function rollminmax(minSource: ArrayLike<number>, maxSource: ArrayLike<number>, period: number, cb?: (minVal: number, maxVal: number, i: number) => void): {
|
|
322
|
+
min: number[];
|
|
323
|
+
max: number[];
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Rolling product over a window. NaN-aware: windows with no valid entries produce NaN.
|
|
327
|
+
* Zeros are handled efficiently by tracking counts.
|
|
328
|
+
* @param source Input array
|
|
329
|
+
* @param period Window length (must be > 0)
|
|
330
|
+
* @returns Float64Array of rolling products (NaN for positions before window fills)
|
|
331
|
+
*/
|
|
332
|
+
export function rollprod(source: ArrayLike<number>, period: number): number[];
|
|
333
|
+
/**
|
|
334
|
+
* Rolling sum over a window with optional NaN-skipping.
|
|
335
|
+
* If `skipna` is true, windows with no valid values produce NaN.
|
|
336
|
+
* Supports a fast dense path when inputs contain no NaNs.
|
|
337
|
+
* @param source Input array
|
|
338
|
+
* @param period Window length (must be > 0)
|
|
339
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
340
|
+
* @returns Float64Array of rolling sums (NaN for positions before window fills)
|
|
341
|
+
*/
|
|
342
|
+
export function rollsum(source: ArrayLike<number>, period: number, skipna?: boolean): number[];
|
|
343
|
+
/**
|
|
344
|
+
* Round values to nearest integer. Ties are rounded away from zero.
|
|
345
|
+
* @param source Input array
|
|
346
|
+
* @returns Float64Array of rounded integers
|
|
347
|
+
*/
|
|
348
|
+
export function round(source: ArrayLike<number>): number[];
|
|
349
|
+
/**
|
|
350
|
+
* Scale an array by a scalar: `source * s`.
|
|
351
|
+
* @param source Input array
|
|
352
|
+
* @param s Scale factor
|
|
353
|
+
* @returns Float64Array scaled values
|
|
354
|
+
*/
|
|
355
|
+
export function scale(source: ArrayLike<number>, s: number): number[];
|
|
356
|
+
/**
|
|
357
|
+
* Element-wise sign (-1, 0, 1) for each entry.
|
|
358
|
+
* @param source Input array
|
|
359
|
+
* @returns Float64Array of sign values
|
|
360
|
+
*/
|
|
361
|
+
export function sign(source: ArrayLike<number>): number[];
|
|
362
|
+
/**
|
|
363
|
+
* Element-wise subtraction.
|
|
364
|
+
* - If `b` is a number, returns `a - b` for each element.
|
|
365
|
+
* - If `b` is an array, returns element-wise difference up to the shorter length.
|
|
366
|
+
* @param a Left operand array
|
|
367
|
+
* @param b Right operand array or scalar
|
|
368
|
+
* @returns Float64Array of differences
|
|
369
|
+
*/
|
|
370
|
+
export function sub(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
371
|
+
/**
|
|
372
|
+
* Sum of array elements with optional NaN-skipping.
|
|
373
|
+
* When `skipna` is true (default) NaNs are ignored; returns NaN if no valid samples.
|
|
374
|
+
* Uses a fast dense path when global optimization allows it.
|
|
375
|
+
* @param source Input array
|
|
376
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
377
|
+
* @returns Sum or NaN
|
|
378
|
+
*/
|
|
379
|
+
export function sum(source: ArrayLike<number>, skipna?: boolean): number;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
declare namespace ta {
|
|
383
|
+
/**
|
|
384
|
+
* Accumulation/Distribution (AD) line.
|
|
385
|
+
* Computes the cumulative money flow: AD[i] = AD[i-1] + MFM[i] * volume[i],
|
|
386
|
+
* where MFM = ((close - low) - (high - close)) / (high - low).
|
|
387
|
+
* NaNs propagate for invalid input tuples and the accumulator only updates on finite values.
|
|
388
|
+
* @param high High price series
|
|
389
|
+
* @param low Low price series
|
|
390
|
+
* @param close Close price series
|
|
391
|
+
* @param volume Volume series
|
|
392
|
+
* @returns Float64Array of AD values
|
|
393
|
+
*/
|
|
394
|
+
export function ad(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, volume: ArrayLike<number>): number[];
|
|
395
|
+
/**
|
|
396
|
+
* Accumulation/Distribution Oscillator (ADOSC).
|
|
397
|
+
* Computes the difference between short- and long-term EMAs of the cumulative
|
|
398
|
+
* money flow (AD). Supports NaN-aware and dense fast-paths; outputs are NaN
|
|
399
|
+
* until the long EMA seeding is complete.
|
|
400
|
+
* @param high High price series
|
|
401
|
+
* @param low Low price series
|
|
402
|
+
* @param close Close price series
|
|
403
|
+
* @param volume Volume series
|
|
404
|
+
* @param shortPeriod Short EMA period
|
|
405
|
+
* @param longPeriod Long EMA period
|
|
406
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
407
|
+
* @returns Float64Array of ADOSC values (NaN where undefined)
|
|
408
|
+
*/
|
|
409
|
+
export function adosc(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, volume: ArrayLike<number>, shortPeriod: number, longPeriod: number, skipna?: boolean): number[];
|
|
410
|
+
/**
|
|
411
|
+
* Average Directional Index (ADX).
|
|
412
|
+
* @param high High price series
|
|
413
|
+
* @param low Low price series
|
|
414
|
+
* @param close Close price series
|
|
415
|
+
* @param period Lookback period (must be > 0)
|
|
416
|
+
* @returns Float64Array of ADX values (NaN where undefined)
|
|
417
|
+
*/
|
|
418
|
+
export function adx(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): number[];
|
|
419
|
+
/**
|
|
420
|
+
* ADXR (Average DX Rating) - smoothed ADX.
|
|
421
|
+
* @param high High price series
|
|
422
|
+
* @param low Low price series
|
|
423
|
+
* @param close Close price series
|
|
424
|
+
* @param period Lookback period (must be > 0)
|
|
425
|
+
* @returns Float64Array of ADXR values (NaN where undefined)
|
|
426
|
+
*/
|
|
427
|
+
export function adxr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): number[];
|
|
428
|
+
/**
|
|
429
|
+
* Awesome Oscillator (AO): difference between short and long simple moving averages
|
|
430
|
+
* of the median price ((high + low)/2). Supports NaN-aware and dense fast-paths.
|
|
431
|
+
* @param high High price series
|
|
432
|
+
* @param low Low price series
|
|
433
|
+
* @param shortPeriod Short SMA period (default 5)
|
|
434
|
+
* @param longPeriod Long SMA period (default 34)
|
|
435
|
+
* @param skipna When true, ignore NaNs inside windows; false forces dense path
|
|
436
|
+
* @returns Float64Array AO series (NaN where undefined)
|
|
437
|
+
*/
|
|
438
|
+
export function ao(high: ArrayLike<number>, low: ArrayLike<number>, shortPeriod?: number, longPeriod?: number, skipna?: boolean): number[];
|
|
439
|
+
/**
|
|
440
|
+
* Absolute Price Oscillator (APO).
|
|
441
|
+
* Computes the difference between a short and a long EMA of `src`.
|
|
442
|
+
* Skips NaNs and seeds EMAs on the first valid value; returns NaN
|
|
443
|
+
* for indices before both EMAs have filled.
|
|
444
|
+
* @param src Input series
|
|
445
|
+
* @param shortPeriod Short EMA period
|
|
446
|
+
* @param longPeriod Long EMA period
|
|
447
|
+
* @returns Float64Array of APO values (NaN where undefined)
|
|
448
|
+
*/
|
|
449
|
+
export function apo(src: ArrayLike<number>, shortPeriod: number, longPeriod: number): number[];
|
|
450
|
+
/**
|
|
451
|
+
* Aroon indicator: returns `[up, down]` arrays in percentage form (0-100)
|
|
452
|
+
* describing the time since the highest/lowest value within the lookback
|
|
453
|
+
* `period`. Supports NaN-aware and dense fast-paths.
|
|
454
|
+
* @param high High price series
|
|
455
|
+
* @param low Low price series
|
|
456
|
+
* @param period Lookback period (>0)
|
|
457
|
+
* @param skipna When true ignore NaNs in windows; false forces dense path
|
|
458
|
+
* @returns Tuple `[up, down]` Float64Array indicators
|
|
459
|
+
*/
|
|
460
|
+
export function aroon(high: ArrayLike<number>, low: ArrayLike<number>, period: number, skipna?: boolean): [number[], number[]];
|
|
461
|
+
/**
|
|
462
|
+
* Average True Range (ATR).
|
|
463
|
+
* Computes ATR using Wilder's RMA over the true-range series. Handles NaNs
|
|
464
|
+
* via the `rma` NaN-aware implementation; returns NaN for indices before the
|
|
465
|
+
* lookback is filled.
|
|
466
|
+
* @param high High price series
|
|
467
|
+
* @param low Low price series
|
|
468
|
+
* @param close Close price series
|
|
469
|
+
* @param period Lookback period (must be > 0)
|
|
470
|
+
* @returns Float64Array of ATR values
|
|
471
|
+
*/
|
|
472
|
+
export function atr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): number[];
|
|
473
|
+
/**
|
|
474
|
+
* Bollinger Bands (BB).
|
|
475
|
+
* Returns `[middle, upper, lower]` where `middle` is the SMA, and `upper`/`lower`
|
|
476
|
+
* are `middle ± mult * stddev`. Uses a NaN-aware or dense `rollstdev` depending
|
|
477
|
+
* on input; positions before the window fills are NaN.
|
|
478
|
+
* @param source Input series
|
|
479
|
+
* @param period Window length (must be > 0)
|
|
480
|
+
* @param mult Standard-deviation multiplier
|
|
481
|
+
* @returns Tuple `[middle, upper, lower]` as Float64Array
|
|
482
|
+
*/
|
|
483
|
+
export function bb(source: ArrayLike<number>, period: number, mult: number): [number[], number[], number[]];
|
|
484
|
+
/**
|
|
485
|
+
* Bollinger Band Width (BBW).
|
|
486
|
+
* Returns the normalized width of the Bollinger Bands as percentage: `100*(upper-lower)/middle`.
|
|
487
|
+
* NaNs propagate and positions with `middle === 0` leave the output unchanged (NaN or 0).
|
|
488
|
+
* @param source Input series
|
|
489
|
+
* @param period Window length
|
|
490
|
+
* @param mult Standard-deviation multiplier used for BB
|
|
491
|
+
* @returns Float64Array of BB width percentages
|
|
492
|
+
*/
|
|
493
|
+
export function bbw(source: ArrayLike<number>, period: number, mult: number): number[];
|
|
494
|
+
/**
|
|
495
|
+
* Commodity Channel Index (CCI).
|
|
496
|
+
* Computes the typical price (TP) and compares to a moving average and
|
|
497
|
+
* mean absolute deviation (MAD) scaled by 0.015. Positions before the
|
|
498
|
+
* full lookback or with invalid inputs are NaN.
|
|
499
|
+
* Performance: O(n*p) due to MAD recomputation per window.
|
|
500
|
+
* @param high High price series
|
|
501
|
+
* @param low Low price series
|
|
502
|
+
* @param close Close price series
|
|
503
|
+
* @param period Lookback period (must be > 0)
|
|
504
|
+
* @returns Float64Array of CCI values (NaN where undefined)
|
|
505
|
+
*/
|
|
506
|
+
export function cci(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): number[];
|
|
507
|
+
/**
|
|
508
|
+
* Simple change over `period`.
|
|
509
|
+
* Computes `src[i] - src[i-period]` for each index `i >= period`.
|
|
510
|
+
* Outputs NaN for indices before `period` and propagates NaNs for invalid pairs.
|
|
511
|
+
* @param src Input series
|
|
512
|
+
* @param period Lookback period (must be > 0)
|
|
513
|
+
* @returns Float64Array of simple change values (NaN where undefined)
|
|
514
|
+
*/
|
|
515
|
+
export function change(src: ArrayLike<number>, period: number): number[];
|
|
516
|
+
/**
|
|
517
|
+
* Chande Momentum Oscillator (CMO).
|
|
518
|
+
* Computes CMO over `period` using percent scaling in [-100, 100].
|
|
519
|
+
* Ignores NaNs in the input deltas; positions before the first
|
|
520
|
+
* computable value are NaN.
|
|
521
|
+
* @param src Input series
|
|
522
|
+
* @param period Period over which to compute the oscillator
|
|
523
|
+
* @returns Float64Array of CMO values (NaN where undefined)
|
|
524
|
+
*/
|
|
525
|
+
export function cmo(src: ArrayLike<number>, period: number): number[];
|
|
526
|
+
/**
|
|
527
|
+
* Test whether series `a` crosses `b` (or a scalar) between the previous and
|
|
528
|
+
* current index. By default uses a symmetric cross test that detects both
|
|
529
|
+
* upward and downward crossings. Comparisons are strict and require non-NaN
|
|
530
|
+
* current and previous values for both operands.
|
|
531
|
+
* @param a Left series
|
|
532
|
+
* @param b Right series or scalar
|
|
533
|
+
* @param test Optional custom comparator receiving (ai, aim1, bi, bim1)
|
|
534
|
+
* @returns Uint8Array mask where 1 indicates a crossing at that index
|
|
535
|
+
*/
|
|
536
|
+
export function cross(a: ArrayLike<number>, b: ArrayLike<number> | number, test?: (ai: number, aim1: number, bi: number, bim1: number) => boolean): number[];
|
|
537
|
+
/**
|
|
538
|
+
* Detect an upward crossover (a crosses above b).
|
|
539
|
+
*/
|
|
540
|
+
export function crossover(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
541
|
+
/**
|
|
542
|
+
* Detect a downward crossunder (a crosses below b).
|
|
543
|
+
*/
|
|
544
|
+
export function crossunder(a: ArrayLike<number>, b: ArrayLike<number> | number): number[];
|
|
545
|
+
/**
|
|
546
|
+
* Double Exponential Moving Average (DEMA).
|
|
547
|
+
* DEMA reduces lag by combining a single EMA and a double-smoothed EMA:
|
|
548
|
+
* DEMA = 2 * EMA(source, period) - EMA(EMA(source, period), period).
|
|
549
|
+
* Preserves NaN gaps and follows the same seeding semantics as `ema`.
|
|
550
|
+
* @param source Input series
|
|
551
|
+
* @param period Smoothing period (must be > 0)
|
|
552
|
+
* @returns Float64Array of DEMA values (NaN where undefined)
|
|
553
|
+
*/
|
|
554
|
+
export function dema(source: ArrayLike<number>, period: number): number[];
|
|
555
|
+
/**
|
|
556
|
+
* Directional Indicators (DI+ and DI-).
|
|
557
|
+
* @param high High price series
|
|
558
|
+
* @param low Low price series
|
|
559
|
+
* @param close Close price series
|
|
560
|
+
* @param period Lookback period (must be > 0)
|
|
561
|
+
* @returns Tuple `[diplus, diminus]` as Float64Array
|
|
562
|
+
*/
|
|
563
|
+
export function di(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): [number[], number[]];
|
|
564
|
+
/**
|
|
565
|
+
* Donchian Channels.
|
|
566
|
+
* Returns `[upper, lower, middle]` where `upper` is the highest high
|
|
567
|
+
* and `lower` the lowest low over the lookback `period`. `middle` is the
|
|
568
|
+
* midpoint. NaNs propagate when inputs are invalid.
|
|
569
|
+
* @param high High price series
|
|
570
|
+
* @param low Low price series
|
|
571
|
+
* @param period Lookback period (must be > 0)
|
|
572
|
+
* @returns Tuple `[upper, lower, middle]` as Float64Array
|
|
573
|
+
*/
|
|
574
|
+
export function donchian(high: ArrayLike<number>, low: ArrayLike<number>, period: number): [number[], number[], number[]];
|
|
575
|
+
/**
|
|
576
|
+
* Detrended Price Oscillator (DPO).
|
|
577
|
+
* Computes DPO[i] = source[i - shift] - SMA(source, period)[i], where
|
|
578
|
+
* shift = floor(period/2) + 1. Outputs are NaN for indices before the
|
|
579
|
+
* shift or when insufficient data exists.
|
|
580
|
+
* @param source Input series
|
|
581
|
+
* @param period Lookback period (must be > 0)
|
|
582
|
+
* @returns Float64Array of DPO values (NaN where undefined)
|
|
583
|
+
*/
|
|
584
|
+
export function dpo(source: ArrayLike<number>, period: number): number[];
|
|
585
|
+
/**
|
|
586
|
+
* DX (Directional Movement Index).
|
|
587
|
+
* @param high High price series
|
|
588
|
+
* @param low Low price series
|
|
589
|
+
* @param close Close price series
|
|
590
|
+
* @param period Lookback period (must be > 0)
|
|
591
|
+
* @returns Float64Array of DX values (NaN where undefined)
|
|
592
|
+
*/
|
|
593
|
+
export function dx(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): number[];
|
|
594
|
+
/**
|
|
595
|
+
* Exponential Moving Average (EMA).
|
|
596
|
+
* Seeds on the first non-NaN value and uses the standard EMA recurrence.
|
|
597
|
+
* Preserves NaN gaps in the input: outputs are NaN until enough valid samples
|
|
598
|
+
* have been seen to initialize the EMA.
|
|
599
|
+
* @param source Input series
|
|
600
|
+
* @param period Smoothing period (must be > 0)
|
|
601
|
+
* @returns Float64Array of EMA values (NaN where undefined)
|
|
602
|
+
*/
|
|
603
|
+
export function ema(source: ArrayLike<number>, period: number): number[];
|
|
604
|
+
/**
|
|
605
|
+
* Falling mask: returns a Uint8Array where `1` indicates `source[i]` is
|
|
606
|
+
* strictly less than the value `length` periods ago (NaN-aware).
|
|
607
|
+
* When `skipna` is true, NaNs are tolerated and preserved; when false a
|
|
608
|
+
* dense fast-path is used (assumes no NaNs).
|
|
609
|
+
* @param source Input numeric series
|
|
610
|
+
* @param length Lookback length (>0)
|
|
611
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
612
|
+
* @returns Uint8Array mask with 0/1 values
|
|
613
|
+
*/
|
|
614
|
+
export function falling(source: ArrayLike<number>, length: number, skipna?: boolean): number[];
|
|
615
|
+
/**
|
|
616
|
+
* Hull Moving Average (HMA).
|
|
617
|
+
* Computes a lower-lag smoothing by combining WMAs at different lengths
|
|
618
|
+
* and then applying a final WMA on the derived series. Pine-compatible
|
|
619
|
+
* and NaN-aware: NaNs propagate where insufficient valid samples exist.
|
|
620
|
+
* @param source Input series
|
|
621
|
+
* @param period Window length (must be > 0)
|
|
622
|
+
* @returns Float64Array of HMA values (NaN where undefined)
|
|
623
|
+
*/
|
|
624
|
+
export function hma(source: ArrayLike<number>, period: number): number[];
|
|
625
|
+
/**
|
|
626
|
+
* Ichimoku Kinko Hyo indicator components.
|
|
627
|
+
* Returns `[tenkan, kijun, senkouA, senkouB, chikou]` where senkou lines
|
|
628
|
+
* are shifted forward by the `kijun` displacement and chikou is the close
|
|
629
|
+
* shifted backward. NaN is produced where rolling inputs are invalid.
|
|
630
|
+
* @param high High price series
|
|
631
|
+
* @param low Low price series
|
|
632
|
+
* @param close Close price series
|
|
633
|
+
* @param options Optional periods `{ tenkan, kijun, senkouB }`
|
|
634
|
+
* @returns Tuple of Float64Array: `[tenkan, kijun, senkouA, senkouB, chikou]`
|
|
635
|
+
*/
|
|
636
|
+
export function ichimoku(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, options?: IchimokuOptions): [number[], number[], number[], number[], number[]];
|
|
637
|
+
/**
|
|
638
|
+
* Kaufman Adaptive Moving Average (KAMA).
|
|
639
|
+
* Adapts smoothing based on the efficiency ratio (market noise vs direction).
|
|
640
|
+
* This implementation supports NaN-aware and dense fast-paths; when NaNs are
|
|
641
|
+
* present the compacting + mapping strategy is used, otherwise an O(n)
|
|
642
|
+
* incremental volatility approach is used for speed.
|
|
643
|
+
* @param source Input series
|
|
644
|
+
* @param period Efficiency smoothing lookback (must be > 0)
|
|
645
|
+
* @param fastPeriod Fast smoothing period (default: 2)
|
|
646
|
+
* @param slowPeriod Slow smoothing period (default: 30)
|
|
647
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
648
|
+
* @returns Float64Array of KAMA values (NaN where undefined)
|
|
649
|
+
*/
|
|
650
|
+
export function kama(source: ArrayLike<number>, period: number, fastPeriod?: number, slowPeriod?: number, skipna?: boolean): number[];
|
|
651
|
+
/**
|
|
652
|
+
* Keltner Channels.
|
|
653
|
+
* Returns `[middle(EMA of typical price), upper, lower]` where upper/lower are `middle ± mult * ATR`.
|
|
654
|
+
* Preserves NaNs when inputs are invalid.
|
|
655
|
+
* @param high High price series
|
|
656
|
+
* @param low Low price series
|
|
657
|
+
* @param close Close price series
|
|
658
|
+
* @param period Lookback period (must be > 0)
|
|
659
|
+
* @param mult Multiplier applied to ATR
|
|
660
|
+
* @returns Tuple `[middle, upper, lower]` as Float64Array
|
|
661
|
+
*/
|
|
662
|
+
export function keltner(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number, mult: number): [number[], number[], number[]];
|
|
663
|
+
/**
|
|
664
|
+
* Know Sure Thing (KST) momentum oscillator.
|
|
665
|
+
* Computes a weighted sum of smoothed rate-of-change series.
|
|
666
|
+
* Parameters may be supplied via the `options` object or defaults are used.
|
|
667
|
+
* The output length equals `src.length`; positions before the required
|
|
668
|
+
* lookback periods are NaN.
|
|
669
|
+
* @param src Input series
|
|
670
|
+
* @param options Optional parameters for ROC and smoothing windows
|
|
671
|
+
* @returns Float64Array of KST values (NaN where insufficient data)
|
|
672
|
+
*/
|
|
673
|
+
export function kst(src: ArrayLike<number>, options?: KstOptions): number[];
|
|
674
|
+
/**
|
|
675
|
+
* Moving Average Convergence Divergence (MACD).
|
|
676
|
+
* Produces the MACD line (short EMA - long EMA), the signal line (EMA of MACD),
|
|
677
|
+
* and the histogram (MACD - signal). Skips NaNs and seeds EMAs on first valid
|
|
678
|
+
* value; outputs are NaN until the EMAs and signal have seeded.
|
|
679
|
+
* @param src Input series
|
|
680
|
+
* @param shortPeriod Short EMA period
|
|
681
|
+
* @param longPeriod Long EMA period
|
|
682
|
+
* @param signalPeriod Signal EMA period
|
|
683
|
+
* @returns Tuple `[macdLine, signalLine, histogram]` as Float64Array
|
|
684
|
+
*/
|
|
685
|
+
export function macd(src: ArrayLike<number>, shortPeriod: number, longPeriod: number, signalPeriod: number): [number[], number[], number[]];
|
|
686
|
+
/**
|
|
687
|
+
* Money Flow Index (MFI).
|
|
688
|
+
* Computes MFI over `period` using typical price and money flow; NaN-aware
|
|
689
|
+
* sliding-window implementation that emits NaN where insufficient valid data exists.
|
|
690
|
+
* @param high High price series
|
|
691
|
+
* @param low Low price series
|
|
692
|
+
* @param close Close price series
|
|
693
|
+
* @param volume Volume series
|
|
694
|
+
* @param period Lookback period (must be > 0)
|
|
695
|
+
* @returns Float64Array of MFI values in [0,100]
|
|
696
|
+
*/
|
|
697
|
+
export function mfi(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, volume: ArrayLike<number>, period: number): number[];
|
|
698
|
+
/**
|
|
699
|
+
* Momentum (difference) indicator.
|
|
700
|
+
* Computes `src[i] - src[i - period]` for each index; positions where
|
|
701
|
+
* the lagged value is not available are NaN.
|
|
702
|
+
* @param src Input series
|
|
703
|
+
* @param period Lag period (must be > 0)
|
|
704
|
+
* @returns Float64Array of momentum values (NaN where undefined)
|
|
705
|
+
*/
|
|
706
|
+
export function mom(src: ArrayLike<number>, period: number): number[];
|
|
707
|
+
export function natr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): number[];
|
|
708
|
+
/**
|
|
709
|
+
* On-Balance Volume (OBV).
|
|
710
|
+
* Accumulates volume by sign of price change: add volume when price rises,
|
|
711
|
+
* subtract when price falls; NaNs in inputs yield NaN outputs for that index.
|
|
712
|
+
* @param price Price series
|
|
713
|
+
* @param volume Volume series
|
|
714
|
+
* @returns Float64Array of OBV values
|
|
715
|
+
*/
|
|
716
|
+
export function obv(price: ArrayLike<number>, volume: ArrayLike<number>): number[];
|
|
717
|
+
/**
|
|
718
|
+
* Positive/Negative Volume Index (PNVI).
|
|
719
|
+
* Returns `[pvi, nvi]` series tracking separate indices when volume increases
|
|
720
|
+
* (PVI) or decreases (NVI). Preserves NaNs and treats zero close as missing.
|
|
721
|
+
* @param close Close price series
|
|
722
|
+
* @param volume Volume series
|
|
723
|
+
* @param start Initial index value (default: 1000)
|
|
724
|
+
* @returns Tuple `[pvi, nvi]` as Float64Array
|
|
725
|
+
*/
|
|
726
|
+
export function pnvi(close: ArrayLike<number>, volume: ArrayLike<number>, start?: number): [number[], number[]];
|
|
727
|
+
/**
|
|
728
|
+
* Percentage Price Oscillator (PPO).
|
|
729
|
+
* PPO = 100 * (EMA_short - EMA_long) / EMA_long.
|
|
730
|
+
* Skips NaNs and seeds EMAs on first valid value; outputs are NaN until the
|
|
731
|
+
* long EMA has enough data. When EMA_long is zero, returns 0 to avoid division.
|
|
732
|
+
* @param src Input series
|
|
733
|
+
* @param shortPeriod Short EMA period
|
|
734
|
+
* @param longPeriod Long EMA period
|
|
735
|
+
* @returns Float64Array of PPO values (NaN where undefined)
|
|
736
|
+
*/
|
|
737
|
+
export function ppo(src: ArrayLike<number>, shortPeriod: number, longPeriod: number): number[];
|
|
738
|
+
/**
|
|
739
|
+
* Parabolic SAR (PSAR) indicator.
|
|
740
|
+
* @param high High price series
|
|
741
|
+
* @param low Low price series
|
|
742
|
+
* @param step Acceleration step increment (>0)
|
|
743
|
+
* @param maxStep Maximum acceleration value (>= step)
|
|
744
|
+
* @param skipna When true ignore NaNs; when false use dense fast-path
|
|
745
|
+
* @returns Float64Array PSAR values (NaN for undefined positions)
|
|
746
|
+
*/
|
|
747
|
+
export function psar(high: ArrayLike<number>, low: ArrayLike<number>, step: number, maxStep: number, skipna?: boolean): number[];
|
|
748
|
+
/**
|
|
749
|
+
* Rising mask: returns a Uint8Array where `1` indicates `source[i]` is
|
|
750
|
+
* strictly greater than the value `length` periods ago (NaN-aware).
|
|
751
|
+
* When `skipna` is true, NaNs are tolerated and preserved; when false a
|
|
752
|
+
* dense fast-path is used (assumes no NaNs).
|
|
753
|
+
* @param source Input numeric series
|
|
754
|
+
* @param length Lookback length (>0)
|
|
755
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
756
|
+
* @returns Uint8Array mask with 0/1 values
|
|
757
|
+
*/
|
|
758
|
+
export function rising(source: ArrayLike<number>, length: number, skipna?: boolean): number[];
|
|
759
|
+
/**
|
|
760
|
+
* Wilder's Moving Average / RMA.
|
|
761
|
+
* Implements the Wilder smoothing recurrence (rma = (rma*(period-1) + x)/period).
|
|
762
|
+
* When `skipna` is true NaNs are ignored during seeding and updates; otherwise
|
|
763
|
+
* a dense fast-path is used for NaN-free inputs.
|
|
764
|
+
* @param source Input series
|
|
765
|
+
* @param period Smoothing period (must be > 0)
|
|
766
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
767
|
+
* @returns Float64Array of RMA values (NaN before window fills)
|
|
768
|
+
*/
|
|
769
|
+
export function rma(source: ArrayLike<number>, period: number, skipna?: boolean): number[];
|
|
770
|
+
/**
|
|
771
|
+
* Percentage Rate-of-Change (ROC).
|
|
772
|
+
* Returns 100 * (src[i] - src[i-period]) / src[i-period]. NaN is returned
|
|
773
|
+
* for indices before `period` or when a denominator is NaN/zero.
|
|
774
|
+
* @param src Input series
|
|
775
|
+
* @param period Lookback period (must be > 0)
|
|
776
|
+
* @returns Float64Array of ROC values (NaN where undefined)
|
|
777
|
+
*/
|
|
778
|
+
export function roc(src: ArrayLike<number>, period: number): number[];
|
|
779
|
+
/**
|
|
780
|
+
* Relative Strength Index (RSI) with optional NaN-aware behavior.
|
|
781
|
+
* - `skipna=false` (dense path): assumes inputs contain no NaNs or that NaN
|
|
782
|
+
* propagation is desired; uses a dense fast-path implementation.
|
|
783
|
+
* - `skipna=true` (NaN-aware): skips NaNs when computing deltas and preserves
|
|
784
|
+
* gaps in the output where insufficient valid data exists.
|
|
785
|
+
* Seeding: the implementation seeds on the first valid value and uses Wilder
|
|
786
|
+
* smoothing once the initial window is filled.
|
|
787
|
+
* @param src Input series
|
|
788
|
+
* @param period Lookback period for RSI (must be > 0)
|
|
789
|
+
* @param skipna Whether to ignore NaNs during computation (default: true)
|
|
790
|
+
* @returns Float64Array of RSI values (NaN where undefined)
|
|
791
|
+
*/
|
|
792
|
+
export function rsi(src: ArrayLike<number>, period: number, skipna?: boolean): number[];
|
|
793
|
+
/**
|
|
794
|
+
* Simple Moving Average (SMA).
|
|
795
|
+
* Computes the arithmetic mean over a sliding window.
|
|
796
|
+
* When `skipna` is true, NaNs inside the window are ignored; when false
|
|
797
|
+
* a dense fast-path is used (assumes no NaNs).
|
|
798
|
+
* @param source Input series
|
|
799
|
+
* @param period Window length (must be > 0)
|
|
800
|
+
* @param skipna Whether to ignore NaNs inside windows (default: true)
|
|
801
|
+
* @returns Float64Array of SMA values (NaN before window fills)
|
|
802
|
+
*/
|
|
803
|
+
export function sma(source: ArrayLike<number>, period: number, skipna?: boolean): number[];
|
|
804
|
+
/**
|
|
805
|
+
* Stochastic oscillator (fast %K and %D smoothed outputs).
|
|
806
|
+
* Computes fast %K based on rolling highest/lowest over `kPeriod`, then
|
|
807
|
+
* smooths with `kSlow` and `dPeriod` using dense SMA. Assumes input series
|
|
808
|
+
* length equality and returns NaN when insufficient data exists.
|
|
809
|
+
* @param high High price series
|
|
810
|
+
* @param low Low price series
|
|
811
|
+
* @param close Close price series
|
|
812
|
+
* @param kPeriod %K lookback period
|
|
813
|
+
* @param kSlow Smoothing period for %K
|
|
814
|
+
* @param dPeriod Smoothing period for %D
|
|
815
|
+
* @returns Tuple `[slowK, slowD]` as Float64Array
|
|
816
|
+
*/
|
|
817
|
+
export function stoch(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, kPeriod: number, kSlow: number, dPeriod: number): [number[], number[]];
|
|
818
|
+
/**
|
|
819
|
+
* Stochastic RSI.
|
|
820
|
+
* Applies a stochastic calculation to the RSI series, producing values in [0,1].
|
|
821
|
+
* This implementation is NaN-aware and maintains deques over valid RSI samples.
|
|
822
|
+
* @param close Close price series
|
|
823
|
+
* @param period RSI lookback period
|
|
824
|
+
* @returns Float64Array of StochRSI values (NaN where undefined)
|
|
825
|
+
*/
|
|
826
|
+
export function stochrsi(close: ArrayLike<number>, period: number): number[];
|
|
827
|
+
/**
|
|
828
|
+
* Supertrend indicator.
|
|
829
|
+
* Returns `[supertrend, finalUpper, finalLower, isUpMask]`.
|
|
830
|
+
* `supertrend` contains the plotted trend line (either finalLower when up or finalUpper when down),
|
|
831
|
+
* `finalUpper`/`finalLower` are the band values, and `isUpMask` is a Uint8Array mask (1 when up).
|
|
832
|
+
* NaNs are preserved for invalid inputs or before enough data is available.
|
|
833
|
+
* @param high High price series
|
|
834
|
+
* @param low Low price series
|
|
835
|
+
* @param close Close price series
|
|
836
|
+
* @param period ATR lookback period
|
|
837
|
+
* @param mult Multiplier applied to ATR to form bands
|
|
838
|
+
* @returns Tuple `[supertrend, finalUpper, finalLower, isUpMask]`
|
|
839
|
+
*/
|
|
840
|
+
export function supertrend(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number, mult: number): [number[], number[], number[], number[]];
|
|
841
|
+
/**
|
|
842
|
+
* Triple Exponential Moving Average (T3)
|
|
843
|
+
*
|
|
844
|
+
* T3 is a triple-smoothed moving average developed by Tim Tillson that reduces lag
|
|
845
|
+
* and smoothing compared to traditional EMAs while maintaining responsiveness to price changes.
|
|
846
|
+
*
|
|
847
|
+
* @param source - Input data array
|
|
848
|
+
* @param period - Smoothing period (default: 5)
|
|
849
|
+
* @param volumeFactor - Volume factor for smoothing (default: 0.7)
|
|
850
|
+
* @returns T3 values
|
|
851
|
+
*/
|
|
852
|
+
/**
|
|
853
|
+
* Triple Exponential Moving Average (T3)
|
|
854
|
+
*
|
|
855
|
+
* Implemented following TA‑Lib's algorithm (see TA_T3 C implementation).
|
|
856
|
+
* This inlines the nested EMA seeding (e1..e6) and performs a single-pass
|
|
857
|
+
* update, which is significantly faster than calling `ema()` six times.
|
|
858
|
+
*
|
|
859
|
+
* Notes:
|
|
860
|
+
* - Lookback = 6 * (period - 1)
|
|
861
|
+
* - For inputs containing NaNs we propagate NaN outputs where we cannot
|
|
862
|
+
* compute valid seeds or updates.
|
|
863
|
+
*/
|
|
864
|
+
export function t3(source: ArrayLike<number>, period: number, volumeFactor: number): number[];
|
|
865
|
+
/**
|
|
866
|
+
* Triple Exponential Moving Average (TEMA).
|
|
867
|
+
* Combines three nested EMAs to reduce lag while smoothing:
|
|
868
|
+
* TEMA = 3*EMA1 - 3*EMA2 + EMA3. Preserves NaN gaps and seeds
|
|
869
|
+
* each EMA before emitting values.
|
|
870
|
+
* @param source Input series
|
|
871
|
+
* @param period Smoothing period (must be > 0)
|
|
872
|
+
* @returns Float64Array of TEMA values (NaN where undefined)
|
|
873
|
+
*/
|
|
874
|
+
export function tema(source: ArrayLike<number>, period: number): number[];
|
|
875
|
+
/**
|
|
876
|
+
* True Range (TR).
|
|
877
|
+
* TR[i] = max(high[i]-low[i], |high[i]-close[i-1]|, |low[i]-close[i-1]|).
|
|
878
|
+
* Preserves NaNs and returns NaN where inputs are invalid.
|
|
879
|
+
* @param high High price series
|
|
880
|
+
* @param low Low price series
|
|
881
|
+
* @param close Close price series
|
|
882
|
+
* @returns Float64Array of TR values
|
|
883
|
+
*/
|
|
884
|
+
export function tr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>): number[];
|
|
885
|
+
/**
|
|
886
|
+
* Triangular Moving Average (TRIMA).
|
|
887
|
+
* A triangular-weighted moving average implemented via two `sma` passes.
|
|
888
|
+
* Preserves NaN handling by delegating to `sma` implementations.
|
|
889
|
+
* @param source Input series
|
|
890
|
+
* @param period Window length (must be > 0)
|
|
891
|
+
* @returns Float64Array of TRIMA values (NaN where undefined)
|
|
892
|
+
*/
|
|
893
|
+
export function trima(source: ArrayLike<number>, period: number): number[];
|
|
894
|
+
/**
|
|
895
|
+
* Ultimate Oscillator (ULTOSC).
|
|
896
|
+
* Combines short-, mid-, and long-term averages of the buying pressure / true range
|
|
897
|
+
* to produce a bounded oscillator in [0,100]. Preserves NaN inputs and returns
|
|
898
|
+
* NaN for indices before the longest lookback has sufficient data.
|
|
899
|
+
* @param high High price series
|
|
900
|
+
* @param low Low price series
|
|
901
|
+
* @param close Close price series
|
|
902
|
+
* @param options Optional periods for short/mid/long (s1,s2,s3)
|
|
903
|
+
* @returns Float64Array of Ultimate Oscillator values (NaN where undefined)
|
|
904
|
+
*/
|
|
905
|
+
export function ultosc(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, options?: UltoscOptions): number[];
|
|
906
|
+
/**
|
|
907
|
+
* Volume Weighted Moving Average (VWMA).
|
|
908
|
+
* Computes pvSum / vSum over a sliding window, NaN-aware. When `skipna` is
|
|
909
|
+
* true NaNs in either series are ignored within the window; when false a
|
|
910
|
+
* dense fast-path is used (assumes no NaNs).
|
|
911
|
+
* @param price Price series
|
|
912
|
+
* @param volume Volume series
|
|
913
|
+
* @param period Window length (>0)
|
|
914
|
+
* @param skipna Whether to ignore NaNs inside windows (default: true)
|
|
915
|
+
* @returns Float64Array of VWMA values (NaN before window fills)
|
|
916
|
+
*/
|
|
917
|
+
export function vwma(price: ArrayLike<number>, volume: ArrayLike<number>, period: number, skipna?: boolean): number[];
|
|
918
|
+
/**
|
|
919
|
+
* Williams Accumulation/Distribution (WAD).
|
|
920
|
+
* Accumulates the money flow based on price movement using either a dense
|
|
921
|
+
* fast-path or a NaN-aware path depending on `skipna` and input contents.
|
|
922
|
+
* @param high High price series
|
|
923
|
+
* @param low Low price series
|
|
924
|
+
* @param close Close price series
|
|
925
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
926
|
+
* @returns Float64Array of WAD values (NaN where undefined)
|
|
927
|
+
*/
|
|
928
|
+
export function wad(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, skipna?: boolean): number[];
|
|
929
|
+
/**
|
|
930
|
+
* Weighted Moving Average (WMA).
|
|
931
|
+
* Computes a linearly-weighted average over a sliding window with weights
|
|
932
|
+
* 1..period (oldest..newest). When `skipna` is true NaNs are ignored
|
|
933
|
+
* within the window; when false a dense fast-path is used.
|
|
934
|
+
* @param source Input series
|
|
935
|
+
* @param period Window length (must be > 0)
|
|
936
|
+
* @param skipna Whether to ignore NaNs inside windows (default: true)
|
|
937
|
+
* @returns Float64Array of WMA values (NaN before window fills)
|
|
938
|
+
*/
|
|
939
|
+
export function wma(source: ArrayLike<number>, period: number, skipna?: boolean): number[];
|
|
940
|
+
/**
|
|
941
|
+
* Williams %R (WPR).
|
|
942
|
+
* Computes %R = (highestHigh - close) / (highestHigh - lowestLow) * -100
|
|
943
|
+
* over a rolling `period`. Uses `rollminmax` to compute window extrema and
|
|
944
|
+
* returns NaN for indices before `period` or when the range is zero.
|
|
945
|
+
* @param high High price series
|
|
946
|
+
* @param low Low price series
|
|
947
|
+
* @param close Close price series
|
|
948
|
+
* @param period Lookback period (must be > 0)
|
|
949
|
+
* @returns Float64Array of %R values (NaN where undefined)
|
|
950
|
+
*/
|
|
951
|
+
export function wpr(high: ArrayLike<number>, low: ArrayLike<number>, close: ArrayLike<number>, period: number): number[];
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
declare namespace arr {
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
declare namespace stats {
|
|
958
|
+
/**
|
|
959
|
+
* Draw `k` bootstrap samples (with replacement) from `arr`.
|
|
960
|
+
* Uses `Math.random()`; tests should stub `Math.random` for determinism.
|
|
961
|
+
* @param arr Source array
|
|
962
|
+
* @param k Number of draws
|
|
963
|
+
* @returns Array of sampled elements (with replacement)
|
|
964
|
+
*/
|
|
965
|
+
export function bootstrap<T>(arr: T[], k: number): T[];
|
|
966
|
+
/**
|
|
967
|
+
* Pearson correlation between `x` and `y`. When `skipna` is true only
|
|
968
|
+
* pairwise-valid entries are used; otherwise a dense fast-path is taken.
|
|
969
|
+
* @param x First input array
|
|
970
|
+
* @param y Second input array
|
|
971
|
+
* @param options Optional `{ skipna? }`
|
|
972
|
+
* @returns Correlation coefficient or NaN
|
|
973
|
+
*/
|
|
974
|
+
export function corr(x: ArrayLike<number>, y: ArrayLike<number>, skipna?: boolean): number;
|
|
975
|
+
/**
|
|
976
|
+
* Pairwise covariance: cov(X,Y) = E[XY] - E[X]E[Y]
|
|
977
|
+
*/
|
|
978
|
+
export function covar(x: ArrayLike<number>, y: ArrayLike<number>, options?: {
|
|
979
|
+
ddof?: number;
|
|
980
|
+
}): number;
|
|
981
|
+
/**
|
|
982
|
+
* Geometric mean (optionally weighted). Values must be positive; NaNs are
|
|
983
|
+
* ignored when `skipna` is true. Returns NaN when no valid values.
|
|
984
|
+
* @param source Input array
|
|
985
|
+
* @param options Optional `{ weights?, skipna? }`
|
|
986
|
+
* @returns Geometric mean or NaN
|
|
987
|
+
*/
|
|
988
|
+
export function gmean(source: ArrayLike<number>, options?: {
|
|
989
|
+
weights?: ArrayLike<number>;
|
|
990
|
+
skipna?: boolean;
|
|
991
|
+
}): number;
|
|
992
|
+
/**
|
|
993
|
+
* Harmonic mean (optionally weighted). Values must be positive; NaNs are
|
|
994
|
+
* ignored when `skipna` is true. Returns NaN when no valid values.
|
|
995
|
+
* @param source Input array
|
|
996
|
+
* @param options Optional `{ weights?, skipna? }`
|
|
997
|
+
* @returns Harmonic mean or NaN
|
|
998
|
+
*/
|
|
999
|
+
export function hmean(source: ArrayLike<number>, options?: {
|
|
1000
|
+
weights?: ArrayLike<number>;
|
|
1001
|
+
skipna?: boolean;
|
|
1002
|
+
}): number;
|
|
1003
|
+
/**
|
|
1004
|
+
* Excess kurtosis (kurtosis - 3) for `source` (ignores NaNs). Returns NaN when insufficient data.
|
|
1005
|
+
* @param source Input array
|
|
1006
|
+
* @returns Excess kurtosis or NaN
|
|
1007
|
+
*/
|
|
1008
|
+
export function kurtosis(source: ArrayLike<number>): number;
|
|
1009
|
+
/**
|
|
1010
|
+
* Mean absolute deviation from the mean. When `skipna` is true NaNs are
|
|
1011
|
+
* ignored. Returns NaN when the input contains no valid values.
|
|
1012
|
+
* @param source Input array
|
|
1013
|
+
* @param options Optional `{ skipna? }`
|
|
1014
|
+
* @returns Mean absolute deviation or NaN
|
|
1015
|
+
*/
|
|
1016
|
+
export function mad(source: ArrayLike<number>, skipna?: boolean): number;
|
|
1017
|
+
/**
|
|
1018
|
+
* Compute the (possibly weighted) mean of `source`.
|
|
1019
|
+
* By default NaNs are skipped (`skipna=true`). When `weights` are provided they
|
|
1020
|
+
* must match `source` length and the function computes the weighted mean.
|
|
1021
|
+
* A dense fast-path is used when the global optimization allows it.
|
|
1022
|
+
* @param source Input array
|
|
1023
|
+
* @param options Optional `{ weights?, skipna? }`
|
|
1024
|
+
* @returns Mean value or NaN when undefined
|
|
1025
|
+
*/
|
|
1026
|
+
export function mean(source: ArrayLike<number>, options?: {
|
|
1027
|
+
weights?: ArrayLike<number>;
|
|
1028
|
+
skipna?: boolean;
|
|
1029
|
+
}): number;
|
|
1030
|
+
/**
|
|
1031
|
+
* Median of `source` (ignores NaNs). Implemented via `quantile(source, 0.5)`.
|
|
1032
|
+
* @param source Input array
|
|
1033
|
+
* @returns Median value or NaN
|
|
1034
|
+
*/
|
|
1035
|
+
export function median(source: ArrayLike<number>): number;
|
|
1036
|
+
/**
|
|
1037
|
+
* Normalize to [0,1] by min/max scaling. Preserves NaNs when `skipna` is true.
|
|
1038
|
+
* @param source Input array
|
|
1039
|
+
* @param options Optional `{ skipna? }`
|
|
1040
|
+
* @returns Float64Array of normalized values
|
|
1041
|
+
*/
|
|
1042
|
+
export function norminmax(source: ArrayLike<number>, skipna?: boolean): number[];
|
|
1043
|
+
/**
|
|
1044
|
+
* Compute multiple percentiles (quantiles) for `source`. When `qs.length`
|
|
1045
|
+
* is small, selection is used for each quantile; otherwise the data are
|
|
1046
|
+
* sorted once for efficiency.
|
|
1047
|
+
* @param source Input array
|
|
1048
|
+
* @param qs Array of quantiles in [0,1]
|
|
1049
|
+
* @returns Array of quantile values
|
|
1050
|
+
*/
|
|
1051
|
+
export function percentiles(source: ArrayLike<number>, qs: number[]): number[];
|
|
1052
|
+
/**
|
|
1053
|
+
* Compute the quantile `q` of `source`, ignoring NaNs. Implements a
|
|
1054
|
+
* selection-based algorithm using quickselect for expected linear time.
|
|
1055
|
+
* @param source Input array
|
|
1056
|
+
* @param q Quantile in [0,1]
|
|
1057
|
+
* @returns Quantile value or NaN
|
|
1058
|
+
*/
|
|
1059
|
+
export function quantile(source: ArrayLike<number>, q: number): number;
|
|
1060
|
+
/**
|
|
1061
|
+
* Rolling Pearson correlation computed from rolling covariance and stddev.
|
|
1062
|
+
* Supports alignment modes via `options.outLength` ('min' or 'max').
|
|
1063
|
+
* @param x First input array
|
|
1064
|
+
* @param y Second input array
|
|
1065
|
+
* @param period Window length
|
|
1066
|
+
* @param options Optional `{ skipna?, outLength? }`
|
|
1067
|
+
* @returns Float64Array of rolling correlations
|
|
1068
|
+
*/
|
|
1069
|
+
export function rollcorr(x: ArrayLike<number>, y: ArrayLike<number>, period: number, options?: {
|
|
1070
|
+
skipna?: boolean;
|
|
1071
|
+
outLength?: 'min' | 'max';
|
|
1072
|
+
}): number[];
|
|
1073
|
+
export function rollcovar(x: ArrayLike<number>, y: ArrayLike<number>, period: number, options?: {
|
|
1074
|
+
ddof?: number;
|
|
1075
|
+
}): number[];
|
|
1076
|
+
/**
|
|
1077
|
+
* Rolling excess kurtosis over a sliding window of length `period`.
|
|
1078
|
+
* @param source Input array
|
|
1079
|
+
* @param period Window length
|
|
1080
|
+
* @returns Float64Array of rolling kurtosis values
|
|
1081
|
+
*/
|
|
1082
|
+
export function rollkurtosis(source: ArrayLike<number>, period: number): number[];
|
|
1083
|
+
/**
|
|
1084
|
+
* Rolling mean (moving average) over a sliding window of length `period`.
|
|
1085
|
+
* When `skipna` is true, NaNs inside windows are ignored; windows with no
|
|
1086
|
+
* valid values produce NaN. A fast dense path is used when no NaNs.
|
|
1087
|
+
* @param source Input array
|
|
1088
|
+
* @param period Window length (>0)
|
|
1089
|
+
* @param skipna Whether to ignore NaNs (default: true)
|
|
1090
|
+
* @returns Float64Array of rolling means
|
|
1091
|
+
*/
|
|
1092
|
+
export function rollmean(source: ArrayLike<number>, period: number, skipna?: boolean): number[];
|
|
1093
|
+
/**
|
|
1094
|
+
* Compute the rolling median over a sliding window.
|
|
1095
|
+
* Ignores NaNs and validates `period`.
|
|
1096
|
+
* Returns a Float64Array with NaN entries for positions before the window fills.
|
|
1097
|
+
* @param source Input array
|
|
1098
|
+
* @param period Window length
|
|
1099
|
+
* @returns Float64Array of rolling medians
|
|
1100
|
+
*/
|
|
1101
|
+
export function rollmedian(source: ArrayLike<number>, period: number): number[];
|
|
1102
|
+
/**
|
|
1103
|
+
* Compute the rolling quantile over a sliding window.
|
|
1104
|
+
* Ignores NaNs and validates `period` and `q`.
|
|
1105
|
+
* Returns a Float64Array with NaN entries for positions before the window fills.
|
|
1106
|
+
* @param source Input array
|
|
1107
|
+
* @param period Window length
|
|
1108
|
+
* @param q Quantile in [0,1]
|
|
1109
|
+
* @returns Float64Array of rolling quantiles
|
|
1110
|
+
*/
|
|
1111
|
+
export function rollquantile(source: ArrayLike<number>, period: number, q: number): number[];
|
|
1112
|
+
/**
|
|
1113
|
+
* Rolling skewness over a sliding window of length `period`.
|
|
1114
|
+
* @param source Input array
|
|
1115
|
+
* @param period Window length
|
|
1116
|
+
* @returns Float64Array of rolling skewness values
|
|
1117
|
+
*/
|
|
1118
|
+
export function rollskew(source: ArrayLike<number>, period: number): number[];
|
|
1119
|
+
export function rollstdev(source: ArrayLike<number>, period: number, options?: {
|
|
1120
|
+
skipna?: boolean;
|
|
1121
|
+
ddof?: number;
|
|
1122
|
+
}): number[];
|
|
1123
|
+
/**
|
|
1124
|
+
* Rolling variance over a sliding window. Accepts `{ skipna?, ddof? }`.
|
|
1125
|
+
* @param source Input array
|
|
1126
|
+
* @param period Window length (>0)
|
|
1127
|
+
* @param options Optional `{ skipna?, ddof? }`
|
|
1128
|
+
* @returns Float64Array of rolling variances
|
|
1129
|
+
*/
|
|
1130
|
+
export function rollvar(source: ArrayLike<number>, period: number, options?: {
|
|
1131
|
+
skipna?: boolean;
|
|
1132
|
+
ddof?: number;
|
|
1133
|
+
}): number[];
|
|
1134
|
+
/**
|
|
1135
|
+
* Draw `k` unique samples without replacement from `arr`.
|
|
1136
|
+
* If `k` >= arr.length a shallow copy is returned. Uses `Math.random()`.
|
|
1137
|
+
* @param arr Source array
|
|
1138
|
+
* @param k Number of samples to draw
|
|
1139
|
+
* @returns Array of sampled elements
|
|
1140
|
+
*/
|
|
1141
|
+
export function sample<T>(arr: T[], k: number): T[];
|
|
1142
|
+
/**
|
|
1143
|
+
* In-place Fisher–Yates shuffle of `arr`.
|
|
1144
|
+
* Uses `Math.random()`; tests should stub `Math.random` for determinism.
|
|
1145
|
+
* @param arr Array to shuffle (mutated)
|
|
1146
|
+
* @returns The shuffled array (same reference)
|
|
1147
|
+
*/
|
|
1148
|
+
export function shuffle<T>(arr: T[]): T[];
|
|
1149
|
+
/**
|
|
1150
|
+
* Fisher-Pearson sample skewness (ignores NaNs). Returns NaN when insufficient data.
|
|
1151
|
+
* @param source Input array
|
|
1152
|
+
* @returns Skewness or NaN
|
|
1153
|
+
*/
|
|
1154
|
+
export function skew(source: ArrayLike<number>): number;
|
|
1155
|
+
/**
|
|
1156
|
+
* Standard deviation: compute a single standard deviation over the whole series, dropping NaNs.
|
|
1157
|
+
* Uses `ddof` (delta degrees of freedom) like NumPy/pandas: denominator = N - ddof.
|
|
1158
|
+
* Default pandas behavior is sample standard deviation (ddof=1), so the default here is ddof=1.
|
|
1159
|
+
*/
|
|
1160
|
+
export function stdev(source: ArrayLike<number>, options?: {
|
|
1161
|
+
ddof?: number;
|
|
1162
|
+
skipna?: boolean;
|
|
1163
|
+
}): number;
|
|
1164
|
+
/**
|
|
1165
|
+
* Variance: compute a single variance over the whole series, dropping NaNs.
|
|
1166
|
+
* Uses `ddof` (delta degrees of freedom) like NumPy/pandas: denominator = N - ddof.
|
|
1167
|
+
* Default pandas behavior is sample variance (ddof=1), so the default here is ddof=1.
|
|
1168
|
+
*/
|
|
1169
|
+
export function variance(source: ArrayLike<number>, options?: {
|
|
1170
|
+
ddof?: number;
|
|
1171
|
+
skipna?: boolean;
|
|
1172
|
+
}): number;
|
|
1173
|
+
/**
|
|
1174
|
+
* Winsorize values to the given lower and upper quantile bounds.
|
|
1175
|
+
* Preserves NaNs when `skipna` is true.
|
|
1176
|
+
* @param source Input array
|
|
1177
|
+
* @param options Optional `{ lower?, upper?, skipna? }` where bounds are in [0,1]
|
|
1178
|
+
* @returns Float64Array of winsorized values
|
|
1179
|
+
*/
|
|
1180
|
+
export function winsorize(source: ArrayLike<number>, options?: {
|
|
1181
|
+
lower?: number;
|
|
1182
|
+
upper?: number;
|
|
1183
|
+
skipna?: boolean;
|
|
1184
|
+
}): number[];
|
|
1185
|
+
/**
|
|
1186
|
+
* Compute z-scores for `source`: (x - mean) / std (ddof=1). NaNs preserved.
|
|
1187
|
+
* @param source Input array
|
|
1188
|
+
* @param options Optional `{ skipna? }` to ignore NaNs
|
|
1189
|
+
* @returns Float64Array of z-scores
|
|
1190
|
+
*/
|
|
1191
|
+
export function zscore(source: ArrayLike<number>, skipna?: boolean): number[];
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
export { math, ta, arr, stats };
|