crypto_history {crypto2} | R Documentation |
Get historic crypto currency market data
Description
Scrape the crypto currency historic market tables from 'CoinMarketCap' https://coinmarketcap.com and display the results in a dataframe/tibble. This can be used to conduct analysis on the crypto financial markets or to attempt to predict future market movements or trends.
Usage
crypto_history(
coin_list = NULL,
convert = "USD",
limit = NULL,
start_date = NULL,
end_date = NULL,
interval = NULL,
sleep = 0,
wait = 60,
finalWait = FALSE,
single_id = FALSE
)
Arguments
coin_list |
string if NULL retrieve all currently existing coins ( |
convert |
(default: USD) to one or more of available fiat or precious metals prices ( |
limit |
integer Return the top n records, default is all tokens |
start_date |
string Start date to retrieve data from, format 'yyyymmdd' |
end_date |
string End date to retrieve data from, format 'yyyymmdd', if not provided, today will be assumed |
interval |
string Interval with which to sample data according to what |
sleep |
integer (default 60) Seconds to sleep between API requests |
wait |
waiting time before retry in case of fail (needs to be larger than 60s in case the server blocks too many attempts, default=60) |
finalWait |
to avoid calling the web-api again with another command before 60s are over (TRUE=default) |
single_id |
Do you want to download data individually coin by coin (default FALSE to reduce down-"load") |
Value
Crypto currency historic OHLC market data in a dataframe and additional information via attribute "info":
timestamp |
Timestamp of entry in database |
slug |
Coin url slug |
id |
Coin market cap unique id |
name |
Coin name |
symbol |
Coin symbol |
ref_cur |
Reference currency |
open |
Market open |
high |
Market high |
low |
Market low |
close |
Market close |
volume |
Volume 24 hours |
market_cap |
Market cap - close x circulating supply |
time_open |
Timestamp of open |
time_close |
Timestamp of close |
time_high |
Timestamp of high |
time_low |
Timestamp of low |
This is the main function of the crypto package. If you want to retrieve
ALL active coins then do not pass an argument to crypto_history()
, or pass the coin name.
Examples
## Not run:
# Retrieving market history for ALL crypto currencies
all_coins <- crypto_history(limit = 2)
one_coin <- crypto_history(limit = 1)
# Retrieving market history since 2020 for ALL crypto currencies
all_coins <- crypto_history(start_date = '20200101',limit=10)
# Retrieving the same coins id by id
all_coins2 <- crypto_history(start_date = '20200101',limit=10, single_id=TRUE)
# Retrieve 2015 history for all 2015 crypto currencies
coin_list_2015 <- crypto_list(only_active=TRUE) %>%
dplyr::filter(first_historical_data<="2015-12-31",
last_historical_data>="2015-01-01")
coins_2015 <- crypto_history(coin_list = coin_list_2015,
start_date = "20150101", end_date="20151231", limit=20, interval="90d")
# retrieve hourly bitcoin data for 2 days
btc_hourly <- crypto_history(coin_list = coin_list_2015,
start_date = "20150101", end_date="20150103", limit=1, interval="1h")
## End(Not run)