forked from ErikBjare/CryptoTax
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.py
More file actions
34 lines (27 loc) · 702 Bytes
/
util.py
File metadata and controls
34 lines (27 loc) · 702 Bytes
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
from datetime import timedelta
from currency_converter import CurrencyConverter
cc = CurrencyConverter()
symbolmap = {
"XXBTC": "XXBT",
"XBT": "XXBT",
"XXDG": "XXDG",
"ETH": "XETH",
"BTC": "XXBT",
"BCH": "XBCH",
"GNO": "XGNO",
"EOS": "XEOS",
"STR": "XXLM",
"SC": "XXSC",
"EUR": "ZEUR",
"USD": "ZUSD"
}
def next_weekday(date):
if date.weekday() > 4:
day_gap = 7 - date.weekday()
return date + timedelta(days=day_gap)
else:
return date
def fiatconvert(amount, cfrom, cto, date):
return cc.convert(amount, cfrom, cto, date=next_weekday(date))
def canonical_symbol(symbol):
return symbolmap.get(symbol, symbol)