diff --git a/orderbook/orderlist.py b/orderbook/orderlist.py index 9637d5e..9128b8c 100644 --- a/orderbook/orderlist.py +++ b/orderbook/orderlist.py @@ -59,8 +59,6 @@ def append_order(self, order): def remove_order(self, order): self.volume -= order.quantity self.length -= 1 - if len(self) == 0: # if there are no more Orders, stop/return - return # Remove an Order from the OrderList. First grab next / prev order # from the Order we are removing. Then relink everything. Finally @@ -76,6 +74,8 @@ def remove_order(self, order): elif prev_order != None: # There is no next order prev_order.next_order = None self.tail_order = prev_order # The previous order becomes the last order in the OrderList after this Order is removed + else: # No order in the list + self.tail_order = self.head_order = None def move_to_tail(self, order): """After updating the quantity of an existing Order, move it to the tail of the OrderList