Cryptocurrency Csv Three Years

Cryptocurrency csv three years

Cryptocurrency csv three years

To access the CryptoCompare public API in Python, we can use the following Python wrapper available on GitHub: cryCompare.

With the coinList() function we can fetch all the available cryptocurrencies (about 1450).

With the histoDay() function we can fetch the historical data (OHLC prices and volumes) for a given pair. We keep only coins which have a non-trivial history (about 1350).

We store all info in a dataframe with 2-level columns: the first level contains the coin names, the second one, the OHLC prices.

Since many coins are quite recent, many have relatively short time series of historical data.

We sort them by the decreasing length of their time series.

Historical data for Bitcoin

BTC (Bitcoin) has the longest one, as expected.

For the following, we will only consider the 300 longest time series.

POTTEKBTC...DGDPIGGYDIEM
closehighlowopenclosehighlowopenclosehigh...lowopenclosehighlowopenclosehighlowopen
time
2017-08-210.12820.13680.12650.13210.0001200.0004510.0000790.0001224005.104097.25...74.1478.930.0006810.0006960.0005550.0006100.0000400.0000410.0000400.000041
2017-08-220.12670.14110.10890.12820.0001230.0001660.0001080.0001204089.704142.68...67.8478.340.0006140.0007040.0003970.0006810.0000410.0000410.0000360.000040
2017-08-230.12450.13350.11910.12670.0001240.0001700.0000810.0001234141.094255.62...76.5778.850.0006210.0008090.0005700.0006140.0000410.0000430.0000410.000041
2017-08-240.12890.13240.12110.12450.0001300.0001310.0000820.0001244318.354364.11...80.0189.700.0006480.0006980.0005760.0006210.0000430.0000440.0000410.000041
2017-08-250.13350.15760.12660.12890.0001330.0001790.0000860.0001304442.464461.71...90.6993.970.0006220.0006690.0006020.0006480.0000440.0000450.0000430.000043

5 rows × 1200 columns

All these 300 time series have at least 1000 days of observed prices.

We will only consider these days for the correlation study.

Below, we compute their daily log-returns.

Notice below that the scale is pretty huge compared to other financial assets (which are usually contained in a (-0.15,0.15) range, with some tails valued at ~2 or 3).

Now, we compute a correlation/distance matrix between all these coins.

Cryptocurrency csv three years

Notice that we consider here the OHLC representation, and thus we have to compute a correlation between random vectors, and not random variables (which is usually done by considering only the ‘close’ price for example).

The distance correlation is a relevant measure of statistical dependence for that purpose.

Cryptocurrency csv three years

We apply it between the 300x299/2 = 44850 pairs in parallel using the joblib library.

Then, using the dendrogram obtained from the Ward hierarchical clustering method, we can sort the coins so that their correlation/distance matrix is more readable.

We can observe that some coins do cluster together as they are correlated and uncorrelated to the rest of the coins in a similar way.

For example, we obtain the following clusters (if we ask for 30 groups).

We can use these clusters to average the values of the correlation-distances inside and in-between the clusters.

We obtain the following filtered matrix:

For example, below are the ‘close’ log-prices of one rather strong cluster:

Scraping Historical Cryptocurrency Prices [Python Beautiful Soup & Selenium Tutorial]