-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcurrates_conf.py
42 lines (37 loc) · 1.86 KB
/
currates_conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from strconv.currates.currdsl import Currency, InEnglish, InRussian
from strconv.currates.types import DataSource
from strconv.currates.extractors import field, iso_date, timestamp_date
__EXCHANGE_RATE_API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXX"
__COINMARKETCAP_API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXX"
_COINMARKETCAP_LIMIT = 1200
UPDATE_VOLATILE_PERIOD_IN_HOURS = 1
EXCHANGE_RATE_SOURCES = [
DataSource('api.exchangerate.host', "https://api.exchangerate.host/latest?base=USD",
field('success'), field('rates'), iso_date('date')),
DataSource('exchangerate-api.com', f"https://v6.exchangerate-api.com/v6/{__EXCHANGE_RATE_API_KEY}/latest/USD",
field('result'), field('conversion_rates'), timestamp_date('time_last_update_unix')),
DataSource('coinmarketcap.com',
f"https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?start=1&limit={_COINMARKETCAP_LIMIT}&convert=USD",
status_checker=lambda json: json['status']['error_code'] == 0,
rates_extractor=lambda json: {x['symbol']:(1/x['quote']['USD']['price']) for x in json['data']},
date_extractor=iso_date('status.timestamp'),
headers={'X-CMC_PRO_API_KEY': __COINMARKETCAP_API_KEY},
volatile=True),
]
CURRENCIES_MAPPING = [
Currency('RUB', 'RUR', 'rur', '₽', 'руб.', 'руб', 'р.', 'р', words=[
InEnglish('ruble'), InRussian('рубл', ('ь', 'я', 'ей'))
]),
Currency('USD', '$', words=[
InEnglish('dollar'), InRussian('доллар', ('', 'а', 'ов'))
]),
Currency('EUR', '€', words=[
InEnglish('euro'), InRussian('евро')
]),
Currency('BTC', '₿', words=[
InEnglish('bitcoin'), InRussian('биткоин', ('', 'а', 'ов'))
]),
Currency('INR', '₹', '₨', 'Rs', 'Rp'),
Currency('GBP', '£'),
Currency('ILS', '₪'),
]