Skip to content

Commit b3060bc

Browse files
authored
Merge pull request #8 from BitMEX-private/docs/tick-lot-size-guidance
docs: add tick size and lot size alignment guidance for order placement
2 parents 61932b2 + 2b78a19 commit b3060bc

3 files changed

Lines changed: 62 additions & 5 deletions

File tree

AGENTS.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,37 @@ bitmex execution trade-history --count 20 -o json
273273
bitmex wallet balance -o json
274274
```
275275

276+
### Tick size and lot size alignment
277+
278+
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.
279+
280+
Fetch constraints before placing:
281+
282+
```bash
283+
constraints=$(bitmex market instrument --symbol XBTUSD -o json | jq '.[0] | {tickSize, lotSize}')
284+
tick_size=$(echo "$constraints" | jq -r '.tickSize')
285+
lot_size=$(echo "$constraints" | jq -r '.lotSize')
286+
```
287+
288+
Round before submitting:
289+
290+
```bash
291+
# round price to nearest tick
292+
price=$(echo "$raw_price $tick_size" | awk '{printf "%g", int($1/$2+0.5)*$2}')
293+
# round qty down to nearest lot
294+
qty=$(echo "$raw_qty $lot_size" | awk '{printf "%g", int($1/$2)*$2}')
295+
```
296+
276297
### Safe order placement workflow
277298

278299
```bash
279-
# 1. Validate
300+
# 1. Fetch tick/lot constraints and align price/qty before submitting
301+
constraints=$(bitmex market instrument --symbol XBTUSD -o json | jq '.[0] | {tickSize, lotSize}')
302+
303+
# 2. Preview the constructed request body (local only — does not validate against exchange)
280304
bitmex order buy XBTUSD 100 --price 50000 --validate -o json
281305

282-
# 2. Confirm with user, then execute
306+
# 3. Confirm with user, then execute (--yes skips interactive prompt for agent use)
283307
bitmex order buy XBTUSD 100 --price 50000 --yes -o json
284308
```
285309

CLAUDE.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,19 @@ bitmex execution trade-history -o json
9191

9292
### Place orders (auth required, dangerous)
9393

94+
Prices must be multiples of `tickSize`; quantities must be multiples of `lotSize`. Fetch these from `bitmex market instrument --symbol <SYMBOL> -o json | jq '.[0] | {tickSize, lotSize}'` before placing. Misaligned values return `400 Invalid price` or `400 Invalid quantity`.
95+
9496
```bash
95-
# Validate first
97+
# Fetch constraints
98+
constraints=$(bitmex market instrument --symbol XBTUSD -o json | jq '.[0] | {tickSize, lotSize}')
99+
tick_size=$(echo "$constraints" | jq -r '.tickSize')
100+
lot_size=$(echo "$constraints" | jq -r '.lotSize')
101+
102+
# Preview request body (local dry-run only — no exchange-side validation)
96103
bitmex order buy XBTUSD 100 --price 50000 --validate -o json
97104

98-
# Then execute (requires user confirmation)
99-
bitmex order buy XBTUSD 100 --price 50000 -o json
105+
# Execute (--yes required for non-interactive/agent use)
106+
bitmex order buy XBTUSD 100 --price 50000 --yes -o json
100107
```
101108

102109
### Testnet

CONTEXT.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,32 @@ bitmex ws trade:XBTUSD orderBookL2_25:XBTUSD
195195
bitmex ws --auth position order execution
196196
```
197197

198+
## Order Constraints: Tick Size and Lot Size
199+
200+
Before placing an order, fetch the instrument's constraints:
201+
202+
```bash
203+
constraints=$(bitmex market instrument --symbol XBTUSD -o json | jq '.[0] | {tickSize, lotSize}')
204+
tick_size=$(echo "$constraints" | jq -r '.tickSize')
205+
lot_size=$(echo "$constraints" | jq -r '.lotSize')
206+
```
207+
208+
| Field | Meaning | Violation error |
209+
|-------|---------|----------------|
210+
| `tickSize` | Minimum price increment — price must be a multiple | `400 Invalid price` |
211+
| `lotSize` | Minimum quantity increment — qty must be a multiple | `400 Invalid quantity` |
212+
213+
Round before submitting:
214+
215+
```bash
216+
# price rounded to nearest tick
217+
price=$(echo "$raw_price $tick_size" | awk '{printf "%g", int($1/$2+0.5)*$2}')
218+
# qty rounded down to nearest lot
219+
qty=$(echo "$raw_qty $lot_size" | awk '{printf "%g", int($1/$2)*$2}')
220+
```
221+
222+
`--validate` is a local dry-run that prints the constructed order JSON without submitting to the exchange. It does not perform server-side price/qty validation — alignment must be correct before live submission.
223+
198224
## MCP Server
199225

200226
```bash

0 commit comments

Comments
 (0)