diff options
author | uvok | 2025-04-17 18:42:45 +0200 |
---|---|---|
committer | uvok | 2025-04-17 18:42:45 +0200 |
commit | ec6feb0ef339f83b78b1d382b345e25e46548eb9 (patch) | |
tree | 12a0d3d576ae92c8bbaf4b2de964858ccd57f919 /trade.py | |
parent | acedaf85eb6305e6dddf9aa6d318bfc7db289a72 (diff) |
Allo wnegative-amount trades
for selling.
Diffstat (limited to 'trade.py')
-rw-r--r-- | trade.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -25,8 +25,12 @@ class Trade: date (str): The date of the trade, formatted as a string. """ - if amount <= 0 or total_cost <= 0: - raise ValueError("Amount and total cost must be > 0") + if amount < 0 and total_cost < 0: + pass + elif amount > 0 and total_cost > 0: + pass + else: + raise ValueError("Amount and tota> cost must be same sign") self.__amount: Decimal = Decimal(amount) self.__total_cost: Decimal = Decimal(total_cost) |