bitmexr 0.3.0 brings some exciting new features to the package. bitmexr now supports placing, editing and cancelling orders through BitMEX’s API. In addition, the testnet version of the API is now supported soyou can try out managing orders using the package in a risk free environment!
Install the latest release from CRAN:
install.packages("bitmexr")
Package site: https://hfshr.github.io/bitmexr/
The latest CRAN release of bitmexr
supports placing, editing and cancelling orders on the BitMEX exchange. These actions are supported by the following functions:
place_order()
edit_order()
cancel_order
or cancel_all_orders()
See the package documentation or the BitMEX website for details on what arguments can be used with each function.
BitMEX has a fully functional Testnet exchange that lets you use a “practice” version of the live exchange. This is great for trying out a new trading idea or using trying these functions out in a risk free environment that is identical to the real thing. Every function in bitmexr
has a Testnet equivalent - simply use the “tn_” prefix to access the Testnet version of the function. For example:
place_order(symbol = "XBTUSD", price = 5000, orderQty = 100)
Will place an order on the live exchange, whereas:
tn_place_order(symbol = "XBTUSD", price = 5000, orderQty = 100)
Will place the order on the Testnet exchange.
In order to use these new functions you must first obtain an API key and secret for the account you wish to use with bitmexr
. With API key and secret in hand, you can add these to your ~/.Renviron file using:
bitmex_apikey = "api key"
bitmex_apisecret = "api secret"
for the live exchange or
testnet_bitmex_apikey = "testnet api key"
testnet_bitmex_apisecret = "tetsnet api secret"
for the Testnet exchange.
See the Authentication vignette for more details.
With authentication set up, map_trades()
and map_bucket_trades()
get a speed boost due to increased API limit when using authentication. Simply set use_auth = TRUE
to get these functions running at 60 API call per minute .
For additional API endpoints that don’t have a dedicated API wrapper in bitmexr
, it is possible use either:
get_bitmex()
for additional GET requestsand
post_bitmex()
for additional POST requests.These functions just need the path to the API endpoint and a named list of valid parameters for that endpoint. For example, you could use:
chat <- get_bitmex(path = "/chat",
args = list(channelID = 1,
reverse = "true"))
To get the latest English trollbox chat data (not sure why anyone would want this, but it is possible!).
Current ideas for a future release:
Of course, any feedback / ideas are more than welcome!
If you see mistakes or want to suggest changes, please create an issue on the source repository.
Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/hfshr/distill_blog, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
For attribution, please cite this work as
Fisher (2020, May 25). Data, Code & Coffee: bitmexr 0.3.0: Place, modify and cancel your orders on BitMEX without leaving R! . Retrieved from https://hfshr.xyz/posts/2020-05-25-bitmexr-updates/
BibTeX citation
@misc{fisher2020bitmexr, author = {Fisher, Harry}, title = {Data, Code & Coffee: bitmexr 0.3.0: Place, modify and cancel your orders on BitMEX without leaving R! }, url = {https://hfshr.xyz/posts/2020-05-25-bitmexr-updates/}, year = {2020} }