Description Usage Arguments Value Examples
View source: R/rest_public_endpoints.R
Candles endpoint of Bitfinex API V2. URL Structure: URL structure: https://api.bitfinex.com/v2/candles/trade::TimeFrame::Symbol/Section
1 2 3 4 |
symbol |
The symbol you want information about (e.g. 'tBTCUSD' for pair Bitcoin/US Dollar or 'fUSD' for funding info). |
time_frame |
Available values: '1m', '5m', '15m', '30m', '1h', '3h', '6h', '12h', '1D', '7D', '14D', '1M'. |
section |
Available values: "last", "hist". |
limit |
Number of candles requested. |
start |
Filter start in milliseconds (ms). |
end |
Filter end in milliseconds (ms). |
period |
(for funding only) |
sort |
if = -1 it sorts results returned with new > old. if = 1 it sorts in the opposite order. Default is -1. |
a tibble
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | ## Not run:
# 15 minutos
candles <- tidyr::crossing(symbol = c("tBTCUSD", "tBCHUSD",
"tBTGUSD", "tIOTUSD",
"tXMRUSD", "tLTCUSD",
"tETHUSD", "tDSHUSD",
"tETCUSD", "tZECUSD",
"tXRPUSD", "tEOSUSD",
"tSANUSD", "tOMGUSD"),
start = as.numeric(1504234800000 + seq(0, 1200000, by = 15000) * 60 * 1000)) %>%
filter(start <= as.numeric(now()) * 1000)
#
safely_bitfinex_candles <- purrr::safely(bitfinex_candles)
candles %<>%
mutate(bitfinex_candles = map2(symbol, start, ~ {
print(.x)
nome_do_rds <- sprintf("data/%s_15m_%s.rds", .x, .y)
if(file.exists(nome_do_rds)) {print("j<c3><a1> existe");return(read_rds(nome_do_rds))}
Sys.sleep(.1)
deu_certo <- FALSE
repeat{
data <- safely_bitfinex_candles(symbol = .x,
time_frame = '15m',
section = 'hist',
limit = 1000,
start = .y,
period = NULL,
aggr = NULL,
sort = 1
)
deu_certo <- is.null(data$error)
if(deu_certo){ break }
print("deu errado. tentando novamente em 60 segundos.")
Sys.sleep(30)
}
data <- data$result %>%
mutate(symbol = .x)
write_rds(data, path = nome_do_rds)
return(data)
}))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.