Statistics

The next class from the bitcoin blockchain library is called statistics.

There are a number of methods that can be called to get a wide variety of blockchain stats data, for example, as shown in the following screenshot:

You can call the different methods as follows:

  • Import the relevant class, call the get method on statistics, and save that object. For example, to get the bitcoin trade volume, we should get the trade_volume_btc property from the stats object that was created, as shown in the following code:
#!/usr/bin/env python

# import blockchain library
from blockchain import statistics

# get the stats object
stats = statistics.get()

# get and print Bitcoin trade volume
print("Bitcoin Trade Volume: %s " % stats.trade_volume_btc)

The following screenshot shows the bitcoin trade volume:

  • To get the total bitcoins mined, call the btc_mined property on stats object, as shown here:
# get and print Bitcoin mined
print("Bitcoin mined: %s " % stats.btc_mined)

The following screenshot shows the output of the number of bitcoins mined:

  • To get the bitcoin market price, use the stats class, call the market price and append that with the particular currency:
# get and print Bitcoin market price in usd
print("Bitcoin market price: %s " % stats.market_price_usd)
  • The current bitcoin price is shown in US dollars as follows:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.158.32