- Python 100%
| docs/img | ||
| sample | ||
| tests | ||
| .gitignore | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
| requirements.txt | ||
| setup.py | ||
| TODO.md | ||
Bitcoin Metrics
About
BitcoinMetrics uses Python to extract and visualize data from the Bitcoin Blockchain.
- It connects to a Bitcoin node and makes rpc calls to get block data and stores the data in a csv file.
- It retrieves selected data from the csv file to use in chart visualizations.
- The dataset and charts are available on Kaggle, here and here respectively.
Examples
Time To Mine Each Bitcoin Block

Difficulty of Each Bitcoin Block

Number of Transactions in Each Bitcoin Block

Total Number of Transactions on the Bitcoin Blockchain

Average Transaction Fee in Each Bitcoin Block

Sum of Transaction Fees in Each Bitcoin Block

Sum of Transaction Fees in Each Bitcoin Block as a % of the Coinbase Amount

Coinbase Amount in Each Bitcoin Block

Setup
Cloning the project
git clone https://github.com/callumr00/btcmetrics.git
Setting up
# Install Dependencies
pip install -r requirements.txt
Data Set
There is an included data set within the Github Repo. The data set is located here. This data set is taken from a local Bitcoin node.
Update the data set
The data set included with the Github Repo will be slightly outdated by the time of your cloning. You may want to include the most recent blocks within the created visualizations. This requires connection to a Bitcoin node.
Run ExtractData.py to update the data set from your local node.
# Run ExtractData.py
cd sample; python ExtractData.py
Replace the data set
You may want to replace the data set with data from your own Bitcoin node to be assured of it's validity. This requires connection to a Bitcoin node.
Delete the current data set so that it can be replaced.
# Delete current data set
rm sample/data/blockData.csv
Navigate to where your Bitcoin node stores data and write to /.bitcoin/bitcoin.conf your desired username and password, used for the rpc connection.
# Create bitcoin.conf if it doesn't exist
touch /.bitcoin/bitcoin.conf
# Write to /.bitcoin/bitcoin.conf
rpcuser=[username]
rpcpassword=[password]
Write to sample/ConnectRPC.py the same username and password
usr = '[username]'
pw = '[password]'
Run ExtractData.py to create a new data set from your local node.
# Run ExtractData.py
cd btcmetrics; cd sample; python ExtractData.py
For reference, this process takes me 4 hours to complete.
Charts
You can create charts using the dataset stored at BitcoinMetrics/sample/data/blockData.csv. This does not require connection a Bitcoin node.
Run SelectChart.py to show the list of supported charts.
# Run SelectChart.py
cd sample; python SelectChart.py
Once ran, you will have a selection of charts to choose from, these are:
- Block Time -- Time To Mine Each Bitcoin Block
- Block Size -- Size of Each Bitcoin Block
- Block Weight -- Weight of Each Bitcoin Block
- Block Difficulty -- Difficulty of Each Bitcoin Block
- Tx Per Block -- Number of Transactions in Each Bitcoin Block
- Tx Total -- Total Number of Transactions on the Bitcoin Blockchain
- Issuance Schedule -- Bitcoin Issuance Schedule
- Supply Inflation -- Bitcoin Supply Inflation
- Average Tx Fee -- Average Transaction Fee in Each Bitcoin Block
- Total Tx Fees -- Sum of Transaction Fees in Each Bitcoin Block
- Tx Fees as a % of Coinbase -- Sum of Transaction Fees in Each Bitcoin Block as a % of the Coinbase Amount
- Block Coinbase -- Coinbase Amount in Each Bitcoin Block
Entered the associated number of the desired chart when prompted for an input.
License
This project is under the MIT license.
Changelog
You can find a list of implemented changes in the CHANGELOG.
TODO
You can find a list of planned changes in the TODO.




