map_trades {bitmexr} | R Documentation |
Trade data over an extended period
Description
The map variant of trades()
uses a repeat loop to continually
request trade data between two time points.
The function will stop when the start_date
is greater than end_date
.
Given the large number of trades executed per day,
a warning message with a choice to continue is presented when inputting a
date range spanning more than one day.
Usage
map_trades(
symbol = "XBTUSD",
start_date = "2019-01-01 12:00:00",
end_date = "2019-01-01 12:15:00",
filter = NULL,
use_auth = FALSE,
verbose = FALSE
)
Arguments
symbol |
a character string for the instrument symbol.
Use |
start_date |
character string.
Starting date for results in the format |
end_date |
character string.
Ending date for results in the format |
filter |
an optional character string for table filtering.
Send JSON key/value pairs, such as |
use_auth |
logical. Use |
verbose |
logical. If |
Details
Warning! Due to the extremely large number of trades executed on the exchange,
using this function over an extended of time frame will result in an extremely
long running process.
For example, during 2019 the exchange averaged approximately 630000 trades per day,
with a maximum of 2114878 trades being executed in a single day.
Obtaining the trade data for this day alone would take over an hour, and the use of
map_bucket_trades()
with a small 'binSize' (e.g., "1m"
) is preferrable.
Value
map_trades()
returns a data.frame
containing:
timestamp: POSIXct. Date and time of trade.
symbol: character. The instrument ticker.
side: character. Whether the trade was buy or sell.
size: numeric. Size of the trade.
price: numeric. Price the trade was executed at
tickDirection: character. Indicates if the trade price was higher, lower or the same as the previous trade price.
trdMatchID: character. Unique trade ID.
grossValue: numeric. How many satoshi were exchanged. 1 satoshi = 0.00000001 BTC.
homeNotional: numeric. BTC value of the trade.
foreignNotional: numeric. USD value of the trade.
References
https://www.bitmex.com/api/explorer/#!/Trade/Trade_get
Examples
## Not run:
# Get all trade data between 2019-05-03 12:00:00 and 2019-05-03 12:15:00
map_trades(
start_date = "2019-05-03 12:00:00",
end_date = "2019-05-03 12:15:00",
symbol = "XBTUSD"
)
## End(Not run)