-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.py
39 lines (29 loc) · 942 Bytes
/
account.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
from enum import Enum
class HoldingsType(Enum):
CASH = ("cash", True)
S_AND_S = ("stocks and shares", True)
PROPERTY = ("property", False)
OTHER = ("other", False)
def __init__(self, label, is_liquid):
self.label = label
self.is_liquid = is_liquid
class Account:
def __init__(self, name: str, holdings_type: HoldingsType, growth_rate: float):
self.name = name
self.holdings_type = holdings_type
self.value = 0
self.growth_rate = growth_rate
@property
def is_liquid(self):
return self.holdings_type.is_liquid
def set_value(self, value):
self.value = value
def set_growth_rate(self, growth_rate):
self.growth_rate = growth_rate
def to_dict(self):
return {
"name": self.name,
"type": self.holdings_type,
"value": self.value,
"growth": self.growth_rate,
}