Appearance

Personalize your experience

Mode
Accent Color
Direction
Strategy DSL — The Live Engine

Live Strategy Engine

Reference

How deployed DSL strategies run: one engine process, one connection per client, shared bar feeds and indicators per symbol and timeframe, the request protocol, and why live trades match the backtest.

One process for every strategy

Like the alerts engine, the engine runs as one long-lived process (dslx_cli --serve) instead of one per . A opens one and sends any number of requests on it — add, replace, , resume and strategies, push market , run backtests — with many requests in flight at once. Replies are matched by id; entry, exit and error events are pushed to every .

  • Shared feeds. Strategies on the same market symbol and timeframe share one bar history. Bars are built from ticks, or taken from closed candles when those arrive (a feed that receives candles stops building bars from ticks).
  • Shared indicators. When a feed confirms a bar, every on it is evaluated with one indicator cache, so an indicator used by many strategies is computed once. The strategies are then in ; events come back in a order (exits before entries).
  • Fresh requests at any time. A to a feed with history is warmed over it without trading — edge-triggered signals learn whether they were already true — and from the next bar. History is trimmed at 5,000 bars to 3,000 by default.
  • Backtests alongside. Backtests run on their own pool and reply when done, while ticks keep flowing on the same .

Live equals backtest

Each runs the same bar step as a backtest: signals at the , stops and targets against the confirmed bar's range, the same and costs. Streaming a history bar by bar reproduces the backtest's ; the checks hundreds of strategies trade for trade. The differences are deliberate: a live strategy keeps positions open at the end, and stops and targets are evaluated when the bar closes, not by tick.

Transports

dslx_cli --serve
dslx_cli --serve --stdio                                  # JSON per line on stdin / stdout
dslx_cli --serve --socket /tmp/dslx.sock                  # JSON per line, Unix socket (owner only)
dslx_cli --serve --ws-port 8095 --token "$DSLX_TOKEN"     # JSON per WebSocket text frame (127.0.0.1)
  --threads N  --backtest-threads N  --max-bars N  --keep-bars N  --max-strategies N
!
Caution:The WebSocket listener binds to 127.0.0.1 by default and requires the token (as ?token= or a Bearer header) when one is set. Do not expose it without a token.

Requests

one connection
→ {"id":1,"op":"add","strategyId":"42","feed":"BINANCE:BTCUSDT","strategy":{…},"seed":[…candles…],"meta":{"userId":7}}
← {"id":1,"ok":true,"strategyId":"42","feed":"BINANCE:BTCUSDT","timeframe":"5m","bars":1000,"sharedWith":12,"warnings":[]}

→ {"id":2,"op":"ticks","ticks":[{"symbol":"BINANCE:BTCUSDT","price":64010.5,"volume":0.3,"time":1717000000000}]}
← {"event":"entry","strategy":"42","feed":"BINANCE:BTCUSDT","timeframe":"5m","barTime":1716999900000,
   "side":"long","price":64001.2,"quantity":0.39,"stop":62721.1,"targets":[66561.2],"openPositions":1}
← {"id":2,"ok":true,"events":1}

→ {"id":3,"op":"backtest","strategy":{…},"candles":[…]}        // replies when done; live traffic continues
← {"id":3,"ok":true,"result":{"trades":[…],"stats":{…},"signalStats":[…]}}

→ {"id":4,"op":"stats"}
← {"id":4,"ok":true,"stats":{"strategies":500,"feeds":5,"strategySteps":300000,"seriesRequested":900000,"seriesComputed":21000,…}}
opDescription
addstrategyId, (), feed (default EXCHANGE:SYMBOL from the strategy), optional seed candles and meta. Replaces a strategy with the same id.
remove / pause / resumestrategyId. A resumed re-learns its signal edges from the last bar before trading.
seedsymbol, timeframe, bars — merge history into a feed (older bars only, once strategies have traded).
tick / tickssymbol, price, volume (this ’s quantity), time — aggregated into every tick-built feed of the symbol.
bar / barssymbol, timeframe, time, open, high, low, close, volume — one closed candle.
statePositions with stops and remaining targets, realised and unrealised P&L, recent .
list / stats / symbolsStrategies, feeds and counters ( steps, indicator series read vs computed, step time).
validate / backtest / catalogAs the CLI. backtest takes or strategies (one shared indicator cache) and candles.
subscribeevents: false stops events on this .
shutdownFinish backtests in flight, reply, exit.

Errors reply {"id":…,"ok":false,"error":"…","path":"…"} — an invalid is refused at add with the same JSON the editors show.

How deployed strategies use it

The bot API's runner keeps one engine . Every deployed strategy saved with an engine DSL is to it; ticks from the market- hub are forwarded in batches and closed candles as they arrive; history is seeded from the candle aggregator; engine entry and exit events become strategy signals. If the engine restarts, the runner reconnects and re-adds its strategies. Strategies saved before the builder wrote the engine DSL keep the older until they are saved again.

See also

Related articles

  • Strategy DSL — Conditions That Can Never Be True

    Coding / Strategy DSL

    Which conditions the engine and the editors reject because no bar could ever satisfy them, how the check works, what it deliberately does not reject, and…

  • Strategy DSL — Execution Model

    Coding / Strategy DSL

    What the engine does on every bar: protective exits, exit signals, entries, layers and re-entries, sizing and costs, and where every statistic in the result…

  • Strategy DSL — Language Reference

    Coding / Strategy DSL

    The strategy JSON the C++ engine executes: every top-level block, signals and flow, operands and the 94-indicator catalog, the eleven operators, and the…

  • Strategy DSL — The Engine

    Coding / Strategy DSL

    The native C++ engine (dslx) that parses, validates, backtests and runs strategy DSL: its modules, the catalog the editors are generated from, indicator…

  • Writing DSL by Hand

    Coding / Strategy DSL

    Authoring strategy JSON directly: the minimum document, small constructors that keep it readable, validating before anything runs, generating variants, and…

  • OHLC Bars

    Charts / Chart Types / Bar Charts

    The original Western bar chart type — four essential data points (Open, High, Low, Close) encoded into a single vertical bar with left and right ticks. OHLC…

  • Step 3 — Preview & Deploy

    Automation / Predefined Strategies / Wizard Steps

    The last read-only checkpoint before real orders exist. Everything shown here is what will be written to the engine config.

  • Step 8 — Review & Deploy

    Automation / Strategy Builder / Wizard Steps

    Review is the final step before deployment. It presents the complete strategy configuration in one place, runs validation checks, highlights errors and…

  • Strategy Builder FAQ

    Automation / Strategy Builder / Reference

    The questions that come up most often, answered with what the engine actually does rather than what would be convenient.

Browse all knowledge base articles →