summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--trade.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/trade.py b/trade.py
index f4f0870..bddc65f 100644
--- a/trade.py
+++ b/trade.py
@@ -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})"