-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBalance.py
37 lines (22 loc) · 797 Bytes
/
Balance.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
import botutils
import botconfig
class Balance:
def __init__(self, amount, currency, exchange=None):
self.Amount = amount
self.Exchange = exchange
self.Currency = currency
self.TxChain = None
self.InWallet = exchange == None
def amountUSD(self):
return botutils.convert_to_USD(self.Amount, self.Currency)
def assign_transactions(self, txchain):
assert self.TxChain == None
self.TxChain = txchain
def is_allocated(self):
return self.TxChain != None
def split(self, n):
newbal = Balance(self.Amount - n, self.Exchange, self.Currency)
self.Amount = n
return newbal
def balance_key(self):
return self.Currency.id + "@w" if self.InWallet else self.Exchange.ID