Simulator¶
slick-trader can trade against slick-sim, an exchange simulator
that serves a venue's own order-entry and market-data protocols on local ports. The broker connectors
need nothing special: you point their URLs at slick-sim. On top of that, the engine keeps a second,
separate connection to slick-sim's CLI port in the Sim environment. It asks which feeds slick-sim
runs, shows them on the dashboard, and starts a pcap replay on request.
Two pieces, then:
- Trading path. Broker URLs in
brokers[]. Ordinary connectors, ordinary events. - Control link.
SimControlLinkinside the web server, driven bysim_control_addrandsim_control_port.
Setup¶
{
"environment": "Sim",
"sim_control_addr": "127.0.0.1",
"sim_control_port": 17400,
"brokers": [
{
"name": "coinbase",
"enabled": true,
"market_data": {
"enabled": true,
"rest_url": "http://localhost:4000",
"websocket_url": "ws://localhost:5000"
},
"order": {
"enabled": true,
"rest_url": "http://localhost:4000",
"websocket_url": "ws://localhost:4001"
}
}
]
}
The shape of the broker block is the one in
config/config_example.json.
| Key | Type | Default | Notes |
|---|---|---|---|
environment |
string | Production |
Sim in any case turns the control link on. Anything that is not a string stops startup |
sim_control_addr |
string | none | slick-sim's address. Required in Sim. Use an IPv4 address: resolving a host name holds up the dashboard |
sim_control_port |
integer | none | slick-sim's cli.port, 1 to 65535. Required in Sim |
There are no defaults on purpose. A missing, empty or wrongly typed key stops startup with a message
naming the key (Environment Sim: config 'sim_control_port' must be slick-sim's cli.port, 1 to 65535).
A guess that landed on the wrong port would hide the pcap feeds and never say so. The check runs before
the web service is read, so a Sim config without the keys fails even with web_service turned off.
Outside Sim the two keys are ignored with a warning.
No web service, no link
The link lives in the web server. With web_service.enabled false the engine still trades against
slick-sim, but nothing asks about feeds, so the environment stays plain Sim and there is no
Simulator panel.
Pointing the brokers at slick-sim¶
The ports above are slick-sim's samples, and yours come from its own config. Market data can come from
slick-sim's market-data WebSocket (sample port 5000) or stay on the real venue, and the connectors read
the same keys either way. Use both order-entry
endpoints for Coinbase, REST for submitting and the WebSocket user channel for what happens to the
order. A REST-only client never learns that its order traded. See slick-sim's
Coinbase integration and
Hyperliquid integration pages for
the endpoints, ports and what differs from the real venue.
- Coinbase's connectors read
market_data.rest_url(product listing),market_data.websocket_url,order.rest_urlandorder.websocket_url. - Hyperliquid's read one
api_urlper connector. slick-sim serves Hyperliquid's order entry and market data on separate ports, so check its page before pointing both at one. Order entry is disabled in the sample configs.
CME and ICE ids exist in the engine, but those brokers are not part of this repository's build. See Brokers.
slick-sim's side¶
The control port is slick-sim's CLI, turned on by a
top-level cli block:
| slick-sim key | Default | Why it matters here |
|---|---|---|
port |
17400 | Must match sim_control_port. 0 lets the OS pick, which the engine cannot guess |
max_connections |
4 | The engine uses one. A connection past the limit is closed on accept |
idle_timeout |
300 s | Closes a silent connection. The engine reconnects at once, see below |
The port binds all interfaces and has no authentication.
The control link¶
The link is a plain TCP client with a packed little-endian framing, serviced from the web server's event loop thread. It never blocks the loop: connect and send timeouts are 3 s and 100 ms, and the link is stepped every 10 ms. The wire format is slick-sim's, in its CLI wire format section.
sim_cli::Request is 105 bytes: a 3-byte header (u16 length, u8 type 3), a u32 request id the
reply echoes, a u8 command, a u8 flag, a 32-byte NUL-padded target and a 64-byte argument. A reply is
type 4, with a u32 request id and a u8 status (0 is OK), then UTF-8 text up to the frame's length.
Replies are matched by request id, and id 0 means none is pending.
| Command | Code | Target | Asked | Reply the engine reads |
|---|---|---|---|---|
version |
10 | none | First on every connection | The version text, such as 0.10.1 |
feeds |
9 | none | After version, and again each second until a list parses |
One live <name> or pcap <name> per line |
watch |
11 | pcap |
Once the list has a pcap feed, and again each second until slick-sim keeps it | As status, then again under the same request id each time it changes |
status |
8 | pcap |
Each second instead, when slick-sim is too old to watch (0.10.1 and before) | One pcap/<feed>: <STATE> <pct>%, capture <t>, window <t>..<t>, speed <n>[ - <message>] per feed |
replay |
7 | pcap |
When a client asks, see below | One <endpoint>: <what it said> per feed |
sequenceDiagram
autonumber
participant D as Dashboard
participant W as WebServer<br/>(uWS thread)
participant S as slick-sim<br/>(CLI port)
W->>S: version
W->>S: feeds
S-->>W: live coinbase / pcap cme/310
W->>S: watch (target pcap)
S-->>W: pcap/cme/310: LOADING 40.0%, ...
loop each time a feed's status changes
S-->>W: pcap/cme/310: LOADING 41.0%, ... (the watch's request id)
W-->>D: sim_status (only if the reply changed)
end
D->>W: POST /api/sim/replay
W->>S: replay (target pcap)
W-->>D: 202 Replay start sent
S-->>W: reply, status OK
W-->>D: sim_replay {ok, message}
Behaviour¶
- Connected means answered.
connectedturns true when slick-sim has answered what feeds it has, and, with pcap feeds, their status. Its version alone does not count. The engine reportsconnectedas false before that, andversionis empty while it is. - Watching. With a pcap feed the engine sends
watchonce, and slick-sim sends the status again whenever it changes: about once a second while a feed loads or replays, and never while it waits atREADY. slick-sim keeps no watch whose answer failed, so the engine asks again a second later. A slick-sim too old to watch getsstatusonce a second instead, never two at once. With no pcap feed (live feeds only, or nothing) the feeds do not change while slick-sim is up, so nothing more is asked. - Timeouts. A request with no reply in 5 s closes the link. slick-sim answers within 2 s even when a feed does not, so five seconds means something is wrong. A malformed reply closes it too. Once watching, no reply is awaited, so a slick-sim that hangs without closing its link goes unnoticed.
- Reconnect. A dropped link is made again 5 s later, and every 5 s after that. While down,
connectedis false andversionandfeedsare cleared. The environment is not: it keeps what the last list said, so a blip does not flip the dashboard to plainSim. A slick-sim that comes back with other feeds changes the environment again. - Idle drops. With no pcap feed, or a watch whose status doesn't change (a feed waiting at
READY), the link goes silent, and slick-sim closes it aftercli.idle_timeout. The engine reconnects immediately and asks again, and no window sees a drop. The feeds stay shown meanwhile, and a start is refused until the new link gives their status. If the reconnect fails, it shows as dropped then. - Dedup. An answer identical to the last one changes nothing, so a window hears only real changes.
- Replies in pieces. TCP can split a reply, and the engine puts it together before reading it.
- Odd answers. A
statuswith no parsable feed line becomes theerrorfield (slick-sim gave no statuswhen empty). Afeedsrefusal other thanunknown commandbecomes theerrorand is asked again. A reply cut inside a UTF-8 character is shown with the bad bytes replaced.
A pcap feed that gives no state
A status line that names a feed but starts with no known state keeps the line as the feed's
message, with state UNKNOWN. It blocks the start, see below.
Feed states¶
The state is the first word of a feed's answer: IDLE, LOADING, SYNCING, READY, REPLAYING,
FINISHED, or ERROR (reported as ERROR, held internally as a failure). Progress is the percentage
through the window, kept as a tenth of a percent. See slick-sim's
PCAP replay for what each state means on
its side.
What the environment is¶
The engine derives the environment from the feeds slick-sim lists:
| slick-sim runs | Environment |
|---|---|
| At least one live feed | Live Sim |
| No live feed, at least one pcap feed | Historical Sim |
| Neither, or the list is not known yet | the config's value, Sim |
Live wins. A venue's feeds are all live or all pcap, but different venues can differ, and then it says
Live Sim while the pcap venue's replay is still there to start. /api/health reports the derived
name, with production false, and every window's amber environment bar and title prefix ([Live Sim])
follow it. When it changes, the engine logs Environment: <name> (not production).
REST endpoints¶
GET /api/sim¶
{"enabled":true,"address":"127.0.0.1:17400","environment":"Historical Sim","connected":true,
"version":"0.10.1","live_feeds":[],"pcap":true,"can_start":true,"start_blocked":"",
"starting":false,"error":"",
"feeds":[{"name":"cme/310","state":"READY","progress":100.0,"capture":"2026-11-06T00:30:00.000Z",
"begin":"2026-11-06T00:30:00.000Z","end":"2026-11-06T01:30:00.000Z","speed":"1","message":""}]}
| Field | Meaning |
|---|---|
enabled |
The control link exists. False off Sim, and then only environment is present |
address |
<addr>:<port> the link uses |
environment |
As derived above |
connected |
slick-sim has answered, see above |
version |
slick-sim's version, empty while not connected or when slick-sim is too old to say |
live_feeds |
Names of the live feeds, each once. An instance with several shows once |
pcap |
slick-sim has pcap feeds. Known while disconnected too |
feeds |
The pcap feeds' status: name, state, progress (0 to 100), capture, begin, end (UTC), speed (text, 0 means as fast as it can), message |
can_start |
The replay can be started now |
start_blocked |
Why not, empty when can_start |
starting |
A start was sent and has not shown in a status yet |
error |
The last problem, such as too old to list its feeds, update it |
start_blocked is the first of these that applies:
Not connected to slick-sim- The
errortext, when there is one Waiting for the feeds' status(pcap feeds are listed but no status yet), orslick-sim has no pcap feedReconnecting to slick-sim, while a dropped link is made again and until it gives the feeds' statusStarting, for up to 5 s after a start was sent<feed> is in ERRORN of M feeds ready, while some feed has not reachedREADYReplayingorFinished, when no feed isREADYany more
A start therefore needs every feed loaded (READY, REPLAYING or FINISHED) and at least one still
READY. A feed that gave no state counts as not loaded.
POST /api/sim/replay¶
The body is ignored. It sends slick-sim's replay to pcap, which starts every loaded pcap feed.
| Status | When |
|---|---|
| 202 | {"success":true,"message":"Replay start sent"}. slick-sim's own answer arrives later as sim_replay |
| 404 | Not a Sim environment: no control link |
| 409 | Connected, but start_blocked says why not. A second click lands here with Starting |
| 503 | Not connected to slick-sim. The body is the same Not connected to slick-sim text |
A start slick-sim refuses, or one whose link drops before the answer, still got a 202. The refusal comes
over the WebSocket, as sim_replay with ok false (the link to slick-sim dropped before it answered
for a drop).
WebSocket messages¶
Every client receives:
sim_statuson connect, and after each change. It is the/api/simbody plus"type":"sim_status".sim_replayonce per start answered:{"type":"sim_replay","ok":true,"message":"..."}.messageis slick-sim's text, a line per endpoint (<endpoint>: <what it said>), and can run to several lines. Every window hears it, not only the one that clicked.
Only the Sim environment sends these. A client that reconnects gets a sim_status after the
welcome, or none if the engine it reached is not in Sim, which the bundled client takes as "clear the
panel". See WebSocket.
The Simulator panel¶
The main window shows a Simulator panel while the engine is in Sim with a link
(sim-panel.js).
Off Sim it is not there.
- Header. A dot for the link,
slick-sim, its version (v0.10.1, when known) and the address. - Start replay. Shown only when slick-sim has pcap feeds. It is enabled by
can_start, and the text beside it says what it waits for (start_blocked). The click callsPOST /api/sim/replay, and a failure shows as a toast and a log entry. - Note line.
Not connected to slick-sim at <address>, retrying...while down.slick-sim: <error>when slick-sim answered with a problem.Live feeds: <names>.No feeds: the books hold only the orders sent to slick-simwhen it lists none. - Feeds table. For each pcap feed: state badge, progress bar, capture time, window and speed (all UTC,
speed
maxfor 0), and slick-sim's message, which carries the reason inERROR. - Log. A feed that changes state writes a line to the Log window:
ERRORas an error,UNKNOWNas a warning,READYandREPLAYINGas success.sim_replaywrites that slick-sim started the replay, or the failure.
Every window, tool windows included, also shows the environment bar and a [Live Sim] or
[Historical Sim] title prefix, as the derived environment says.
Versions¶
| slick-sim | What the engine does |
|---|---|
| 0.9.0 and earlier | No feeds command. The panel says too old to list its feeds, update it, the environment stays Sim, and the start is blocked |
| 0.10.0 | Lists feeds and replays. No version command, so version stays empty |
| Later | Also reports its version, shown in the panel and /api/sim |
The engine asks version before anything else. An unknown command only leaves version empty and
changes nothing else. slick-sim's own pages cover the rest: CLI,
PCAP replay and
Architecture.
Related¶
- REST API and WebSocket for the shared plumbing.
- Web dashboard for the rest of the main window.
- Configuration for every config key.