Market LabDocs

CLI Reference

High-level command map for the current Market Lab CLI surface.

CLI Reference

Current top-level commands:

  • markets
  • trade
  • positions
  • orders
  • fills
  • cancel
  • close
  • daemon
  • inspect
  • replay
  • source
  • study
  • script
  • strategy
  • health
  • status
  • upgrade
  • auth

Markets

Inspect an embedded exchange market catalog and trading rules.

Current catalog exchange:

  • bulk

List the local snapshot:

mlab markets --exchange bulk

Inspect one market using Market Lab or BULK symbol notation:

mlab markets --exchange bulk --symbol BTC/USDT
mlab markets --exchange bulk --symbol BTC-USD

Return the full catalog or one market as JSON:

mlab markets --exchange bulk --json
mlab markets --exchange bulk --symbol BTC/USDT --json

markets reads a versioned snapshot embedded in the binary. It performs no runtime request and requires no credentials. See BULK Provider.

Inspect

Historical or reconstructed market-state inspection.

Example:

mlab inspect --provider mmt --exchange binancef --symbol BTC/USDT --at 1779399687271 --depth 20 --output terminal

Source

Raw provider-facing commands.

The CLI identity rule is exchange-first:

  • use --exchange bulk for the standalone BULK exchange and omit --provider
  • use --provider mmt --exchange <exchange> when MMT routes data for an exchange
  • --provider currently accepts only mmt

Future standalone exchange adapters follow the BULK shape: --exchange <exchange> without a provider flag.

Current source commands:

  • source orderbook
  • source candles
  • source vd
  • source oi
  • source volumes
  • source stats
  • source funding

Examples:

mlab source orderbook --provider mmt --exchange bybitf --symbol BTC/USDT --depth 100 --output json
mlab source candles --provider mmt --exchange binancef --symbol BTC/USDT --timeframe 60 --from 1779880000000 --to 1779883600000 --output json
mlab source vd --provider mmt --exchange bybitf --symbol BTC/USDT --timeframe 60 --from 1779620400000 --to 1779624000000 --bucket 1 --output json
mlab source oi --provider mmt --exchange bybitf --symbol BTC/USDT --timeframe 60 --from 1779660000000 --to 1779705600000 --output json
mlab source volumes --provider mmt --exchange bybitf --symbol BTC/USDT --timeframe 60 --from 1779660000000 --to 1779705600000 --output json

BULK is a standalone exchange, so select it directly and omit --provider:

mlab source orderbook --exchange bulk --symbol BTC/USDT --depth 100 --output json
mlab source candles --exchange bulk --symbol BTC/USDT --timeframe 60 --from 1780307559000 --to 1780523645000 --output json
mlab source oi --exchange bulk --symbol BTC/USDT --stream --output jsonl
mlab source vd --exchange bulk --symbol BTC/USDT --stream --output jsonl
mlab source stats --exchange bulk --period 7d --output json
mlab source funding --exchange bulk --symbol BTC/USDT --stream --output jsonl

BULK source modes and flags differ by source. See BULK Provider.

Execution

BULK is currently the default and only execution venue. Canonical trade directions are long and short.

Preview a normalized order without signing or starting mlabd:

mlab trade long BTC/USDT --margin 10 --dry-run

Market and limit examples:

mlab trade long BTC/USDT --margin 100 --leverage 5
mlab trade short BTC/USDT --size 0.001 --type limit --price 65000 --tif alo
mlab trade long BTC/USDT --margin 100 --sl 63000 --tp 69000

Account state and order management:

mlab positions
mlab orders
mlab fills
mlab cancel BTC/USDT <ORDER_ID> --dry-run
mlab close BTC/USDT --dry-run

Runtime management:

mlab daemon start
mlab daemon status
mlab daemon events --limit 20
mlab daemon stop

Live place, cancel, and close commands ask for terminal confirmation. Structured live output requires --yes. Execution supports only terminal, json, and jsonl output.

See Execution for validation, configuration, runtime security, and lifecycle events.

Script

Run local JavaScript against Market Lab data sources.

Reusable script settings can be loaded with --config marketlab.toml. See Configuration.

Script commands:

  • script run
  • script backtest
  • script jobs
  • script status
  • script logs
  • script stop
  • script restart
  • script runs list
  • script runs show

Backtest execution calls against historical data:

mlab script backtest ./scripts/sma-cross.js --symbol BTC/USDT --from 1704067200000 --to 1704667200000 --source candles@bybitf@mmt:timeframe=60 --param fast=20 --param slow=50 --param margin=1000 --param leverage=5 --output json

The backtest simulator intercepts ctx.trade and ctx.cancel. It tracks market and limit orders, pending cancellations, net positions, position leverage, and sl/tp exits without signing or submitting anything.

Backtest the same source kind across multiple MMT exchanges:

mlab script backtest ./examples/cross-exchange-spread.js \
  --symbol BTC/USDT \
  --from 1704067200000 \
  --to 1704667200000 \
  --source candles@binancef@mmt:timeframe=60 \
  --source candles@okx@mmt:timeframe=60

The exact selectors bind each source to its exchange and provider.

Deploy an analysis-only live job:

mlab script run ./scripts/candle-summary.js --symbol BTC/USDT --source candles@bulk:timeframe=5

Explicitly enable BULK execution:

mlab script run ./scripts/bulk-limit-protected.js --symbol BTC/USDT --source candles@bulk:timeframe=5 --venue bulk --param armed=true

Limit a live job to one hour:

mlab script run ./scripts/market-maker.js --symbol BTC/USDT --source orderbook@bulk:depth=20 --venue bulk --duration 3600

--duration is measured in seconds. When it expires, the job ends normally with completed status. Omit it to run forever.

script run snapshots the script, starts a detached worker through mlabd, prints the job ID, and returns. Omitting --venue disables ctx.trade and ctx.cancel.

Manage live jobs:

mlab script jobs
mlab script status <JOB_ID>
mlab script logs <JOB_ID> --follow
mlab script stop <JOB_ID>
mlab script restart <JOB_ID>

script logs --follow supports terminal or JSONL output. script status, stop, and restart accept the exact job ID.

Historical runtime telemetry remains separate from active jobs:

mlab script runs list
mlab script runs show <run-id>

See Scripts and Script Execution.

Auth

Store provider credentials in the operating system keychain:

mlab auth set mmt
mlab auth set bulk
mlab auth status
mlab auth remove mmt
mlab auth remove bulk

auth status never prints an MMT API key or BULK private key. For BULK it prints the registration state, account public key when known, and agent public key.

auth set bulk:

  • generates an agent wallet locally
  • stores the agent credential in the operating system keychain
  • prompts for the main wallet private key without echoing it
  • uses the main key once to sign agent authorization and never stores it
  • preserves an unconfirmed agent as pending so the same registration can be retried safely

auth remove bulk revokes an active agent on BULK before deleting the local credential. It asks for the matching main wallet private key to sign the revocation.

The BULK command surface includes public market data, embedded market rules, agent-wallet management, account state, and order execution. See BULK Provider and Execution.

Study

Derived metrics and calculations.

Current study commands:

  • study spread
  • study depth
  • study imbalance
  • study slippage
  • study vamp
  • study cvd

Examples:

mlab study spread --provider mmt --exchange bybitf --symbol BTC/USDT --depth 20 --output json
mlab study slippage --provider mmt --exchange bybitf --symbol BTC/USDT --side buy --notional 100000 --depth 100 --output json

Strategy

Native execution strategies supervised by mlabd.

Current strategy commands:

  • strategy run twap
  • strategy jobs
  • strategy status
  • strategy logs
  • strategy stop

Preview a TWAP without creating a job:

mlab strategy run twap BTC/USDT --exchange bulk --side buy --margin 100 --duration 300 --interval 60 --dry-run

Submit a live TWAP job:

mlab strategy run twap BTC/USDT --exchange bulk --side buy --margin 100 --duration 300 --interval 60

Manage the detached job:

mlab strategy jobs
mlab strategy status <JOB_ID>
mlab strategy logs <JOB_ID> --follow
mlab strategy stop <JOB_ID>

The current TWAP implementation uses market child orders. It does not yet accept --type, --price, or --tif. See TWAP for scheduling, validation, live-job behavior, and current limitations.

Health

Provider health and connectivity checks.

mlab health --provider mmt --output json
mlab health --exchange bulk --output json

Status

Local CLI and runtime status.

mlab status

Upgrade

Check for newer CLI releases.

mlab upgrade --check

On this page