Market LabDocs

Execution

Preview, submit, inspect, cancel, and close Market Lab orders.

Use mlab trade for a direct order. Built-in strategies, bots, and scripts use the same execution layer.

Before You Trade

  1. Configure the venue in Authentication.
  2. Refresh its market snapshot with mlab markets --exchange <exchange> --refresh.
  3. Start with --dry-run.
mlab auth status
mlab daemon status

Venues

VenueMarketNetwork
bulkfBULK perpetualsMainnet; --testnet for testnet
hyperliquidHyperliquid Spot and HIP-4 outcomesMainnet; --testnet for testnet
hyperliquidfHyperliquid core and HIP-3 perpetualsMainnet; --testnet for testnet
hyperlinkHyperLink Spot executionMainnet only
hyperlinkfHyperLink core and HIP-3 perpetual executionMainnet only

BULK and Hyperliquid use mainnet by default; add --testnet for their testnets. HyperLink has no public testnet and reuses Hyperliquid's public Spot and perpetual market snapshots.

HIP-3 uses the same hyperliquidf venue as core perpetuals. Put the DEX in the symbol, such as xyz:TSLA. See Hyperliquid Market Data for discovery and HyperLink Execution for its execution-only boundary.

Dry Run

mlab trade long BTC \
  --venue hyperliquidf \
  --margin 100 \
  --leverage 5 \
  --dry-run

A dry run validates the market, amount, price rules, and available account information. It does not sign or submit an order.

Perpetual Order

Perpetuals use the base symbol:

mlab trade long BTC \
  --venue hyperliquidf \
  --margin 100 \
  --leverage 5

Use long to buy exposure and short to sell exposure.

For HIP-3, keep the venue and scope the symbol:

mlab trade long xyz:TSLA \
  --venue hyperliquidf \
  --margin 100 \
  --leverage 5 \
  --dry-run

Route a core or HIP-3 perpetual through HyperLink by changing only the execution venue:

mlab trade long BTC \
  --venue hyperlinkf \
  --margin 100 \
  --leverage 5 \
  --dry-run

mlab trade long xyz:TSLA \
  --venue hyperlinkf \
  --margin 100 \
  --leverage 5 \
  --dry-run

Configure it first with mlab auth set hyperlink. HyperLink's authenticated market metadata determines valid perpetual leverage. Market Lab caches that value in daemon memory and reloads it on demand after restart.

Spot Order

Spot uses the exact pair and buy or sell:

mlab trade buy HYPE/USDC \
  --venue hyperliquid \
  --margin 100 \
  --dry-run

mlab trade sell HYPE/USDC \
  --venue hyperliquid \
  --size 10 \
  --type limit \
  --price 45 \
  --tif alo \
  --dry-run

Use --venue hyperlink to route the same Spot pair through HyperLink mainnet.

Spot does not use leverage, reduce-only, attached stop loss, attached take profit, or mlab close.

Outcome Order

Outcome symbols use <outcome-id>:<side>:

mlab trade long \
  1009:0 \
  --venue hyperliquid \
  --margin 100 \
  --dry-run

long buys the selected outcome token. short sells tokens already held. Naked outcome shorting is not supported.

See Hyperliquid outcomes for discovery and account actions.

Amount

Every order uses exactly one amount:

FlagMeaning
--sizeExact base-asset or token quantity
--marginCollateral budget

For perpetuals, exposure is approximately margin × leverage before market-rule rounding. For a spot or outcome buy, margin is the quote-token budget.

Order Type

Market order:

mlab trade long BTC --venue hyperliquidf --margin 100 --leverage 5 --type market --dry-run

Limit order:

mlab trade short BTC \
  --venue hyperliquidf \
  --size 0.001 \
  --leverage 3 \
  --type limit \
  --price 65000 \
  --tif alo \
  --dry-run

Limit time-in-force values:

  • gtc: good until cancelled
  • ioc: immediate or cancel
  • alo: add liquidity only

Perpetual Protection

mlab trade long BTC \
  --venue hyperliquidf \
  --margin 100 \
  --leverage 5 \
  --sl 63000 \
  --tp 69000 \
  --dry-run

--sl, --tp, --leverage, and --reduce-only are perpetual-only.

Account State

mlab positions --venue hyperliquidf
mlab orders --venue hyperliquidf
mlab fills --venue hyperliquidf
mlab positions --venue hyperliquidf --symbol xyz:TSLA

Add --testnet for BULK or Hyperliquid testnet. Filter with --symbol when needed.

Cancel and Close

mlab cancel BTC <ORDER_ID> --venue hyperliquidf --dry-run
mlab close BTC --venue hyperliquidf --dry-run
mlab close xyz:TSLA --venue hyperliquidf --dry-run

close exits a complete perpetual position with a reduce-only market order. Spot and outcomes must be sold instead.

Non-Interactive Execution

Terminal output asks for confirmation. Automation must add --yes and use structured output:

mlab trade long BTC \
  --venue hyperliquidf \
  --margin 100 \
  --leverage 5 \
  --yes \
  --output json

Live signing and order state run through mlabd.

On this page