MarketDeck docs
trails
Real-wallet trailing stop-loss state — read, configure, and inspect the daemon-evaluated trails.
Hyperliquid has no native "trail this SL" primitive — it only accepts fixed trigger prices. MarketDeck keeps per-(wallet, coin) trail metadata in a sidecar JSON file and a daemon feed re-submits a tighter SL whenever price moves favourably enough.
Usage#
marketdeck trails <subcommand> [args]
Subcommands#
| Subcommand | What it does |
|---|---|
list | Every active trail. Shows wallet, coin, trail %, last submitted SL, fail count, last update. |
show <wallet> <coin> | Single entry, full record. |
set <wallet> <coin> --pct N [--sl X] | Upsert a trail entry. --pct is the trail distance in percent; --sl seeds the last-submitted SL. |
clear <wallet> <coin> | Remove a trail. |
<wallet> resolves by uuid / prefix / name.
Examples#
marketdeck trails list --format text
marketdeck trails set live BTC --pct 2 --sl 65000
marketdeck trails show live BTC
marketdeck trails clear live BTC
How the daemon evaluates them#
The trailing-stop loop lives at lib/daemon/feeds/real-trailing.js. Every 15 s the feed:
- Reads every trail entry.
- Groups by wallet so one
userStateHTTP round-trip serves every trail on that wallet. - For each (wallet, coin), looks up the live position; if there's no open position, clears the trail.
- Reads the current mid via the daemon's mids feed (cached) or falls back to a one-shot
assetInfocall. - Computes the new SL:
mark × (1 − trail_pct/100)for longs,mark × (1 + trail_pct/100)for shorts. - Rounds to the exchange's
pxDecimals. - Submits only when the new SL is tighter than the previous one by at least 0.05 % (a "dead zone" against thrash).
- Submits via
modifyBracketSlTp, preserving existing TPs. - Records success / failure in the store. After three consecutive failures the feed emits a
trail_failureevent for the UI (throttled to one notify per 30 minutes per trail).
The math is unit-tested in test-trailing.js. The exchange half-path is exercised through manual smoke tests against a Testnet wallet — never let a never-tested change to this file go live unverified.
Channel + RPC#
Subscribe to realTrailing on the daemon to receive every ratchet / failure event live:
marketdeck daemon attach --channel realTrailing
RPC methods:
realTrailingStatus— counters (ticks, evaluated, ratcheted, failed) and last-tick timestamp.realTrailingTickNow— force one tick out-of-band, useful right after atrails set.