Parameter sweep engine over crowd trading ideas (the "Sweep").
Finds production strategy parameters (hard stop, trailing take,
hold duration, author ban rule) by simulating every idea against
every point of the grid — WITHOUT re-running a backtest per point.
Authors are graded STRICTLY in isolation — no interaction metrics
(consensus counting, vote weighting) exist here by design; swarm
ranking over long histories is userspace. The root iteration is
over IDEAS, not candles and not grid points:
Each idea gets ONE asynchronous forward candle pass from the
minute after its publication, capped by the grid's longest
hold (max of the holdMinutes axis — the schema defines the
horizon, not an engine constant). The pass produces a
per-candle trajectory
profile (MFE/MAE extremes, whale shakeout depth). Overlapping
and sparse ideas are both supported: candle chunks are fetched
lazily through the Exchange (persist cache first), gaps between
ideas are never requested.
The author ban list is TRAINED on the whole range (lookahead
inside train is deliberate): authors with enough ideas and a hit
rate worse than a coin are excluded from entries. The list is
part of the result — apply it in production as-is.
The outcome of every grid point is derived arithmetically from
the profiles with production slot semantics (one position per
author, busy-slot ideas skipped). Honesty contracts: entry at
next-minute open, exits by candle wicks (never close-to-close),
stop wins inside an ambiguous candle, trailing arms only from
previous-candle peaks, fees and slippage from GLOBAL_CONFIG on
both legs.
Grid winners are picked by four rankings (Sharpe, Sortino, PnL,
total PnL) with an anti-fluke minimum-trades guard.
Every stage emits an ISweepCallbacks hook; the client itself
is stateless between runs — each run() call is independent.
Validation of the chosen parameters MUST be done by a real engine
backtest (Backtest.run): the sweep picks candidates, it does
not replace the engine.
Filters the input array by symbol, sorts by publication time,
drops NEUTRAL ideas and flood duplicates (at most one idea
per author per direction per AUTHOR_DEDUPE_MINUTES)
-> onIdeas(symbol, total, directional).
Builds one trajectory profile per idea (lazy candle fetch
through the Exchange schema; ideas with no candle data are
dropped) -> onProfiles(symbol, profiles, truncatedCount).
Trains the author ban list on the whole range
-> onAuthorsTrained(symbol, stats, bannedIdeas).
Evaluates the cartesian grid of params.gridAxes over the
profiles, checking trade invariants on every point
-> onGridPoint(symbol, report, trades) per point.
Ranks all points by Sharpe, Sortino and total PnL
-> onRanking(symbol, criterion, sorted, best) per criterion.
Assembles the final result -> onDone(symbol, result).
The ideas array may contain multiple symbols — foreign ones are
filtered out before any computation, so one shared feed can be
passed for every symbol.