Cryptocurrencies: correlations, clustering and data analysis​
​Anton Antonov​
​MathematicaVsR at GitHub​
​MathematicaForPrediction at WordPress​
June 2021

Introduction

The main goal of this notebook is to provide some basic views and insights into the landscape of cryptocurrencies. The “landscape” we consider consists of price action and trading volume time series for cryptocurrencies found in Yahoo Finance.
Here is the work plan followed in this notebook:
1
.
Get cryptocurrency data
2
.
Do basic data analysis over suitable date ranges
3
.
Gather important cryptocurrency events
4
.
Plot together cryptocurrency prices and trading volume time series together with the events
5
.
Make observations and conjectures over the plots
6
.
Find “global” correlations between the different cryptocurrencies
7
.
Find clusters of cryptocurrencies based on time series correlations
Here are some details for the steps above:
◼
  • The procedure of obtaining the cryptocurrencies data, point 1, is explained in detail in [AA1].
  • ◼
  • There is a dedicated resource object CrypocurrencyData that provides cryptocurrency data and related documentation.
  • ◼
  • The cryptocurrency events data, point 3, is taken from different news sites.
  • ◼
  • Links are provided in the corresponding dataset.
  • ◼
  • The points 6 and 7 follow similar explorations (and code) described in [AA2, AA3].
  • ◼
  • Those two articles deal with COVID-19 time series.
  • Remark: Note that in this notebook we do not discuss philosophical, macro-economic, and environmental issues with cryptocurrencies. We only discuss financial time series data.

    Cryptocurrencies data

    The cryptocurrencies data used in this notebook is obtained from found in Yahoo Finance . The procedure of obtaining the cryptocurrencies data is explained in detail in [AA1]. There is a dedicated resource object CrypocurrencyData that provides the cryptocurrency data and related documentation.
    Here are all cryptocurrencies we have data for:
    In[]:=
    ResourceFunction["CryptocurrencyData"]["CryptocurrencyNames"]
    Out[]=
    BTCBitcoin,ETHEthereum,USDTTether,BNBBinanceCoin,ADACardano,XRPXRP,USDCCoin,DOGEDogecoin,DOT1Polkadot,HEXHEX,UNI3Uniswap,BCHBitcoinCash,LTCLitecoin,LINKChainlink,SOL1Solana,MATICMaticNetwork,THETATHETA,XLMStellar,VETVeChain,ICP1InternetComputer,ETCEthereumClassic,TRXTRON,FILFilecoinFutures,XMRMonero,EOSEOS
    Remark: FinancialData is “aware” of 10 cryptocurrencies, but that is not documented (as far as I can tell) and only prices are provided. (For more details see the discussion in CrypocurrencyData.) Here are examples:
    In[]:=
    Row[DateListPlot[FinancialData[#,"Jan 1 2021"],ImageSize->Medium,AspectRatio1/4,PlotLabel#]&/@{"BTC","ETH"}]
    Out[]=

    Significant cryptocurrencies

    In this section we analyze the summaries of cryptocurrencies data in order to derive a list of the most significant ones.
    We choose the phrase "significant cryptocurrency" to mean "a cryptocurrency with high market capitalization, price, or trading volume.”
    Together with the summaries we look into the Pareto principle adherence of the corresponding values.
    Remark: The Pareto principle adherence should be interpreted carefully here -- the cryptocurrencies are not mutually exclusive when in comes to money invested and trading volumes. Nevertheless, we can interpret the corresponding value ratios as indicators of “mind share” or “significance.”

    By summaries

    Here is a summary of the cryptocurrencies we consider (from Yahoo Finance) ordered by “Market Cap” (largest first):
    In[]:=
    dsCCSummary=ResourceFunction["CryptocurrencyData"][All,"Summary"]
    Out[]=
    Symbol
    Name
    Price (Intraday)
    Change
    % Change
    Market Cap
    Volume in Currency (Since 0:00 UTC)
    Volume in Currency (24Hr)
    Total Volume All Currencies (24Hr)
    Circulating Supply
    BTC-USD
    Bitcoin USD
    32203.5
    -235.51
    -0.0073
    603514000000.
    58989000000.
    58989000000.
    58989000000.
    18741000.
    ETH-USD
    Ethereum USD
    1896.61
    -44.12
    -0.0227
    220760000000.
    36332000000.
    36332000000.
    36332000000.
    116397000.
    USDT-USD
    Tether USD
    1.0015
    0.0009
    0.0009
    62585000000.
    102634000000.
    102634000000.
    102634000000.
    62492000000.
    BNB-USD
    BinanceCoin USD
    263.91
    -36.01
    -0.1201
    40493000000.
    4094000000.
    4094000000.
    4094000000.
    153433000.
    ADA-USD
    Cardano USD
    1.1915
    -0.0795
    -0.0625
    38065000000.
    6021000000.
    6021000000.
    6021000000.
    31946000000.
    XRP-USD
    XRP USD
    0.568599
    -0.099552
    -0.149
    26273000000.
    4928000000.
    4928000000.
    4928000000.
    46206000000.
    USDC-USD
    USDCoin USD
    1.0011
    0.0006
    0.0006
    25249000000.
    4360000000.
    4360000000.
    4360000000.
    25223000000.
    DOGE-USD
    Dogecoin USD
    0.189643
    -0.027676
    -0.1274
    24678000000.
    7275000000.
    7275000000.
    7275000000.
    130130000000.
    DOT1-USD
    Polkadot USD
    15.18
    -1.89
    -0.1109
    14489000000.
    3077000000.
    3077000000.
    3077000000.
    954217000.
    HEX-USD
    HEX USD
    0.079822
    -0.005203
    -0.0612
    13842000000.
    38192000.
    38192000.
    38192000.
    173411000000.
    UNI3-USD
    Uniswap USD
    16.43
    -0.48
    -0.0284
    9452000000.
    712503000.
    712503000.
    712503000.
    575171000.
    BCH-USD
    BitcoinCash USD
    439.72
    -41.89
    -0.087
    8254000000.
    2618000000.
    2618000000.
    2618000000.
    18770000.
    LTC-USD
    Litecoin USD
    119.14
    -14.04
    -0.1054
    7953000000.
    3692000000.
    3692000000.
    3692000000.
    66752000.
    LINK-USD
    Chainlink USD
    17.12
    -1.1
    -0.0605
    7431000000.
    2214000000.
    2214000000.
    2214000000.
    434010000.
    SOL1-USD
    Solana USD
    26.64
    -2.18
    -0.0758
    7264000000.
    1240000000.
    1240000000.
    1240000000.
    272637000.
    MATIC-USD
    MaticNetwork USD
    1.1203
    -0.0958
    -0.0788
    7050000000.
    2579000000.
    2579000000.
    2579000000.
    6293000000.
    THETA-USD
    THETA USD
    6.3656
    -0.9544
    -0.1304
    6366000000.
    606707000.
    606707000.
    606707000.
    1000000000
    XLM-USD
    Stellar USD
    0.236137
    -0.022256
    -0.0861
    5471000000.
    897055000.
    897055000.
    897055000.
    23170000000.
    VET-USD
    VeChain USD
    0.075609
    -0.006508
    -0.0793
    4863000000.
    1174000000.
    1174000000.
    1174000000.
    64316000000.
    ICP1-USD
    InternetComputer USD
    36.65
    -2.4
    -0.0613
    4728000000.
    260754000.
    260754000.
    260754000.
    128986000.
    rows 1–20 of 25
    Here is the summary of summary dataset above:
    In[]:=
    ResourceFunction["RecordsSummary"][dsCCSummary]
    Out[]=
    
    1 Symbol
    ADA-USD
    1
    BCH-USD
    1
    BNB-USD
    1
    BTC-USD
    1
    DOGE-USD
    1
    DOT1-USD
    1
    (Other)
    19
    ,
    2 Name
    BinanceCoin USD
    1
    BitcoinCash USD
    1
    Bitcoin USD
    1
    Cardano USD
    1
    Chainlink USD
    1
    Dogecoin USD
    1
    (Other)
    19
    ,
    3 Price (Intraday)
    Min
    0.051171
    1st Qu
    0.892975
    Median
    15.18
    3rd Qu
    68.14
    Mean
    1413.75
    Max
    32203.5
    ,
    4 Change
    Min
    -235.51
    Mean
    -16.1763
    1st Qu
    -7.8975
    Median
    -0.48
    3rd Qu
    -0.026321
    Max
    0.0009
    ,
    5 % Change
    Min
    -0.149
    1st Qu
    -0.1132
    Median
    -0.0788
    Mean
    -0.076064
    3rd Qu
    -0.052475
    Max
    0.0009
    ,
    6 Market Cap
    Min
    3.273×
    9
    10
    1st Qu
    4.82925×
    9
    10
    Median
    7.953×
    9
    10
    3rd Qu
    2.5505×
    10
    10
    Mean
    4.63154×
    10
    10
    Max
    6.03514×
    11
    10
    ,
    7 Volume in Currency (Since 0:00 UTC)
    Min
    3.8192×
    7
    10
    1st Qu
    1.10476×
    9
    10
    Median
    2.579×
    9
    10
    3rd Qu
    4.502×
    9
    10
    Mean
    1.00751×
    10
    10
    Max
    1.02634×
    11
    10
    ,
    8 Volume in Currency (24Hr)
    Min
    3.8192×
    7
    10
    1st Qu
    1.10476×
    9
    10
    Median
    2.579×
    9
    10
    3rd Qu
    4.502×
    9
    10
    Mean
    1.00751×
    10
    10
    Max
    1.02634×
    11
    10
    ,
    9 Total Volume All Currencies (24Hr)
    Min
    3.8192×
    7
    10
    1st Qu
    1.10476×
    9
    10
    Median
    2.579×
    9
    10
    3rd Qu
    4.502×
    9
    10
    Mean
    1.00751×
    10
    10
    Max
    1.02634×
    11
    10
    ,
    10 Circulating Supply
    Min
    1.7937×
    7
    10
    1st Qu
    1.16376×
    8
    10
    Median
    9.54217×
    8
    10
    Mean
    2.55902×
    10
    10
    3rd Qu
    3.5511×
    10
    10
    Max
    1.73411×
    11
    10
    
    Here is a Pareto principle adherence plot for the cryptocurrency market caps:
    In[]:=
    aMCaps=Normal[dsCCSummary[Association,StringSplit[#Symbol,"-"]〚1〛->#["Market Cap"]&]];ResourceFunction["ParetoPrinciplePlot"][aMCaps,PlotRange->All,PlotLabel->"Pareto principle for cryptocurrency market caps"]
    Out[]=
    Here is the Pareto statistic for the top 12 cryptocurrencies:
    In[]:=
    Take[AssociationThread[Keys@aMCaps,Accumulate[Values@aMCaps]]/Total[aMCaps],12]
    Out[]=
    BTC0.521221,ETH0.71188,USDT0.765931,BNB0.800902,ADA0.833777,XRP0.856467,USDC0.878274,DOGE0.899587,DOT10.9121,HEX0.924055,UNI30.932218,BCH0.939346

    By price

    Get the mean daily closing prices data for the last two weeks and show the corresponding data summary:
    In[]:=
    startDate=DatePlus[Now,-Quantity[2,"Weeks"]];aMeans=ReverseSort[Association[#->Mean[ResourceFunction["CryptocurrencyData"][#,"Close",startDate]["Values"]]&/@ResourceFunction["CryptocurrencyData"]["Cryptocurrencies"]]];​​ResourceFunction["RecordsSummary"][aMeans,Thread->True]
    Out[]=
    
    1 column 1
    ADA
    1
    BCH
    1
    BNB
    1
    BTC
    1
    DOGE
    1
    DOT1
    1
    (Other)
    19
    
    1 column 1
    Min
    0.0682441
    1st Qu
    0.952632
    Median
    21.5208
    3rd Qu
    90.35
    Mean
    1627.18
    Max
    36717.1
    
    Pareto principle adherence plot:
    Here are the Pareto statistic values for the top 12 cryptocurrencies:
    Plot the daily closing prices of top cryptocurrencies since January 2018:

    By trading volume

    Get the mean daily trading volumes data for the last two weeks and show the corresponding data summary:
    Pareto principle adherence plot:
    Here are the Pareto statistic values for the top 12 cryptocurrencies:
    Plot the daily closing prices of top cryptocurrencies since January 2018:

    Related events

    In this section we make a dataset that has the dates of certain cryptocurrency related events and links to their news announcements.
    The events were taken by observing cryptocurrency board stories in the news aggregation site slashdot.org.

    Cryptocurrency time series with events

    In this section we discuss possible correlation and causation effects of reported cryptocurrency events.
    Remark: The discussion is based on time series and events only, without considering other operational properties of the cryptocurrencies.
    Here is a date range:
    Here get time series for the daily opening and closing prices for the selected date range:
    Here are the summaries for prices:
    Here are the summaries for trading volumes:
    Here we plot the cryptocurrency events with together with the Bitcoin (BTC) price time series:
    Here we plot the cryptocurrency events with together with the Ether (ETH) price time series:
    Here we plot the cryptocurrency events with together with the BTC trading volume time series:
    ​

    Observations

    Going down

    We can see that opening prices and volume going down correlate with:
    1
    .
    The news announcement that China plans to crackdown on mining and trading
    2
    .
    The news announcement Iran bans crypto mining
    3
    .
    The Sichuan Provincial Development and Reform Commission and the Sichuan Energy Bureau issue of a joint notice, ordering local electricity companies to “screen, clean up and terminate” mining operations
    4
    .
    The start of the “Bitcoin 2021” conference
    Related conjectures:
    ◼
  • We can easily conjecture that 1 and 2 made cryptocurrencies (Bitcoin) less attractive to miners or traders in China and Iran, hence the price and the volume went down.
  • ◼
  • The most active Bitcoin traders were attending the “Bitcoin 2021” conference, hence the price and volume went down.
  • Going up

    We can see the prices and volume going up correlate with:
    1
    .
    The news announcement of El Salvador adopting BTC as legal tender currency
    2
    .
    The news announcement that US Justice Department recovered most of the ransom paid to the Colonial Pipeline hackers
    3
    .
    The end of the “Bitcoin 2021” conference
    Related conjectures:
    ◼
  • Of course, a country deciding to use BTC as legal tender would make (some) traders willing to invest in BTC.
  • ◼
  • The announcement that USA Justice Department, have made (some) traders to more confidently invest in BTC.
  • ◼
  • Although, the opposite could also happen -- for some people if BTC can be recovered by law enforcement, then BTC is less attractive for financial transactions.
  • ◼
  • After the end of “Bitcoin 2021” conference the attending traders resumed their usual activity.
  • ◼
  • That conjecture and the “start of Bitcoin 2021” conjecture above support each other.
  • ◼
  • The same pattern is observed for both BTC and ETH trading volumes.
  • Time series correlations

    In this section we compute and visualize correlations between the time series of a set of cryptocurrencies.

    Getting time series data

    Here are the cryptocurrencies we consider:

    Opening price time series

    Show heat-map plot corresponding to the max-normalized time series with clustering:
    Derive correlation triplets using SpearmanRho :
    Show summary of the correlation triplets:
    Show correlations that too high or too low:
    Cross tabulate the correlation triplets and show the corresponding dataset:
    Cross tabulate the correlation triplets and plot the corresponding matrix with heat-map plot:

    Trading volume time series

    Show heat-map plot corresponding to the max-normalized time series with clustering:
    Derive correlation triplets using SpearmanRho :
    Show summary of the correlation triplets:
    Show correlations that too high or too low:
    Cross tabulate the correlation triplets and show the corresponding dataset:
    Cross tabulate the correlation triplets and plot the corresponding matrix with heat-map plot:

    Observations

    Here are the correlation matrix plots above placed next to each other:
    Generally speaking, the two clustering patterns are different. This is one of the reasons to do the nearest neighbor graph clusterings below.

    Nearest neighbors graphs

    In this section we create nearest neighbor graphs of the correlation matrices computed above and plot clusterings of the nodes.

    Graphs overview

    Here we create the nearest neighbor graphs:
    Here we plot the graphs with clusters:
    Here are the corresponding time series plots for each cluster:

    Other types of analysis

    I investigated the data with several other methods:
    ◼
  • Clustering with different methods and distance functions
  • ◼
  • Clustering after the application of Independent Component Analysis (ICA), [AAw5]
  • ◼
  • Time series analysis with Quantile Regression (QR), [AAw6]
  • None of the outcomes provided some “immediate”, notable insight. The analyses with ICA and QR, though, seem to provide some interesting and fruitful future explorations.

    Load packages

    Definitions

    References

    Articles

    [AA1] Anton Antonov, "Crypto-currencies data acquisition with visualization", (2021), MathematicaForPrediction at WordPress.
    [AA2] Anton Antonov, "NY Times COVID-19 data visualization", (2020), SystemModeling at GitHub.
    [AA3] Anton Antonov, “Apple mobility trends data visualization”, (2020), SystemModeling at GitHub.

    Packages

    [AAp1] Anton Antonov, Data reshaping Mathematica package, (2018), MathematicaForPrediciton at GitHub.
    [AAp2] Anton Antonov, Heatmap plot Mathematica package, (2018), MathematicaForPrediciton at GitHub.

    Resource functions

    [AAw1] Anton Antonov, CryptocurrencyData, (2021).
    [AAw2] Anton Antonov, RecordsSummary, (2019).
    [AAw3] Anton Antonov, ParetoPrinciplePlot, (2019).
    [AAw4] Anton Antonov, CrossTabulate, (2019).
    [AAw5] Anton Antonov, IndependentComponentAnalysis, (2019).
    [AAw6] Anton Antonov, QuantileRegression, (2019).