Cryptocurrencies-explorations

Cryptocurrencies explorations

Introduction

The main goal of this computational Markdown document 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.

In this document we compute and plot with Raku the statistics in [AA1].

Details on "running" the document

The Raku package used for data retrieval is "Data::Cryptocurrencies", [AAp1]. The JavaScript D3 plots are made via "JavaScript::D3", [AAp2].

This Markdown document is converted to its woven Markdown version with "Text::CodeProcessing", [AAp3]. The woven Markdown document is converted to an HTML document with "Markdown::Grammar", [AAp4].

Here is the corresponding shell command:

file-code-chunks-eval Cryptocurrencies-explorations.md &&
  from-markdown Cryptocurrencies-explorations_woven.md -t html -o Cryptocurrencies-explorations.html &&
  open Cryptocurrencies-explorations.html

Setup

Here we load the packages used below:

use Data::Cryptocurrencies;
use Data::Reshapers;
use Data::Summarizers;
use Text::Plot;
use JavaScript::D3;

Time series

Here we get Bitcoin (BTC) data from 1/1/2020 until now:

my %ccTS = cryptocurrency-data(<BTC ETH>, dates => (DateTime.new(2020,1,1,0,0,0), now), props => <DateTime Close>, format => 'hash'):cache-all;

say %ccTS.elems;

Here is a summary:

records-summary(%ccTS);

Here are D3.js plots:

my %ts4 = %ccTS.map({ $_.key => $_.value.map(-> %r { %( date => %r<DateTime>.Str.substr(0,10), value => %r<Close>.Numeric, group => $_.key ) }).grep({ $_.<value> ~~ Numeric }) });
say %ts4>>.elems;
deduce-type(%ts4<BTC>)
js-d3-date-list-plot(%ts4<BTC>, plot-label => 'BTC', width => 800, height => 400, format => 'html', div-id => 'BTC');
js-d3-date-list-plot(%ts4<ETH>, plot-label => 'ETH', width => 800, height => 400, format => 'html', div-id => 'ETH');

Pareto principle adherence

Get data for all cryptocurrencies:

my @dsData = cryptocurrency-data('all', dates => (now - 14 * 24 * 3600, now), props => ['Symbol', 'DateTime', 'Close', 'Volume'], format => 'dataset');
say "Dimensions : {dimensions(@dsData)}.";

Clean data and show summary:

@dsData = @dsData.grep({ $_<Close> ~~ Numeric });
#records-summary(@dsData);

Group by "Symbol" and find price- and volume totals per group:

my %groups = group-by(@dsData, "Symbol");

my %prices = %groups.map({ $_.key => $_.value.map(*<Close>).sum });
my %volumes = %groups.map({ $_.key => $_.value.map(*<Volume>).sum });

say %volumes.sort({ -$_.value }).head(5);
say text-pareto-principle-plot(%prices.values.List, title => 'Prices');
say text-pareto-principle-plot(%volumes.values.List, title => 'Volumes');

Here is the Pareto plot for closing prices:

my @cumSumPrices = produce(&[+], %prices.values.sort.reverse);
@cumSumPrices = @cumSumPrices X/ max(@cumSumPrices);
js-d3-list-plot(@cumSumPrices,
                plot-label => 'Pareto principle adherence for closing prices',
                width => 400, height => 300,
                format => 'html', div-id => 'pareto-prices'):grid-lines;

Here is the Pareto plot for trading volumes:

my @cumSumVolumes = produce(&[+], %volumes.values.sort.reverse);
@cumSumVolumes = @cumSumVolumes X/ max(@cumSumVolumes);
js-d3-list-plot(@cumSumVolumes,
                plot-label => 'Pareto principle adherence for trading volumes',
                width => 400, height => 300,
                format => 'html', div-id => 'pareto-volumes'):grid-lines;

References

Articles

[AA1] Anton Antonov "Crypto-currencies data acquisition with visualization", (2021), MathematicaForPrediction at WordPress.

[AA2] Anton Antonov "Cryptocurrencies data explorations", (2021), MathematicaForPrediction at WordPress.

Functions, packages

[AAf1] Anton Antonov, CryptocurrencyData Mathematica resource function, (2021). WolframCloud/antononcube.

[AAp1] Anton Antonov, Data::Cryptocurrencies Raku package, (2023). GitHub/antononcube.

[AAp2] Anton Antonov, JavaScript::D3 Raku package, (2022). GitHub/antononcube.

[AAp3] Anton Antonov, Text::CodeProcessing Raku package, (2021). GitHub/antononcube.

[AAp4] Anton Antonov, Markdown::Grammar, (2022). GitHub/antononcube.

Data::Cryptocurrencies v0.1.0

Cryptocurrency data retrieval.

Authors

  • Anton Antonov

License

Artistic-2.0

Dependencies

Data::ExampleDatasets:ver<0.2.3>Data::Reshapers:ver<0.3.0>DateTime::Grammar:ver<0.1.0+>JSON::Fast:ver<0.17>+Hash::Merge:ver<2.0.0+>:api<2+>LWP::Simple:ver<0.109+>XDG::BaseDirectory:ver<0.0.13+>:auth<zef:jonathanstowe>:api<1.0+>

Test Dependencies

Provides

  • Data::Cryptocurrencies
  • Data::Cryptocurrencies::YahooFinance

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.