diff options
-rw-r--r-- | trade.py | 10 | ||||
-rw-r--r-- | trade_queue.py | 8 |
2 files changed, 14 insertions, 4 deletions
@@ -106,6 +106,16 @@ class Trade: return self.__timestamp.split(" ")[0] @property + def timestamp(self) -> str: + """ + Get the timestamp of the trade. + + Returns: + str: The trade timestamp as a string. + """ + return self.__timestamp + + @property def price_per_coin(self) -> Decimal: """ Calculate the price per coin based on the total cost and current amount. diff --git a/trade_queue.py b/trade_queue.py index 6e8c2c5..4c48779 100644 --- a/trade_queue.py +++ b/trade_queue.py @@ -46,15 +46,15 @@ class FIFOQueue: """ return list(deepcopy(self.__queue)) - def add(self, amount: Decimal, total_cost: Decimal, date: str) -> None: + def add(self, amount: Decimal, total_cost: Decimal, timestamp: str) -> None: """ Add a trade to the queue by specifying properties. """ - trade = Trade(amount, total_cost, date) + trade = Trade(amount, total_cost, timestamp) bisect.insort( self.__queue, trade, - key=lambda t: t.date + key=lambda t: t.timestamp ) self._cache_valid = False logger.info(f"Added trade: {trade}.") @@ -66,7 +66,7 @@ class FIFOQueue: bisect.insort( self.__queue, trade, - key=lambda t: t.date + key=lambda t: t.timestamp ) self._cache_valid = False logger.info(f"Added trade: {trade}.") |