---
title: "Getting started"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{getting-started}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

This vignette gives a brief overview of the main functions within the `bitmexr` package. The package supports both the testnet and live API endpoints, simply use the `tn_` prefix to any of the functions in the package (e.g., `bitmexr::trades()` accesses trade data from the live API whereas `bitmexr::tn_trades()` accesses trade data from the testnet API). This is useful is you want to test out placing/managing orders in a risk free environment.

# Trade data

To access trades that have been executed on the exchange you can use either:

- `trades()`: to get individual trades that have been executed.
- `bucket_trades()`: to get bucketed trade data in 1-minute, 5-minute, 1-hour or 1-day buckets

`bucket_trades()` is typically more useful when wanting data over an extended period of time due to the sheer volume of trades that are executed on the exchange each day. These functions also have map_* variants to help overcome the 1000 row per request limit.

Please see the [Trade data](trade-data.html) vignette for more details on these functions.

# Placing, editing and cancelling orders

`bitmexr` also supports placing and managing orders on the exchange. These functions require an API key and secret to work. Please read the vignette [Authentication](authentication.html) for information on how to set this up in `bitmexr`.

The following functions are available:

- `place_order()` for placing orders
- `edit_order()` for editing orders
- `cancel_order()` or `cancel_all_orders()` to cancel orders

Please see the vignette [Placing and managing order with bitmexr](placing-orders.html) for more information.

# Further information

It is recommended to have a thorough understanding of the BitMEX API documentation prior to using the package. Please take some time to read both https://www.bitmex.com/app/apiOverview and https://www.bitmex.com/api/explorer/. 
