Skip to content
Open
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
20 changes: 20 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,26 @@ bitmex order buy XBTUSD 100 --price 50000 --validate -o json
bitmex order buy XBTUSD 100 --price 50000 --yes -o json
```

### Closing positions (Stop-Loss, Take-Profit, OCO)

`order close` places a 100% position-closing order. It omits `orderQty`, so the order tracks the **entire** position dynamically — BitMEX renders it as `SL (100%)` / `TP (100%)`, and it never needs resyncing as the position size changes. `--side sell` closes a long; `--side buy` closes a short. A trigger price type (`--trigger last|mark|index`) is required whenever `--stop-px` or `--tp-px` is set; `mark` resists wick-outs and is recommended for risk orders.

```bash
# Stop-Loss 100% (Stop; add --stop-limit-px for StopLimit)
bitmex order close XBTUSD --side sell --stop-px 50000 --trigger mark --yes -o json

# Take-Profit 100% (MarketIfTouched; add --tp-limit-px for LimitIfTouched)
bitmex order close XBTUSD --side sell --tp-px 60000 --trigger last --yes -o json

# OCO bracket: SL + TP linked via clOrdLinkID + contingencyType. Filling one cancels the other.
bitmex order close XBTUSD --side sell --stop-px 50000 --tp-px 60000 --trigger mark --yes -o json

# Immediate market close of the full position
bitmex order close XBTUSD --side sell --yes -o json
```

Preview any of these with `--validate` to inspect the exact request body (for OCO, both legs) before submitting.

### Stream live data to a pipeline

```bash
Expand Down
7 changes: 7 additions & 0 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ bitmex order cancel --order-id <id> --yes -o json
bitmex order cancel-all --symbol XBTUSD --yes -o json
bitmex order list --symbol XBTUSD -o json

# 100% position-closing orders (orderQty omitted -> tracks full position; SL/TP 100%)
# --side sell closes a long, buy closes a short. --trigger required with --stop-px/--tp-px.
bitmex order close XBTUSD --side sell --stop-px 50000 --trigger mark --yes -o json # Stop-Loss 100%
bitmex order close XBTUSD --side sell --tp-px 60000 --trigger last --yes -o json # Take-Profit 100%
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%

# Positions
bitmex position list -o json
bitmex position leverage XBTUSD 10 -o json
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,20 @@ bitmex order amend --order-id <id> --price 51000
bitmex order cancel --order-id <id>
bitmex order cancel-all [--symbol XBTUSD]
bitmex order cancel-after 60000 # Dead Man's Switch (ms)
bitmex order close-position XBTUSD
bitmex order list [--symbol XBTUSD]
```

100% position-closing orders — `orderQty` is omitted, so they track the full
position dynamically (BitMEX renders them as SL/TP 100%). `--side sell` closes a
long, `--side buy` closes a short. `--trigger` is required with `--stop-px`/`--tp-px`.

```bash
bitmex order close XBTUSD --side sell --stop-px 50000 --trigger mark # Stop-Loss 100%
bitmex order close XBTUSD --side sell --tp-px 60000 --trigger last # Take-Profit 100%
bitmex order close XBTUSD --side sell --stop-px 50000 --tp-px 60000 --trigger mark # OCO bracket
bitmex order close XBTUSD --side sell # market close 100%
```

### Positions (auth required)

```bash
Expand Down
22 changes: 22 additions & 0 deletions agents/tool-catalog.json

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

Loading