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.
Files changed (72) hide show
  1. package/LICENSE +695 -0
  2. package/README.md +60 -0
  3. package/dist/arr/arr.d.ts +81 -0
  4. package/dist/bundle/index.d.ts +1573 -0
  5. package/dist/bundle/index.js +3169 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/math/basic.d.ts +174 -0
  8. package/dist/math/index.d.ts +11 -0
  9. package/dist/math/linalg.d.ts +36 -0
  10. package/dist/math/minmax.d.ts +81 -0
  11. package/dist/math/prod.d.ts +20 -0
  12. package/dist/math/random.d.ts +22 -0
  13. package/dist/math/sum.d.ts +26 -0
  14. package/dist/stats/index.d.ts +10 -0
  15. package/dist/stats/mean.d.ts +53 -0
  16. package/dist/stats/quantile.d.ts +42 -0
  17. package/dist/stats/sampling.d.ts +23 -0
  18. package/dist/stats/skew.d.ts +26 -0
  19. package/dist/stats/transforms.d.ts +48 -0
  20. package/dist/stats/var.d.ts +42 -0
  21. package/dist/ta/index.d.ts +13 -0
  22. package/dist/ta/momentum-oscillators/ao.d.ts +11 -0
  23. package/dist/ta/momentum-oscillators/apo.d.ts +11 -0
  24. package/dist/ta/momentum-oscillators/aroon.d.ts +11 -0
  25. package/dist/ta/momentum-oscillators/cmo.d.ts +10 -0
  26. package/dist/ta/momentum-oscillators/index.d.ts +14 -0
  27. package/dist/ta/momentum-oscillators/kst.d.ts +29 -0
  28. package/dist/ta/momentum-oscillators/macd.d.ts +12 -0
  29. package/dist/ta/momentum-oscillators/mom.d.ts +9 -0
  30. package/dist/ta/momentum-oscillators/ppo.d.ts +11 -0
  31. package/dist/ta/momentum-oscillators/roc.d.ts +18 -0
  32. package/dist/ta/momentum-oscillators/rsi.d.ts +14 -0
  33. package/dist/ta/momentum-oscillators/stoch.d.ts +14 -0
  34. package/dist/ta/momentum-oscillators/stochrsi.d.ts +9 -0
  35. package/dist/ta/momentum-oscillators/ultosc.d.ts +17 -0
  36. package/dist/ta/momentum-oscillators/wpr.d.ts +12 -0
  37. package/dist/ta/moving-averages/dema.d.ts +10 -0
  38. package/dist/ta/moving-averages/ema.d.ts +10 -0
  39. package/dist/ta/moving-averages/hma.d.ts +10 -0
  40. package/dist/ta/moving-averages/index.d.ts +11 -0
  41. package/dist/ta/moving-averages/kama.d.ts +14 -0
  42. package/dist/ta/moving-averages/rma.d.ts +11 -0
  43. package/dist/ta/moving-averages/sma.d.ts +11 -0
  44. package/dist/ta/moving-averages/t3.d.ts +24 -0
  45. package/dist/ta/moving-averages/tema.d.ts +10 -0
  46. package/dist/ta/moving-averages/trima.d.ts +9 -0
  47. package/dist/ta/moving-averages/vwma.d.ts +17 -0
  48. package/dist/ta/moving-averages/wma.d.ts +11 -0
  49. package/dist/ta/trend/cci.d.ts +13 -0
  50. package/dist/ta/trend/di.d.ts +36 -0
  51. package/dist/ta/trend/dpo.d.ts +10 -0
  52. package/dist/ta/trend/ichimoku.d.ts +20 -0
  53. package/dist/ta/trend/index.d.ts +6 -0
  54. package/dist/ta/trend/psar.d.ts +10 -0
  55. package/dist/ta/trend/supertrend.d.ts +14 -0
  56. package/dist/ta/util.d.ts +53 -0
  57. package/dist/ta/volatility/atr.d.ts +23 -0
  58. package/dist/ta/volatility/bb.d.ts +11 -0
  59. package/dist/ta/volatility/bbw.d.ts +10 -0
  60. package/dist/ta/volatility/donchian.d.ts +11 -0
  61. package/dist/ta/volatility/index.d.ts +5 -0
  62. package/dist/ta/volatility/keltner.d.ts +12 -0
  63. package/dist/ta/volume-money-flow/ad.d.ts +12 -0
  64. package/dist/ta/volume-money-flow/adosc.d.ts +15 -0
  65. package/dist/ta/volume-money-flow/index.d.ts +6 -0
  66. package/dist/ta/volume-money-flow/mfi.d.ts +12 -0
  67. package/dist/ta/volume-money-flow/obv.d.ts +9 -0
  68. package/dist/ta/volume-money-flow/pnvi.d.ts +10 -0
  69. package/dist/ta/volume-money-flow/wad.d.ts +11 -0
  70. package/dist/untyped/index.d.ts +1194 -0
  71. package/dist/untyped/index.js +29 -0
  72. package/package.json +58 -0
@@ -0,0 +1,4 @@
1
+ export * as math from './math/index.js';
2
+ export * as ta from './ta/index.js';
3
+ export * as arr from './arr/arr.js';
4
+ export * as stats from './stats/index.js';
@@ -0,0 +1,174 @@
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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export declare function diff(source: ArrayLike<number>): Float64Array;
97
+ /**
98
+ * Map a callback across `source` producing a new Float64Array.
99
+ * @param source Input array
100
+ * @param cb Mapping callback `(value, index, array) => number`
101
+ * @returns Float64Array of mapped values
102
+ */
103
+ export declare function apply(source: ArrayLike<number>, cb: (v: number, i: number, arr: ArrayLike<number>) => number): Float64Array;
104
+ /**
105
+ * Apply a callback to each element in `source` in-place.
106
+ * Modifies the provided array.
107
+ * @param source Mutable array to update
108
+ * @param cb Callback `(value, index) => newValue`
109
+ */
110
+ export declare function applyInPlace(source: number[] | Float64Array, cb: (value: number, index: number) => number): void;
111
+ /**
112
+ * Element-wise less-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
+ export declare function lt(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
118
+ /**
119
+ * Element-wise less-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
+ export declare function lte(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
125
+ /**
126
+ * Element-wise greater-than comparison. Returns `Uint8Array` mask with 1 where true.
127
+ * @param a Left operand
128
+ * @param b Right operand or scalar
129
+ * @returns Uint8Array mask of comparisons
130
+ */
131
+ export declare function gt(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
132
+ /**
133
+ * Element-wise greater-than-or-equal comparison (with epsilon tolerance).
134
+ * @param a Left operand
135
+ * @param b Right operand or scalar
136
+ * @returns Uint8Array mask of comparisons
137
+ */
138
+ export declare function gte(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
139
+ /**
140
+ * Element-wise equality comparison using `Number.EPSILON` tolerance.
141
+ * @param a Left operand
142
+ * @param b Right operand or scalar
143
+ * @returns Uint8Array mask of equality tests
144
+ */
145
+ export declare function eq(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
146
+ /**
147
+ * Element-wise inequality comparison.
148
+ * @param a Left operand
149
+ * @param b Right operand or scalar
150
+ * @returns Uint8Array mask where elements are not equal
151
+ */
152
+ export declare function neq(a: ArrayLike<number>, b: ArrayLike<number> | number): Uint8Array;
153
+ /**
154
+ * Logical AND for boolean masks (Uint8Array) or with a scalar.
155
+ * Returns a Uint8Array of 1/0 values.
156
+ * @param a Left boolean mask
157
+ * @param b Right boolean mask or scalar
158
+ * @returns Uint8Array mask result
159
+ */
160
+ export declare function and(a: Uint8Array, b: Uint8Array | number): Uint8Array;
161
+ /**
162
+ * Logical OR for boolean masks (Uint8Array) or with a scalar.
163
+ * Returns a Uint8Array of 1/0 values.
164
+ * @param a Left boolean mask
165
+ * @param b Right boolean mask or scalar
166
+ * @returns Uint8Array mask result
167
+ */
168
+ export declare function or(a: Uint8Array, b: Uint8Array | number): Uint8Array;
169
+ /**
170
+ * Logical NOT for a boolean mask (Uint8Array).
171
+ * @param a Input boolean mask
172
+ * @returns Uint8Array mask with bits inverted
173
+ */
174
+ export declare function not(a: Uint8Array): Uint8Array;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Barrel exports for math helpers. Re-exports individual functions from
3
+ * the `src/math` submodules for convenient imports.
4
+ */
5
+ import { diff, add, sub, mul, div, avg, scale, clamp, abs, sign, round, floor, ceil, eq, neq, and, or, not, gt, gte, lt, lte } from './basic.js';
6
+ import { prod, cumprod, rollprod } from './prod.js';
7
+ import { sum, rollsum, cumsum } from './sum.js';
8
+ import { min, rollmin, max, rollmax, argmin, argmax, cummax, cummin, rollminmax, rollargmin, rollargmax } from './minmax.js';
9
+ import { randuniform, randnormal } from './random.js';
10
+ import { dot, norm, ols, olsMulti } from './linalg.js';
11
+ export { add, sub, avg, mul, div, scale, abs, sign, round, floor, ceil, eq, neq, gt, gte, lt, lte, and, or, not, clamp, sum, prod, min, max, argmin, argmax, cumsum, cumprod, cummax, cummin, rollsum, rollmin, rollmax, rollminmax, rollprod, rollargmin, rollargmax, diff, randuniform, randnormal, dot, norm, ols, olsMulti };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Dot product of two vectors: sum_i x[i] * y[i].
3
+ * Operates up to the shorter length of the inputs.
4
+ * @param x First vector
5
+ * @param y Second vector
6
+ * @returns Scalar dot product
7
+ */
8
+ export declare function dot(x: ArrayLike<number>, y: ArrayLike<number>): number;
9
+ /**
10
+ * Vector p-norm. Supports common p values (1, 2, Infinity) with a fast dense path.
11
+ * When `skipna` is true the implementation ignores NaNs and returns NaN if no valid entries exist.
12
+ * @param x Input vector
13
+ * @param p Norm order (default 2)
14
+ * @param skipna Whether to ignore NaNs (default true)
15
+ * @returns Norm value or NaN
16
+ */
17
+ export declare function norm(x: ArrayLike<number>, p?: number, skipna?: boolean): number;
18
+ /**
19
+ * Ordinary least squares for a simple linear model y = intercept + slope * x.
20
+ * Ignores paired NaN entries and returns NaN coefficients if no valid pairs or singular design.
21
+ * @param x Predictor values
22
+ * @param y Response values
23
+ * @returns Object with `intercept` and `slope` or NaNs on failure
24
+ */
25
+ export declare function ols(x: ArrayLike<number>, y: ArrayLike<number>): {
26
+ intercept: number;
27
+ slope: number;
28
+ };
29
+ /**
30
+ * Multiple linear regression using normal equations (adds intercept column internally).
31
+ * Returns coefficient vector or null if the normal matrix is singular or inputs are empty.
32
+ * @param X Design matrix (rows = observations, cols = features)
33
+ * @param y Response vector
34
+ * @returns Coefficient array [intercept, beta1, beta2, ...] or null
35
+ */
36
+ export declare function olsMulti(X: number[][], y: number[]): number[] | null;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Rolling minimum over a window. NaN-aware: windows containing only NaNs produce NaN.
3
+ * @param source Input values
4
+ * @param period Window length (must be > 0)
5
+ * @returns Float64Array of rolling minima (NaN for positions before the window fills)
6
+ */
7
+ export declare function rollmin(source: ArrayLike<number>, period: number): Float64Array;
8
+ /**
9
+ * Rolling maximum over a window. NaN-aware: windows containing only NaNs produce NaN.
10
+ * @param source Input values
11
+ * @param period Window length (must be > 0)
12
+ * @returns Float64Array of rolling maxima (NaN for positions before the window fills)
13
+ */
14
+ export declare function rollmax(source: ArrayLike<number>, period: number): Float64Array;
15
+ /**
16
+ * Compute rolling minima and maxima pairwise over two input series.
17
+ * Optional callback `cb(minVal, maxVal, i)` is invoked for each computed window.
18
+ * @param minSource Input for minima
19
+ * @param maxSource Input for maxima
20
+ * @param period Window length (must be > 0)
21
+ * @param cb Optional callback invoked per window
22
+ * @returns Object with `min` and `max` Float64Array results
23
+ */
24
+ export declare function rollminmax(minSource: ArrayLike<number>, maxSource: ArrayLike<number>, period: number, cb?: (minVal: number, maxVal: number, i: number) => void): {
25
+ min: Float64Array;
26
+ max: Float64Array;
27
+ };
28
+ /**
29
+ * Minimum of an array, ignoring NaNs. Returns NaN if no valid entries.
30
+ * @param source Input array
31
+ * @returns Minimum value or NaN
32
+ */
33
+ export declare function min(source: ArrayLike<number>): number;
34
+ /**
35
+ * Maximum of an array, ignoring NaNs. Returns NaN if no valid entries.
36
+ * @param source Input array
37
+ * @returns Maximum value or NaN
38
+ */
39
+ export declare function max(source: ArrayLike<number>): number;
40
+ /**
41
+ * Index of the first minimum value (ignores NaNs). Returns -1 if none found.
42
+ * @param source Input array
43
+ * @returns Index of minimum or -1
44
+ */
45
+ export declare function argmin(source: ArrayLike<number>): number;
46
+ /**
47
+ * Index of the first maximum value (ignores NaNs). Returns -1 if none found.
48
+ * @param source Input array
49
+ * @returns Index of maximum or -1
50
+ */
51
+ export declare function argmax(source: ArrayLike<number>): number;
52
+ /**
53
+ * Cumulative maximum: at each index the maximum over all prior valid elements.
54
+ * NaNs are preserved in the output at positions where input is NaN.
55
+ * @param source Input array
56
+ * @returns Float64Array of cumulative maxima
57
+ */
58
+ export declare function cummax(source: ArrayLike<number>): Float64Array;
59
+ /**
60
+ * Cumulative minimum: at each index the minimum over all prior valid elements.
61
+ * NaNs are preserved in the output at positions where input is NaN.
62
+ * @param source Input array
63
+ * @returns Float64Array of cumulative minima
64
+ */
65
+ export declare function cummin(source: ArrayLike<number>): Float64Array;
66
+ /**
67
+ * Rolling argmin: returns the index (into `source`) of the minimum value in each window.
68
+ * Positions before the window fills are NaN.
69
+ * @param source Input array
70
+ * @param period Window length
71
+ * @returns Float64Array of argmin indices (NaN when not available)
72
+ */
73
+ export declare function rollargmin(source: ArrayLike<number>, period: number): Float64Array;
74
+ /**
75
+ * Rolling argmax: returns the index (into `source`) of the maximum value in each window.
76
+ * Positions before the window fills are NaN.
77
+ * @param source Input array
78
+ * @param period Window length
79
+ * @returns Float64Array of argmax indices (NaN when not available)
80
+ */
81
+ export declare function rollargmax(source: ArrayLike<number>, period: number): Float64Array;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Product of array elements, ignoring NaNs. Returns NaN if no valid entries.
3
+ * @param source Input array
4
+ * @returns Product of values or NaN
5
+ */
6
+ export declare function prod(source: ArrayLike<number>): number;
7
+ /**
8
+ * Cumulative product (NaN-preserving). At each index the product of all prior valid elements.
9
+ * @param source Input array
10
+ * @returns Float64Array of cumulative products (NaN where input was NaN)
11
+ */
12
+ export declare function cumprod(source: ArrayLike<number>): Float64Array;
13
+ /**
14
+ * Rolling product over a window. NaN-aware: windows with no valid entries produce NaN.
15
+ * Zeros are handled efficiently by tracking counts.
16
+ * @param source Input array
17
+ * @param period Window length (must be > 0)
18
+ * @returns Float64Array of rolling products (NaN for positions before window fills)
19
+ */
20
+ export declare function rollprod(source: ArrayLike<number>, period: number): Float64Array;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Generate `n` uniform random values in [lo, hi).
3
+ * Uses `Math.random()`; tests should stub `Math.random` for determinism.
4
+ * @param n Number of samples to generate
5
+ * @param options Optional `{ lo, hi }` bounds (defaults to 0..1)
6
+ * @returns Float64Array of length `n`
7
+ */
8
+ export declare function randuniform(n: number, options?: {
9
+ lo?: number;
10
+ hi?: number;
11
+ }): Float64Array;
12
+ /**
13
+ * Generate `n` standard normal samples using the Box-Muller transform.
14
+ * Uses `Math.random()`; tests should stub `Math.random` for determinism.
15
+ * @param n Number of samples to generate
16
+ * @param options Optional `{ mean, sd }` to shift/scale samples
17
+ * @returns Float64Array of length `n`
18
+ */
19
+ export declare function randnormal(n: number, options?: {
20
+ mean?: number;
21
+ sd?: number;
22
+ }): Float64Array;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Sum of array elements with optional NaN-skipping.
3
+ * When `skipna` is true (default) NaNs are ignored; returns NaN if no valid samples.
4
+ * Uses a fast dense path when global optimization allows it.
5
+ * @param source Input array
6
+ * @param skipna Whether to ignore NaNs (default: true)
7
+ * @returns Sum or NaN
8
+ */
9
+ export declare function sum(source: ArrayLike<number>, skipna?: boolean): number;
10
+ /**
11
+ * Cumulative sum preserving NaNs: NaN entries do not increase the running sum
12
+ * but are represented as the running total up to that point.
13
+ * @param source Input array
14
+ * @returns Float64Array of cumulative sums
15
+ */
16
+ export declare function cumsum(source: ArrayLike<number>): Float64Array;
17
+ /**
18
+ * Rolling sum over a window with optional NaN-skipping.
19
+ * If `skipna` is true, windows with no valid values produce NaN.
20
+ * Supports a fast dense path when inputs contain no NaNs.
21
+ * @param source Input array
22
+ * @param period Window length (must be > 0)
23
+ * @param skipna Whether to ignore NaNs (default: true)
24
+ * @returns Float64Array of rolling sums (NaN for positions before window fills)
25
+ */
26
+ export declare function rollsum(source: ArrayLike<number>, period: number, skipna?: boolean): Float64Array;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Stats barrel: re-export statistical helpers for convenient imports.
3
+ */
4
+ import { variance, covar, stdev, rollvar, rollstdev, rollcovar } from './var.js';
5
+ import { zscore, norminmax, corr, rollcorr, winsorize } from './transforms.js';
6
+ import { rollmean, mean, hmean, gmean, mad } from './mean.js';
7
+ import { median, rollmedian, quantile, percentiles, rollquantile } from './quantile.js';
8
+ import { skew, kurtosis, rollskew, rollkurtosis } from './skew.js';
9
+ import { bootstrap, sample, shuffle } from './sampling.js';
10
+ export { mean, hmean, gmean, mad, skew, kurtosis, median, quantile, percentiles, variance as var, covar, stdev, corr, rollcorr, rollmean, rollvar, rollcovar, rollstdev, rollmedian, rollquantile, rollskew, rollkurtosis, zscore, norminmax, winsorize, sample, shuffle, bootstrap };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Compute the (possibly weighted) mean of `source`.
3
+ * By default NaNs are skipped (`skipna=true`). When `weights` are provided they
4
+ * must match `source` length and the function computes the weighted mean.
5
+ * A dense fast-path is used when the global optimization allows it.
6
+ * @param source Input array
7
+ * @param options Optional `{ weights?, skipna? }`
8
+ * @returns Mean value or NaN when undefined
9
+ */
10
+ export declare function mean(source: ArrayLike<number>, options?: {
11
+ weights?: ArrayLike<number>;
12
+ skipna?: boolean;
13
+ }): number;
14
+ /**
15
+ * Rolling mean (moving average) over a sliding window of length `period`.
16
+ * When `skipna` is true, NaNs inside windows are ignored; windows with no
17
+ * valid values produce NaN. A fast dense path is used when no NaNs.
18
+ * @param source Input array
19
+ * @param period Window length (>0)
20
+ * @param skipna Whether to ignore NaNs (default: true)
21
+ * @returns Float64Array of rolling means
22
+ */
23
+ export declare function rollmean(source: ArrayLike<number>, period: number, skipna?: boolean): Float64Array;
24
+ /**
25
+ * Harmonic mean (optionally weighted). Values must be positive; NaNs are
26
+ * ignored when `skipna` is true. Returns NaN when no valid values.
27
+ * @param source Input array
28
+ * @param options Optional `{ weights?, skipna? }`
29
+ * @returns Harmonic mean or NaN
30
+ */
31
+ export declare function hmean(source: ArrayLike<number>, options?: {
32
+ weights?: ArrayLike<number>;
33
+ skipna?: boolean;
34
+ }): number;
35
+ /**
36
+ * Geometric mean (optionally weighted). Values must be positive; NaNs are
37
+ * ignored when `skipna` is true. Returns NaN when no valid values.
38
+ * @param source Input array
39
+ * @param options Optional `{ weights?, skipna? }`
40
+ * @returns Geometric mean or NaN
41
+ */
42
+ export declare function gmean(source: ArrayLike<number>, options?: {
43
+ weights?: ArrayLike<number>;
44
+ skipna?: boolean;
45
+ }): number;
46
+ /**
47
+ * Mean absolute deviation from the mean. When `skipna` is true NaNs are
48
+ * ignored. Returns NaN when the input contains no valid values.
49
+ * @param source Input array
50
+ * @param options Optional `{ skipna? }`
51
+ * @returns Mean absolute deviation or NaN
52
+ */
53
+ export declare function mad(source: ArrayLike<number>, skipna?: boolean): number;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Median of `source` (ignores NaNs). Implemented via `quantile(source, 0.5)`.
3
+ * @param source Input array
4
+ * @returns Median value or NaN
5
+ */
6
+ export declare function median(source: ArrayLike<number>): number;
7
+ /**
8
+ * Compute the rolling median over a sliding window.
9
+ * Ignores NaNs and validates `period`.
10
+ * Returns a Float64Array with NaN entries for positions before the window fills.
11
+ * @param source Input array
12
+ * @param period Window length
13
+ * @returns Float64Array of rolling medians
14
+ */
15
+ export declare function rollmedian(source: ArrayLike<number>, period: number): Float64Array;
16
+ /**
17
+ * Compute the quantile `q` of `source`, ignoring NaNs. Implements a
18
+ * selection-based algorithm using quickselect for expected linear time.
19
+ * @param source Input array
20
+ * @param q Quantile in [0,1]
21
+ * @returns Quantile value or NaN
22
+ */
23
+ export declare function quantile(source: ArrayLike<number>, q: number): number;
24
+ /**
25
+ * Compute multiple percentiles (quantiles) for `source`. When `qs.length`
26
+ * is small, selection is used for each quantile; otherwise the data are
27
+ * sorted once for efficiency.
28
+ * @param source Input array
29
+ * @param qs Array of quantiles in [0,1]
30
+ * @returns Array of quantile values
31
+ */
32
+ export declare function percentiles(source: ArrayLike<number>, qs: number[]): number[];
33
+ /**
34
+ * Compute the rolling quantile over a sliding window.
35
+ * Ignores NaNs and validates `period` and `q`.
36
+ * Returns a Float64Array with NaN entries for positions before the window fills.
37
+ * @param source Input array
38
+ * @param period Window length
39
+ * @param q Quantile in [0,1]
40
+ * @returns Float64Array of rolling quantiles
41
+ */
42
+ export declare function rollquantile(source: ArrayLike<number>, period: number, q: number): Float64Array;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * In-place Fisher–Yates shuffle of `arr`.
3
+ * Uses `Math.random()`; tests should stub `Math.random` for determinism.
4
+ * @param arr Array to shuffle (mutated)
5
+ * @returns The shuffled array (same reference)
6
+ */
7
+ export declare function shuffle<T>(arr: T[]): T[];
8
+ /**
9
+ * Draw `k` unique samples without replacement from `arr`.
10
+ * If `k` >= arr.length a shallow copy is returned. Uses `Math.random()`.
11
+ * @param arr Source array
12
+ * @param k Number of samples to draw
13
+ * @returns Array of sampled elements
14
+ */
15
+ export declare function sample<T>(arr: T[], k: number): T[];
16
+ /**
17
+ * Draw `k` bootstrap samples (with replacement) from `arr`.
18
+ * Uses `Math.random()`; tests should stub `Math.random` for determinism.
19
+ * @param arr Source array
20
+ * @param k Number of draws
21
+ * @returns Array of sampled elements (with replacement)
22
+ */
23
+ export declare function bootstrap<T>(arr: T[], k: number): T[];
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Fisher-Pearson sample skewness (ignores NaNs). Returns NaN when insufficient data.
3
+ * @param source Input array
4
+ * @returns Skewness or NaN
5
+ */
6
+ export declare function skew(source: ArrayLike<number>): number;
7
+ /**
8
+ * Excess kurtosis (kurtosis - 3) for `source` (ignores NaNs). Returns NaN when insufficient data.
9
+ * @param source Input array
10
+ * @returns Excess kurtosis or NaN
11
+ */
12
+ export declare function kurtosis(source: ArrayLike<number>): number;
13
+ /**
14
+ * Rolling skewness over a sliding window of length `period`.
15
+ * @param source Input array
16
+ * @param period Window length
17
+ * @returns Float64Array of rolling skewness values
18
+ */
19
+ export declare function rollskew(source: ArrayLike<number>, period: number): Float64Array;
20
+ /**
21
+ * Rolling excess kurtosis over a sliding window of length `period`.
22
+ * @param source Input array
23
+ * @param period Window length
24
+ * @returns Float64Array of rolling kurtosis values
25
+ */
26
+ export declare function rollkurtosis(source: ArrayLike<number>, period: number): Float64Array;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Compute z-scores for `source`: (x - mean) / std (ddof=1). NaNs preserved.
3
+ * @param source Input array
4
+ * @param options Optional `{ skipna? }` to ignore NaNs
5
+ * @returns Float64Array of z-scores
6
+ */
7
+ export declare function zscore(source: ArrayLike<number>, skipna?: boolean): Float64Array;
8
+ /**
9
+ * Normalize to [0,1] by min/max scaling. Preserves NaNs when `skipna` is true.
10
+ * @param source Input array
11
+ * @param options Optional `{ skipna? }`
12
+ * @returns Float64Array of normalized values
13
+ */
14
+ export declare function norminmax(source: ArrayLike<number>, skipna?: boolean): Float64Array;
15
+ /**
16
+ * Pearson correlation between `x` and `y`. When `skipna` is true only
17
+ * pairwise-valid entries are used; otherwise a dense fast-path is taken.
18
+ * @param x First input array
19
+ * @param y Second input array
20
+ * @param options Optional `{ skipna? }`
21
+ * @returns Correlation coefficient or NaN
22
+ */
23
+ export declare function corr(x: ArrayLike<number>, y: ArrayLike<number>, skipna?: boolean): number;
24
+ /**
25
+ * Rolling Pearson correlation computed from rolling covariance and stddev.
26
+ * Supports alignment modes via `options.outLength` ('min' or 'max').
27
+ * @param x First input array
28
+ * @param y Second input array
29
+ * @param period Window length
30
+ * @param options Optional `{ skipna?, outLength? }`
31
+ * @returns Float64Array of rolling correlations
32
+ */
33
+ export declare function rollcorr(x: ArrayLike<number>, y: ArrayLike<number>, period: number, options?: {
34
+ skipna?: boolean;
35
+ outLength?: 'min' | 'max';
36
+ }): Float64Array;
37
+ /**
38
+ * Winsorize values to the given lower and upper quantile bounds.
39
+ * Preserves NaNs when `skipna` is true.
40
+ * @param source Input array
41
+ * @param options Optional `{ lower?, upper?, skipna? }` where bounds are in [0,1]
42
+ * @returns Float64Array of winsorized values
43
+ */
44
+ export declare function winsorize(source: ArrayLike<number>, options?: {
45
+ lower?: number;
46
+ upper?: number;
47
+ skipna?: boolean;
48
+ }): Float64Array;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Variance: compute a single variance over the whole series, dropping NaNs.
3
+ * Uses `ddof` (delta degrees of freedom) like NumPy/pandas: denominator = N - ddof.
4
+ * Default pandas behavior is sample variance (ddof=1), so the default here is ddof=1.
5
+ */
6
+ export declare function variance(source: ArrayLike<number>, options?: {
7
+ ddof?: number;
8
+ skipna?: boolean;
9
+ }): number;
10
+ /**
11
+ * Standard deviation: compute a single standard deviation over the whole series, dropping NaNs.
12
+ * Uses `ddof` (delta degrees of freedom) like NumPy/pandas: denominator = N - ddof.
13
+ * Default pandas behavior is sample standard deviation (ddof=1), so the default here is ddof=1.
14
+ */
15
+ export declare function stdev(source: ArrayLike<number>, options?: {
16
+ ddof?: number;
17
+ skipna?: boolean;
18
+ }): number;
19
+ /**
20
+ * Pairwise covariance: cov(X,Y) = E[XY] - E[X]E[Y]
21
+ */
22
+ export declare function covar(x: ArrayLike<number>, y: ArrayLike<number>, options?: {
23
+ ddof?: number;
24
+ }): number;
25
+ /**
26
+ * Rolling variance over a sliding window. Accepts `{ skipna?, ddof? }`.
27
+ * @param source Input array
28
+ * @param period Window length (>0)
29
+ * @param options Optional `{ skipna?, ddof? }`
30
+ * @returns Float64Array of rolling variances
31
+ */
32
+ export declare function rollvar(source: ArrayLike<number>, period: number, options?: {
33
+ skipna?: boolean;
34
+ ddof?: number;
35
+ }): Float64Array;
36
+ export declare function rollcovar(x: ArrayLike<number>, y: ArrayLike<number>, period: number, options?: {
37
+ ddof?: number;
38
+ }): Float64Array;
39
+ export declare function rollstdev(source: ArrayLike<number>, period: number, options?: {
40
+ skipna?: boolean;
41
+ ddof?: number;
42
+ }): Float64Array;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Technical indicators barrel: re-export grouped TA modules for convenient imports.
3
+ * This file collects moving averages, momentum oscillators, trend and
4
+ * volatility indicators, as well as utility helpers.
5
+ */
6
+ export { dema, ema, hma, kama, sma, wma, vwma, trima, t3, tema, rma, } from './moving-averages/index.js';
7
+ export { ao, apo, aroon, change, cmo, kst, macd, mom, ppo, roc, rsi, stoch, stochrsi, ultosc, wpr } from './momentum-oscillators/index.js';
8
+ export type { KstOptions, UltoscOptions } from './momentum-oscillators/index.js';
9
+ export { supertrend, adx, adxr, dx, cci, di, dpo, ichimoku, psar } from './trend/index.js';
10
+ export type { IchimokuOptions } from './trend/index.js';
11
+ export { atr, tr, natr, bb, bbw, donchian, keltner } from './volatility/index.js';
12
+ export { adosc, obv, pnvi, wad, ad, mfi } from './volume-money-flow/index.js';
13
+ export { cross, crossover, crossunder, rising, falling } from './util.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Awesome Oscillator (AO): difference between short and long simple moving averages
3
+ * of the median price ((high + low)/2). Supports NaN-aware and dense fast-paths.
4
+ * @param high High price series
5
+ * @param low Low price series
6
+ * @param shortPeriod Short SMA period (default 5)
7
+ * @param longPeriod Long SMA period (default 34)
8
+ * @param skipna When true, ignore NaNs inside windows; false forces dense path
9
+ * @returns Float64Array AO series (NaN where undefined)
10
+ */
11
+ export declare function ao(high: ArrayLike<number>, low: ArrayLike<number>, shortPeriod?: number, longPeriod?: number, skipna?: boolean): Float64Array;