Configuration
Reuse Market Lab command settings with marketlab.toml.
Configuration
Market Lab can load script and execution settings from a TOML file. Configuration contains only non-secret values. Provider credentials are stored separately in the operating system keychain.
Discovery
Pass an exact file:
mlab script backtest --config ./marketlab.tomlWhen --config is omitted, Market Lab uses ./marketlab.toml if it exists. It does not search parent directories or alternate filenames.
Current TOML support covers:
script runscript backtesttrade longtrade short
Precedence
Values resolve in this order:
built-in defaults < marketlab.toml < CLI flagsCLI values always win:
mlab script backtest --config marketlab.toml --symbol BTC/USDT --param leverage=10Only symbol and the script's leverage parameter are changed by this command.
File Shape
version = 1
[market]
symbol = "BTC/USDT"
[output]
format = "terminal"
verbose = false
[sources."candles@binancef@mmt"]
timeframe = 60
[sources."orderbook@bulk"]
depth = 20
[script]
path = "./scripts/orderflow.js"
# Optional live runtime in seconds. Omit to run forever.
duration = 3600
[script.params]
fast = 20
slow = 50
margin = 1000
max_spread_bps = 3
[execution]
venue = "bulk"
[backtest]
from = 1780497965372
to = 1780618018000Source tables become source flags:
[sources."vd@hyperliquid@mmt"]
timeframe = 60
bucket = 1is equivalent to:
--source vd@hyperliquid@mmt:timeframe=60,bucket=1Source selectors are quoted TOML table names. MMT selectors contain the exchange and provider; BULK selectors use @bulk:
[market]
symbol = "BTC/USDT"
[sources."candles@okx@mmt"]
timeframe = 60
[sources."orderbook@bulk"]
depth = 20Script source tables must use exact selectors. Script configuration has no global market.provider or market.exchange; this is what allows one script to combine several MMT exchanges with BULK.
Script parameter tables become parameter flags:
[script.params]
fast = 20
slow = 50is equivalent to:
--param fast=20 --param slow=50Script paths in TOML are resolved relative to the TOML file. Paths passed directly on the command line are resolved relative to the current shell directory.
For script run, [script].duration is the maximum live runtime in seconds and is equivalent to --duration. Omit it for an unlimited job. It is ignored by script backtest, whose range is controlled by [backtest].from and [backtest].to.
For script run, [execution].venue = "bulk" is equivalent to --venue bulk and explicitly enables ctx.trade and ctx.cancel. Omit the table for analysis-only jobs. Script order size, margin, leverage, and protection still come from each ctx.trade request, not from the top-level execution table.
Execution Configuration
Execution uses a focused TOML shape:
version = 1
[market]
symbol = "BTC/USDT"
[execution]
venue = "bulk"
margin = 100
order_type = "market"
leverage = 5
sl = 63000
tp = 69000
reduce_only = false
dry_run = true
yes = false
[output]
format = "terminal"Run the configured plan:
mlab trade long --config ./marketlab.tomlUse exactly one of size or margin in [execution]. Margin is multiplied by leverage to produce exposure. sl and tp are optional native on-fill protection prices. Limit orders can also set price and tif:
[execution]
venue = "bulk"
size = 0.001
order_type = "limit"
price = 65000
tif = "alo"
leverage = 3
dry_run = trueCLI values override the file without changing it:
mlab trade long --config ./marketlab.toml --margin 250 --leverage 2Remove dry_run = true only after reviewing the plan and validation result. Live terminal execution asks for confirmation; structured live output requires --yes.
Credentials
Never add API keys, wallet private keys, or agent credentials to marketlab.toml.
Store the MMT key securely:
mlab auth set mmtInspect credential status without exposing the key:
mlab auth statusRemove it:
mlab auth remove mmtFor CI and non-interactive environments, MMT_API_KEY overrides the OS keychain:
MMT_API_KEY=your_key mlab health --provider mmtThe API key is never read from the project TOML file.
Authorize a BULK agent wallet separately:
mlab auth set bulkMarket Lab stores the generated agent credential in the operating system keychain. The main wallet private key is requested only through a hidden prompt when authorizing or revoking the agent and is never loaded from TOML. Live signing remains inside mlabd.
See Execution for order validation, confirmation rules, and daemon behavior.