crypto_history: Get historic crypto currency market data

View source: R/crypto_history.R

crypto_historyR 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 = 60,
  finalWait = TRUE
)

Arguments

coin_list

string if NULL retrieve all currently existing coins (crypto_list()), or provide list of crypto currencies in the crypto_list() format (e.g. current and/or dead coins since 2015)

convert

(default: USD) to one or more of available fiat or precious metals prices (fiat_list()). If more than one are selected please separate by comma (e.g. "USD,BTC")

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 seq() needs

sleep

integer (default 60) Seconds to sleep between API requests

finalWait

to avoid calling the web-api again with another command before 60s are over (TRUE=default)

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)

# 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")


## End(Not run)


crypto2 documentation built on July 18, 2022, 5:08 p.m.