mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 19:06:26 +00:00
16 lines
468 B
Python
16 lines
468 B
Python
|
|
from decouple import config
|
|
import requests
|
|
import ring
|
|
|
|
storage = {}
|
|
|
|
@ring.dict(storage, expire=30) #keeps in cache for 30 seconds
|
|
def get_exchange_rate(currency):
|
|
# TODO Add fallback Public APIs and error handling
|
|
# Think about polling price data in a different way (e.g. store locally every t seconds)
|
|
|
|
market_prices = requests.get(config('MARKET_PRICE_API')).json()
|
|
exchange_rate = float(market_prices[currency]['last'])
|
|
|
|
return exchange_rate |