def update(self): """ Gets the latest data from blockchain.info. """ from blockchain import statistics, exchangerates self.stats = statistics.get() self.ticker = exchangerates.get_ticker()
def main(): s = stats.get() print("Total blocks", s.total_blocks) print("# of Tx in last 24 hours", s.number_of_transactions) print("Total BTC sent last 24 hours", "{:,.2f}".format(satoshi_to_btc(s.total_btc_sent))) print("Miners revenue USD last 24 hours", "{:,.2f}".format(s.miners_revenue_usd)) print("Hash rate", s.hash_rate) print("Difficulty", s.difficulty)
def main(): s = statistics.get() print("Trade Volume:", s.trade_volume_btc) print("# of Tx last 24 hours: ", s.number_of_transactions) print("Total BTC Sent last 24 hours: ", '{:,.2f}'.format(satoshis_to_btc(s.total_btc_sent))) print("Miners Revenue USD last 24 hours", '${:,.2f}'.format(s.miners_revenue_usd))
def main(): GPIO.setmode(GPIO.BCM) GPIO.setup(SW1, GPIO.IN) GPIO.setup(SW2, GPIO.IN) GPIO.setup(SW3, GPIO.IN) GPIO.setup(SW4, GPIO.IN) papirus = Papirus() write_text(papirus, defaultText, SIZE) while True: if GPIO.input(SW1) == False: stats = statistics.get() btcBlockHeight = stats.total_blocks # The blockchain api returns bits, need to convert to kB btcBlockSizeCleaned = (stats.blocks_size) / 125000 write_text( papirus, "%s --BITCOIN--\nBlockheight:%d \nBlocksize : %d kB" % (todayCleaned(), btcBlockHeight, btcBlockSizeCleaned), SIZE) time.sleep(10) write_text(papirus, defaultText, SIZE) if GPIO.input(SW2) == False: responseBlockr = urllib2.urlopen( "http://ltc.blockr.io/api/v1/coin/info") htmlResponse = simplejson.load(responseBlockr) ltcBlockHeight = int(htmlResponse["data"]["last_block"]["nb"]) write_text( papirus, "%s --LITECOIN--\nBlockheight:%d" % (todayCleaned(), ltcBlockHeight), SIZE) time.sleep(10) write_text(papirus, defaultText, SIZE) if GPIO.input(SW3) == False: write_text(papirus, "Three", SIZE) time.sleep(10) write_text(papirus, defaultText, SIZE) if GPIO.input(SW4) == False: write_text(papirus, "Shutdown Begun \nCheers!", SIZE) time.sleep(2) write_text(papirus, "", SIZE) shutdown() #time.sleep(10) #write_text(papirus, defaultText, SIZE) time.sleep(0.1)
def get_stats(opt: int): stats = statistics.get() if opt == 1: logging.info('{0}'.format(stats.total_btc_sent)) logging.info(str_task.format(threading.current_thread())) elif opt == 2: logging.info('{0}'.format(stats.number_of_transactions)) logging.info(str_task.format(threading.current_thread())) elif opt == 3: logging.info('{0}'.format(stats.btc_mined)) logging.info(str_task.format(threading.current_thread()))
def main(): GPIO.setmode(GPIO.BCM) GPIO.setup(SW1, GPIO.IN) GPIO.setup(SW2, GPIO.IN) GPIO.setup(SW3, GPIO.IN) GPIO.setup(SW4, GPIO.IN) papirus = Papirus() write_text(papirus, defaultText, SIZE) while True: if GPIO.input(SW1) == False: stats = statistics.get() btcBlockHeight = stats.total_blocks # The blockchain api returns bits, need to convert to kB btcBlockSizeCleaned = (stats.blocks_size)/125000 write_text(papirus, "%s --BITCOIN--\nBlockheight:%d \nBlocksize : %d kB" % (todayCleaned(), btcBlockHeight,btcBlockSizeCleaned), SIZE) time.sleep(10) write_text(papirus, defaultText, SIZE) if GPIO.input(SW2) == False: responseBlockr = urllib2.urlopen("http://ltc.blockr.io/api/v1/coin/info") htmlResponse = simplejson.load(responseBlockr) #print(htmlResponse["data"]["last_block"]["nb"]) ltcBlockHeight = int(htmlResponse["data"]["last_block"]["nb"]) dayDate = todayCleaned() write_text(papirus,"%s --LITECOIN--\nBlockheight:%d" % (todayCleaned(), ltcBlockHeight), SIZE) time.sleep(10) write_text(papirus, defaultText, SIZE) if GPIO.input(SW3) == False: write_text(papirus, "Three", SIZE) time.sleep(10) write_text(papirus, defaultText, SIZE) if GPIO.input(SW4) == False: write_text(papirus, "Shutdown Begun \nCheers!", SIZE) shutdown() #time.sleep(10) #write_text(papirus, defaultText, SIZE) time.sleep(0.1)
def gettoday(self): df_names = { 0: 'market_price', 1: 'avg_block_size', 2: 'blocks_size', 3: 'cost_per_txn', 4: 'difficulty', 5: 'txn_vol', 6: 'hash_rate', 7: 'market_cap', 8: 'confirm_time', 9: 'miners_revenue', 10: 'n_transaction', 11: 'n_transaction_exclude_popular', 12: 'txn_per_block', 13: 'output_vol', 14: 'total_bitcoins', 15: 'trade_volume', 16: 'txn_fees' } stats = statistics.get() dataframes = [ stats.market_price_usd, self.s_avg_block_size()['values'][-1]['y'], stats.blocks_size, self.s_cost_per_txn()['values'][-1]['y'], stats.difficulty, self.s_txn_vol()['values'][-1]['y'], stats.hash_rate, self.s_market_cap()['values'][-1]['y'], self.s_confirm_time()['values'][-1]['y'], stats.miners_revenue_usd, stats.number_of_transactions, self.s_n_transaction_exclude_popular()['values'][-1]['y'], self.s_txn_per_block()['values'][-1]['y'], self.s_output_vol()['values'][-1]['y'], stats.total_btc, stats.trade_volume_usd, stats.total_fees_btc ] toreturn = pd.DataFrame(dataframes) toreturn = toreturn.transpose() toreturn = toreturn.rename(columns=df_names) print(len(toreturn)) toreturn = toreturn.to_dict('records') return toreturn
def update(self): """Get the latest data from blockchain.com.""" self.stats = statistics.get() self.ticker = exchangerates.get_ticker()
from blockchain import statistics stats = statistics.get() print("Bitcoin Trade Volume: %s" % stats.trade_volume_btc) print("Bitcoin mined: %s\n" % stats.btc_mined) print(stats.market_price_usd)
from flask import Flask, render_template, request, redirect, url_for, Blueprint from blockchain import exchangerates, statistics import urllib2, json, requests, datetime import pandas as pd import numpy as np import scipy.stats chart = Blueprint('chart',__name__) #For statistics stats = statistics.get() actualtimelist = [] actualtimelist_rev = [] ticker = exchangerates.get_ticker() #Chart section jsonfilein = 'https://blockchain.info/charts/market-price?showDataPoints=false×pan=&show_header=true&daysAverageString=1&scale=0&format=json&address=' r = requests.get(jsonfilein) j = r.json() entries = j['values'] def ccylists(): return ticker def ccyprice(): for k in ticker: yield ticker[k].p15min def ccysymbol(): for s in ticker: yield ticker[s].symbol
def get_stats(): stats = statistics.get(api_code=app.api_code) return stats
def statistics(self): stats = statistics.get() return stats