summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruvok2025-04-17 18:42:45 +0200
committeruvok2025-04-17 18:42:45 +0200
commitec6feb0ef339f83b78b1d382b345e25e46548eb9 (patch)
tree12a0d3d576ae92c8bbaf4b2de964858ccd57f919
parentacedaf85eb6305e6dddf9aa6d318bfc7db289a72 (diff)
Allo wnegative-amount trades
for selling.
-rw-r--r--trade.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/trade.py b/trade.py
index 796f824..9e782a5 100644
--- a/trade.py
+++ b/trade.py
@@ -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)