Author

Topic: BitMEX's Largest API Update: 10 New Order Types, Bulk/Amending Orders & More (Read 314 times)

newbie
Activity: 17
Merit: 0
Hey Bitcointalk,

We've been quiet lately, because we've been working on one of the biggest updates BitMEX has ever received.

This is a multi-part upgrade; today we're launching the API, but we'll be launching a few new contracts and a reworked order dashboard very soon.

So what's new in this update?

All updates are additions; no breaking changes have been made. In short:

  • 10 new order types, including some very advanced types
  • Bulk ordering
  • Order Amending
  • Bulk amending
  • A new way to manage your leverage, before and while having an open position, and
  • Various performance & stability updates.

Detailed Notes:

  • Order: New endpoint: POST /api/v1/order/bulk.
      (docs)
      Send an array of orders and they will all be validated and executed at the same time. If any of the orders fail to validate, none will execute. To encourage use, bulk orders (and amends) are ratelimited  at ceil(orders.length / 2); for example, placing 2 orders consumes 1 call, and 9 consumes 5 calls.
  • Order: New endpoint: PUT /api/v1/order.
      (docs)
      You may now amend an existing order's price and quantity. This is very useful for market makers who want to save an  API call (cancel/replace) and not lose their position in the book.
  • Order: New endpoint: PUT /api/v1/order/bulk
      (docs)
      You may now amend multiple orders. The same behavior as bulk order placement applies.

New Order Types: (docs)

  • Market: We gave in. For simplicity's sake, we now support Market orders. As always, be careful. Required: orderQty and symbol.
  • Stop: A Stop Market order. Required: orderQty, stopPx, and symbol.
  • MarketWithLeftOverAsLimit: A market order that, after eating through the order book as far as permitted by available margin, will become a limit order. The difference between this type and Market only affects the behavior in thin books. Upon reaching the deepest possible price, if there is quantity left over, a Market order will cancel the remaining quantity. MarketWithLeftOverAsLimit will keep the remaining quantity in the books as a Limit.
  • Trailing Stop: A trailing stop follows the current market price at an offset, enabling a trade to remain open, yet closing if the market changes direction by a certain amount. Send a pegPriceType: 'TrailingStopPeg' and a pegOffsetValue: number. The pegOffsetValue is a price offset. Use a negative pegOffsetValue for sell orders.
  • OCO: One Cancels the Other. A very flexible version of the standard Stop / Take Profit technique. Multiple orders may be linked together using a single clOrdLinkID. Send a contingencyType of OneCancelsTheOther on the orders. The first order that fully or partially executes (or activates for Stop orders) will cancel all other orders with the same clOrdLinkID.
  • OTO: One Triggers the Other. Send a contingencyType of OneTriggersTheOther on the primary order and then subsequent orders with the same clOrdLinkID will be not be triggered until the primary order fully executes.
  • OUOA: One Updates the Other Absolute. Send a contingencyType of OneUpdatesTheOtherAbsolute on the orders. Then as one order has a execution, other orders with the same clOrdLinkID will have their order quantity amended down by the execution quantity.
  • OUOP: One Updates the Other Proportional. Send a contingencyType of OneUpdatesTheOtherProportional on the orders. Then as one order has a execution, other orders with the same clOrdLinkID will have their order quantity reduced proportionally by the fill percentage.

New Order Attributes:

  • Hidden Orders: Send a displayQty, where 0 <= displayQty < orderQty. A displayQty of 0 is a fully hidden order. You may partially hide an order by choosing a non-zero displayQty. When the order is hit, the non-hidden portion will be refilled, up to the order's total quantity. Note that hidden orders incur the Taker fee.
  • Post-Only Orders: Any non-Market order may be made "Post-Only" by sending an execInst of ParticipateDoNotInitiate. This will reject the order if it would execute against the market, ensuring your order receives the Maker rebate. To prevent feeling out Hidden Orders, Post-Only Orders will still execute against Hidden Orders, but you will receive the Maker rebate as Hidden Orders always incur the Taker fee.
  • Time In Force: Valid options: Day, GoodTillCancel, ImmediateOrCancel, FillOrKill. Defaults to GoodTillCancel for Limit and StopLimit orders.
  • Simple Quantities: Send a simpleOrderQty instead of an orderQty to create an order denominated in the underlying currency. Useful for e.g. opening up a position with 1 XBT of exposure without having to calculate how many contracts it is.

Other Changes:

  • WebSockets: Upon subscribing to a topic, a data image is now immediately pushed to the consumer. This means consumers no longer need to orchestrate calls to the HTTP API or use pushAccount/pushSymbol. As a result pushAccount/pushSymbol have been made redundant and are now deprecated. They will be removed in a later release.
  • Position: New endpoint: POST /api/v1/position/leverage. Accepts a symbol and leverage integer.
      This is a very easy way to update a position to isolated(fixed) margining at a given leverage. In the very near future, this will allow users on the website to easily adjust their leverage, even on open positions!
      For example:
     
    • A user deposits 1 XBT of margin.
    • The user opens a cross-margin XBT24H position with a gross value of 2 XBT.
    • The user decides to switch to isolated margin to protect his total account equity, and updates leverage to 50.
    • The system assigns 2 XBT / 50 or 0.04 XBT to the position. The other 0.96 XBT in the user's account is no longer at risk.
    • The user decides to switch to 1x isolated margin. Because the position value is 2 XBT and the user only has 1 XBT in the account, this will error and no change will occur.
    • The user's position loses 0.02 XBT of value, and only 0.02 XBT remains assigned, for an effective leverage of 100x. The user then decides to switch to 10x leverage. The system then assigns 2 XBT / 10 or 0.20 XBT to the position. The user has 0.78 XBT of unassigned margin left.
  • UDF/TradeBin: Indices (.XBT, .BVOL, etc) are now supported via the UDF (TradingView) and /api/v1/tradeBin routes. In the near future, we will officially support overlaying underlying prices on the charts.

-----

The new bulk order calls greatly simplify market making on BitMEX. We have updated our Reference Market Maker to support the latest calls, and as a result has been significantly improved in speed and accuracy.

Much more is on the way. Stay tuned.

As always, catch us in our chat box, on Telegram (we're in the major trading channels), or via email ([email protected]) if you have questions.

Good Luck,

Samuel Reed, CTO, BitMEX
Jump to: