def gemini(url, pairs):
    res = requests.get(url).json()
    validation = isValid(res, schemas['gemini'])
    if validation is not Exception:
        return {
            "average": '0',
            "high": '0',
            "low": '0',
            "ask": res['ask'],
            "bid": res['bid'],
            "last": res['last'],
            "date": time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime())
        }
    else:
        return {'error': str(res)}
def poloniex(url, pairs):
    res = requests.get(url).json()
    res = res[pairs]
    validation = isValid(res, schemas['poloniex'])
    if validation is not Exception:
        return {
            "average": (float(res['low24hr']) + float(res['high24hr'])) / 2,
            "high": res['high24hr'],
            "low": res['low24hr'],
            "ask": res['lowestAsk'],
            "bid": res['highestBid'],
            "last": res['last'],
            "date": time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime())
        }
    else:
        return {'error': str(res)}
def bitfinex(res):
    data = {
        "average":
        res['mid'],
        "high":
        res['high'],
        "low":
        res['low'],
        "ask":
        res['ask'],
        "bid":
        res['bid'],
        "last":
        res['last_price'],
        "date":
        time.strftime('%Y-%m-%d %H:%M:%S',
                      time.localtime(float(res['timestamp'])))
    }
    validation = isValid(res, response_schema)
    if validation is not Exception:
        return data
def bitfinex(url, pairs):
    res = requests.get(url).json()
    validation = isValid(res, schemas['bitfinex'])
    if validation is not Exception:
        return {
            "average":
            res['mid'],
            "high":
            res['high'],
            "low":
            res['low'],
            "ask":
            res['ask'],
            "bid":
            res['bid'],
            "last":
            res['last_price'],
            "date":
            time.strftime('%Y-%m-%d %H:%M:%S',
                          time.localtime(float(res['timestamp'])))
        }
    else:
        return {'error': str(res)}