Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,30 @@ bitmex order buy XBTUSD 100 --price 50000 --strategy Long --yes -o json
bitmex order sell XBTUSD 100 --price 52000 --strategy Short --yes -o json
```

### Peg, Chaser & Trailing Stop orders

Pegged orders price relative to the live market instead of a fixed price. The primitive
`--peg-price-type`/`--peg-offset-value` flags on `buy`/`sell` map straight to the API
`pegPriceType`/`pegOffsetValue` fields; `chase` and `trailing-stop` are guided wrappers that
set `ordType`/`execInst` and **reject a wrong-sign offset locally** (category `validation`)
before it reaches the exchange.

```bash
# Pegged limit — requires exec_inst Fixed. PrimaryPeg = near touch, MarketPeg = far touch.
bitmex order buy XBTUSD 100 --order-type Pegged --exec-inst Fixed \
--peg-price-type PrimaryPeg --peg-offset-value -1 --yes -o json

# Chaser (ordType Pegged) — follows the top of book. Sign rule: Buy offset <= 0, Sell >= 0.
# Max 5 chaser orders per account. --bothways keeps a constant distance (ChaserBothways).
bitmex order chase XBTUSD Buy 100 --offset -1 --yes -o json
bitmex order chase XBTUSD Sell 100 --offset 1 --bothways --yes -o json

# Trailing stop (pegPriceType TrailingStopPeg) — sign rule is the OPPOSITE of chaser:
# Sell offset <= 0, Buy offset >= 0. --limit-price promotes Stop to StopLimit.
bitmex order trailing-stop XBTUSD Sell 100 --offset -100 --yes -o json
bitmex order trailing-stop XBTUSD Sell 100 --offset -100 --limit-price 49000 --yes -o json
```

### Tick size and lot size alignment

Every instrument enforces a minimum price increment (`tickSize`) and minimum quantity increment (`lotSize`). Submitting a price or quantity that isn't a multiple of these will return a `400 Invalid price` or `400 Invalid quantity` error.
Expand Down
19 changes: 19 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,25 @@ bitmex order buy XBTUSD 100 --price 50000 --validate -o json
bitmex order buy XBTUSD 100 --price 50000 --yes -o json
```

### Peg, chaser & trailing-stop orders (auth required, dangerous)

Pegged orders price relative to the live market. `chase` and `trailing-stop` are guided
wrappers that set `ordType`/`execInst` and enforce the offset sign locally (a wrong sign
returns a `validation` error before reaching the exchange). Their sign rules are opposite:

```bash
# Pegged limit — requires exec_inst Fixed (PrimaryPeg = near touch, MarketPeg = far touch)
bitmex order buy XBTUSD 100 --order-type Pegged --exec-inst Fixed \
--peg-price-type PrimaryPeg --peg-offset-value -1 --yes -o json

# Chaser — follows the top of book. Buy offset <= 0, Sell offset >= 0. Max 5 per account.
bitmex order chase XBTUSD Buy 100 --offset -1 --yes -o json
bitmex order chase XBTUSD Sell 100 --offset 1 --bothways --yes -o json

# Trailing stop — Sell offset <= 0, Buy offset >= 0 (opposite of chaser)
bitmex order trailing-stop XBTUSD Sell 100 --offset -100 --yes -o json
```

### Testnet

```bash
Expand Down
7 changes: 7 additions & 0 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ bitmex order close XBTUSD --side sell --tp-px 60000 --trigger last --yes -o json
bitmex order close XBTUSD --side sell --stop-px 50000 --tp-px 60000 --trigger mark --yes -o json # OCO bracket (fill one cancels the other)
bitmex order close XBTUSD --side sell --yes -o json # market close 100%

# Peg / Chaser / Trailing Stop (offset sign is enforced client-side)
bitmex order buy XBTUSD 100 --order-type Pegged --exec-inst Fixed \
--peg-price-type PrimaryPeg --peg-offset-value -1 --yes -o json # pegged limit
bitmex order chase XBTUSD Buy 100 --offset -1 --yes -o json # chaser: Buy <= 0, Sell >= 0
bitmex order chase XBTUSD Sell 100 --offset 1 --bothways --yes -o json
bitmex order trailing-stop XBTUSD Sell 100 --offset -100 --yes -o json # trailing: Sell <= 0, Buy >= 0

# Positions
bitmex position list -o json
bitmex position leverage XBTUSD 10 -o json
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,30 @@ bitmex order close XBTUSD --side sell --stop-px 50000 --tp-px 60000 --trigger ma
bitmex order close XBTUSD --side sell # market close 100%
```

Pegged orders price relative to the live market. `chase` and `trailing-stop` are guided
wrappers that set the right `ordType`/`execInst` and enforce the offset **sign rule**
locally (a wrong sign is rejected before it reaches the exchange).

```bash
# Pegged limit — Fixed price relative to the touch (PrimaryPeg = near, MarketPeg = far)
bitmex order buy XBTUSD 100 --order-type Pegged --exec-inst Fixed \
--peg-price-type PrimaryPeg --peg-offset-value -1

# Chaser — re-prices to follow the top of book. Buy offset <= 0, Sell offset >= 0.
bitmex order chase XBTUSD Buy 100 --offset -1 # ChaserClassic (default)
bitmex order chase XBTUSD Sell 100 --offset 1 --bothways # ChaserBothways

# Trailing stop — stopPx trails the market. Sell offset <= 0, Buy offset >= 0.
bitmex order trailing-stop XBTUSD Sell 100 --offset -100 # Stop
bitmex order trailing-stop XBTUSD Sell 100 --offset -100 --limit-price 49000 # StopLimit

# Amend a live peg's offset without cancel/replace
bitmex order amend --order-id <id> --peg-offset-value -2
```

See [Order Types & Execution Instructions](https://support.bitmex.com/hc/en-gb/articles/6911327963293)
for the full peg/chaser reference.

### Positions (auth required)

```bash
Expand Down
64 changes: 60 additions & 4 deletions agents/tool-catalog.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading