diff options
Diffstat (limited to 'trade.py')
-rw-r--r-- | trade.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -13,7 +13,9 @@ class Trade: Provides methods to modify the trade and access various attributes. """ - def __init__(self, amount: Decimal, total_cost: Decimal, date: str) -> None: + def __init__( + self, amount: Decimal, total_cost: Decimal, date: str, refid: str | None = None + ) -> None: """ Initialize a new Trade instance. @@ -29,6 +31,7 @@ class Trade: self.__amount: Decimal = Decimal(amount) self.__total_cost: Decimal = Decimal(total_cost) self.__date: str = date + self.__refid: str | None = refid def remove_coins( self, @@ -114,4 +117,5 @@ class Trade: Returns: str: A formatted string displaying the trade details. """ - return f"Trade(amount={self.amount:.2f}, price_per_coin={self.price_per_coin:.2f}, total_cost={self.total_cost:.2f}, date={self.date})" + rid = self.__refid or "" + return f"Trade(amount={self.amount:.2f}, price_per_coin={self.price_per_coin:.2f}, total_cost={self.total_cost:.2f}, date={self.date}, refid={rid})" |