Concepts
Understand the core Market Lab model before using individual commands.
Concepts
Market Lab is organized around five command layers:
source: raw market data accessstudy: computed market metrics built on top of market datastrategy: native Rust execution algorithms for user-supplied trading intentscript: JavaScript analysis and strategy logic over one or more sourcesexecution: simulated or live trade effects produced by explicit execution calls
This separation matters because it keeps the CLI predictable.
Source
source commands expose provider data directly.
Examples:
source orderbooksource candlessource vdsource oisource volumes
Use source when you want:
- current market state
- raw or lightly-normalized time series
- streaming updates from a provider
Study
study commands compute market structure or execution metrics from source data.
Examples:
study spreadstudy depthstudy imbalancestudy slippagestudy vampstudy cvd
Use study when you want:
- execution cost estimates
- liquidity shape
- orderbook imbalance
- derived statistics that are more useful than raw provider output
Strategy
strategy commands execute a parent order according to a native algorithm. The user supplies the symbol, side, amount, and execution controls. The strategy determines how the order is scheduled or divided.
Current strategy:
strategy run twap
TWAP divides a parent amount into child orders and submits them over time. Live strategies are detached jobs owned by mlabd, so the CLI returns after deployment.
Use a strategy when you already know what you want to execute:
- side: buy or sell
- amount: exact size or margin multiplied by leverage
- execution window and cadence
A strategy does not decide whether the market should be bought or sold. An autonomous bot owns that decision internally. Scripts remain the flexible layer and can implement either model. See Strategies.
Script
script commands run JavaScript in a bounded QuickJS runtime.
Scripts are not split into study scripts and strategy scripts. Their behavior determines how Market Lab uses them:
- returning metrics is analysis-oriented
- calling
ctx.tradeorctx.cancelis strategy execution script backtestsends those calls to the historical simulatorscript run --venue bulksends those calls tomlabdfor live BULK execution
Current script commands:
script runscript backtestscript jobsscript statusscript logsscript stopscript restartscript runs listscript runs show
Execution
Execution is always explicit. CLI users issue trade, cancel, close, or submit a confirmed built-in strategy; scripts call ctx.trade or ctx.cancel. Script return values are optional diagnostics, not execution instructions; signal and intent fields are rejected.
Use execution when you want to:
- preview an order with
--dry-run - place a confirmed market or limit order
- inspect positions, open orders, and fills
- cancel an order or close a position
- inspect
mlabdlifecycle state and events - deploy and supervise live strategy jobs
Live mutations route through mlabd; public market data, backtest simulation, and read-only account queries do not. See Execution and Script Execution.
Time Model
Market Lab uses milliseconds at the app boundary.
That means --from, --to, and ts_ms are millisecond-oriented in the CLI and JSON outputs.
Some providers, such as MMT, accept seconds over their API. Market Lab converts to provider-native units only at the adapter boundary.
Output Modes
The CLI is designed for both humans and machines.
terminal: compact human-readable outputjson: machine-readable outputjsonl: stream-friendly machine-readable output
For studies, default JSON is compact. Built-in strategy submission returns a persistent job record; strategy worker output is available through strategy logs.