/** * Pure finance helpers. Each takes values in time order and returns an array of the same length, * with `null` wherever the input is missing or the window has not filled yet, so results line up * with the rows they came from. */ export type Series = readonly (number | null | undefined)[]; /** Simple moving average over the last `period` values; a gap in the window yields null. */ export declare function sma(values: Series, period: number): (number | null)[]; /** * Exponential moving average, seeded with the simple average of the first `period` values. * A missing value reads null and leaves the average where it was. */ export declare function ema(values: Series, period: number): (number | null)[]; /** * Relative strength index with Wilder's smoothing, from 0 to 100. The first reading needs * `period` changes, so it lands on index `period`. */ export declare function rsi(values: Series, period?: number): (number | null)[]; export interface MacdResult { macd: (number | null)[]; signal: (number | null)[]; histogram: (number | null)[]; } /** Moving average convergence divergence: fast EMA minus slow EMA, its signal EMA, and the gap. */ export declare function macd(values: Series, fast?: number, slow?: number, signal?: number): MacdResult; export interface BollingerResult { middle: (number | null)[]; upper: (number | null)[]; lower: (number | null)[]; } /** Bollinger bands: a simple average with bands `deviations` population deviations either side. */ export declare function bollinger(values: Series, period?: number, deviations?: number): BollingerResult; /** How far each value sits below the highest so far: 0 at a new high, −0.05 five percent below. */ export declare function drawdown(values: Series): (number | null)[]; /** Change from the first present value as a fraction, so series of different sizes compare. */ export declare function rebase(values: Series): (number | null)[]; export interface BookLevel { price: number; size: number; } export interface DepthLevel { price: number; /** Cumulative bid size from the best bid down to this price; null on the ask side. */ bid: number | null; /** Cumulative ask size from the best ask up to this price; null on the bid side. */ ask: number | null; /** Size resting at exactly this price. */ size: number; side: 'bid' | 'ask'; } export interface DepthSummary { /** Every level in ascending price, bids then asks. */ levels: DepthLevel[]; bestBid: number | null; bestAsk: number | null; mid: number | null; spread: number | null; bidDepth: number; askDepth: number; } /** * Cumulative depth on each side of the book. Bids accumulate from the best (highest) bid down, * asks from the best (lowest) ask up. Prices at one level merge. */ export declare function depthLevels(bids: readonly BookLevel[], asks: readonly BookLevel[]): DepthSummary;