JSON Output
Compact machine output, verbose mode, and stream-friendly JSONL behavior.
JSON Output
Market Lab has two priorities:
- good human terminal output
- compact machine-readable output
Market Catalog JSON
The markets command uses a dedicated --json flag:
mlab markets --exchange bulk --jsonFull catalog JSON contains:
schemaVersionprovidersourceUrlfetchedAtmarkets
Requesting one symbol returns that market object directly:
mlab markets --exchange bulk --symbol BTC/USDT --jsonEach market contains symbol mapping, status, precision, tick and lot sizes, minimum notional, maximum leverage, order types, and time-in-force values. This output is an embedded rules snapshot, not live market data.
Default JSON
Study JSON is intentionally compact. Built-in strategy submission returns a persistent job record, while strategy worker activity is written as JSONL job output.
That means the default output includes only the fields an agent or script usually needs.
Script JSON follows the same rule: default output stays compact, while runtime reports can be inspected separately with script runs list and script runs show.
Verbose JSON
Add --verbose to include expanded context.
Examples:
mlab study spread --provider mmt --exchange bybitf --symbol BTC/USDT --depth 20 --output json --verboseStream JSONL
Use jsonl for stream-oriented commands.
Examples:
mlab source candles --provider mmt --exchange binancef --symbol BTC/USDT --timeframe 60 --stream --output jsonlExecution JSON
Execution commands support terminal, json, and jsonl. CSV and Parquet are rejected.
A dry-run trade emits the normalized TradePlan directly:
mlab trade long BTC/USDT --margin 10 --dry-run --output jsonThe plan contains:
- creation timestamp and venue
- account, internal symbol, and venue symbol
- direction and order side
- order kind and time in force
- requested margin or exact size, plus normalized size
- limit price or market reference price
- estimated margin and exposure, leverage, and reduce-only state
- optional native stop-loss and take-profit prices
- projected liquidation price (
nullbefore execution because BULK computes it from portfolio state)
A submitted trade emits both the reviewed plan and venue receipt:
mlab trade long BTC/USDT --margin 10 --yes --output json{
"plan": {},
"receipt": {
"venue": "bulk",
"account": "...",
"order_id": "...",
"status": "...",
"terminal": false,
"submitted_at_ms": 1780000000000,
"raw_status": {}
},
"post_trade_position": {}
}The same plan/result behavior applies to cancel. positions, orders, and fills emit JSON arrays of normalized account records.
Structured live execution cannot prompt, so it requires --yes. Use --dry-run first.
Daemon JSON and Events
Inspect runtime state:
mlab daemon status --output jsonStatus contains:
- runtime protocol
version runningandpidstarted_at_msaccount_stream_connectedlast_account_event_msandlast_recovery_mslast_errortracked_ordersscript_jobsstrategy_jobs
Read the lifecycle journal as a JSON array or JSONL stream:
mlab daemon events --limit 20 --output json
mlab daemon events --limit 20 --output jsonlCurrent event names are:
order_submittedorder_cancelledorder_tracking_startedorder_statusaccount_wsaccount_recovery_fill
Every event has ts_ms and event. Submission events add plan and receipt; tracking events add normalized order state; account events carry the raw BULK account payload.
Study Shape
Default compact study JSON contains:
typeversionproviderexchangesymbolts_msstreammetrics
Verbose study JSON also includes:
inputsmeta
Strategy Shape
strategy run deploys a detached native job. Structured live execution requires --yes:
mlab strategy run twap BTC/USDT \
--side buy \
--margin 100 \
--duration 300 \
--interval 60 \
--yes \
--output jsonThe returned record contains:
- job
idandstatus - worker
pid - the tagged strategy definition and immutable TWAP configuration
- symbol, side, target margin and exposure, normalized total size, duration, interval, leverage, and reduce-only state
- created, started, stopped, and heartbeat timestamps
- last worker error
List and inspect strategy jobs:
mlab strategy jobs --output json
mlab strategy status <JOB_ID> --output jsonWorker output is stored as JSONL and includes strategy.plan, strategy.child_order, strategy.run.finished, and strategy.run.failed records:
mlab strategy logs <JOB_ID> --follow --output jsonlUse --dry-run --output json to receive the normalized TWAP plan instead of creating a job.
Script Backtest Shape
Script hooks may return:
metrics- optional
meta nullwhen the hook only performs execution calls
Strategy behavior comes from ctx.trade and ctx.cancel. The backtest runtime intercepts those calls with its simulator.
Default script backtest JSON contains:
typeversionproviderexchangesymbolts_msscriptsummaryperformanceparams
The summary includes submitted, pending, and cancelled simulated orders alongside closed trades and open positions.
Performance reports capital_required as the peak simulated margin in use. Leverage belongs to each open-long or open-short request rather than to the backtest command as a whole.
Verbose script backtest JSON also includes:
windowwith the requestedfromandtotimestampsclosed_tradesopen_positionslatest_outputwhen the script explicitly returned non-empty diagnosticsmeta
Closed trades and open positions include their stable script order_id and events_held count when they came from ctx.trade. Open positions also include simulated stop_loss_price and take_profit_price when configured.
Script Job Shape
script run deploys a detached job and returns its job record rather than a stream result:
mlab script run ./strategy.js \
--symbol BTC/USDT \
--source candles@bulk:timeframe=5 \
--venue bulk \
--output jsonThe record contains:
- job
idandstatus - worker
pid - immutable script definition and snapshot path
- provider, exchange, symbol, sources, params, and execution venue
- created, started, stopped, and heartbeat timestamps
- last worker error
- execution-event sequence and acknowledged cursor
List and inspect records:
mlab script jobs --output json
mlab script status <JOB_ID> --output jsonWorker output is JSONL internally. Tail it directly:
mlab script logs <JOB_ID> --follow --output jsonlAn explicit non-empty { metrics, meta } return from live onData is stored as script.run.result. Returning nothing, null, or {} stores no routine result. Execution delivery uses script.execution.event, optionally including non-empty hook diagnostics. A command-routing failure is appended as script.execution.error.
The onExecution event envelope uses camel-case fields:
seq,jobId,tsMs, andtype- optional
orderId,key,venue,venueOrderId, andstatus terminal- provider payload in
data
Script Runtime Reports
Script runtime reports are stored locally and can be viewed from the CLI.
mlab script runs list --output jsonmlab script runs show <run-id> --output jsonRuntime report JSON contains:
scriptcommandproviderexchangesymbolstarted_at_msended_at_msduration_msstatuslimitsruntimeerror