Configuration¶
slick-trader takes one JSON file as its only argument. This page lists every key the code reads,
with its default and where it is read. Keys not listed here are ignored. The checked-in template is
config/config_example.json.
Copy it and edit the copy (everything else under config/ is gitignored).
Running the engine¶
| Item | Behaviour |
|---|---|
| Arguments | One: the config path. With none the binary prints Usage: <exe> <config.json> and exits with 1. Extra arguments are ignored |
| Exit codes | 0 after a signal-driven shutdown. 1 for a missing argument, an unreadable or unparsable config, or any startup error that TradingEngine::initialize reports. An exception that escapes (a wrong JSON type, a queue size that is not a power of two) ends the process through std::terminate |
| Signals | SIGINT and SIGTERM start a graceful shutdown. The handlers are installed after start() returns, so a signal during startup has the default effect and ends the process |
| Banner | SlickTrader <version> is now RUNNING... once everything has started. The version is the one in the root CMakeLists.txt and is also reported by GET /api/health |
| Shutdown order | Brokers get begin_stop(), then strategies stop (so their cancels still reach the brokers), then brokers stop, then the web server stops |
| Working directory | Every relative path below (the log file, state/, the strategy folders, web/static) is resolved against the process's current directory, not the config file's. Run from the directory the paths assume |
| Environment variables | The engine reads none. Coinbase credentials are read by its SDK, see Credentials |
The startup sequence in TradingEngine::initialize
runs in this order: logger, environment, the sim control link, position_store, the queues,
brokers, strategies, web_service, then a wait for broker registration.
main.cpp then calls start().
Brokers start first, then the strategy manager, then the web server.
Console output needs a Debug build
The logger always writes log_file_path. A console sink is added only when the binary was built with
CMAKE_BUILD_TYPE=Debug (the DEBUG define). Visual Studio generators leave CMAKE_BUILD_TYPE
empty, so those builds never print to the console. See Building.
Top-level keys¶
Read in TradingEngine::initialize.
| Key | Type | Default | Notes |
|---|---|---|---|
environment |
string | "Production" |
Names the venue environment. "", Production and Prod (any case) count as production. Anything else puts a warning bar on every dashboard window. A non-string value stops startup. See Environment and sim keys |
sim_control_addr |
string | none | Required when environment is Sim, ignored (with a warning) otherwise |
sim_control_port |
int | none | Required when environment is Sim, 1 to 65535 |
log_file_path |
string | "logs/slick_trader.log" |
The logger creates the folder if it is missing |
log_level |
string | "info" |
trace, debug, info, warn, error or fatal, parsed by slick::logger::to_log_level. It must be a string: a number throws at startup |
waiting_time_out |
int (s) | 30 |
How long the engine waits for broker registration. See the warning in Queues |
brokers |
array | none | See brokers[]. Without it the engine logs a warning and runs with no market data or orders |
strategies |
object | none | See strategies. Required when web_service is present |
position_store |
object | none | See position_store |
web_service |
object | none | See web_service. Absent means no web server |
Queues¶
Each is a lock-free queue. Sizes are bytes of a uint8_t ring, except event_queue_size, which counts
16-byte records. A slick::queue throws std::invalid_argument for a size that is not a power of two,
so use powers of two for all of them.
A *_shm_name key backs the queue with a named shared-memory segment so another process can attach.
Without it the queue lives in process memory.
| Key | Type | Default | Notes |
|---|---|---|---|
event_queue_size |
uint | 16777216 (1<<24) |
Number of 16-byte records in the multiplexer's one shared queue, which the strategy manager and web server read. It does not size a producer buffer: each producer sets its own capacity (queue_size and control_size in a connector block, TOB_queue_size, config_queue_size) |
event_queue_shm_name |
string | none | Shared memory name for the multiplexer |
control_queue_size |
uint | 1048576 (1<<20) |
Startup registration queue (broker REGISTER events) |
control_queue_shm_name |
string | none | |
md_request_queue_size |
uint | 1048576 (1<<20) |
Market data requests, one queue per broker, each of this size |
md_request_queue_shm_name |
string | none | Each queue is named <name>_<BROKER>, for example md_COINBASE |
order_request_queue_size |
uint | 16777216 (1<<24) |
The one shared order request queue. Each connector filters it for its own broker |
order_request_queue_shm_name |
string | none |
config_example.json
overrides three of these: order_request_queue_size to 1048576 and md_request_queue_size to 32768, and it
sets event_queue_size to the default.
waiting_time_out does not wait the way its name suggests
wait_for_brokers_ready loops while (!(timed_out = now < end)), so it leaves the loop after one
pass whenever the deadline has not passed. The value therefore sets a limit that is never waited
out. The pass reads the control queue once, and with no brokers array that queue is empty, so the
code then reads event->type through a null pointer. Keep a brokers array in every config. See
Known gaps.
position_store¶
Optional. When present the engine keeps every position in a memory-mapped file and restores it before
anything can book a fill. A store that cannot be opened (or is not a position store) stops startup.
PositionStore creates the
parent folder.
| Key | Type | Default | Notes |
|---|---|---|---|
path |
string | "state/positions.dat" |
|
capacity |
uint | 1024 |
Number of position slots. An existing file grows if this is larger. A full store refuses new positions but still updates existing ones |
Without the block, positions live in memory and every restart starts flat. See Positions, PnL and risk.
brokers[]¶
One object per broker. The adapter is looked up by name in the
BrokerRegistry, case-insensitively.
The same name, upper-cased, must also be a BrokerId (it is used to find the broker's market data request queue).
| Key | Type | Default | Notes |
|---|---|---|---|
name |
string | "unknown" |
coinbase or hyperliquid in-tree, plus any external broker built in |
enabled |
bool | true |
A disabled entry is skipped before the adapter lookup, so it needs no adapter in the binary |
market_data |
object | none | Missing or {} means the market data connector is disabled |
order |
object | none | Missing or {} means the order connector is disabled |
An enabled broker with no adapter stops startup
The engine logs No broker adapter for '<name>'. This build has: ... and returns exit code 1. A
typo and a broker left out of the build fail the same way. Set "enabled": false to keep an entry
without building it.
Both connector blocks take enabled (default true once the block is non-empty). Connector keys are
read in the connector constructors under
src/brokers/.
shm_name and callback_shm_name¶
The market data connectors read shm_name. The order connectors read callback_shm_name. Both name
a shared-memory segment that backs that connector's event buffer, and both are copied into the connector's
REGISTER event. The engine attaches a producer by that name for a connector that registers with one.
Leave them unset for an in-process broker.
Coinbase¶
Source: coinbase_md_connector.cpp
and coinbase_order_connector.cpp.
market_data:
| Key | Type | Default | Notes |
|---|---|---|---|
enabled |
bool | true |
|
websocket_url |
string | wss://advanced-trade-ws.coinbase.com |
|
rest_url |
string | https://api.coinbase.com |
Used to list public products for instrument definitions |
shm_name |
string | none | |
queue_size |
uint | 1<<26 |
The producer buffer. The same key also sizes the WebSocket client's queue, whose default is 1<<24 |
control_size |
uint | 1<<24 |
The producer buffer's control area. The same key also sizes the WebSocket client's control area, whose default is 1<<18 |
recording |
bool | false |
Record the raw WebSocket stream through the SDK |
log_data_path |
string | "logs/coinbase" |
Where the recording goes, only when recording is true |
order:
| Key | Type | Default | Notes |
|---|---|---|---|
enabled |
bool | true |
|
rest_url |
string | https://api.coinbase.com |
Order entry and the taker fee rate |
websocket_url |
string | wss://advanced-trade-ws-user.coinbase.com |
The authenticated user channel |
callback_shm_name |
string | none | |
queue_size |
uint | 1<<24 |
Producer buffer and WebSocket client queue |
control_size |
uint | 1<<18 for the producer buffer, 32 for the WebSocket client |
One key, two defaults |
To point Coinbase at slick-sim, set order.rest_url and
order.websocket_url to its order-entry ports and market_data.websocket_url to its market data port. See
Simulator.
Hyperliquid¶
Source: hyperliquid_md_connector.cpp
and hyperliquid_order_connector.cpp.
| Block | Key | Type | Default | Notes |
|---|---|---|---|---|
market_data |
enabled |
bool | true |
|
market_data |
api_url |
string | hyperliquid::MAINNET_API_URL (https://api.hyperliquid.xyz) |
|
market_data |
shm_name |
string | none | |
market_data |
queue_size |
uint | 1<<26 |
Only read when the connector is enabled |
market_data |
control_size |
uint | 1<<24 |
Only read when the connector is enabled |
order |
enabled |
bool | true |
|
order |
api_url |
string | hyperliquid::MAINNET_API_URL |
|
order |
callback_shm_name |
string | none | |
order |
queue_size |
uint | 1<<26 |
|
order |
control_size |
uint | 1<<24 |
Hyperliquid order entry cannot connect in this build
The order connector's private_key_ member is never assigned. connect() then logs
Private key not set (set HYPERLIQUID_PRIVATE_KEY env var) and returns false, so the connector does
not start. Nothing in the repository reads HYPERLIQUID_PRIVATE_KEY. Keep order.enabled false for
Hyperliquid, as both sample configs do.
strategies¶
Read by StrategyManager.
The block must be an object. An array (the old inline layout) makes config.value(...) throw.
| Key | Type | Default | Notes |
|---|---|---|---|
enabled |
bool | true |
When false the manager exists but loads nothing, not even MANUAL |
strategy_plugins_folder |
string | "strategies" |
Created if it is missing. Every file with the platform's plugin extension (.dll, .so, .dylib) in it is tried as a plugin, in sorted order |
strategy_configs_folder |
string | the plugins folder | Where *.config.json files are scanned |
TOB_queue_size |
int | 1048576 |
Buffer for the top-of-book producer the manager publishes on the event bus |
TOB_control_size |
int | 65536 |
Its control area |
TOB_shm_name |
string | none | |
md_request_stall_timeout_ms |
int | 5000 |
How long a market data connector may leave requests unread before the manager logs it, and before stop() gives up on it |
The example config's plugin folder, build/strategies/Debug, is the Visual Studio layout. Single-config
generators on Linux and macOS put plugins in build/strategies/, so edit the folder to match your build.
The release packages ship a strategies/ folder and a config already pointed at it.
Web service needs a strategies block
TradingEngine::initialize builds the web server from *strategy_manager_. Without a strategies
key that pointer is null and the dereference is undefined behaviour. Give strategies any object
({"enabled": false} is enough) whenever web_service is present.
Strategy config files¶
For each plugin, the manager looks for a *.config.json file in strategy_configs_folder whose
name field matches the strategy's name. The file name only has to end in .config.json. Parsing is
StrategyConfig::from_json.
strategies/market_maker.json and strategies/order_stacker.json in the repository are working
examples (copy them to <name>.config.json).
{
"name": "MarketMaker",
"enabled": true,
"parameters": { "instrument": "BTC/USD", "order_size": 0.005 },
"risk_limits": {
"max_position_size": 0.05,
"max_order_value": 10000.0,
"max_orders_per_second": 10,
"max_loss_per_strategy": -200.0,
"instruments": {
"BTC-USD": { "max_position_size": 0.02, "max_order_value": 5000.0 }
}
}
}
| Key | Type | Default | Notes |
|---|---|---|---|
name |
string | none | Must equal the strategy's name(). A file with an empty name is ignored. An unparsable file logs a warning and is skipped |
enabled |
bool | true |
False skips the plugin |
parameters |
object | {} |
Handed to the strategy's initialize. Anything that is not an object is dropped. Strategy-specific keys are in Strategy reference |
risk_limits.max_position_size |
number | 1000000 |
Per instrument, in base units |
risk_limits.max_order_value |
number | 100000 |
Notional per order |
risk_limits.max_orders_per_second |
uint | 100 |
|
risk_limits.max_loss_per_strategy |
number | -10000 |
A negative number. Breaching it halts the strategy |
risk_limits.instruments.<name> |
object | none | Optional max_position_size and max_order_value for that instrument |
A plugin with no config file gets different limits
The defaults in the table apply to a config file that omits a key. A plugin with no config file at
all gets 1.0 position, 50000 order value and 10 orders per second (loss limit stays -10000), and is
initialized with empty parameters. The manager logs No config find for strategy <name>.
MANUAL, the built-in strategy behind dashboard orders, is always registered. A file with "name": "MANUAL"
configures it: its parameters.instruments list narrows what ladders show, and risk_limits apply as above
(with none, the table's defaults). See Web dashboard.
PUT /api/strategies/:id/config changes parameters live and writes them back. It finds the same
*.config.json file by name, replaces only its parameters block and rewrites the file with four-space
indentation. With no matching file the new parameters stay in memory and the log says they will not survive a
restart. See REST API.
web_service¶
Read by WebServer::initialize.
The block must exist for a web server to start.
| Key | Type | Default | Notes |
|---|---|---|---|
enabled |
bool | true |
|
web_server_port |
int | 8080 |
The example config uses 3000 |
web_server_cors |
bool | true |
Adds Access-Control-Allow-Origin: * and the method and header allowances to every API answer |
web_server_static_path |
string | "web/static" |
Dashboard files, relative to the working directory |
web_server_ladder_release_ms |
uint | 5000 |
How long an instrument stays subscribed after the last ladder leaves it |
web_server_workspaces_file |
string | "state/workspaces.json" |
Saved window layouts. The folder is created |
web_server_allow_popups |
object | none | {"ip": "localhost", "port": 3000}. On Windows, adds http://<ip>:<port> to the current user's Edge and Chrome PopupsAllowedForUrls policy under HKCU. Elsewhere it only logs a failure. ip defaults to localhost and port to the server's port |
web_server_secure_origin |
object | none | Same shape. Lists the origin under OverrideSecurityRestrictionsOnInsecureOrigin, needed to place windows on other screens over plain http from any address but localhost |
ladder_config |
object | {"default_qty": 0.01, "per_instrument": {}} |
Order sizes the dashboard ladders use |
config_queue_size |
uint | 65536 |
Producer buffer the server publishes strategy parameter updates through |
config_control_size |
uint | 4096 |
Its control area |
ladder_config.per_instrument.<instrument> takes default_qty and default_broker_id, which the
dashboard reads (web/static/js/core/instruments.js). PUT /api/ladder-config replaces the
in-memory config and requires default_qty. It is not written back to the config file.
The web server has no authentication and listens on every interface
WebServer::Config::host is 0.0.0.0 and nothing else sets it. The listen call binds only a port. Any
host that can reach the port can place and cancel orders. CORS is on by default. Put the port behind a
firewall or a tunnel.
The two policy keys edit the current user's browser settings and are off unless set.
Environment and sim keys¶
environment is a label, not a switch. Venues do not say which environment a session is on, so the
config does, and the dashboard flags anything that is not production. Only the value Sim (any case)
changes behaviour: the engine then requires sim_control_addr and sim_control_port (slick-sim's
cli.port) and opens a control link to it from the web server. Startup stops if either is missing or
wrong. With environment not Sim, both keys are ignored and the log says so.
Live Sim and Historical Sim are what the dashboard shows after asking slick-sim which feeds it
runs. They are never configured. See Simulator.
Credentials¶
Credentials never go in the config file. The engine reads no environment variable itself.
| Broker | How |
|---|---|
| Coinbase | The coinbase-advanced-cpp SDK builds its JWT from the environment variables COINBASE_API_KEY and COINBASE_API_SECRET. Both names are present in the SDK library, and the repository's own docs and main.cpp header say to set them. Market data on public channels does not need them. Order entry does |
| Hyperliquid | None can be supplied. See the warning under Hyperliquid |
Unverified in this repository
The SDK's source is not in this repository, so the exact variable handling (a PEM key with literal \n
sequences, for one) is the SDK's. coinbase/auth.hpp declares fix_pem_format for that case.
The template¶
Every key in config/config_example.json, verified against the code above:
{
"environment": "Production",
"log_file_path": "logs/slick_trader.log",
"log_level": "info",
"event_queue_size": 16777216,
"order_request_queue_size": 1048576,
"md_request_queue_size": 32768,
"brokers": [
{
"name": "coinbase",
"enabled": true,
"market_data": {
"enabled": true,
"rest_url": "https://api.coinbase.com",
"websocket_url": "wss://advanced-trade-ws.coinbase.com"
},
"order": {
"enabled": true,
"rest_url": "https://api.coinbase.com",
"websocket_url": "wss://advanced-trade-ws-user.coinbase.com"
}
},
{
"name": "hyperliquid",
"enabled": true,
"market_data": {
"enabled": true,
"api_url": "https://api.hyperliquid.xyz"
},
"order": {
"enabled": false,
"api_url": "https://api.hyperliquid.xyz"
}
}
],
"strategies": {
"enabled": true,
"strategy_plugins_folder": "build/strategies/Debug",
"strategy_configs_folder": "config",
"TOB_queue_size": 1048576,
"TOB_control_size": 65536
},
"web_service": {
"enabled": true,
"web_server_cors": true,
"web_server_ladder_release_ms": 5000,
"web_server_port": 3000,
"web_server_static_path": "web/static",
"web_server_workspaces_file": "state/workspaces.json",
"ladder_config": {
"default_qty": 0.01,
"per_instrument": {
"BTC-USD": { "default_qty": 0.001 },
"ETH-USD": { "default_qty": 0.01 }
}
}
}
}
The template trades on real Coinbase
environment is Production and both Coinbase connectors are enabled. With COINBASE_API_KEY and
COINBASE_API_SECRET set, orders from the dashboard or a strategy are live. To try the engine first, use
a slick-sim setup.
A reduced config for a simulator run, using slick-sim's sample ports:
{
"environment": "Sim",
"sim_control_addr": "127.0.0.1",
"sim_control_port": 17400,
"brokers": [
{
"name": "coinbase",
"market_data": { "websocket_url": "ws://localhost:5000", "rest_url": "http://localhost:4000" },
"order": { "rest_url": "http://localhost:4000", "websocket_url": "ws://localhost:4001" }
}
],
"strategies": { "strategy_plugins_folder": "strategies", "strategy_configs_folder": "strategies" },
"web_service": { "web_server_port": 3000 }
}
Legacy keys that nothing reads
An old config/config_real.json may sit in a working tree (it is not tracked). Its md_queue_size,
order_reply_queue_size, enable_web_server, top-level web_server_*, top-level
strategy_plugins_folder and top-level ladder_config are ignored. Its numeric log_level and its
strategies array make the engine throw at startup. Start from config_example.json instead.