def supported_currencies(exchange=None): if exchange: currencies = Price.objects(exchange=exchange).distinct(field="currency") else: currencies = Price.objects().distinct(field="currency") if not currencies: currencies = [currency for currency in constants.CURRENCIES] return sorted(currencies)
def update_price(exchange, currency, cryptocurrency, current_price): price = Price.objects(exchange=exchange, currency=currency, cryptocurrency=cryptocurrency).first() if price: price.current_price = current_price price.save() else: price = Price( exchange = exchange, currency = currency, cryptocurrency = cryptocurrency, current_price = current_price, ).save()
def get_current_price(exchange, currency, cryptocurrency): price = Price.objects(exchange=exchange, currency=currency, cryptocurrency=cryptocurrency).first() return price.current_price