summaryrefslogtreecommitdiff
path: root/trade.py
blob: bddc65fa4df2f30d162118f96cd38028a311450d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Trade:
    def __init__(self, amount: float, total_cost: float, date: str) -> None:
        self.amount: float = amount
        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}, price_per_coin={self.price_per_coin:.2f}, total_cost={self.total_cost:.2f}, date={self.date})"