diff options
Diffstat (limited to 'trade.py')
-rw-r--r-- | trade.py | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -4,5 +4,12 @@ class Trade: self.total_cost: float = total_cost self.date: str = date + @property + def price_per_coin(self) -> float: + """ + Calculate the price per coin based on the total cost and the current amount + """ + return self.total_cost / self.amount + def __repr__(self) -> str: - return f"Trade(amount={self.amount}, total_cost={self.total_cost}, date={self.date})" + return f"Trade(amount={self.amount}, price_per_coin={self.price_per_coin:.2f}, total_cost={self.total_cost:.2f}, date={self.date})" |