diff options
author | uvok | 2025-04-14 20:15:57 +0200 |
---|---|---|
committer | uvok | 2025-04-14 20:15:57 +0200 |
commit | d7c7f15c195ef35792f5e342137f04b37b9f045b (patch) | |
tree | 790c88b4bf7d703ae4b9bb9ac7be82d5af10feff /trade.py | |
parent | 32ba43ba48aefe97b978ce5d10deb5b327c82adf (diff) |
Add method to remove coins
Diffstat (limited to 'trade.py')
-rw-r--r-- | trade.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -4,6 +4,13 @@ class Trade: self.__total_cost: float = total_cost self.__date: str = date + def remove_coins(self, amount: float) -> None: + if amount > self.__amount: + raise ValueError(f"Can't remove more than {self.__amount}") + + self.__total_cost -= amount * self.price_per_coin + self.__amount -= amount + @property def amount(self) -> float: return self.__amount |