feat: add peg, chaser, and trailing-stop order types#23
Open
vkbalakrishnan wants to merge 1 commit into
Open
Conversation
order buy|sell forwarded --order-type/--exec-inst as freeform strings, so the Pegged/Fixed/ChaserClassic labels were reachable — but pegPriceType and pegOffsetValue had no flags, so none of these order types could actually be placed. Add first-class support: - Primitive --peg-price-type / --peg-offset-value flags on buy/sell (and --peg-offset-value on amend), mapping straight to the API fields. - order chase <symbol> <side> <qty> --offset N [--bothways] — Pegged + ChaserClassic/ChaserBothways; re-prices to follow the top of book. - order trailing-stop <symbol> <side> <qty> --offset N [--limit-price P] [--trigger T] — Stop/StopLimit + TrailingStopPeg. Both guided commands enforce the pegOffsetValue sign convention client-side (chaser: buy <= 0, sell >= 0; trailing: sell <= 0, buy >= 0 — the opposite), returning a validation error before the order reaches the exchange. Expose the new params/commands as MCP tools in agents/tool-catalog.json (also fixes the order sell entry's missing tif/exec_inst). Docs updated in README, CONTEXT, AGENTS, and CLAUDE. Tests: unit coverage for sign rules, body construction, and MCP arg routing; integration --help and --validate dry-run tests.
TraderSamwise
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds first-class support for BitMEX pegged, chaser, and trailing-stop orders — on the CLI and as MCP tools.
Why
order buy|sellalready forwarded--order-type/--exec-instas freeform strings, so the labelsPegged/Fixed/ChaserClassicwere reachable — but there were no flags forpegPriceTypeorpegOffsetValue, the two fields every one of these order types requires. As a result none of them could actually be placed via the CLI or its MCP tools.What changed
Primitive flags (thin pass-through) on
buy/sell:--peg-price-type <PrimaryPeg|MarketPeg|TrailingStopPeg|LastPeg|MidPricePeg>--peg-offset-value <N>--peg-offset-valuealso added toamend(amend a live peg without cancel/replace).Guided subcommands that set
ordType/execInstand validate the offset sign locally:order chase <symbol> <side> <qty> --offset N [--bothways]→Pegged+ChaserClassic/ChaserBothways; re-prices to follow the top of book.order trailing-stop <symbol> <side> <qty> --offset N [--limit-price P] [--trigger T]→Stop/StopLimit+TrailingStopPeg.Sign-convention safety
The two guided commands enforce the
pegOffsetValuesign client-side, returning avalidationerror before the order reaches the exchange. The rules are opposite, which is exactly the footgun this guards:MCP + docs
agents/tool-catalog.json: peg params onorder buy/order sell,peg_offset_valueonamend, and neworder chase/order trailing-stopentries withoneOfenums. Also fixes pre-existing drift where theorder sellentry was missingtif/exec_inst(needed for chaser/pegged via the primitive path over MCP).README.md,CONTEXT.md,AGENTS.md,CLAUDE.md.Examples
Testing
order.rs):as_apimappings,build_order_bodypeg fields, chase/trailing sign rules,ordType/execInstselection.registry.rs,server.rs): new tools registered with correct schema; full MCP→CLI arg routing for thesidepositional + hyphen-value--offset.cli_tests.rs):--helpfor the new subcommands;--validatedry-runs assert the emitted body and sign rejection.cargo test(112 lib + 22 integration) green;cargo clippyclean onorder.rs.Semantics grounded in BitMEX's
swagger.json, the engine'sNewOrderChaserValidator, and the Chaser order blog post.