# Execution (/execution)



Use `mlab trade` for a direct order. Built-in [strategies](/strategies), [bots](/bots), and scripts use the same execution layer.

## Before You Trade [#before-you-trade]

1. Configure the venue in [Authentication](/authentication).
2. Refresh its market snapshot with `mlab markets --exchange <exchange> --refresh`.
3. Start with `--dry-run`.

```bash
mlab auth status
mlab daemon status
```

## Venues [#venues]

| Venue          | Market                                       | Network                          |
| -------------- | -------------------------------------------- | -------------------------------- |
| `bulkf`        | BULK perpetuals                              | Mainnet; `--testnet` for testnet |
| `hyperliquid`  | Hyperliquid Spot and HIP-4 outcomes          | Mainnet; `--testnet` for testnet |
| `hyperliquidf` | Hyperliquid core and HIP-3 perpetuals        | Mainnet; `--testnet` for testnet |
| `hyperlink`    | HyperLink Spot execution                     | Mainnet only                     |
| `hyperlinkf`   | HyperLink core and HIP-3 perpetual execution | Mainnet 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](/providers-market-data/hyperliquid) for discovery and [HyperLink Execution](/providers-execution/hyperlink) for its execution-only boundary.

## Dry Run [#dry-run]

```bash
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 [#perpetual-order]

Perpetuals use the base symbol:

```bash
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:

```bash
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:

```bash
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-order]

Spot uses the exact pair and `buy` or `sell`:

```bash
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-order]

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

```bash
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](/providers-execution/hyperliquid#outcome-markets) for discovery and account actions.

## Amount [#amount]

Every order uses exactly one amount:

| Flag       | Meaning                            |
| ---------- | ---------------------------------- |
| `--size`   | Exact base-asset or token quantity |
| `--margin` | Collateral 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 [#order-type]

Market order:

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

Limit order:

```bash
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 [#perpetual-protection]

```bash
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 [#account-state]

```bash
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 [#cancel-and-close]

```bash
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 [#non-interactive-execution]

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

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

Live signing and order state run through [mlabd](/daemon).
