Market LabDocs

Configuration

Reuse script and trade settings with marketlab.toml.

Market Lab reads non-secret settings from TOML. Keep credentials in the credential store, not in configuration files.

File Discovery

Pass a file explicitly:

mlab script backtest --config ./marketlab.toml

Without --config, Market Lab uses ./marketlab.toml when it exists. It does not search parent directories.

Supported commands:

  • script run
  • script backtest
  • trade long
  • trade short

Precedence

built-in defaults < marketlab.toml < CLI flags

CLI values override the file for the current command.

Python V2 script configuration

version = 1

[script]
path = "./strategy.py"
python = ".venv/bin/python"
duration = 3600

[script.params]
fast = 5
slow = 30
margin = 100

[backtest]
from = "2026-07-15"
to = "2026-07-16"

[output]
format = "terminal"

Python V2 declares its sources directly in history.source(...) calls. Do not add [sources] or script.sources.

Script paths and Python paths in TOML are resolved relative to the TOML file.

For script run, duration limits the live job in seconds. Omit it to run until stopped. Backtests use [backtest].from and [backtest].to instead.

Backtest boundaries are UTC strings in YYYY-MM-DD or YYYY-MM-DD HH:MM:SS format. A date without a time means midnight.

Python V2 must not set [execution].venue. Each ctx.trade(...) or ctx.order(...) request declares its own exchange and symbol.

JavaScript V1 script configuration

JavaScript V1 keeps explicit source tables:

[sources."btc@candles@binancef"]
timeframe = 60

[sources."btc@orderbook@hyperliquidf"]
depth = 20

These are equivalent to repeated V1 --source flags.

Execution

JavaScript V1 enables one execution venue through configuration:

[execution]
venue = "hyperliquidf"

Omit [execution] for an analysis-only JavaScript job.

Trade Configuration

Perpetual example:

version = 1

[market]
symbol = "BTC"

[execution]
venue = "hyperliquidf"
margin = 100
leverage = 5
order_type = "market"
dry_run = true

[output]
format = "terminal"
mlab trade long --config ./marketlab.toml

Use exactly one of size or margin.

Limit order fields:

[execution]
venue = "hyperliquidf"
size = 0.001
order_type = "limit"
price = 65000
tif = "alo"
leverage = 3
dry_run = true

Spot keeps the exact pair and omits perpetual-only fields:

[market]
symbol = "HYPE/USDC"

[execution]
venue = "hyperliquid"
margin = 100
order_type = "market"
dry_run = true

Never add API keys, wallet keys, or agent credentials to marketlab.toml.

On this page