def opening_price_sparkline(market, crop, unit): prices = list(Offer.average_price_history_for(market, crop, unit)[:10]) if prices: last_price = prices[-1] average = mean(prices) values = [deviation(price, average) for price in prices] return sparkline(values, "%s ZMK" % int(last_price)) else: return sparkline([], "No opening prices yet")
def average_opening_price(market, crop, unit): prices = list(Offer.average_price_history_for(market, crop, unit)[:10]) return floatformat(mean(prices), 2)