Blockchain

Bitcoin Metadata

Introduction

The Bitcoin Metadata dataset by Blockchain provides 23 fundamental metadata of Bitcoin directly fetched from the Bitcoin blockchain. The data starts in January 2009 and delivered on a daily frequency. This dataset contains mining statistics like hash rate and miner revenue; transaction metadata like transaction per block, transaction fee, and number of addresses; and blockchain metadata like blockchain size and block size.

For more information about the Bitcoin Metadata dataset, including CLI commands and pricing, see the dataset listing.

About the Provider

Blockchain is a website that publishes data related to Bitcoin. It has been online since 2011 and publishes the Bitcoin Metadata history back to 2009.

Getting Started

The following snippet demonstrates how to request data from the Bitcoin Metadata dataset:

self.symbol = self.AddCrypto("BTCUSD", Resolution.Daily, Market.Bitfinex).Symbol
self.dataset_symbol = self.AddData(BitcoinMetadata, self.symbol).Symbol 
_symbol = AddCrypto("BTCUSD", Resolution.Daily, Market.Bitfinex).Symbol;
_datasetSymbol = AddData<BitcoinMetadata>(_symbol).Symbol; 

Data Summary

The following table describes the dataset properties:

PropertyValue
Start DateJanuary 2009
CoverageBitcoin blockchain
Data DensityRegular
ResolutionDaily
TimezoneUTC

Data Point Attributes

The Bitcoin Metadata dataset provides BitcoinMetadata objects, which have the following attributes:

Requesting Data

To add Bitcoin Metadata data to your algorithm, call the AddData method with the BTCUSD Symbol. Save a reference to the dataset Symbol so you can access the data later in your algorithm.

class BlockchainBitcoinMetadataAlgorithm(QCAlgorithm):

    def Initialize(self) -> None:
        self.SetStartDate(2019, 1, 1)
        self.SetEndDate(2020, 6, 1)
        self.SetCash(100000)

        self.symbol = self.AddCrypto("BTCUSD", Resolution.Daily, Market.Bitfinex).Symbol
        self.dataset_symbol = self.AddData(BitcoinMetadata, self.symbol).Symbol 
namespace QuantConnect
{
    public class BlockchainBitcoinMetadataAlgorithm: QCAlgorithm
    {
        private Symbol _symbol, _datasetSymbol;

        public override void Initialize()
        {
            SetStartDate(2019, 1, 1);
            SetEndDate(2020, 6, 1);
            SetCash(100000);

            _symbol = AddCrypto("BTCUSD", Resolution.Daily, Market.Bitfinex).Symbol;
            _datasetSymbol = AddData<BitcoinMetadata>(_symbol).Symbol;
        }
    }
}

Accessing Data

To get the current Bitcoin Metadata data, index the current Slice with the dataset Symbol. Slice objects deliver unique events to your algorithm as they happen, but the Slice may not contain data for your dataset at every time step. To avoid issues, check if the Slice contains the data you want before you index it.

def OnData(self, slice: Slice) -> None:
    if slice.ContainsKey(self.dataset_symbol):
        data_point = slice[self.dataset_symbol]
        self.Log(f"{self.dataset_symbol} miner revenue at {slice.Time}: {data_point.MinersRevenue}")
public override void OnData(Slice slice)
{
    if (slice.ContainsKey(_datasetSymbol))
    {
        var dataPoint = slice[_datasetSymbol];
        Log($"{_datasetSymbol} miner revenue at {slice.Time}: {dataPoint.MinersRevenue}");
    }
}

To iterate through all of the dataset objects in the current Slice, call the Get method.

def OnData(self, slice: Slice) -> None:
    for dataset_symbol, data_point in slice.Get(BlockchainBitcoinData).items():
        self.Log(f"{dataset_symbol} miner revenue at {slice.Time}: {data_point.MinersRevenue}")
public override void OnData(Slice slice)
{
    foreach (var kvp in slice.Get<BlockchainBitcoinData>())
    {
        var datasetSymbol = kvp.Key;
        var dataPoint = kvp.Value;
        Log($"{datasetSymbol} miner revenue at {slice.Time}: {dataPoint.MinersRevenue}");
    }
}

Historical Data

To get historical Bitcoin Metadata data, call the History method with the dataset Symbol. If there is no data in the period you request, the history result is empty.

# DataFrame
history_df = self.History(self.dataset_symbol, 100, Resolution.Daily)

# Dataset objects
history_bars = self.History[BlockchainBitcoinData](self.dataset_symbol, 100, Resolution.Daily)
var history = History<BlockchainBitcoinData>(_datasetSymbol, 100, Resolution.Daily);

For more information about historical data, see History Requests.

Remove Subscriptions

To remove a subscription, call the RemoveSecurity method.

self.RemoveSecurity(self.dataset_symbol)
RemoveSecurity(_datasetSymbol);

Example Applications

The Bitcoin Metadata dataset enables you to incorporate metadata from the Bitcoin blockchain into your strategies. Examples include the following strategies:

  • Comparing mining and transaction statistics to provide insight on the supply-demand relationship of the Bitcoin blockchain service.
  • Measuring the activity and popularity of the Bitcoin blockchain to predict the price movements of the Cryptocurrency.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: