import requests
import json


def get_latest_btc_prices(days_of_prices): 
    """Fetches the latest daily Bitcoin prices up to days_of_prices days in the past.

        Parameters
        ----------
        days_of_prices : int
            Number of days in the past, to fetch BTC prices from. 
    """

    response = requests.get('https://min-api.cryptocompare.com/data/v2/histoday?fsym=BTC&tsym=USD&limit={}'.format(days_of_prices - 1))
    json_prices = json.loads(response.text)
    return [ ( (json_price['high'] + json_price['low']) / 2 )  for json_price in json_prices['Data']['Data'] ]