Giter VIP home page Giter VIP logo

crypto2's Introduction

crypto2

Project Status R-CMD-check test-coverage pr-commands CRAN_latest_release_date CRAN status CRAN downloads CRAN downloads last month CRAN downloads last week Lifecycle: stable Website - pkgdown

Historical Cryptocurrency Prices for Active and Delisted Tokens!

This is a modification of the original crypto package by jesse vent. It is entirely set up to use means from the tidyverse and provides tibbles with all data available via the web-api of coinmarketcap.com. It does not require an API key but in turn only provides information that is also available through the website of coinmarketcap.com.

It allows the user to retrieve

  • crypto_listings() a list of all coins that were historically listed on CMC (main dataset to avoid delisting bias) according to the CMC API documentation
  • crypto_list() a list of all coins that are listed as either being active, delisted or untracked according to the CMC API documentation
  • crypto_info() a list of all information available for all available coins according to the CMC API documentation
  • crypto_history() the most powerful function of this package that allows to download the entire available history for all coins covered by CMC according to the CMC API documentation
  • crypto_global_quotes() a dataset of historical global crypto currency market metrics to the CMC API documentation
  • fiat_list() a mapping of all fiat currencies (plus precious metals) available via the CMC WEB API
  • exchange_list() a list of all exchanges available as either being active, delisted or untracked according to the CMC API documentation
  • exchange_info() a list of all information available for all given exchanges according to the CMC API documentation

Update

Version 2.0.1 (July 2024)

Slight change in api output broke crypto_info(). Fixed.

Version 2.0.0 (May 2024)

After a major change in the api structure of coinmarketcap.com, the package had to be rewritten. As a result, many functions had to be rewritten, because data was not available any more in a similar format or with similar accuracy. Unfortunately, this will potentially break many users implementations. Here is a detailed list of changes:

  • crypto_list() has been modified and delivers the same data as before.
  • exchange_list() has been modified and delivers the same data as before.
  • fiat_list() has been modified and no longer delivers all available currencies and precious metals (therefore only USD and Bitcoin are available any more).
  • crypto_listings() needed to be modified, as multiple base currencies are not available any more. Also some of the fields downloaded from CMC might have changed. It still retrieves the latest listings, the new listings as well as historical listings. The fields returned have somewhat slightly changed. Also, no sorting is available any more, so if you want to download the top x CCs by market cap, you have to download all CCs and then sort them in R.
  • crypto_info() has been modified, as the data structure has changed. The fields returned have somewhat slightly changed.
  • crypto_history() has been modified. It still retrieves all the OHLC history of all the coins, but is slower due to an increased number of necessary api calls. The number of available intervals is strongly limited, but hourly and daily data is still available. Currently only USD and BTC are available as quote currencies through this library.
  • crypto_global_quotes() has been modified. It still produces a clear picture of the global market, but the data structure has somewhat slightly changed.

Version 1.4.7

Since version 1.4.6 I have added the possibility to “sort” the historical crypto_listings() in _asc_ending or _desc_ending order (“sort_dir”) to allow for the possibility to download only the top x crypto currencies using “limit” based on the requested sort (not available for “new” sorting). Also corrected some problems when sourcing lists that now do not have the “last_historical_data” field available any more.

Since version 1.4.5 I have added a new function crypto_global_quotes() which retrieves global aggregate market statistics for CMC. There also were some bugs fixed.

Since version 1.4.4 a new function crypto_listings() was introduced that retrieves new/latest/historical listings and listing information at CMC. Additionally some aspects of the other functions have been reworked. We noticed that finalWait = TRUE does not seem to be necessary at the moment, as well as sleep can be set to ‘0’ seconds. If you experience strange behavior this might be due to the the api sending back strange (old) results. In this case let sleep = 60 (the default) and finalWait = TRUE (the default).

Since version 1.4.0 the package has been reworked to retrieve as many assets as possible with one api call, as there is a new “feature” introduced by CMC to send back the initially requested data for each api call within 60 seconds. So one needs to wait 60s before calling the api again. Additionally, since version v1.4.3 the package allows for a data interval larger than daily (e.g. ‘2d’ or ‘7d’ or ‘weekly’)

Installation

You can install crypto2 from CRAN with

install.packages("crypto2")

or directly from github with:

# install.packages("devtools")
devtools::install_github("sstoeckl/crypto2")

Package Contribution

The package provides API free and efficient access to all information from https://coinmarketcap.com that is also available through their website. It uses a variety of modification and web-scraping tools from the tidyverse (especially purrr).

As this provides access not only to active coins but also to those that have now been delisted and also those that are categorized as untracked, including historical pricing information, this package provides a valid basis for any Asset Pricing Studies based on crypto currencies that require survivorship-bias-free information. In addition to that, the package maintainer is currently working on also providing delisting returns (similarly to CRSP for stocks) to also eliminate the delisting bias.

Package Usage

First we load the crypto2-package and download the set of active coins from https://coinmarketcap.com (additionally one could load delisted coins with only_Active=FALSE as well as untracked coins with add_untracked=TRUE).

library(crypto2)
library(dplyr)
#> 
#> Attache Paket: 'dplyr'
#> Die folgenden Objekte sind maskiert von 'package:stats':
#> 
#>     filter, lag
#> Die folgenden Objekte sind maskiert von 'package:base':
#> 
#>     intersect, setdiff, setequal, union

# List all active coins
coins <- crypto_list(only_active=TRUE)

Next we download information on the first three coins from that list.

# retrieve information for all (the first 3) of those coins
coin_info <- crypto_info(coins, limit=3, finalWait=FALSE)
#> ❯ Scraping crypto info
#> 
#> ❯ Processing crypto info
#> 

# and give the first two lines of information per coin
coin_info
#> # A tibble: 3 × 32
#>      id name     symbol slug     category description   date_added status notice
#>   <int> <chr>    <chr>  <chr>    <chr>    <chr>         <date>     <chr>  <chr> 
#> 1     1 Bitcoin  BTC    bitcoin  coin     "## What Is … 2010-07-13 active ""    
#> 2     2 Litecoin LTC    litecoin coin     "## What Is … 2013-04-28 active ""    
#> 3     3 Namecoin NMC    namecoin coin     "Namecoin (N… 2013-04-28 active ""    
#> # ℹ 23 more variables: alert_type <int>, alert_link <chr>,
#> #   latest_update_time <dttm>, watch_list_ranking <int>, date_launched <date>,
#> #   is_audited <lgl>, display_tv <int>, is_infinite_max_supply <int>,
#> #   tv_coin_symbol <chr>, use_faq <lgl>, holders_flag <lgl>,
#> #   ratings_flag <lgl>, analysis_flag <lgl>, socials_flag <lgl>,
#> #   has_extra_info_flag <lgl>, upcoming <named list>, tags <list>,
#> #   crypto_rating <list>, urls <list>, faq_description <list>, …

In a next step we show the logos of the three coins as provided by https://coinmarketcap.com.

In addition we show tags provided by https://coinmarketcap.com.

coin_info %>% select(slug,tags) %>% tidyr::unnest(tags) %>% group_by(slug) %>% slice(1,n())
#> # A tibble: 6 × 2
#> # Groups:   slug [3]
#>   slug     tags$slug             $name                    $category
#>   <chr>    <chr>                 <chr>                    <chr>    
#> 1 bitcoin  mineable              "Mineable"               OTHERS   
#> 2 bitcoin  ftx-bankruptcy-estate "FTX Bankruptcy Estate " CATEGORY 
#> 3 litecoin mineable              "Mineable"               OTHERS   
#> 4 litecoin medium-of-exchange    "Medium of Exchange"     INDUSTRY 
#> 5 namecoin mineable              "Mineable"               OTHERS   
#> 6 namecoin platform              "Platform"               CATEGORY

Additionally: Here are some urls pertaining to these coins as provided by https://coinmarketcap.com.

coin_info %>% pull(urls) %>% .[[1]] |> unlist()
#>                            urls.website                      urls.technical_doc 
#>                  "https://bitcoin.org/"       "https://bitcoin.org/bitcoin.pdf" 
#>                          urls.explorer1                          urls.explorer2 
#>              "https://blockchain.info/"     "https://live.blockcypher.com/btc/" 
#>                          urls.explorer3                          urls.explorer4 
#>        "https://blockchair.com/bitcoin"       "https://explorer.viabtc.com/btc" 
#>                          urls.explorer5                        urls.source_code 
#> "https://www.okx.com/web3/explorer/btc"    "https://github.com/bitcoin/bitcoin" 
#>                      urls.message_board                             urls.reddit 
#>               "https://bitcointalk.org"          "https://reddit.com/r/bitcoin"

In a next step we download time series data for these coins.

# retrieve historical data for all (the first 3) of them
coin_hist <- crypto_history(coins, limit=3, start_date="20210101", end_date="20210105", finalWait=FALSE)
#> ❯ Scraping historical crypto data
#> 
#> ❯ Processing historical crypto data
#> 

# and give the first two times of information per coin
coin_hist %>% group_by(slug) %>% slice(1:2)
#> # A tibble: 6 × 17
#> # Groups:   slug [3]
#>      id slug     name     symbol timestamp           ref_cur_id ref_cur_name
#>   <int> <chr>    <chr>    <chr>  <dttm>              <chr>      <chr>       
#> 1     1 bitcoin  Bitcoin  BTC    2021-01-01 23:59:59 2781       USD         
#> 2     1 bitcoin  Bitcoin  BTC    2021-01-02 23:59:59 2781       USD         
#> 3     2 litecoin Litecoin LTC    2021-01-01 23:59:59 2781       USD         
#> 4     2 litecoin Litecoin LTC    2021-01-02 23:59:59 2781       USD         
#> 5     3 namecoin Namecoin NMC    2021-01-01 23:59:59 2781       USD         
#> 6     3 namecoin Namecoin NMC    2021-01-02 23:59:59 2781       USD         
#> # ℹ 10 more variables: time_open <dttm>, time_close <dttm>, time_high <dttm>,
#> #   time_low <dttm>, open <dbl>, high <dbl>, low <dbl>, close <dbl>,
#> #   volume <dbl>, market_cap <dbl>

Similarly, we could download data on an hourly basis.

# retrieve historical data for all (the first 3) of them
coin_hist_m <- crypto_history(coins, limit=3, start_date="20210101", end_date="20210102", interval ="1h", finalWait=FALSE)
#> ❯ Scraping historical crypto data
#> 
#> ❯ Processing historical crypto data
#> 

# and give the first two times of information per coin
coin_hist_m %>% group_by(slug) %>% slice(1:2)
#> # A tibble: 6 × 17
#> # Groups:   slug [3]
#>      id slug     name     symbol timestamp           ref_cur_id ref_cur_name
#>   <int> <chr>    <chr>    <chr>  <dttm>              <chr>      <chr>       
#> 1     1 bitcoin  Bitcoin  BTC    2021-01-01 01:59:59 2781       USD         
#> 2     1 bitcoin  Bitcoin  BTC    2021-01-01 02:59:59 2781       USD         
#> 3     2 litecoin Litecoin LTC    2021-01-01 01:59:59 2781       USD         
#> 4     2 litecoin Litecoin LTC    2021-01-01 02:59:59 2781       USD         
#> 5     3 namecoin Namecoin NMC    2021-01-01 01:59:59 2781       USD         
#> 6     3 namecoin Namecoin NMC    2021-01-01 02:59:59 2781       USD         
#> # ℹ 10 more variables: time_open <dttm>, time_close <dttm>, time_high <dttm>,
#> #   time_low <dttm>, open <dbl>, high <dbl>, low <dbl>, close <dbl>,
#> #   volume <dbl>, market_cap <dbl>

Alternatively, we could determine the price of these coins in other currencies. A list of such currencies is available as fiat_list()

fiats <- fiat_list()
fiats
#> # A tibble: 1 × 4
#>      id name                 sign  symbol
#>   <int> <chr>                <chr> <chr> 
#> 1  2781 United States Dollar $     USD

So we download the time series again depicting prices in terms of Bitcoin and Euro (note that multiple currencies can be given to convert, separated by “,”).

# retrieve historical data for all (the first 3) of them
coin_hist2 <- crypto_history(coins, convert="USD", limit=3, start_date="20210101", end_date="20210105", finalWait=FALSE)
#> ❯ Scraping historical crypto data
#> 
#> ❯ Processing historical crypto data
#> 

# and give the first two times of information per coin
coin_hist2 %>% group_by(slug,ref_cur_name) %>% slice(1:2)
#> # A tibble: 6 × 17
#> # Groups:   slug, ref_cur_name [3]
#>      id slug     name     symbol timestamp           ref_cur_id ref_cur_name
#>   <int> <chr>    <chr>    <chr>  <dttm>              <chr>      <chr>       
#> 1     1 bitcoin  Bitcoin  BTC    2021-01-01 23:59:59 2781       USD         
#> 2     1 bitcoin  Bitcoin  BTC    2021-01-02 23:59:59 2781       USD         
#> 3     2 litecoin Litecoin LTC    2021-01-01 23:59:59 2781       USD         
#> 4     2 litecoin Litecoin LTC    2021-01-02 23:59:59 2781       USD         
#> 5     3 namecoin Namecoin NMC    2021-01-01 23:59:59 2781       USD         
#> 6     3 namecoin Namecoin NMC    2021-01-02 23:59:59 2781       USD         
#> # ℹ 10 more variables: time_open <dttm>, time_close <dttm>, time_high <dttm>,
#> #   time_low <dttm>, open <dbl>, high <dbl>, low <dbl>, close <dbl>,
#> #   volume <dbl>, market_cap <dbl>

As a new features in version 1.4.4. we introduced the possibility to download historical listings and listing information (add quote = TRUE).

latest_listings <- crypto_listings(which="latest", limit=10, quote=TRUE, finalWait=FALSE)
latest_listings
#> # A tibble: 5,000 × 30
#>       id name        symbol slug   cmc_rank market_pair_count circulating_supply
#>    <int> <chr>       <chr>  <chr>     <int>             <int>              <dbl>
#>  1     1 Bitcoin     BTC    bitco…        1             11491          19719287 
#>  2     2 Litecoin    LTC    litec…       19              1206          74705744.
#>  3     3 Namecoin    NMC    namec…     1214                 7          14736400 
#>  4     5 Peercoin    PPC    peerc…      926                41          28978051.
#>  5     8 Feathercoin FTC    feath…     1537                12         236600238 
#>  6    25 Goldcoin    GLC    goldc…     2004                12          43681422.
#>  7    35 Phoenixcoin PXC    phoen…     1824                 4          91008781.
#>  8    42 Primecoin   XPM    prime…     1611                 3          50016494.
#>  9    45 CasinoCoin  CSC    casin…     3969                 9                 0 
#> 10    52 XRP         XRP    xrp           7              1346       55688327582 
#> # ℹ 4,990 more rows
#> # ℹ 23 more variables: self_reported_circulating_supply <dbl>,
#> #   total_supply <dbl>, max_supply <dbl>, is_active <int>, last_updated <date>,
#> #   date_added <chr>, ref_currency <chr>, price <dbl>, volume24h <dbl>,
#> #   market_cap <dbl>, percent_change1h <dbl>, percent_change24h <dbl>,
#> #   percent_change7d <dbl>, percent_change30d <dbl>, percent_change60d <dbl>,
#> #   percent_change90d <dbl>, fully_dillutted_market_cap <dbl>, …

An additional feature that was added in version 1.4.5 retrieves global aggregate market statistics for CMC.

all_quotes <- crypto_global_quotes(which="historical", quote=TRUE)
#> ❯ Scraping historical global data
#> 
#> ❯ Processing historical crypto data
#> 
all_quotes
#> # A tibble: 4,081 × 17
#>    timestamp  btc_dominance eth_dominance         score USD_total_market_cap
#>    <date>             <dbl>         <dbl>         <dbl>                <dbl>
#>  1 2013-04-29          94.2             0 1367193600000           1583440000
#>  2 2013-04-30          94.4             0 1367280000000           1686950016
#>  3 2013-05-01          94.4             0 1367366400000           1637389952
#>  4 2013-05-02          94.1             0 1367452800000           1333880064
#>  5 2013-05-03          94.2             0 1367539200000           1275410048
#>  6 2013-05-04          93.9             0 1367625600000           1169469952
#>  7 2013-05-05          94.0             0 1367712000000           1335379968
#>  8 2013-05-06          94.1             0 1367798400000           1370880000
#>  9 2013-05-07          94.4             0 1367884800000           1313900032
#> 10 2013-05-08          94.4             0 1367971200000           1320509952
#> # ℹ 4,071 more rows
#> # ℹ 12 more variables: USD_total_volume24h <dbl>,
#> #   USD_total_volume24h_reported <dbl>, USD_altcoin_volume24h <dbl>,
#> #   USD_altcoin_volume24h_reported <dbl>, USD_altcoin_market_cap <dbl>,
#> #   USD_original_score <chr>, active_cryptocurrencies <int>,
#> #   active_market_pairs <int>, active_exchanges <int>,
#> #   total_cryptocurrencies <int>, total_exchanges <int>, origin_id <chr>

We can use those quotes to plot information on the aggregate market capitalization:

all_quotes %>% select(timestamp, USD_total_market_cap, USD_altcoin_market_cap) %>% 
  tidyr::pivot_longer(cols = 2:3, names_to = "Market Cap", values_to = "bn. USD") %>% 
  tidyr::separate(`Market Cap`,into = c("Currency","Type","Market","Cap")) %>% 
  dplyr::mutate(`bn. USD`=`bn. USD`/1000000000) %>% 
  ggplot2::ggplot(ggplot2::aes(x=timestamp,y=`bn. USD`,color=Type)) + ggplot2::geom_line() +
  ggplot2::labs(title="Market capitalization in bn USD", subtitle="CoinMarketCap.com")

Last and least, one can get information on exchanges. For this download a list of active/inactive/untracked exchanges using exchange_list():

exchanges <- exchange_list(only_active=TRUE)
exchanges
#> # A tibble: 787 × 6
#>       id name         slug  is_active first_historical_data last_historical_data
#>    <int> <chr>        <chr>     <int> <date>                <date>              
#>  1    16 Poloniex     polo…         1 2018-04-26            2024-07-02          
#>  2    21 BTCC         btcc          1 2018-04-26            2024-07-02          
#>  3    24 Kraken       krak…         1 2018-04-26            2024-07-02          
#>  4    34 Bittylicious bitt…         1 2018-04-26            2024-07-02          
#>  5    36 CEX.IO       cex-…         1 2018-04-26            2024-07-02          
#>  6    37 Bitfinex     bitf…         1 2018-04-26            2024-07-02          
#>  7    42 HitBTC       hitb…         1 2018-04-26            2024-07-02          
#>  8    50 EXMO         exmo          1 2018-04-26            2024-07-02          
#>  9    61 Okcoin       okco…         1 2018-04-26            2024-07-02          
#> 10    68 Indodax      indo…         1 2018-04-26            2024-07-02          
#> # ℹ 777 more rows

and then download information on “binance” and “bittrex”:

ex_info <- exchange_info(exchanges %>% filter(slug %in% c('binance','kraken')), finalWait=FALSE)
#> ❯ Scraping crypto info
#> 
#> ❯ Processing exchange info
#> 
ex_info
#> # A tibble: 2 × 19
#>      id name    slug    logo   description date_launched notice is_hidden status
#>   <int> <chr>   <chr>   <chr>  <chr>       <date>        <chr>      <int> <chr> 
#> 1    24 Kraken  kraken  https… "## What I… 2011-07-28    ""             0 active
#> 2   270 Binance binance https… "## What I… 2017-07-14    ""             0 active
#> # ℹ 10 more variables: type <chr>, maker_fee <dbl>, taker_fee <dbl>,
#> #   platform_id <int>, dex_status <int>, wallet_source_status <int>,
#> #   tags <lgl>, countries <lgl>, fiats <list>, urls <list>

Then we can access information on the fee structure,

ex_info %>% select(contains("fee"))
#> # A tibble: 2 × 2
#>   maker_fee taker_fee
#>       <dbl>     <dbl>
#> 1      0.02      0.05
#> 2      0.02      0.04

or the fiat currencies allowed:

ex_info %>% select(slug,fiats) %>% tidyr::unnest(fiats)
#> # A tibble: 18 × 2
#>    slug    fiats 
#>    <chr>   <chr> 
#>  1 kraken  "USD" 
#>  2 kraken  "EUR" 
#>  3 kraken  "GBP" 
#>  4 kraken  "CAD" 
#>  5 kraken  "JPY" 
#>  6 kraken  "CHF" 
#>  7 kraken  "AUD" 
#>  8 binance "EUR" 
#>  9 binance " GBP"
#> 10 binance " BRL"
#> 11 binance " AUD"
#> 12 binance " UAH"
#> 13 binance " RUB"
#> 14 binance " TRY"
#> 15 binance " ZAR"
#> 16 binance " PLN"
#> 17 binance " NGN"
#> 18 binance " RON"

Author/License

This project is licensed under the MIT License - see the <license.md> file for details</license.md>

Acknowledgments

crypto2's People

Contributors

amrrs avatar jessevent avatar jnwarp avatar sneakers-the-rat avatar sstoeckl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crypto2's Issues

Use data.frame over tibble

Thanks for this great package. Is there any reason for using tibble over data.frame as the data format? Tibble is as slow as data.frame but more noisey, and can cause issues when converted to data.table. Would you consider using data.frame as the data format?

Improvements

For the next release we implement:

  • a "single_id" switch for crypto_history (to not fail the entire download when one coin in id-list is missing)
  • a "wait" selector to reduce waiting time between/after failed download to self-selected values (is automated at 60s as previously this was the servers default "you can load new data now" method for the free-api)

'coin_info' not found

Hello,

What could the the error trying to run the example code below, please?

R> library(crypto2)
R> library(dplyr)
R> # List all active coins
R> coins <- crypto_list(only_active=TRUE)
R> # retrieve information for all (the first 3) of those coins
R> coin_info <- crypto_info(coins, limit=3, finalWait=FALSE)
❯ Scraping crypto info

\ [3 / 3] [=====================================================================================================] 100% in 00:00:00 ETA: 0s
❯ Processing crypto info

\ [3 / 3] [=====================================================================================================] 100% in 00:00:00 ETA: 0s
Error in .rowNamesDF<-(x, value = value) :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’

R> coin_info
Error: object 'coin_info' not found

TIA,

Andre Luiz
PS - running RStudio Version 2024.04.2+764 (2024.04.2+764) on MacOSX v11.7.10

Faster queries for short amount of data?

Hi, thanks for making this package, this is really useful.
I was trying out the crypto_history function and it seems that no matter if you put a short timeline to cover (just the past 7 days for example), it fetches the whole data anyway and executes a filter at the end. Would it be possible to fetch only the data of interest instead to make for much faster queries?
Thanks!

Is there a way to categorize coins by consensus mechanism?

Hey there,

First of all, I just wanted to say that the package is really really good and I am a very happy user!

I was wondering whether there is a way to retrieve a list of coins (and time series) based on consensus mechanism such as "proof-of-work"?

For instance, there is a list of pow coins on CMC:
https://coinmarketcap.com/view/pow/

I have also found a category identifier in the API description on CMC called "consensus_mechanism" (see attachment).

That way crypto2 package users would be able to create coin indices based on consensus mechanism as well.

Thank you very much in advance for a short reply!

Best regards,
André

image

crypto_listings - Error in open.connection(con, "rb")

This:
> crypto_listings(which="latest", limit=10, quote=TRUE, finalWait=FALSE)
Gives:

Error in open.connection(con, "rb") : 
  cannot open the connection to 'https://web-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?limit=10&aux=market_cap_by_total_supply&convert=USD&sort=cmc_rank&sort_dir=desc&start=1'
In addition: Warning message:
In open.connection(con, "rb") :
  cannot open URL 'https://web-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?limit=10&aux=market_cap_by_total_supply&convert=USD&sort=cmc_rank&sort_dir=desc&start=1': HTTP status was '400 Bad Request'

sessionInfo()

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_1.1.2      crypto2_1.4.5.99

loaded via a namespace (and not attached):
 [1] progress_1.2.2    zoo_1.8-12        tidyselect_1.2.0  remotes_2.4.2     purrr_1.0.1       lattice_0.21-8   
 [7] vctrs_0.6.3       generics_0.1.3    miniUI_0.1.1.1    htmltools_0.5.5   usethis_2.1.6     utf8_1.2.3       
[13] rlang_1.1.1       pkgbuild_1.4.0    later_1.3.1       pillar_1.9.0      urlchecker_1.0.1  glue_1.6.2       
[19] withr_2.5.0       sessioninfo_1.2.2 plyr_1.8.8        lifecycle_1.0.3   stringr_1.5.0     devtools_2.4.5   
[25] htmlwidgets_1.6.2 memoise_2.0.1     callr_3.7.3       fastmap_1.1.1     httpuv_1.6.10     ps_1.7.5         
[31] curl_5.0.0        fansi_1.0.4       Rcpp_1.0.10       xtable_1.8-4      promises_1.2.0.1  cachem_1.0.8     
[37] desc_1.4.2        pkgload_1.3.2     jsonlite_1.8.4    mime_0.12         fs_1.6.2          hms_1.1.3        
[43] digest_0.6.31     stringi_1.7.12    processx_3.8.1    shiny_1.7.4       RJSONIO_1.3-1.8   grid_4.2.1       
[49] rprojroot_2.0.3   cli_3.6.1         tools_4.2.1       magrittr_2.0.3    tibble_3.2.1      profvis_0.3.8    
[55] tidyr_1.3.0       crayon_1.5.2      pkgconfig_2.0.3   ellipsis_0.3.2    prettyunits_1.1.1 timechange_0.2.0 
[61] lubridate_1.9.2   rstudioapi_0.14   R6_2.5.1          compiler_4.2.1   



crypto_list() error

This package has always worked for me before, but today I am getting this error when I use crypto_list():

Error: Problem with mutate() input ..1.
i ..1 = dplyr::across(7:8, as.Date).
x 'origin' must be supplied

Error in interval time smaller than daily

When trying to collect historical price data of e.g., BTC for time intervals smaller than daily, I run into errors.

For example:
CMC_coin_data <- crypto_history(selected_coin, finalWait=FALSE, interval="hourly")

will give this error:
In crypto_history(selected_coin, finalWait = FALSE, interval = "hourly") :
interval was not valid, using "daily". see documentation for allowed values.

However, these work just fine:
CMC_coin_data <- crypto_history(selected_coin, finalWait=FALSE, interval="daily")
CMC_coin_data <- crypto_history(selected_coin, finalWait=FALSE, interval="monthly")

Which is strange, especially since the documentation in the crypto_history.R file states the following:

#' @param interval string Interval with which to sample data, default 'daily'. Must be one of "hourly" "daily" "weekly" #' "monthly" "yearly" "1d" "2d" "3d" "7d" "14d" "15d" "30d" "60d" "90d" "365d"

Or am I missing something here? Thank you!

https://web-api.coinmarketcap.com/v1/cryptocurrency/map no longer works?

Hello,

The get the error below trying to test this library:

R> library(crypto2)
R> library(dplyr)
R> # List all active coins
R> coins <- crypto_list(only_active=TRUE)
Error in open.connection(con, "rb") :
cannot open the connection to 'https://web-api.coinmarketcap.com/v1/cryptocurrency/map'
In addition: Warning message:
In open.connection(con, "rb") :
cannot open URL 'https://web-api.coinmarketcap.com/v1/cryptocurrency/map': HTTP status was '404 Not Found'

How to solve it, please?

TIA

crypto_history limit needs to be set with coin_list argument set

To start with, amazing package!

Not sure if intended but when filtering on a single coin in the coin_list argument by first using the crypto_list (within the crypto_history) function) it looks like the limit needs to be set in order for the function to work properly. It gives an error when the limit argument is kept at default (NULL) and when provided it runs.

Not setting the limit argument and keeping it to NULL (Default) causes error below.

image

if (!is.null(limit)) coin_list <- coin_list[1:limit, ]

Error in if (limit == 1) { : argument is of length zero

Hello

crypto_history() returns the above error in most cases. It is particularly frustrating when it happens after a very long download time, as nothing is saved due to the error. Is there a way around this? Thanks

> data_1 <- crypto_history(start_date = "20130101", end_date = "20130201", sleep = 1)
> Scraping historical crypto data

| [32 / 32] [=====================================================] 100% in 00:32:00 ETA: 0s
Error in if (limit == 1) { : argument is of length zero
> data_1
Error: object 'data_1' not found

Hourly Data

Love the package. Thanks for developing this. Question: Do you have plans to integrate the "hourly" interval by chance? If not, I recommend removing it from the docs.

Self-reported tags need to get "nested"

nest self-reported tags (the coin-info-list has more entries than the coin-list due to the self-reported tags). Current workaround:
ALLINFO %>% group_by(slug) %>% nest(self_reported_tags = c(self_reported_tags))

convert tibble to data.frame

Thanks for this great R package! I used the crypto_history function to get all historical crypto prices from CoinMarketCap and got a tibble. When I convert this tibble to a data.frame, the resulted data.frame only has 11 rows. Not sure how this issue happened.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.