Examples
Real command examples for sources, studies, and strategies.
This page focuses on the commands people will actually run first:
sourcemarketsstudyscript backtestscript runs listscript runs showscript jobs,status,logs,stop, andrestartstrategy run twapstrategy jobs,status,logs, andstoptrade longtrade shortpositions,orders, andfillscancelandclosedaemon
MMT examples below assume:
--provider mmt- readable UTC dates at the CLI boundary
Binance Spot and Binance USD-M perpetual futures are also standalone public-data sources. Use --exchange binance or --exchange binancef, omit --provider, and do not configure a Binance API key. MMT access such as --provider mmt --exchange binancef remains separate.
BULK source examples use --exchange bulkf and omit --provider. Public BULK market data does not require credentials. Account and execution commands require an authorized BULK agent. Mainnet is the default; --testnet selects the public testnet where supported.
Hyperliquid is also standalone. Use hyperliquid for Spot and hyperliquidf for every perpetual market. Core symbols look like BTC; HIP-3 symbols include their DEX, such as xyz:TSLA or io:ANTH. Use hyperlink for Spot and hyperlinkf for core or HIP-3 perpetual execution through HyperLink. Add --testnet to direct Hyperliquid commands when the market exists there; HyperLink is mainnet-only. Do not add --provider unless MMT should route the data.
Binance Markets
Refresh the standalone snapshots
mlab markets --exchange binance --refresh
mlab markets --exchange binancef --refreshInspect a futures market
mlab markets --exchange binancef --symbol BTCBinance Historical Data
Spot candles
mlab source candles \
--exchange binance \
--symbol BTC/USDT \
--timeframe 60 \
--from "2026-05-27 11:06:40" \
--to "2026-05-27 12:06:40" \
--output jsonUSD-M perpetual futures volume bars
mlab source volumes \
--exchange binancef \
--symbol BTC \
--timeframe 60 \
--from "2026-05-27 11:06:40" \
--to "2026-05-27 12:06:40" \
--output jsonBinance volume bars are derived from candle volume. Historical requests paginate automatically and stop at 5,000 records.
Backtest a script
mlab script backtest ./scripts/sma-cross.js \
--from 2024-01-01 \
--to "2024-01-07 22:40:00" \
--source btc@candles@binancef:timeframe=60 \
--param fast=20 \
--param slow=50 \
--param margin=1000 \
--param leverage=5 \
--output jsonStandalone Binance selectors are historical-only. See Binance Market Data for supported selectors and limits.
BULK Markets
Refresh and list the installed catalog
mlab markets --exchange bulkf --refresh
mlab markets --exchange bulkfInspect one market
mlab markets --exchange bulkf --symbol BTCGet one rule set as JSON
mlab markets --exchange bulkf --symbol BTC --jsonOnly the refresh command makes a network request. The list and lookup commands read the installed snapshot and require no provider credential.
BULK Sources
Public orderbook
mlab source orderbook \
--exchange bulkf \
--symbol BTC \
--depth 100 \
--output terminalHistorical candles
mlab source candles \
--exchange bulkf \
--symbol BTC \
--timeframe 60 \
--from "2026-06-01 09:52:39" \
--to "2026-06-03 21:54:05" \
--output jsonLive order flow
mlab source vd \
--exchange bulkf \
--symbol BTC \
--stream \
--output jsonlMarket statistics and funding
mlab source stats --exchange bulkf --period 7d --output json
mlab source funding --exchange bulkf --symbol BTC --stream --output jsonlSee BULK Market Data for the exact range, snapshot, and stream contract of each source.
BULK Execution
Preview a market order
mlab trade long BTC --margin 10 --dry-runDry-run output is the same normalized plan reviewed before a live order. It does not sign, submit, or start mlabd.
Preview an ALO limit order
mlab trade short BTC \
--size 0.001 \
--type limit \
--price 65000 \
--tif alo \
--leverage 3 \
--dry-runPreview native stop and take-profit protection
mlab trade long BTC \
--margin 100 \
--leverage 5 \
--sl 63000 \
--tp 69000 \
--dry-runSubmit with terminal confirmation
mlab trade long BTC --margin 100 --leverage 5Inspect account state
mlab positions
mlab orders --symbol BTC
mlab fills --symbol BTCPreview cancellation and closing
mlab cancel BTC <ORDER_ID> --dry-run
mlab close BTC --dry-runInspect the execution runtime
mlab daemon status
mlab daemon events --limit 20 --output jsonl
mlab daemon stopSee Execution for order behavior, Configuration for TOML, and Daemon for runtime operation.
Hyperliquid
Refresh markets and inspect public data
mlab markets --exchange hyperliquidf --refresh
mlab markets --exchange hyperliquidf --symbol BTC
mlab source orderbook --exchange hyperliquidf --symbol BTC --depth 20
mlab source candles --exchange hyperliquidf --symbol BTC --timeframe 60 --from "2026-06-01 09:52:39" --to "2026-06-03 21:54:05" --output jsonAuthorize mainnet and testnet
mlab auth set hyperliquidThe authorization command configures separate API agents for both networks using the same master account. Preview either network explicitly:
# Hyperliquid mainnet
mlab trade long BTC \
--venue hyperliquidf \
--margin 100 \
--leverage 5 \
--dry-run
# Hyperliquid testnet
mlab trade long BTC \
--venue hyperliquidf \
--testnet \
--margin 100 \
--leverage 5 \
--dry-run
# XYZ mainnet
mlab trade long xyz:TSLA \
--venue hyperliquidf \
--margin 100 \
--leverage 5 \
--dry-run
# EntropyIO mainnet
mlab trade long io:ANTH \
--venue hyperliquidf \
--margin 100 \
--leverage 5 \
--dry-run
# HyperLink mainnet execution
mlab trade long BTC \
--venue hyperlinkf \
--margin 100 \
--leverage 5 \
--dry-runRun a script on direct Hyperliquid data
mlab script run ./scripts/strategy.js \
--source btc@candles@hyperliquidf:timeframe=5 \
--source btc@orderbook@hyperliquidf:depth=20 \
--venue hyperliquidfThis script executes on mainnet. Add --testnet to execute it on testnet. See Authentication, Hyperliquid Market Data, and Hyperliquid Execution.
XYZ scripts use the same shape with normalized base symbols:
mlab script run ./scripts/xyz.js \
--source tsla@candles@hyperliquidf-xyz:timeframe=60 \
--source tsla@orderbook@hyperliquidf-xyz:depth=20 \
--venue hyperliquidf-xyzSources
Orderbook snapshot
mlab source orderbook \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--depth 100 \
--output terminalOrderbook stream
mlab source orderbook \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--depth 100 \
--stream \
--min-size 0.1 \
--price-group 1 \
--interval-ms 1000 \
--buffer-size 20 \
--output terminalCandles range
mlab source candles \
--provider mmt \
--exchange binancef \
--symbol BTC \
--timeframe 60 \
--from "2026-05-27 11:06:40" \
--to "2026-05-27 12:06:40" \
--output jsonCandles stream
mlab source candles \
--provider mmt \
--exchange binancef \
--symbol BTC \
--timeframe 60 \
--stream \
--output jsonlVD range
mlab source vd \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--timeframe 60 \
--from "2026-05-24 11:00:00" \
--to "2026-05-24 12:00:00" \
--bucket 1 \
--output jsonVD stream
mlab source vd \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--timeframe 60 \
--bucket 1 \
--stream \
--output jsonlOI range
mlab source oi \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--timeframe 60 \
--from "2026-05-24 22:00:00" \
--to "2026-05-25 10:40:00" \
--output jsonOI stream
mlab source oi \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--timeframe 60 \
--stream \
--output jsonlVolumes range
mlab source volumes \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--timeframe 60 \
--from "2026-05-24 22:00:00" \
--to "2026-05-25 10:40:00" \
--output jsonVolumes stream
mlab source volumes \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--timeframe 60 \
--stream \
--output jsonlScripts
Backtest a JavaScript strategy
mlab script backtest ./scripts/sma-cross.js \
--from 2024-01-01 \
--to "2024-01-07 22:40:00" \
--source btc@candles@bybitf@mmt:timeframe=60 \
--param fast=20 \
--param slow=50 \
--param margin=1000 \
--leverage 5 \
--output jsonBacktest a VD script
mlab script backtest ./scripts/vd-summary.js \
--from "2026-06-03 14:46:05" \
--to "2026-06-05 00:06:58" \
--source btc@vd@hyperliquidf@mmt:timeframe=3600,bucket=1 \
--param min_delta=500 \
--output jsonCompare candles across exchanges
mlab script backtest ./examples/cross-exchange-spread.js \
--from 2024-01-01 \
--to "2024-01-07 22:40:00" \
--source btc@candles@binancef@mmt:timeframe=60 \
--source btc@candles@okx@mmt:timeframe=60 \
--output jsonThe script reads both histories with history.source("btc@candles@binancef@mmt") and history.source("btc@candles@okx@mmt") in backtests and live mode.
Backtest independent position exits
mlab script backtest ./scripts/dip-tp-positions.js \
--from "2026-06-03 14:46:05" \
--to "2026-06-05 00:06:58" \
--source btc@candles@hyperliquidf@mmt:timeframe=3600 \
--param drop_bps=20 \
--param take_profit_bps=50 \
--param margin=1000 \
--leverage 5 \
--output terminalThis script opens separate long positions on dips and closes only the position whose position_id hits its take-profit condition.
Deploy a live analysis script
mlab script run ./scripts/all-sources-live.js \
--source btc@candles@hyperliquidf@mmt:timeframe=5 \
--source btc@orderbook@hyperliquidf@mmt:depth=100 \
--source btc@vd@hyperliquidf@mmt:timeframe=60,bucket=1script run returns a detached job ID. It does not hold the terminal open.
Deploy a strategy with BULK execution
mlab script run ./examples/bulk-limit-protected.js \
--source btc@candles@bulkf:timeframe=5 \
--venue bulkf \
--param armed=trueThe script calls ctx.trade directly. --venue bulkf is required to enable BULK execution; the market data can still come from MMT, BULK, Hyperliquid, or a combination.
Manage live script 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>List script runtime reports
mlab script runs listView a script runtime report
mlab script runs show <run-id>Runtime reports are historical telemetry. Use script jobs and script status for deployed workers.
Studies
Spread
mlab study spread \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--depth 20 \
--output jsonDepth
mlab study depth \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--levels 20 \
--output jsonImbalance
mlab study imbalance \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--depth 50 \
--output jsonSlippage
mlab study slippage \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--side buy \
--notional 100000 \
--depth 100 \
--output jsonVAMP
mlab study vamp \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--depth 100 \
--dollar-depth 250000 \
--output jsonCVD
mlab study cvd \
--provider mmt \
--exchange bybitf \
--symbol BTC \
--timeframe 3600 \
--from "2026-05-24 11:00:00" \
--to "2026-05-24 12:00:00" \
--bucket 1 \
--output jsonTWAP Strategy
Preview the normalized schedule
mlab strategy run twap BTC \
--venue bulkf \
--side buy \
--margin 100 \
--duration 300 \
--interval 60 \
--dry-runDeploy a live TWAP job
mlab strategy run twap BTC \
--venue bulkf \
--side buy \
--margin 100 \
--duration 300 \
--interval 60The CLI asks for confirmation, submits the immutable plan to mlabd, prints the job ID, and returns.
Submit by size with structured output
mlab strategy run twap BTC \
--venue bulkf \
--side sell \
--size 0.01 \
--duration 600 \
--interval 30 \
--yes \
--output jsonMonitor and stop the 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. Stopping prevents later children; it does not reverse fills or close the resulting position. See TWAP.