import requests
import calendar
import time


def btcavticker(currency='USD'):
    """ get current bitcoin exchange rate from Bitcoinaverage """
    data = requests.get('https://api.bitcoinaverage.com/ticker/global/all').json()
    dataprice = data[currency]['last']
    datatime = calendar.timegm(time.strptime(
        data[currency]['timestamp'], "%a, %d %b %Y %H:%M:%S %z"))
    return dataprice, datatime