Skip to content

feat: add Hedge Mode (MultiWay position mode) support#16

Merged
byshing merged 1 commit into
BitMEX:masterfrom
vkbalakrishnan:feat/hedge-mode
Jun 24, 2026
Merged

feat: add Hedge Mode (MultiWay position mode) support#16
byshing merged 1 commit into
BitMEX:masterfrom
vkbalakrishnan:feat/hedge-mode

Conversation

@vkbalakrishnan

Copy link
Copy Markdown
Contributor

What

Adds Hedge Mode (MultiWay position mode) to the CLI, letting users hold independent Long and Short positions on the same contract instead of netting into one.

Switch position mode — POST /user/positionMode

bitmex account position-mode multiway   # enable Hedge Mode (alias: hedge)
bitmex account position-mode oneway      # back to One-Way (netting)
bitmex position mode multiway            # alias for `account position-mode`

account position-mode is the canonical command (sibling of account margining-mode, which posts to the analogous /user/marginingMode); position mode is a CLI alias delegating to the same handler. Optional --target-account-id for paired/sub-accounts. Confirmation-gated like other state-changing commands (skip with --yes). MultiWay sends {"positionMode":"MultiWay"}; One-Way omits the field, per the API contract.

Hedge legs on orders — strategy field on POST /order

bitmex order buy  XBTUSD 100 --price 50000 --strategy Long
bitmex order sell XBTUSD 100 --price 52000 --strategy Short

--strategy accepts oneway / long / short and maps to the exact API casing. The strategy column is now shown in position list and order list.

MCP

agents/tool-catalog.json gains the strategy param on buy/sell and a new dangerous account position-mode tool. The position mode alias is intentionally CLI-only (no catalog entry) to avoid a duplicate MCP tool.

Docs

README / AGENTS / CONTEXT document Hedge Mode, with links to the BitMEX support articles.

Testing

  • cargo build and cargo test pass — 98 unit + 16 integration tests (new coverage: position-mode body builder, order strategy builder, MCP registry, and help-text assertions).
  • cargo clippy is clean on the changed files.
  • Smoke-tested the built binary: --validate shows "strategy":"Long" in the order body (omitted when unset); all mode aliases (multiway/hedge/oneway/multi-way/one-way) route to /user/positionMode; invalid values are rejected by clap.

Notes

  • Scoped change, no unrelated refactoring or formatting.
  • For One-Way the positionMode field is omitted (swagger: "leave empty for one way mode"); equivalent to sending null.

🤖 Generated with Claude Code

Lets users hold independent Long and Short positions on the same contract.

- account position-mode <oneway|multiway> (alias: position mode) -> POST /user/positionMode
- order buy/sell --strategy <oneway|long|short> -> order `strategy` field
- show `strategy` column in `position list` and `order list`
- register the position-mode tool in the MCP tool-catalog (dangerous)
- document Hedge Mode in README/AGENTS/CONTEXT

Verified: cargo build + cargo test green (98 unit + 16 integration);
clippy clean on changed files.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byshing byshing merged commit 761e3c0 into BitMEX:master Jun 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants