bitmexr now supports placing, editing and cancelling orders on both the testnet API and live API provided by BitMEX. This vignette outlines how you can use
cancel_order() to manage your BitMEX trading directly from R! For more information about the API please visit (https://www.bitmex.com/app/apiOverview)
The following examples will use the tn_* varients of the managing trades functions (
tn_cancel_order()) to access the testnet API. These functions will work in exactly the same way when using the live API (without the tn_ prefix).
Use the following to place an order on the exchange
price is not specified, a market order will be used.
You can specific
side = Sell or use a negative
orderQty to initiate a sell order.
?place_order() to see the full list of order options, or visit https://www.bitmex.com/api/explorer/#/Order
Once an order has been placed, it is possible to edit the order using either the
orderID returned when using
place_order() or the custom client order id specified using
For example placing the following order:
Could be edited using:
Cancelling order is very similar to editing order, simply use the orderID or clOrdID
It is also possible to cancel all orders. For example cancel all sell orders using:
post_bitmex functions can be used to access additional API endpoints that do not have a dedicated wrapper.
path argument is the API endpoint and always starts with a “/” (e.g., “/chat”). The
args argument is a named list of valid parameter values to pass to the API endpoint. These are well documented on https://www.bitmex.com/api/explorer/
For example, to access the user information for your testnet account you can use:
As this is a private API endpoint, authentication was required.
A POST example to increase the leverage on a position is:
Please use the https://www.bitmex.com/api/explorer/ to view all possible API endpoints.