Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tripolskypetr/pump-anomaly/llms.txt
Use this file to discover all available pages before exploring further.
PumpMatrix is the main facade of the pump-anomaly library. It wraps the full training pipeline, the exit tensor, the liquidation-cascade detector, and the serialized allow-list policy into a single stable class. After training once with PumpMatrix.fit(), you call model.save() to persist the weights, then PumpMatrix.load() in production to restore the model without retraining. Execution methods — signals(), plan(), backtest(), planFor(), and planForAt() — return only actionable TradeSignal objects; veto decisions are filtered out internally before the result is returned.
Static Methods
PumpMatrix.fit()
Trains a new model from scratch on a history of channel signals. This is the slow path: it fetches 1m candles for every candidate burst, replays your production exit plan (trailing take / hard stop / staleness) over those candles to assign labels, then runs a grid search with time-series K-fold cross-validation. The winner is chosen by the one-standard-error rule (Breiman) rather than argmax, to avoid overfitting to grid noise.Array of channel-signal objects. Each item must have
channel, symbol, direction, and ts (Unix ms). Optional entryFromPrice / entryToPrice define the entry zone; an optional id threads through to dump() and live-signal origin for post-level tracebacks.Async candle source with signature
(symbol, interval, limit?, sDate?, eDate?) => Promise<ICandleData[]>. Training labels are built on 1m candles. The same function is reused by plan() at runtime for live cascade detection.Optional training configuration. Key fields:
grid?: Partial<TrainGrid>— override any grid axis (e.g. narrowhardStoporstaleMinutes).folds?: number— time-series K-fold count (default4).shrinkageK?: number— shrinkage strength for the objectivemean · N/(N+k)(default5).mode?: "auto" | "matrix" | "single"— entry-selection mode.auto(default) picksmatrixwhen the author correlation is viable, otherwise falls back tosingle.policy?: SignalPolicy— allow-list baked into the model at training time (serialized into model JSON). Execution can only narrow this, never widen it.reliability?: Partial<ReliabilityConfig>— override confidence thresholds.viability?: Partial<ViabilityConfig>— override matrix-viability thresholds for auto mode.selection?: Partial<SelectionConfig>— SE-corridor multiplier and nested-CV outer folds.onProgress?: ProgressFn— progress callback. Defaults to a stdout bar; passsilentProgressto suppress.metaLedger?: MetaLedgerState— meta-overfitting guard: if provided, the DSR certificate usesΣ configsacross all past fit attempts instead of just this grid’s size.
Promise<PumpMatrix> — a fully trained, ready-to-use model instance.
PumpMatrix.load()
Restores a previously trained model from serialized JSON. Does not retrain or touch candles. Use this in production aftermodel.save() wrote the weights to disk.
Either the JSON string produced by
model.save(), or a pre-parsed TrainedParams object (e.g. imported from a .json file with with { type: "json" }). The method handles backward-compatibility defaults for policy, riskReward, and pnl fields that were absent in earlier serialized models.PumpMatrix — a fully functional model instance without retraining.
Only params
version: 3 is supported. Models serialized by older versions of the library (v1 or v2) are incompatible due to structural changes in the exit tensor — retrain to upgrade.Execution Methods
Three methods cover the three candle-access patterns. Choose based on whether you are running live, have preloaded candles, or are replaying closed history.| Method | Candles used | Returns | Use |
|---|---|---|---|
signals(items, policy?) | None | TradeSignal[] | Fast path — cascade not evaluated; every outcome is enter |
plan(items, source, policy?) | Strictly before the signal | TradeSignal[] or Promise<TradeSignal[]> | Live decision — no look-ahead |
backtest(items, source, policy?) | After the signal | BacktestSignal[] or Promise<BacktestSignal[]> | Replay over closed history with realized PnL |
signals()
The main production call when you do not have candles available. Returns only executable signals — veto (liquidation cascade) is already filtered out. Because no candles are provided, the cascade detector is not evaluated, so every returned signal hasaction: "enter".
Live channel signals to evaluate.
Optional runtime policy that can only narrow the trained allow-list — never widen it. For example
{ allow: ["enter"] } suppresses inversion signals for this call only.TradeSignal[] — flat array of executable signals. Empty if all signals were vetoed or filtered by policy.
plan()
Live decision — fetches candles strictly before the signal to evaluate volume regime and squeeze pressure (squeezePressureBefore). Never looks at candles from the future. Accepts either an async getCandles function (returns a Promise) or a pre-loaded { symbol: candles } map (returns synchronously).
Live channel signals to evaluate.
Candle source. Pass a
getCandles function for the async path (same function used in fit), or a pre-loaded { SOLUSDT: candles, ... } map for the synchronous path. A broken symbol (data gap or adapter error) degrades gracefully to a no-candle signal rather than crashing the whole call.Optional runtime policy narrowing.
Promise<TradeSignal[]> (async) or TradeSignal[] (sync map).
backtest()
Replays each signal forward over closed historical candles and returns the realized PnL alongside the signal. Cascade pressure is evaluated from candles after the entry (squeezePressure rather than squeezePressureBefore), which is permissible because the history is already closed. Returns BacktestSignal — a TradeSignal extended with a result field containing pnl, reason, heldMinutes, etc.
Historical channel signals to replay.
Candle source providing candles after the signal (forward over the impact horizon). Same dual-overload pattern as
plan().Optional runtime policy narrowing.
Promise<BacktestSignal[]> (async) or BacktestSignal[] (sync map).
planFor()
Single-position live helper. Builds oneTradeSignal for a known (symbol, direction, channel) from a pre-loaded candle slice. Cascade is evaluated from candles before the last candle’s timestamp (live, no look-ahead). Returns null on veto or policy rejection.
Trading pair, e.g.
"SOLUSDT".Channel-posted direction (before any inversion).
Channel name, or
null for matrix-mode signals.Pre-loaded 1m candles ending at the signal timestamp. The entry timestamp is taken from the last candle.
Optional runtime policy narrowing.
TradeSignal | null — ready signal, or null if vetoed or outside policy.
planForAt()
Single-position backtest helper. LikeplanFor() but for a specific entryTs in the past, replaying the exit plan forward over the provided candles. Returns a BacktestSignal with the fully realized result.
Trading pair.
Channel-posted direction.
Channel name, or
null for matrix mode.1m candles covering the forward window from
entryTs. Entry zone defaults to open of the first candle (no entryFromPrice / entryToPrice override).Signal timestamp in Unix milliseconds.
Optional runtime policy narrowing.
BacktestSignal | null — signal with replayed result, or null on veto/policy rejection.
explain()
Returns the full internal prediction report for debugging: all verdicts (including skipped), the author cluster map, the detected lag τ, the burst window, the used mode, and the viability assessment. Useful for understanding why a particular burst was or was not turned into a signal.Items to evaluate.
PredictionResult with:
signals— onlyaction: "open"verdicts, sorted by confidence descendingverdicts— all verdicts includingaction: "skip"authors—Map<channel, clusterId>showing which channels belong to the same author clusterauthorCount— number of independent authors detectedtauMs— self-estimated characteristic lag between sibling channelswindowMs— effective burst synchrony windowusedMode—"matrix"or"single"as actually executedviability— why auto mode chose matrix or single (withreasonstring)
Serialization
save()
Serializes the full model to a JSON string. The output includes the trained detector config, exit tensor, policy, risk-reward statistics, PnL statistics, signal history, and all metadata. Pass this string toPumpMatrix.load() to restore without retraining.
string — JSON representation of TrainedParams (version 3).
dump()
Exports the training-time signal history of the selected configuration as a flat array ofSignalRecord objects, or as a JSON string. Includes signals that did not enter (entered: false) — non-entries from no-entry or cascade-veto — so external analytics can count skips alongside realized trades.
If
true, returns a JSON string. If false or omitted, returns a SignalRecord[] array. Defaults to false.SignalRecord[] | string.
SignalRecord contains: id?, ids?, symbol, direction, channel, ts, entered, entryPrice, exitPrice, pnl, peak, reason, heldMinutes, inverted, volRegime, independentClusters.
historySize
0 if the model was loaded from JSON that did not include history (e.g. stripped for deployment size).
Model Properties
These read-only getters expose training diagnostics, configuration, and statistics baked into the model.reliable
true if training had sufficient data for the model to be trustworthy. Computed as confidence >= 0.6 AND totalN >= 40. On a small sample this is false — the model still produces signals but warns you honestly. Grows to true as data accumulates.
confidence
[0, 1], computed as support × stability × significance. Each axis grows independently as data grows — support from sample size, stability from cross-fold consistency, significance from a t-test against zero. No code changes needed as data accumulates.
certification
certified: false is the honest refusal — training ran and argmax found a “best” config, but the certificate says the winner is a noise artifact. The e2e test fit-noise-rejection verifies that a full fit on a pure random walk always produces certified: false.
effectiveTrials
fit calls (meta-overfitting guard). If metaLedger was passed to fit, this equals Σ configs across all past fit attempts — the honest denominator for DSR. Without metaLedger, equals innerTrials (single fit, naïve N).
innerTrials
fit call. Used as the baseline for the DSR N-trials penalty in a single-fit scenario.
fitAttempts
fit has been run in the tracked chain (from metaLedger). Useful for auditing the meta-trial count in a self-learning loop.
labeling
totalSamples is zero, outcomes reveals why:
ok— labeled and enteredadapter-error—getCandlesthrew (look-ahead guard, data gap, unknown symbol)no-candles—getCandlesreturned empty (symbol or range gave nothing)no-entry— candles exist but no exit set entered the zone
errors maps each unique getCandles exception message to its occurrence count (e.g. { "ccxt: symbol not found": 32 }), so adapter errors are never silent.
impactHorizonMinutes
staleMinutes value selected by the grid for the global fallback — the maximum time a position is held before life-cap exit.
mode
"matrix" requires ≥ 2 independent author clusters converging on the same ticker. "single" treats every post as an entry; exit quality decides the outcome.
modeReason
"auto → single: one channel — correlation impossible""auto → matrix: 3 strong edges, overlap 5, clusters >1: 2""matrix задан явно (opts.mode)"
minClusters
2. Not applied in single mode.
minSharedEvents
config.viability. Default 3.
lookbackMinutes
plan() needs per signal: max(volBaselineWindow, cascadeWindowMinutes) + 5. In production, keep at least this many minutes of candle history available for every fresh signal.
exit
[mode][channel][symbol][direction][volRegime] with hierarchical fallback through symbol-dir → mode → global. Exposed for auditing which cell resolved a given signal’s exit via origin.exitSource.
policy
riskReward
pnl / hardStop (units of risk captured). Per-symbol statistics are used by the runtime minRiskReward filter; global is for reporting.