From a25069002d9933aa40a3172673d01c3ce9d3e8d3 Mon Sep 17 00:00:00 2001 From: uvok Date: Thu, 17 Apr 2025 18:48:35 +0200 Subject: Add trade directly --- trade_queue.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'trade_queue.py') diff --git a/trade_queue.py b/trade_queue.py index 73640bf..ae21f95 100644 --- a/trade_queue.py +++ b/trade_queue.py @@ -41,6 +41,14 @@ class FIFOQueue: self._cache_valid = False logger.info(f"Added trade: {trade}.") + def add_trade(self, trade: Trade) -> None: + """ + Add a trade to the queue. + """ + self.__queue.append(trade) + self._cache_valid = False + logger.info(f"Added trade: {trade}.") + def remove_coins(self, amount: float | Decimal) -> List[Trade]: """ Remove a specified amount of coins from the queue, returning the @@ -121,7 +129,9 @@ class FIFOQueue: raise ValueError("No trade matches the given predicate.") elif len(matching_trades) > 1: logger.error("Multiple matching trades found for removal.") - raise ValueError("Multiple trades match the given predicate. Please refine your criteria.") + raise ValueError( + "Multiple trades match the given predicate. Please refine your criteria." + ) # Locate the exact match in the original queue trade_to_remove = matching_trades[0] -- cgit v1.2.3