Esempio n. 1
0
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")
Esempio n. 2
0
def average_opening_price(market, crop, unit):
    prices = list(Offer.average_price_history_for(market, crop, unit)[:10])
    return floatformat(mean(prices), 2)