/** * Element-wise addition. * - If `b` is a number, returns `a + b` for each element. * - If `b` is an array, returns element-wise sum up to the shorter length. * @param a Left operand array * @param b Right operand array or scalar * @returns Float64Array of sums */ declare function add(a: ArrayLike, b: ArrayLike | number): Float64Array; /** * Element-wise subtraction. * - If `b` is a number, returns `a - b` for each element. * - If `b` is an array, returns element-wise difference up to the shorter length. * @param a Left operand array * @param b Right operand array or scalar * @returns Float64Array of differences */ declare function sub(a: ArrayLike, b: ArrayLike | number): Float64Array; /** * Element-wise multiplication. * - If `b` is a number, scales each element of `a` by `b`. * - If `b` is an array, returns element-wise products up to the shorter length. * @param a Left operand array * @param b Right operand array or scalar * @returns Float64Array of products */ declare function mul(a: ArrayLike, b: ArrayLike | number): Float64Array; /** * Element-wise division. * - If `b` is a number, divides each element of `a` by `b`. * - If `b` is an array, returns element-wise quotients up to the shorter length. * @param a Numerator array * @param b Denominator array or scalar * @returns Float64Array of quotients */ declare function div(a: ArrayLike, b: ArrayLike | number): Float64Array; /** * Element-wise average: (a + b) / 2. * Computes the average without allocating temporaries. * @param a First array * @param b Second array or scalar * @returns Float64Array of averages */ declare function avg(a: ArrayLike, b: ArrayLike | number): Float64Array; /** * Scale an array by a scalar: `source * s`. * @param source Input array * @param s Scale factor * @returns Float64Array scaled values */ declare function scale(source: ArrayLike, s: number): Float64Array; /** * Clamp values to the inclusive range [lo, hi]. Preserves NaN entries. * @param source Input array * @param lo Lower bound * @param hi Upper bound * @returns Float64Array with values clamped or NaN preserved */ declare function clamp(source: ArrayLike, lo: number, hi: number): Float64Array; /** * Element-wise absolute value. * @param source Input array * @returns Float64Array of absolute values */ declare function abs(source: ArrayLike): Float64Array; /** * Element-wise sign (-1, 0, 1) for each entry. * @param source Input array * @returns Float64Array of sign values */ declare function sign(source: ArrayLike): Float64Array; /** * Round values to nearest integer. Ties are rounded away from zero. * @param source Input array * @returns Float64Array of rounded integers */ declare function round(source: ArrayLike): Float64Array; /** * Element-wise floor operation. * @param source Input array * @returns Float64Array of floored values */ declare function floor(source: ArrayLike): Float64Array; /** * Element-wise ceil operation. * @param source Input array * @returns Float64Array of ceiled values */ declare function ceil(source: ArrayLike): Float64Array; /** * First difference: output[i] = source[i] - source[i-1]. * The first element is NaN (no previous value). * @param source Input array * @returns Float64Array of differences (first element NaN) */ declare function diff(source: ArrayLike): Float64Array; /** * Element-wise less-than comparison. Returns `Uint8Array` mask with 1 where true. * @param a Left operand * @param b Right operand or scalar * @returns Uint8Array mask of comparisons */ declare function lt(a: ArrayLike, b: ArrayLike | number): Uint8Array; /** * Element-wise less-than-or-equal comparison (with epsilon tolerance). * @param a Left operand * @param b Right operand or scalar * @returns Uint8Array mask of comparisons */ declare function lte(a: ArrayLike, b: ArrayLike | number): Uint8Array; /** * Element-wise greater-than comparison. Returns `Uint8Array` mask with 1 where true. * @param a Left operand * @param b Right operand or scalar * @returns Uint8Array mask of comparisons */ declare function gt(a: ArrayLike, b: ArrayLike | number): Uint8Array; /** * Element-wise greater-than-or-equal comparison (with epsilon tolerance). * @param a Left operand * @param b Right operand or scalar * @returns Uint8Array mask of comparisons */ declare function gte(a: ArrayLike, b: ArrayLike | number): Uint8Array; /** * Element-wise equality comparison using `Number.EPSILON` tolerance. * @param a Left operand * @param b Right operand or scalar * @returns Uint8Array mask of equality tests */ declare function eq(a: ArrayLike, b: ArrayLike | number): Uint8Array; /** * Element-wise inequality comparison. * @param a Left operand * @param b Right operand or scalar * @returns Uint8Array mask where elements are not equal */ declare function neq(a: ArrayLike, b: ArrayLike | number): Uint8Array; /** * Logical AND for boolean masks (Uint8Array) or with a scalar. * Returns a Uint8Array of 1/0 values. * @param a Left boolean mask * @param b Right boolean mask or scalar * @returns Uint8Array mask result */ declare function and(a: Uint8Array, b: Uint8Array | number): Uint8Array; /** * Logical OR for boolean masks (Uint8Array) or with a scalar. * Returns a Uint8Array of 1/0 values. * @param a Left boolean mask * @param b Right boolean mask or scalar * @returns Uint8Array mask result */ declare function or(a: Uint8Array, b: Uint8Array | number): Uint8Array; /** * Logical NOT for a boolean mask (Uint8Array). * @param a Input boolean mask * @returns Uint8Array mask with bits inverted */ declare function not(a: Uint8Array): Uint8Array; /** * Product of array elements, ignoring NaNs. Returns NaN if no valid entries. * @param source Input array * @returns Product of values or NaN */ declare function prod(source: ArrayLike): number; /** * Cumulative product (NaN-preserving). At each index the product of all prior valid elements. * @param source Input array * @returns Float64Array of cumulative products (NaN where input was NaN) */ declare function cumprod(source: ArrayLike): Float64Array; /** * Rolling product over a window. NaN-aware: windows with no valid entries produce NaN. * Zeros are handled efficiently by tracking counts. * @param source Input array * @param period Window length (must be > 0) * @returns Float64Array of rolling products (NaN for positions before window fills) */ declare function rollprod(source: ArrayLike, period: number): Float64Array; /** * Sum of array elements with optional NaN-skipping. * When `skipna` is true (default) NaNs are ignored; returns NaN if no valid samples. * Uses a fast dense path when global optimization allows it. * @param source Input array * @param skipna Whether to ignore NaNs (default: true) * @returns Sum or NaN */ declare function sum(source: ArrayLike, skipna?: boolean): number; /** * Cumulative sum preserving NaNs: NaN entries do not increase the running sum * but are represented as the running total up to that point. * @param source Input array * @returns Float64Array of cumulative sums */ declare function cumsum(source: ArrayLike): Float64Array; /** * Rolling sum over a window with optional NaN-skipping. * If `skipna` is true, windows with no valid values produce NaN. * Supports a fast dense path when inputs contain no NaNs. * @param source Input array * @param period Window length (must be > 0) * @param skipna Whether to ignore NaNs (default: true) * @returns Float64Array of rolling sums (NaN for positions before window fills) */ declare function rollsum(source: ArrayLike, period: number, skipna?: boolean): Float64Array; /** * Rolling minimum over a window. NaN-aware: windows containing only NaNs produce NaN. * @param source Input values * @param period Window length (must be > 0) * @returns Float64Array of rolling minima (NaN for positions before the window fills) */ declare function rollmin(source: ArrayLike, period: number): Float64Array; /** * Rolling maximum over a window. NaN-aware: windows containing only NaNs produce NaN. * @param source Input values * @param period Window length (must be > 0) * @returns Float64Array of rolling maxima (NaN for positions before the window fills) */ declare function rollmax(source: ArrayLike, period: number): Float64Array; /** * Compute rolling minima and maxima pairwise over two input series. * Optional callback `cb(minVal, maxVal, i)` is invoked for each computed window. * @param minSource Input for minima * @param maxSource Input for maxima * @param period Window length (must be > 0) * @param cb Optional callback invoked per window * @returns Object with `min` and `max` Float64Array results */ declare function rollminmax(minSource: ArrayLike, maxSource: ArrayLike, period: number, cb?: (minVal: number, maxVal: number, i: number) => void): { min: Float64Array; max: Float64Array; }; /** * Minimum of an array, ignoring NaNs. Returns NaN if no valid entries. * @param source Input array * @returns Minimum value or NaN */ declare function min(source: ArrayLike): number; /** * Maximum of an array, ignoring NaNs. Returns NaN if no valid entries. * @param source Input array * @returns Maximum value or NaN */ declare function max(source: ArrayLike): number; /** * Index of the first minimum value (ignores NaNs). Returns -1 if none found. * @param source Input array * @returns Index of minimum or -1 */ declare function argmin(source: ArrayLike): number; /** * Index of the first maximum value (ignores NaNs). Returns -1 if none found. * @param source Input array * @returns Index of maximum or -1 */ declare function argmax(source: ArrayLike): number; /** * Cumulative maximum: at each index the maximum over all prior valid elements. * NaNs are preserved in the output at positions where input is NaN. * @param source Input array * @returns Float64Array of cumulative maxima */ declare function cummax(source: ArrayLike): Float64Array; /** * Cumulative minimum: at each index the minimum over all prior valid elements. * NaNs are preserved in the output at positions where input is NaN. * @param source Input array * @returns Float64Array of cumulative minima */ declare function cummin(source: ArrayLike): Float64Array; /** * Rolling argmin: returns the index (into `source`) of the minimum value in each window. * Positions before the window fills are NaN. * @param source Input array * @param period Window length * @returns Float64Array of argmin indices (NaN when not available) */ declare function rollargmin(source: ArrayLike, period: number): Float64Array; /** * Rolling argmax: returns the index (into `source`) of the maximum value in each window. * Positions before the window fills are NaN. * @param source Input array * @param period Window length * @returns Float64Array of argmax indices (NaN when not available) */ declare function rollargmax(source: ArrayLike, period: number): Float64Array; /** * Generate `n` uniform random values in [lo, hi). * Uses `Math.random()`; tests should stub `Math.random` for determinism. * @param n Number of samples to generate * @param options Optional `{ lo, hi }` bounds (defaults to 0..1) * @returns Float64Array of length `n` */ declare function randuniform(n: number, options?: { lo?: number; hi?: number; }): Float64Array; /** * Generate `n` standard normal samples using the Box-Muller transform. * Uses `Math.random()`; tests should stub `Math.random` for determinism. * @param n Number of samples to generate * @param options Optional `{ mean, sd }` to shift/scale samples * @returns Float64Array of length `n` */ declare function randnormal(n: number, options?: { mean?: number; sd?: number; }): Float64Array; /** * Dot product of two vectors: sum_i x[i] * y[i]. * Operates up to the shorter length of the inputs. * @param x First vector * @param y Second vector * @returns Scalar dot product */ declare function dot(x: ArrayLike, y: ArrayLike): number; /** * Vector p-norm. Supports common p values (1, 2, Infinity) with a fast dense path. * When `skipna` is true the implementation ignores NaNs and returns NaN if no valid entries exist. * @param x Input vector * @param p Norm order (default 2) * @param skipna Whether to ignore NaNs (default true) * @returns Norm value or NaN */ declare function norm(x: ArrayLike, p?: number, skipna?: boolean): number; /** * Ordinary least squares for a simple linear model y = intercept + slope * x. * Ignores paired NaN entries and returns NaN coefficients if no valid pairs or singular design. * @param x Predictor values * @param y Response values * @returns Object with `intercept` and `slope` or NaNs on failure */ declare function ols(x: ArrayLike, y: ArrayLike): { intercept: number; slope: number; }; /** * Multiple linear regression using normal equations (adds intercept column internally). * Returns coefficient vector or null if the normal matrix is singular or inputs are empty. * @param X Design matrix (rows = observations, cols = features) * @param y Response vector * @returns Coefficient array [intercept, beta1, beta2, ...] or null */ declare function olsMulti(X: number[][], y: number[]): number[] | null; /** * Barrel exports for math helpers. Re-exports individual functions from * the `src/math` submodules for convenient imports. */ declare const index_d$3_abs: typeof abs; declare const index_d$3_add: typeof add; declare const index_d$3_and: typeof and; declare const index_d$3_argmax: typeof argmax; declare const index_d$3_argmin: typeof argmin; declare const index_d$3_avg: typeof avg; declare const index_d$3_ceil: typeof ceil; declare const index_d$3_clamp: typeof clamp; declare const index_d$3_cummax: typeof cummax; declare const index_d$3_cummin: typeof cummin; declare const index_d$3_cumprod: typeof cumprod; declare const index_d$3_cumsum: typeof cumsum; declare const index_d$3_diff: typeof diff; declare const index_d$3_div: typeof div; declare const index_d$3_dot: typeof dot; declare const index_d$3_eq: typeof eq; declare const index_d$3_floor: typeof floor; declare const index_d$3_gt: typeof gt; declare const index_d$3_gte: typeof gte; declare const index_d$3_lt: typeof lt; declare const index_d$3_lte: typeof lte; declare const index_d$3_max: typeof max; declare const index_d$3_min: typeof min; declare const index_d$3_mul: typeof mul; declare const index_d$3_neq: typeof neq; declare const index_d$3_norm: typeof norm; declare const index_d$3_not: typeof not; declare const index_d$3_ols: typeof ols; declare const index_d$3_olsMulti: typeof olsMulti; declare const index_d$3_or: typeof or; declare const index_d$3_prod: typeof prod; declare const index_d$3_randnormal: typeof randnormal; declare const index_d$3_randuniform: typeof randuniform; declare const index_d$3_rollargmax: typeof rollargmax; declare const index_d$3_rollargmin: typeof rollargmin; declare const index_d$3_rollmax: typeof rollmax; declare const index_d$3_rollmin: typeof rollmin; declare const index_d$3_rollminmax: typeof rollminmax; declare const index_d$3_rollprod: typeof rollprod; declare const index_d$3_rollsum: typeof rollsum; declare const index_d$3_round: typeof round; declare const index_d$3_scale: typeof scale; declare const index_d$3_sign: typeof sign; declare const index_d$3_sub: typeof sub; declare const index_d$3_sum: typeof sum; declare namespace index_d$3 { export { index_d$3_abs as abs, index_d$3_add as add, index_d$3_and as and, index_d$3_argmax as argmax, index_d$3_argmin as argmin, index_d$3_avg as avg, index_d$3_ceil as ceil, index_d$3_clamp as clamp, index_d$3_cummax as cummax, index_d$3_cummin as cummin, index_d$3_cumprod as cumprod, index_d$3_cumsum as cumsum, index_d$3_diff as diff, index_d$3_div as div, index_d$3_dot as dot, index_d$3_eq as eq, index_d$3_floor as floor, index_d$3_gt as gt, index_d$3_gte as gte, index_d$3_lt as lt, index_d$3_lte as lte, index_d$3_max as max, index_d$3_min as min, index_d$3_mul as mul, index_d$3_neq as neq, index_d$3_norm as norm, index_d$3_not as not, index_d$3_ols as ols, index_d$3_olsMulti as olsMulti, index_d$3_or as or, index_d$3_prod as prod, index_d$3_randnormal as randnormal, index_d$3_randuniform as randuniform, index_d$3_rollargmax as rollargmax, index_d$3_rollargmin as rollargmin, index_d$3_rollmax as rollmax, index_d$3_rollmin as rollmin, index_d$3_rollminmax as rollminmax, index_d$3_rollprod as rollprod, index_d$3_rollsum as rollsum, index_d$3_round as round, index_d$3_scale as scale, index_d$3_sign as sign, index_d$3_sub as sub, index_d$3_sum as sum, }; } /** * Simple Moving Average (SMA). * Computes the arithmetic mean over a sliding window. * When `skipna` is true, NaNs inside the window are ignored; when false * a dense fast-path is used (assumes no NaNs). * @param source Input series * @param period Window length (must be > 0) * @param skipna Whether to ignore NaNs inside windows (default: true) * @returns Float64Array of SMA values (NaN before window fills) */ declare function sma(source: ArrayLike, period: number, skipna?: boolean): Float64Array; /** * Exponential Moving Average (EMA). * Seeds on the first non-NaN value and uses the standard EMA recurrence. * Preserves NaN gaps in the input: outputs are NaN until enough valid samples * have been seen to initialize the EMA. * @param source Input series * @param period Smoothing period (must be > 0) * @returns Float64Array of EMA values (NaN where undefined) */ declare function ema(source: ArrayLike, period: number): Float64Array; /** * Weighted Moving Average (WMA). * Computes a linearly-weighted average over a sliding window with weights * 1..period (oldest..newest). When `skipna` is true NaNs are ignored * within the window; when false a dense fast-path is used. * @param source Input series * @param period Window length (must be > 0) * @param skipna Whether to ignore NaNs inside windows (default: true) * @returns Float64Array of WMA values (NaN before window fills) */ declare function wma(source: ArrayLike, period: number, skipna?: boolean): Float64Array; /** * Volume Weighted Moving Average (VWMA). * Computes pvSum / vSum over a sliding window, NaN-aware. When `skipna` is * true NaNs in either series are ignored within the window; when false a * dense fast-path is used (assumes no NaNs). * @param price Price series * @param volume Volume series * @param period Window length (>0) * @param skipna Whether to ignore NaNs inside windows (default: true) * @returns Float64Array of VWMA values (NaN before window fills) */ declare function vwma(price: ArrayLike, volume: ArrayLike, period: number, skipna?: boolean): Float64Array; /** * Double Exponential Moving Average (DEMA). * DEMA reduces lag by combining a single EMA and a double-smoothed EMA: * DEMA = 2 * EMA(source, period) - EMA(EMA(source, period), period). * Preserves NaN gaps and follows the same seeding semantics as `ema`. * @param source Input series * @param period Smoothing period (must be > 0) * @returns Float64Array of DEMA values (NaN where undefined) */ declare function dema(source: ArrayLike, period: number): Float64Array; /** * Triangular Moving Average (TRIMA). * A triangular-weighted moving average implemented via two `sma` passes. * Preserves NaN handling by delegating to `sma` implementations. * @param source Input series * @param period Window length (must be > 0) * @returns Float64Array of TRIMA values (NaN where undefined) */ declare function trima(source: ArrayLike, period: number): Float64Array; /** * Triple Exponential Moving Average (TEMA). * Combines three nested EMAs to reduce lag while smoothing: * TEMA = 3*EMA1 - 3*EMA2 + EMA3. Preserves NaN gaps and seeds * each EMA before emitting values. * @param source Input series * @param period Smoothing period (must be > 0) * @returns Float64Array of TEMA values (NaN where undefined) */ declare function tema(source: ArrayLike, period: number): Float64Array; /** * Hull Moving Average (HMA). * Computes a lower-lag smoothing by combining WMAs at different lengths * and then applying a final WMA on the derived series. Pine-compatible * and NaN-aware: NaNs propagate where insufficient valid samples exist. * @param source Input series * @param period Window length (must be > 0) * @returns Float64Array of HMA values (NaN where undefined) */ declare function hma(source: ArrayLike, period: number): Float64Array; /** * Kaufman Adaptive Moving Average (KAMA). * Adapts smoothing based on the efficiency ratio (market noise vs direction). * This implementation supports NaN-aware and dense fast-paths; when NaNs are * present the compacting + mapping strategy is used, otherwise an O(n) * incremental volatility approach is used for speed. * @param source Input series * @param period Efficiency smoothing lookback (must be > 0) * @param fastPeriod Fast smoothing period (default: 2) * @param slowPeriod Slow smoothing period (default: 30) * @param skipna Whether to ignore NaNs (default: true) * @returns Float64Array of KAMA values (NaN where undefined) */ declare function kama(source: ArrayLike, period: number, fastPeriod?: number, slowPeriod?: number, skipna?: boolean): Float64Array; /** * Wilder's Moving Average / RMA. * Implements the Wilder smoothing recurrence (rma = (rma*(period-1) + x)/period). * When `skipna` is true NaNs are ignored during seeding and updates; otherwise * a dense fast-path is used for NaN-free inputs. * @param source Input series * @param period Smoothing period (must be > 0) * @param skipna Whether to ignore NaNs during computation (default: true) * @returns Float64Array of RMA values (NaN before window fills) */ declare function rma(source: ArrayLike, period: number, skipna?: boolean): Float64Array; /** * Triple Exponential Moving Average (T3) * * T3 is a triple-smoothed moving average developed by Tim Tillson that reduces lag * and smoothing compared to traditional EMAs while maintaining responsiveness to price changes. * * @param source - Input data array * @param period - Smoothing period (default: 5) * @param volumeFactor - Volume factor for smoothing (default: 0.7) * @returns T3 values */ /** * Triple Exponential Moving Average (T3) * * Implemented following TA‑Lib's algorithm (see TA_T3 C implementation). * This inlines the nested EMA seeding (e1..e6) and performs a single-pass * update, which is significantly faster than calling `ema()` six times. * * Notes: * - Lookback = 6 * (period - 1) * - For inputs containing NaNs we propagate NaN outputs where we cannot * compute valid seeds or updates. */ declare function t3(source: ArrayLike, period: number, volumeFactor: number): Float64Array; /** * Awesome Oscillator (AO): difference between short and long simple moving averages * of the median price ((high + low)/2). Supports NaN-aware and dense fast-paths. * @param high High price series * @param low Low price series * @param shortPeriod Short SMA period (default 5) * @param longPeriod Long SMA period (default 34) * @param skipna When true, ignore NaNs inside windows; false forces dense path * @returns Float64Array AO series (NaN where undefined) */ declare function ao(high: ArrayLike, low: ArrayLike, shortPeriod?: number, longPeriod?: number, skipna?: boolean): Float64Array; /** * Absolute Price Oscillator (APO). * Computes the difference between a short and a long EMA of `src`. * Skips NaNs and seeds EMAs on the first valid value; returns NaN * for indices before both EMAs have filled. * @param src Input series * @param shortPeriod Short EMA period * @param longPeriod Long EMA period * @returns Float64Array of APO values (NaN where undefined) */ declare function apo(src: ArrayLike, shortPeriod: number, longPeriod: number): Float64Array; /** * Chande Momentum Oscillator (CMO). * Computes CMO over `period` using percent scaling in [-100, 100]. * Ignores NaNs in the input deltas; positions before the first * computable value are NaN. * @param src Input series * @param period Period over which to compute the oscillator * @returns Float64Array of CMO values (NaN where undefined) */ declare function cmo(src: ArrayLike, period: number): Float64Array; /** * Moving Average Convergence Divergence (MACD). * Produces the MACD line (short EMA - long EMA), the signal line (EMA of MACD), * and the histogram (MACD - signal). Skips NaNs and seeds EMAs on first valid * value; outputs are NaN until the EMAs and signal have seeded. * @param src Input series * @param shortPeriod Short EMA period * @param longPeriod Long EMA period * @param signalPeriod Signal EMA period * @returns Tuple `[macdLine, signalLine, histogram]` as Float64Array */ declare function macd(src: ArrayLike, shortPeriod: number, longPeriod: number, signalPeriod: number): [Float64Array, Float64Array, Float64Array]; /** * Momentum (difference) indicator. * Computes `src[i] - src[i - period]` for each index; positions where * the lagged value is not available are NaN. * @param src Input series * @param period Lag period (must be > 0) * @returns Float64Array of momentum values (NaN where undefined) */ declare function mom(src: ArrayLike, period: number): Float64Array; /** * Percentage Price Oscillator (PPO). * PPO = 100 * (EMA_short - EMA_long) / EMA_long. * Skips NaNs and seeds EMAs on first valid value; outputs are NaN until the * long EMA has enough data. When EMA_long is zero, returns 0 to avoid division. * @param src Input series * @param shortPeriod Short EMA period * @param longPeriod Long EMA period * @returns Float64Array of PPO values (NaN where undefined) */ declare function ppo(src: ArrayLike, shortPeriod: number, longPeriod: number): Float64Array; /** * Simple change over `period`. * Computes `src[i] - src[i-period]` for each index `i >= period`. * Outputs NaN for indices before `period` and propagates NaNs for invalid pairs. * @param src Input series * @param period Lookback period (must be > 0) * @returns Float64Array of simple change values (NaN where undefined) */ declare function change(src: ArrayLike, period: number): Float64Array; /** * Percentage Rate-of-Change (ROC). * Returns 100 * (src[i] - src[i-period]) / src[i-period]. NaN is returned * for indices before `period` or when a denominator is NaN/zero. * @param src Input series * @param period Lookback period (must be > 0) * @returns Float64Array of ROC values (NaN where undefined) */ declare function roc(src: ArrayLike, period: number): Float64Array; /** * Relative Strength Index (RSI) with optional NaN-aware behavior. * - `skipna=false` (dense path): assumes inputs contain no NaNs or that NaN * propagation is desired; uses a dense fast-path implementation. * - `skipna=true` (NaN-aware): skips NaNs when computing deltas and preserves * gaps in the output where insufficient valid data exists. * Seeding: the implementation seeds on the first valid value and uses Wilder * smoothing once the initial window is filled. * @param src Input series * @param period Lookback period for RSI (must be > 0) * @param skipna Whether to ignore NaNs during computation (default: true) * @returns Float64Array of RSI values (NaN where undefined) */ declare function rsi(src: ArrayLike, period: number, skipna?: boolean): Float64Array; /** * Stochastic oscillator (fast %K and %D smoothed outputs). * Computes fast %K based on rolling highest/lowest over `kPeriod`, then * smooths with `kSlow` and `dPeriod` using dense SMA. Assumes input series * length equality and returns NaN when insufficient data exists. * @param high High price series * @param low Low price series * @param close Close price series * @param kPeriod %K lookback period * @param kSlow Smoothing period for %K * @param dPeriod Smoothing period for %D * @returns Tuple `[slowK, slowD]` as Float64Array */ declare function stoch(high: ArrayLike, low: ArrayLike, close: ArrayLike, kPeriod: number, kSlow: number, dPeriod: number): [Float64Array, Float64Array]; /** * Stochastic RSI. * Applies a stochastic calculation to the RSI series, producing values in [0,1]. * This implementation is NaN-aware and maintains deques over valid RSI samples. * @param close Close price series * @param period RSI lookback period * @returns Float64Array of StochRSI values (NaN where undefined) */ declare function stochrsi(close: ArrayLike, period: number): Float64Array; type UltoscOptions = { s1?: number; s2?: number; s3?: number; }; /** * Ultimate Oscillator (ULTOSC). * Combines short-, mid-, and long-term averages of the buying pressure / true range * to produce a bounded oscillator in [0,100]. Preserves NaN inputs and returns * NaN for indices before the longest lookback has sufficient data. * @param high High price series * @param low Low price series * @param close Close price series * @param options Optional periods for short/mid/long (s1,s2,s3) * @returns Float64Array of Ultimate Oscillator values (NaN where undefined) */ declare function ultosc(high: ArrayLike, low: ArrayLike, close: ArrayLike, options?: UltoscOptions): Float64Array; /** * Williams %R (WPR). * Computes %R = (highestHigh - close) / (highestHigh - lowestLow) * -100 * over a rolling `period`. Uses `rollminmax` to compute window extrema and * returns NaN for indices before `period` or when the range is zero. * @param high High price series * @param low Low price series * @param close Close price series * @param period Lookback period (must be > 0) * @returns Float64Array of %R values (NaN where undefined) */ declare function wpr(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number): Float64Array; /** * Aroon indicator: returns `[up, down]` arrays in percentage form (0-100) * describing the time since the highest/lowest value within the lookback * `period`. Supports NaN-aware and dense fast-paths. * @param high High price series * @param low Low price series * @param period Lookback period (>0) * @param skipna When true ignore NaNs in windows; false forces dense path * @returns Tuple `[up, down]` Float64Array indicators */ declare function aroon(high: ArrayLike, low: ArrayLike, period: number, skipna?: boolean): [Float64Array, Float64Array]; /** * Know Sure Thing (KST) momentum oscillator * Default parameters match common KST configuration */ type KstOptions = { r1?: number; r2?: number; r3?: number; r4?: number; n1?: number; n2?: number; n3?: number; n4?: number; w1?: number; w2?: number; w3?: number; w4?: number; }; /** * Know Sure Thing (KST) momentum oscillator. * Computes a weighted sum of smoothed rate-of-change series. * Parameters may be supplied via the `options` object or defaults are used. * The output length equals `src.length`; positions before the required * lookback periods are NaN. * @param src Input series * @param options Optional parameters for ROC and smoothing windows * @returns Float64Array of KST values (NaN where insufficient data) */ declare function kst(src: ArrayLike, options?: KstOptions): Float64Array; /** * Commodity Channel Index (CCI). * Computes the typical price (TP) and compares to a moving average and * mean absolute deviation (MAD) scaled by 0.015. Positions before the * full lookback or with invalid inputs are NaN. * Performance: O(n*p) due to MAD recomputation per window. * @param high High price series * @param low Low price series * @param close Close price series * @param period Lookback period (must be > 0) * @returns Float64Array of CCI values (NaN where undefined) */ declare function cci(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number): Float64Array; /** * Directional Indicators (DI+ and DI-). * @param high High price series * @param low Low price series * @param close Close price series * @param period Lookback period (must be > 0) * @returns Tuple `[diplus, diminus]` as Float64Array */ declare function di(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number): [Float64Array, Float64Array]; /** * DX (Directional Movement Index). * @param high High price series * @param low Low price series * @param close Close price series * @param period Lookback period (must be > 0) * @returns Float64Array of DX values (NaN where undefined) */ declare function dx(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number): Float64Array; /** * Average Directional Index (ADX). * @param high High price series * @param low Low price series * @param close Close price series * @param period Lookback period (must be > 0) * @returns Float64Array of ADX values (NaN where undefined) */ declare function adx(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number): Float64Array; /** * ADXR (Average DX Rating) - smoothed ADX. * @param high High price series * @param low Low price series * @param close Close price series * @param period Lookback period (must be > 0) * @returns Float64Array of ADXR values (NaN where undefined) */ declare function adxr(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number): Float64Array; /** * Detrended Price Oscillator (DPO). * Computes DPO[i] = source[i - shift] - SMA(source, period)[i], where * shift = floor(period/2) + 1. Outputs are NaN for indices before the * shift or when insufficient data exists. * @param source Input series * @param period Lookback period (must be > 0) * @returns Float64Array of DPO values (NaN where undefined) */ declare function dpo(source: ArrayLike, period: number): Float64Array; /** * Parabolic SAR (PSAR) indicator. * @param high High price series * @param low Low price series * @param step Acceleration step increment (>0) * @param maxStep Maximum acceleration value (>= step) * @param skipna When true ignore NaNs; when false use dense fast-path * @returns Float64Array PSAR values (NaN for undefined positions) */ declare function psar(high: ArrayLike, low: ArrayLike, step: number, maxStep: number, skipna?: boolean): Float64Array; /** * Supertrend indicator. * Returns `[supertrend, finalUpper, finalLower, isUpMask]`. * `supertrend` contains the plotted trend line (either finalLower when up or finalUpper when down), * `finalUpper`/`finalLower` are the band values, and `isUpMask` is a Uint8Array mask (1 when up). * NaNs are preserved for invalid inputs or before enough data is available. * @param high High price series * @param low Low price series * @param close Close price series * @param period ATR lookback period * @param mult Multiplier applied to ATR to form bands * @returns Tuple `[supertrend, finalUpper, finalLower, isUpMask]` */ declare function supertrend(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number, mult: number): [Float64Array, Float64Array, Float64Array, Uint8Array]; type IchimokuOptions = { tenkan?: number; kijun?: number; senkouB?: number; }; /** * Ichimoku Kinko Hyo indicator components. * Returns `[tenkan, kijun, senkouA, senkouB, chikou]` where senkou lines * are shifted forward by the `kijun` displacement and chikou is the close * shifted backward. NaN is produced where rolling inputs are invalid. * @param high High price series * @param low Low price series * @param close Close price series * @param options Optional periods `{ tenkan, kijun, senkouB }` * @returns Tuple of Float64Array: `[tenkan, kijun, senkouA, senkouB, chikou]` */ declare function ichimoku(high: ArrayLike, low: ArrayLike, close: ArrayLike, options?: IchimokuOptions): [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array]; /** * True Range (TR). * TR[i] = max(high[i]-low[i], |high[i]-close[i-1]|, |low[i]-close[i-1]|). * Preserves NaNs and returns NaN where inputs are invalid. * @param high High price series * @param low Low price series * @param close Close price series * @returns Float64Array of TR values */ declare function tr(high: ArrayLike, low: ArrayLike, close: ArrayLike): Float64Array; /** * Average True Range (ATR). * Computes ATR using Wilder's RMA over the true-range series. Handles NaNs * via the `rma` NaN-aware implementation; returns NaN for indices before the * lookback is filled. * @param high High price series * @param low Low price series * @param close Close price series * @param period Lookback period (must be > 0) * @returns Float64Array of ATR values */ declare function atr(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number): Float64Array; declare function natr(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number): Float64Array; /** * Bollinger Bands (BB). * Returns `[middle, upper, lower]` where `middle` is the SMA, and `upper`/`lower` * are `middle ± mult * stddev`. Uses a NaN-aware or dense `rollstdev` depending * on input; positions before the window fills are NaN. * @param source Input series * @param period Window length (must be > 0) * @param mult Standard-deviation multiplier * @returns Tuple `[middle, upper, lower]` as Float64Array */ declare function bb(source: ArrayLike, period: number, mult: number): [Float64Array, Float64Array, Float64Array]; /** * Bollinger Band Width (BBW). * Returns the normalized width of the Bollinger Bands as percentage: `100*(upper-lower)/middle`. * NaNs propagate and positions with `middle === 0` leave the output unchanged (NaN or 0). * @param source Input series * @param period Window length * @param mult Standard-deviation multiplier used for BB * @returns Float64Array of BB width percentages */ declare function bbw(source: ArrayLike, period: number, mult: number): Float64Array; /** * Donchian Channels. * Returns `[upper, lower, middle]` where `upper` is the highest high * and `lower` the lowest low over the lookback `period`. `middle` is the * midpoint. NaNs propagate when inputs are invalid. * @param high High price series * @param low Low price series * @param period Lookback period (must be > 0) * @returns Tuple `[upper, lower, middle]` as Float64Array */ declare function donchian(high: ArrayLike, low: ArrayLike, period: number): [Float64Array, Float64Array, Float64Array]; /** * Keltner Channels. * Returns `[middle(EMA of typical price), upper, lower]` where upper/lower are `middle ± mult * ATR`. * Preserves NaNs when inputs are invalid. * @param high High price series * @param low Low price series * @param close Close price series * @param period Lookback period (must be > 0) * @param mult Multiplier applied to ATR * @returns Tuple `[middle, upper, lower]` as Float64Array */ declare function keltner(high: ArrayLike, low: ArrayLike, close: ArrayLike, period: number, mult: number): [Float64Array, Float64Array, Float64Array]; /** * Accumulation/Distribution (AD) line. * Computes the cumulative money flow: AD[i] = AD[i-1] + MFM[i] * volume[i], * where MFM = ((close - low) - (high - close)) / (high - low). * NaNs propagate for invalid input tuples and the accumulator only updates on finite values. * @param high High price series * @param low Low price series * @param close Close price series * @param volume Volume series * @returns Float64Array of AD values */ declare function ad(high: ArrayLike, low: ArrayLike, close: ArrayLike, volume: ArrayLike): Float64Array; /** * Accumulation/Distribution Oscillator (ADOSC). * Computes the difference between short- and long-term EMAs of the cumulative * money flow (AD). Supports NaN-aware and dense fast-paths; outputs are NaN * until the long EMA seeding is complete. * @param high High price series * @param low Low price series * @param close Close price series * @param volume Volume series * @param shortPeriod Short EMA period * @param longPeriod Long EMA period * @param skipna Whether to ignore NaNs during computation (default: true) * @returns Float64Array of ADOSC values (NaN where undefined) */ declare function adosc(high: ArrayLike, low: ArrayLike, close: ArrayLike, volume: ArrayLike, shortPeriod: number, longPeriod: number, skipna?: boolean): Float64Array; /** * Money Flow Index (MFI). * Computes MFI over `period` using typical price and money flow; NaN-aware * sliding-window implementation that emits NaN where insufficient valid data exists. * @param high High price series * @param low Low price series * @param close Close price series * @param volume Volume series * @param period Lookback period (must be > 0) * @returns Float64Array of MFI values in [0,100] */ declare function mfi(high: ArrayLike, low: ArrayLike, close: ArrayLike, volume: ArrayLike, period: number): Float64Array; /** * On-Balance Volume (OBV). * Accumulates volume by sign of price change: add volume when price rises, * subtract when price falls; NaNs in inputs yield NaN outputs for that index. * @param price Price series * @param volume Volume series * @returns Float64Array of OBV values */ declare function obv(price: ArrayLike, volume: ArrayLike): Float64Array; /** * Positive/Negative Volume Index (PNVI). * Returns `[pvi, nvi]` series tracking separate indices when volume increases * (PVI) or decreases (NVI). Preserves NaNs and treats zero close as missing. * @param close Close price series * @param volume Volume series * @param start Initial index value (default: 1000) * @returns Tuple `[pvi, nvi]` as Float64Array */ declare function pnvi(close: ArrayLike, volume: ArrayLike, start?: number): [Float64Array, Float64Array]; /** * Williams Accumulation/Distribution (WAD). * Accumulates the money flow based on price movement using either a dense * fast-path or a NaN-aware path depending on `skipna` and input contents. * @param high High price series * @param low Low price series * @param close Close price series * @param skipna Whether to ignore NaNs (default: true) * @returns Float64Array of WAD values (NaN where undefined) */ declare function wad(high: ArrayLike, low: ArrayLike, close: ArrayLike, skipna?: boolean): Float64Array; /** * Rising mask: returns a Uint8Array where `1` indicates `source[i]` is * strictly greater than the value `length` periods ago (NaN-aware). * When `skipna` is true, NaNs are tolerated and preserved; when false a * dense fast-path is used (assumes no NaNs). * @param source Input numeric series * @param length Lookback length (>0) * @param skipna Whether to ignore NaNs during computation (default: true) * @returns Uint8Array mask with 0/1 values */ declare function rising(source: ArrayLike, length: number, skipna?: boolean): Uint8Array; /** * Falling mask: returns a Uint8Array where `1` indicates `source[i]` is * strictly less than the value `length` periods ago (NaN-aware). * When `skipna` is true, NaNs are tolerated and preserved; when false a * dense fast-path is used (assumes no NaNs). * @param source Input numeric series * @param length Lookback length (>0) * @param skipna Whether to ignore NaNs during computation (default: true) * @returns Uint8Array mask with 0/1 values */ declare function falling(source: ArrayLike, length: number, skipna?: boolean): Uint8Array; /** * Test whether series `a` crosses `b` (or a scalar) between the previous and * current index. By default uses a symmetric cross test that detects both * upward and downward crossings. Comparisons are strict and require non-NaN * current and previous values for both operands. * @param a Left series * @param b Right series or scalar * @param test Optional custom comparator receiving (ai, aim1, bi, bim1) * @returns Uint8Array mask where 1 indicates a crossing at that index */ declare function cross(a: ArrayLike, b: ArrayLike | number, test?: (ai: number, aim1: number, bi: number, bim1: number) => boolean): Uint8Array; /** * Detect an upward crossover (a crosses above b). */ declare function crossover(a: ArrayLike, b: ArrayLike | number): Uint8Array; /** * Detect a downward crossunder (a crosses below b). */ declare function crossunder(a: ArrayLike, b: ArrayLike | number): Uint8Array; /** * Technical indicators barrel: re-export grouped TA modules for convenient imports. * This file collects moving averages, momentum oscillators, trend and * volatility indicators, as well as utility helpers. */ type index_d$2_IchimokuOptions = IchimokuOptions; type index_d$2_KstOptions = KstOptions; type index_d$2_UltoscOptions = UltoscOptions; declare const index_d$2_ad: typeof ad; declare const index_d$2_adosc: typeof adosc; declare const index_d$2_adx: typeof adx; declare const index_d$2_adxr: typeof adxr; declare const index_d$2_ao: typeof ao; declare const index_d$2_apo: typeof apo; declare const index_d$2_aroon: typeof aroon; declare const index_d$2_atr: typeof atr; declare const index_d$2_bb: typeof bb; declare const index_d$2_bbw: typeof bbw; declare const index_d$2_cci: typeof cci; declare const index_d$2_change: typeof change; declare const index_d$2_cmo: typeof cmo; declare const index_d$2_cross: typeof cross; declare const index_d$2_crossover: typeof crossover; declare const index_d$2_crossunder: typeof crossunder; declare const index_d$2_dema: typeof dema; declare const index_d$2_di: typeof di; declare const index_d$2_donchian: typeof donchian; declare const index_d$2_dpo: typeof dpo; declare const index_d$2_dx: typeof dx; declare const index_d$2_ema: typeof ema; declare const index_d$2_falling: typeof falling; declare const index_d$2_hma: typeof hma; declare const index_d$2_ichimoku: typeof ichimoku; declare const index_d$2_kama: typeof kama; declare const index_d$2_keltner: typeof keltner; declare const index_d$2_kst: typeof kst; declare const index_d$2_macd: typeof macd; declare const index_d$2_mfi: typeof mfi; declare const index_d$2_mom: typeof mom; declare const index_d$2_natr: typeof natr; declare const index_d$2_obv: typeof obv; declare const index_d$2_pnvi: typeof pnvi; declare const index_d$2_ppo: typeof ppo; declare const index_d$2_psar: typeof psar; declare const index_d$2_rising: typeof rising; declare const index_d$2_rma: typeof rma; declare const index_d$2_roc: typeof roc; declare const index_d$2_rsi: typeof rsi; declare const index_d$2_sma: typeof sma; declare const index_d$2_stoch: typeof stoch; declare const index_d$2_stochrsi: typeof stochrsi; declare const index_d$2_supertrend: typeof supertrend; declare const index_d$2_t3: typeof t3; declare const index_d$2_tema: typeof tema; declare const index_d$2_tr: typeof tr; declare const index_d$2_trima: typeof trima; declare const index_d$2_ultosc: typeof ultosc; declare const index_d$2_vwma: typeof vwma; declare const index_d$2_wad: typeof wad; declare const index_d$2_wma: typeof wma; declare const index_d$2_wpr: typeof wpr; declare namespace index_d$2 { export { index_d$2_ad as ad, index_d$2_adosc as adosc, index_d$2_adx as adx, index_d$2_adxr as adxr, index_d$2_ao as ao, index_d$2_apo as apo, index_d$2_aroon as aroon, index_d$2_atr as atr, index_d$2_bb as bb, index_d$2_bbw as bbw, index_d$2_cci as cci, index_d$2_change as change, index_d$2_cmo as cmo, index_d$2_cross as cross, index_d$2_crossover as crossover, index_d$2_crossunder as crossunder, index_d$2_dema as dema, index_d$2_di as di, index_d$2_donchian as donchian, index_d$2_dpo as dpo, index_d$2_dx as dx, index_d$2_ema as ema, index_d$2_falling as falling, index_d$2_hma as hma, index_d$2_ichimoku as ichimoku, index_d$2_kama as kama, index_d$2_keltner as keltner, index_d$2_kst as kst, index_d$2_macd as macd, index_d$2_mfi as mfi, index_d$2_mom as mom, index_d$2_natr as natr, index_d$2_obv as obv, index_d$2_pnvi as pnvi, index_d$2_ppo as ppo, index_d$2_psar as psar, index_d$2_rising as rising, index_d$2_rma as rma, index_d$2_roc as roc, index_d$2_rsi as rsi, index_d$2_sma as sma, index_d$2_stoch as stoch, index_d$2_stochrsi as stochrsi, index_d$2_supertrend as supertrend, index_d$2_t3 as t3, index_d$2_tema as tema, index_d$2_tr as tr, index_d$2_trima as trima, index_d$2_ultosc as ultosc, index_d$2_vwma as vwma, index_d$2_wad as wad, index_d$2_wma as wma, index_d$2_wpr as wpr }; export type { index_d$2_IchimokuOptions as IchimokuOptions, index_d$2_KstOptions as KstOptions, index_d$2_UltoscOptions as UltoscOptions }; } /** * Elementwise equality comparison of two arrays, treating NaNs as equal. * If `precision` is provided, numeric comparison uses a tolerance of 10^-precision. * @param source1 First input array * @param source2 Second input array * @param precision Optional decimal precision for fuzzy equality * @returns `true` if arrays are equal, `false` otherwise */ declare function equals(source1: ArrayLike, source2: ArrayLike, precision?: number): boolean; /** * Return true if all elements are NaN. * @param source Input array * @returns `true` when every entry is NaN */ declare function allna(source: ArrayLike): boolean; /** * Count NaN entries in `source`. * @param source Input array * @returns Number of NaNs in the array */ declare function countna(source: ArrayLike): number; /** * Test whether any of the provided arrays contains a NaN at the same index. * Performs a single-pass scan across arrays and exits early on the first NaN. * @param sources One or more input arrays * @returns `true` if any NaN is found, otherwise `false` */ declare function havena(...sources: ArrayLike[]): boolean; /** * Return a mask indicating NaN positions: 1 for NaN, 0 otherwise. * @param source Input array * @returns Float64Array mask of 0/1 values */ declare function isna(source: ArrayLike): Float64Array; /** * Inverse of `isna`: mask with 1 for valid numbers and 0 for NaNs. * @param source Input array * @returns Float64Array mask of 0/1 values */ declare function notna(source: ArrayLike): Float64Array; /** * Replace NaNs with `value`. When `inplace=true` and `source` is a Float64Array, * the original buffer is mutated. * @param source Input array * @param value Replacement value for NaNs * @param inplace Whether to mutate the input when possible * @returns Float64Array with NaNs replaced */ declare function fillna(source: ArrayLike, value: number, inplace?: boolean): Float64Array; /** * Forward-fill NaNs: propagate the last valid value forward. Leading NaNs remain NaN. * @param source Input array * @param inplace Whether to mutate the input when possible * @returns Float64Array with forward-filled values */ declare function ffill(source: ArrayLike, inplace?: boolean): Float64Array; /** * Backward-fill NaNs: propagate the next valid value backward. Trailing NaNs remain NaN. * @param source Input array * @param inplace Whether to mutate the input when possible * @returns Float64Array with backward-filled values */ declare function bfill(source: ArrayLike, inplace?: boolean): Float64Array; declare function lag(source: ArrayLike, shift?: number): Float64Array; /** * Replace occurrences of `fromValue` with `toValue`. If `fromValue` is NaN, * NaN entries are replaced. * @param source Input array * @param fromValue Value to replace (may be NaN) * @param toValue Replacement value * @param inplace Whether to mutate the input when possible * @returns Float64Array with replacements applied */ declare function replace(source: ArrayLike, fromValue: number, toValue: number, inplace?: boolean): Float64Array; /** * Remove NaN entries from `source` and return a compacted Float64Array. * @param source Input array * @returns New Float64Array containing only the non-NaN values */ declare function dropna(source: ArrayLike): Float64Array; declare const arr_d_allna: typeof allna; declare const arr_d_bfill: typeof bfill; declare const arr_d_countna: typeof countna; declare const arr_d_dropna: typeof dropna; declare const arr_d_equals: typeof equals; declare const arr_d_ffill: typeof ffill; declare const arr_d_fillna: typeof fillna; declare const arr_d_havena: typeof havena; declare const arr_d_isna: typeof isna; declare const arr_d_lag: typeof lag; declare const arr_d_notna: typeof notna; declare const arr_d_replace: typeof replace; declare namespace arr_d { export { arr_d_allna as allna, arr_d_bfill as bfill, arr_d_countna as countna, arr_d_dropna as dropna, arr_d_equals as equals, arr_d_ffill as ffill, arr_d_fillna as fillna, arr_d_havena as havena, arr_d_isna as isna, arr_d_lag as lag, arr_d_notna as notna, arr_d_replace as replace, }; } /** * Variance: compute a single variance over the whole series, dropping NaNs. * Uses `ddof` (delta degrees of freedom) like NumPy/pandas: denominator = N - ddof. * Default pandas behavior is sample variance (ddof=1), so the default here is ddof=1. */ declare function variance(source: ArrayLike, options?: { ddof?: number; skipna?: boolean; }): number; /** * Standard deviation: compute a single standard deviation over the whole series, dropping NaNs. * Uses `ddof` (delta degrees of freedom) like NumPy/pandas: denominator = N - ddof. * Default pandas behavior is sample standard deviation (ddof=1), so the default here is ddof=1. */ declare function stdev(source: ArrayLike, options?: { ddof?: number; skipna?: boolean; }): number; /** * Pairwise covariance: cov(X,Y) = E[XY] - E[X]E[Y] */ declare function covar(x: ArrayLike, y: ArrayLike, options?: { ddof?: number; }): number; /** * Rolling variance over a sliding window. Accepts `{ skipna?, ddof? }`. * @param source Input array * @param period Window length (>0) * @param options Optional `{ skipna?, ddof? }` * @returns Float64Array of rolling variances */ declare function rollvar(source: ArrayLike, period: number, options?: { skipna?: boolean; ddof?: number; }): Float64Array; declare function rollcovar(x: ArrayLike, y: ArrayLike, period: number, options?: { ddof?: number; }): Float64Array; declare function rollstdev(source: ArrayLike, period: number, options?: { skipna?: boolean; ddof?: number; }): Float64Array; /** * Compute z-scores for `source`: (x - mean) / std (ddof=1). NaNs preserved. * @param source Input array * @param options Optional `{ skipna? }` to ignore NaNs * @returns Float64Array of z-scores */ declare function zscore(source: ArrayLike, skipna?: boolean): Float64Array; /** * Normalize to [0,1] by min/max scaling. Preserves NaNs when `skipna` is true. * @param source Input array * @param options Optional `{ skipna? }` * @returns Float64Array of normalized values */ declare function norminmax(source: ArrayLike, skipna?: boolean): Float64Array; /** * Pearson correlation between `x` and `y`. When `skipna` is true only * pairwise-valid entries are used; otherwise a dense fast-path is taken. * @param x First input array * @param y Second input array * @param options Optional `{ skipna? }` * @returns Correlation coefficient or NaN */ declare function corr(x: ArrayLike, y: ArrayLike, skipna?: boolean): number; /** * Rolling Pearson correlation computed from rolling covariance and stddev. * Supports alignment modes via `options.outLength` ('min' or 'max'). * @param x First input array * @param y Second input array * @param period Window length * @param options Optional `{ skipna?, outLength? }` * @returns Float64Array of rolling correlations */ declare function rollcorr(x: ArrayLike, y: ArrayLike, period: number, options?: { skipna?: boolean; outLength?: 'min' | 'max'; }): Float64Array; /** * Winsorize values to the given lower and upper quantile bounds. * Preserves NaNs when `skipna` is true. * @param source Input array * @param options Optional `{ lower?, upper?, skipna? }` where bounds are in [0,1] * @returns Float64Array of winsorized values */ declare function winsorize(source: ArrayLike, options?: { lower?: number; upper?: number; skipna?: boolean; }): Float64Array; /** * Compute the (possibly weighted) mean of `source`. * By default NaNs are skipped (`skipna=true`). When `weights` are provided they * must match `source` length and the function computes the weighted mean. * A dense fast-path is used when the global optimization allows it. * @param source Input array * @param options Optional `{ weights?, skipna? }` * @returns Mean value or NaN when undefined */ declare function mean(source: ArrayLike, options?: { weights?: ArrayLike; skipna?: boolean; }): number; /** * Rolling mean (moving average) over a sliding window of length `period`. * When `skipna` is true, NaNs inside windows are ignored; windows with no * valid values produce NaN. A fast dense path is used when no NaNs. * @param source Input array * @param period Window length (>0) * @param skipna Whether to ignore NaNs (default: true) * @returns Float64Array of rolling means */ declare function rollmean(source: ArrayLike, period: number, skipna?: boolean): Float64Array; /** * Harmonic mean (optionally weighted). Values must be positive; NaNs are * ignored when `skipna` is true. Returns NaN when no valid values. * @param source Input array * @param options Optional `{ weights?, skipna? }` * @returns Harmonic mean or NaN */ declare function hmean(source: ArrayLike, options?: { weights?: ArrayLike; skipna?: boolean; }): number; /** * Geometric mean (optionally weighted). Values must be positive; NaNs are * ignored when `skipna` is true. Returns NaN when no valid values. * @param source Input array * @param options Optional `{ weights?, skipna? }` * @returns Geometric mean or NaN */ declare function gmean(source: ArrayLike, options?: { weights?: ArrayLike; skipna?: boolean; }): number; /** * Mean absolute deviation from the mean. When `skipna` is true NaNs are * ignored. Returns NaN when the input contains no valid values. * @param source Input array * @param options Optional `{ skipna? }` * @returns Mean absolute deviation or NaN */ declare function mad(source: ArrayLike, skipna?: boolean): number; /** * Median of `source` (ignores NaNs). Implemented via `quantile(source, 0.5)`. * @param source Input array * @returns Median value or NaN */ declare function median(source: ArrayLike): number; /** * Compute the rolling median over a sliding window. * Ignores NaNs and validates `period`. * Returns a Float64Array with NaN entries for positions before the window fills. * @param source Input array * @param period Window length * @returns Float64Array of rolling medians */ declare function rollmedian(source: ArrayLike, period: number): Float64Array; /** * Compute the quantile `q` of `source`, ignoring NaNs. Implements a * selection-based algorithm using quickselect for expected linear time. * @param source Input array * @param q Quantile in [0,1] * @returns Quantile value or NaN */ declare function quantile(source: ArrayLike, q: number): number; /** * Compute multiple percentiles (quantiles) for `source`. When `qs.length` * is small, selection is used for each quantile; otherwise the data are * sorted once for efficiency. * @param source Input array * @param qs Array of quantiles in [0,1] * @returns Array of quantile values */ declare function percentiles(source: ArrayLike, qs: number[]): number[]; /** * Compute the rolling quantile over a sliding window. * Ignores NaNs and validates `period` and `q`. * Returns a Float64Array with NaN entries for positions before the window fills. * @param source Input array * @param period Window length * @param q Quantile in [0,1] * @returns Float64Array of rolling quantiles */ declare function rollquantile(source: ArrayLike, period: number, q: number): Float64Array; /** * Fisher-Pearson sample skewness (ignores NaNs). Returns NaN when insufficient data. * @param source Input array * @returns Skewness or NaN */ declare function skew(source: ArrayLike): number; /** * Excess kurtosis (kurtosis - 3) for `source` (ignores NaNs). Returns NaN when insufficient data. * @param source Input array * @returns Excess kurtosis or NaN */ declare function kurtosis(source: ArrayLike): number; /** * Rolling skewness over a sliding window of length `period`. * @param source Input array * @param period Window length * @returns Float64Array of rolling skewness values */ declare function rollskew(source: ArrayLike, period: number): Float64Array; /** * Rolling excess kurtosis over a sliding window of length `period`. * @param source Input array * @param period Window length * @returns Float64Array of rolling kurtosis values */ declare function rollkurtosis(source: ArrayLike, period: number): Float64Array; /** * In-place Fisher–Yates shuffle of `arr`. * Uses `Math.random()`; tests should stub `Math.random` for determinism. * @param arr Array to shuffle (mutated) * @returns The shuffled array (same reference) */ declare function shuffle(arr: T[]): T[]; /** * Draw `k` unique samples without replacement from `arr`. * If `k` >= arr.length a shallow copy is returned. Uses `Math.random()`. * @param arr Source array * @param k Number of samples to draw * @returns Array of sampled elements */ declare function sample(arr: T[], k: number): T[]; /** * Draw `k` bootstrap samples (with replacement) from `arr`. * Uses `Math.random()`; tests should stub `Math.random` for determinism. * @param arr Source array * @param k Number of draws * @returns Array of sampled elements (with replacement) */ declare function bootstrap(arr: T[], k: number): T[]; /** * Stats barrel: re-export statistical helpers for convenient imports. */ declare const index_d$1_bootstrap: typeof bootstrap; declare const index_d$1_corr: typeof corr; declare const index_d$1_covar: typeof covar; declare const index_d$1_gmean: typeof gmean; declare const index_d$1_hmean: typeof hmean; declare const index_d$1_kurtosis: typeof kurtosis; declare const index_d$1_mad: typeof mad; declare const index_d$1_mean: typeof mean; declare const index_d$1_median: typeof median; declare const index_d$1_norminmax: typeof norminmax; declare const index_d$1_percentiles: typeof percentiles; declare const index_d$1_quantile: typeof quantile; declare const index_d$1_rollcorr: typeof rollcorr; declare const index_d$1_rollcovar: typeof rollcovar; declare const index_d$1_rollkurtosis: typeof rollkurtosis; declare const index_d$1_rollmean: typeof rollmean; declare const index_d$1_rollmedian: typeof rollmedian; declare const index_d$1_rollquantile: typeof rollquantile; declare const index_d$1_rollskew: typeof rollskew; declare const index_d$1_rollstdev: typeof rollstdev; declare const index_d$1_rollvar: typeof rollvar; declare const index_d$1_sample: typeof sample; declare const index_d$1_shuffle: typeof shuffle; declare const index_d$1_skew: typeof skew; declare const index_d$1_stdev: typeof stdev; declare const index_d$1_winsorize: typeof winsorize; declare const index_d$1_zscore: typeof zscore; declare namespace index_d$1 { export { index_d$1_bootstrap as bootstrap, index_d$1_corr as corr, index_d$1_covar as covar, index_d$1_gmean as gmean, index_d$1_hmean as hmean, index_d$1_kurtosis as kurtosis, index_d$1_mad as mad, index_d$1_mean as mean, index_d$1_median as median, index_d$1_norminmax as norminmax, index_d$1_percentiles as percentiles, index_d$1_quantile as quantile, index_d$1_rollcorr as rollcorr, index_d$1_rollcovar as rollcovar, index_d$1_rollkurtosis as rollkurtosis, index_d$1_rollmean as rollmean, index_d$1_rollmedian as rollmedian, index_d$1_rollquantile as rollquantile, index_d$1_rollskew as rollskew, index_d$1_rollstdev as rollstdev, index_d$1_rollvar as rollvar, index_d$1_sample as sample, index_d$1_shuffle as shuffle, index_d$1_skew as skew, index_d$1_stdev as stdev, variance as var, index_d$1_winsorize as winsorize, index_d$1_zscore as zscore, }; } /** * Compute simple period returns from a level series. * For each i>0: returns[i] = source[i]/source[i-1] - 1 when both values are finite and previous != 0. * The first element is always NaN. Invalid or non-finite inputs produce NaN at that position. * @param source Input level series (prices/equity) * @returns Float32Array of simple returns (same length as `source`) */ declare function returns(source: ArrayLike): Float32Array; /** * Compute log returns from a level series. * For each i>0: logreturns[i] = log(source[i]/source[i-1]) when both values are finite and previous>0. * The first element is always NaN. Invalid or non-positive previous values yield NaN. * @param source Input level series (prices/equity) * @returns Float32Array of log returns (same length as `source`) */ declare function logreturns(source: ArrayLike): Float32Array; /** * Compute cumulative compound returns from a returns series, skipping NaNs. * Cumulative return at i is prod_{j<=i, r_j finite} (1+r_j) - 1; NaN inputs leave an output NaN at that position. * @param returns Simple returns series * @returns Float64Array of cumulative returns */ declare function cumreturns(returns: ArrayLike): Float64Array; /** * Compute the compound annual growth rate (CAGR) from a returns series. * Ignores NaNs. `freq` is the number of periods per year (default 252). * @param returns Simple returns series * @param freq Periods per year (default 252) * @returns CAGR as a number, or NaN when insufficient data */ declare function cagr(returns: ArrayLike, freq?: number): number; /** * Aggregate irregular (event-aligned) returns into calendar-day returns. * * The function groups `returnsArr` by calendar day (optionally shifted by `tzOffsetMinutes`), * compounds returns within each day (prod(1+r)-1) and returns a continuous range of days * from the minimum to the maximum observed day. Missing days are filled with zero returns. * * @param tsMs Array of timestamps (ms since epoch) aligned to `returnsArr` * @param returnsArr Array of simple returns aligned to `tsMs` * @param tzOffsetMinutes Optional timezone offset in minutes (default 0, UTC) * @returns Object { days: number[], dailyReturns: Float32Array } */ declare function dailyreturns(tsMs: ArrayLike, returnsArr: ArrayLike, tzOffsetMinutes?: number): { days: number[]; dailyReturns: Float32Array; }; type DrawdownDurationResult = { durations: Int32Array; maxDuration: number; }; type MaxDrawdownInfo = { maxDrawdown: number; peakIndex: number; troughIndex: number; startIndex: number; endIndex: number; }; /** * Compute the drawdown series from an equity/price series. * For valid points: out[i] = equity[i]/peak - 1 (<= 0). NaNs propagate and do not update the peak. * @param equity Array-like equity or price series * @returns Float64Array of drawdowns (same length) */ declare function dd(equity: ArrayLike): Float64Array; /** * Compute the maximum drawdown magnitude over the entire series. * Returns a positive number (0..+inf) or NaN when no valid points. * @param equity Array-like equity or price series * @returns Maximum drawdown magnitude (positive) or NaN */ declare function maxdd(equity: ArrayLike): number; /** * Compute detailed information about the maximum drawdown, including peak, trough, and recovery indices. * When no valid points exist returns NaN/placeholder indices (-1). * @param equity Array-like equity or price series * @returns MaxDrawdownInfo with `maxDrawdown`, `peakIndex`, `troughIndex`, `startIndex`, and `endIndex` */ declare function maxddDetails(equity: ArrayLike): MaxDrawdownInfo; /** * Rolling maximum drawdown over a trailing window. * For each index i computes the max drawdown observed within the trailing window. * @param equity Array-like equity or price series * @param window Rolling window length (positive integer) * @returns Float64Array of rolling max drawdowns */ declare function rollmaxdd(equity: ArrayLike, window: number): Float64Array; /** * Compute drawdown durations (consecutive periods in current drawdown) and the maximum duration. * Positions where equity is NaN are marked with -1. * @param equity Array-like equity or price series * @returns DrawdownDurationResult { durations: Int32Array, maxDuration: number } */ declare function dduration(equity: ArrayLike): DrawdownDurationResult; /** * Recovery factor: ratio of annualized return (CAGR) to maximum drawdown magnitude. * Returns NaN if insufficient data, invalid start value, or zero/NaN max drawdown. * @param equity Array-like equity or price series * @param freq Periods per year (default 252) * @returns Recovery factor or NaN */ declare function recoveryfactor(equity: ArrayLike, freq?: number): number; /** * Calmar ratio: CAGR over a lookback period divided by the max drawdown magnitude over the same period. * If `lookbackPeriodYears` is null uses the entire series. Returns NaN on invalid inputs or zero drawdown. * @param equity Array-like equity or price series * @param lookbackPeriodYears Lookback window in years (null = full span) * @param freq Periods per year (default 252) * @returns Calmar ratio or NaN */ declare function calmar(equity: ArrayLike, lookbackPeriodYears?: number | null, freq?: number): number; /** * Ulcer Index: measures depth and duration of drawdowns (root-mean-square of depths). * Returns NaN for empty input. * @param equity Array-like equity or price series * @returns Ulcer Index (>=0) or NaN */ declare function ulcer(equity: ArrayLike): number; /** * Rolling Ulcer Index computed over a trailing window. * Returns NaN for windows with insufficient valid samples (< minPeriod) or invalid window. * @param equity Array-like equity or price series * @param window Rolling window length (positive integer) * @param minPeriod Minimum number of valid points required in window * @returns Float64Array of rolling ulcer index values */ declare function rollulcer(equity: ArrayLike, window: number, minPeriod?: number): Float64Array; /** * Compute the (annualized) Sharpe ratio for a returns series. * Uses NaN-aware mean and sample standard deviation (ddof=1). * Returns NaN for empty input, zero or NaN volatility, or invalid mean. * @param returns Array-like returns series * @param riskFree Annualized risk-free rate (default 0) * @param freq Periods per year (default 252) * @returns Sharpe ratio (annualized) or NaN */ declare function sharpe(returns: ArrayLike, riskFree?: number, freq?: number): number; /** * Compute the (annualized) Sortino ratio for a returns series. * Uses downside deviation (sample corrected) computed over negative excess returns. * Requires at least two downside observations; returns NaN otherwise. * @param returns Array-like returns series * @param requiredReturn Target return to define downside (default 0) * @param freq Periods per year (default 252) * @param minPeriod Minimum valid periods (unused for scalar Sortino) * @returns Sortino ratio (annualized) or NaN */ declare function sortino(returns: ArrayLike, requiredReturn?: number, freq?: number, minPeriod?: number): number; /** * Rolling Sharpe ratio computed over a trailing window. * Output is a Float64Array aligned with `returns`; positions before enough data are NaN. * @param returns Array-like returns series * @param window Rolling window length * @param riskFree Annualized risk-free rate (default 0) * @param freq Periods per year (default 252) * @param minPeriod Minimum number of valid samples required per window (default 1) * @returns Float64Array of rolling Sharpe ratios */ declare function rollsharpe(returns: ArrayLike, window: number, riskFree?: number, freq?: number, minPeriod?: number): Float64Array; /** * Rolling Sortino ratio computed over a trailing window using downside deviations. * Outputs NaN where insufficient downside or invalid data exists. * @param returns Array-like returns series * @param window Rolling window length * @param requiredReturn Target return to define downside (default 0) * @param freq Periods per year (default 252) * @param minPeriod Minimum number of valid samples required per window (default 1) * @returns Float64Array of rolling Sortino ratios */ declare function rollsortino(returns: ArrayLike, window: number, requiredReturn?: number, freq?: number, minPeriod?: number): Float64Array; /** * Annualized volatility (sample standard deviation) of returns. * Uses NaN-aware `stats.stdev` with ddof=1. Returns NaN for empty input or zero/NaN sigma. * @param returns Array-like returns series * @param freq Periods per year (default 252) * @returns Annualized volatility or NaN */ declare function vol(returns: ArrayLike, freq?: number): number; /** * Rolling annualized volatility (sample stddev) over a trailing window. * Outputs NaN for windows with insufficient valid samples or zero/NaN sigma. * @param returns Array-like returns series * @param window Rolling window length * @param freq Periods per year (default 252) * @param minPeriod Minimum number of valid samples required per window (default 1) * @returns Float64Array of rolling volatilities */ declare function rollvol(returns: ArrayLike, window: number, freq?: number, minPeriod?: number): Float64Array; /** * Value-at-Risk (VaR) estimator. * Supports `historical` (empirical quantile) and `parametric` (normal) methods. * Returns NaN for empty inputs or invalid alpha or when parametric stats are invalid. * @param returns Array-like returns series * @param alpha Tail probability (default 0.05) * @param method 'historical' | 'parametric' (default 'historical') * @returns VaR as a number (left-tail) or NaN */ declare function valueAtRisk(returns: ArrayLike, alpha?: number, method?: 'historical' | 'parametric'): number; /** * Expected shortfall (conditional tail expectation) estimator. * Supports `historical` (empirical mean of losses <= VaR) and `parametric` (normal) methods. * Returns NaN for empty inputs, invalid alpha, or invalid parametric stats. * @param returns Array-like returns series * @param alpha Tail probability (default 0.05) * @param method 'historical' | 'parametric' (default 'historical') * @returns Expected shortfall (left-tail) or NaN */ declare function expshortfall(returns: ArrayLike, alpha?: number, method?: 'historical' | 'parametric'): number; /** * Tail ratio: mean of upper tail divided by absolute mean of lower tail. * Returns NaN for empty inputs, invalid alpha, or when either tail has no observations or lower mean is zero. * @param returns Array-like returns series * @param alpha Tail probability (default 0.05) * @returns Tail ratio or NaN */ declare function tail(returns: ArrayLike, alpha?: number): number; /** * Omega ratio: sum of gains above `requiredReturn` divided by sum of losses below it. * Returns NaN for empty inputs or when there is no variation (all gains or all losses zero). * @param returns Array-like returns series * @param requiredReturn Threshold for gains/losses (default 0) * @returns Omega ratio number, Infinity if no losses, or NaN when no variation */ declare function omega(returns: ArrayLike, requiredReturn?: number): number; type index_d_DrawdownDurationResult = DrawdownDurationResult; type index_d_MaxDrawdownInfo = MaxDrawdownInfo; declare const index_d_cagr: typeof cagr; declare const index_d_calmar: typeof calmar; declare const index_d_cumreturns: typeof cumreturns; declare const index_d_dailyreturns: typeof dailyreturns; declare const index_d_dd: typeof dd; declare const index_d_dduration: typeof dduration; declare const index_d_expshortfall: typeof expshortfall; declare const index_d_logreturns: typeof logreturns; declare const index_d_maxdd: typeof maxdd; declare const index_d_maxddDetails: typeof maxddDetails; declare const index_d_omega: typeof omega; declare const index_d_recoveryfactor: typeof recoveryfactor; declare const index_d_returns: typeof returns; declare const index_d_rollmaxdd: typeof rollmaxdd; declare const index_d_rollsharpe: typeof rollsharpe; declare const index_d_rollsortino: typeof rollsortino; declare const index_d_rollulcer: typeof rollulcer; declare const index_d_rollvol: typeof rollvol; declare const index_d_sharpe: typeof sharpe; declare const index_d_sortino: typeof sortino; declare const index_d_tail: typeof tail; declare const index_d_ulcer: typeof ulcer; declare const index_d_valueAtRisk: typeof valueAtRisk; declare const index_d_vol: typeof vol; declare namespace index_d { export { index_d_cagr as cagr, index_d_calmar as calmar, index_d_cumreturns as cumreturns, index_d_dailyreturns as dailyreturns, index_d_dd as dd, index_d_dduration as dduration, index_d_expshortfall as expshortfall, index_d_logreturns as logreturns, index_d_maxdd as maxdd, index_d_maxddDetails as maxddDetails, index_d_omega as omega, index_d_recoveryfactor as recoveryfactor, index_d_returns as returns, index_d_rollmaxdd as rollmaxdd, index_d_rollsharpe as rollsharpe, index_d_rollsortino as rollsortino, index_d_rollulcer as rollulcer, index_d_rollvol as rollvol, index_d_sharpe as sharpe, index_d_sortino as sortino, index_d_tail as tail, index_d_ulcer as ulcer, index_d_valueAtRisk as valueAtRisk, valueAtRisk as var, index_d_vol as vol }; export type { index_d_DrawdownDurationResult as DrawdownDurationResult, index_d_MaxDrawdownInfo as MaxDrawdownInfo }; } export { arr_d as arr, index_d$3 as math, index_d as perf, index_d$1 as stats, index_d$2 as ta }; export type { DrawdownDurationResult, IchimokuOptions, KstOptions, MaxDrawdownInfo, UltoscOptions };