From ec6feb0ef339f83b78b1d382b345e25e46548eb9 Mon Sep 17 00:00:00 2001 From: uvok Date: Thu, 17 Apr 2025 18:42:45 +0200 Subject: Allo wnegative-amount trades for selling. --- trade.py | 8 ++++++-- 1 file 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) -- cgit v1.2.3