From f52d21a2e24fbb3debbe3f0227f3eb917d0cf038 Mon Sep 17 00:00:00 2001 From: Lee Unsworth Date: Wed, 16 Aug 2023 09:33:56 +0100 Subject: [PATCH] Reverts changes to process.py --- flumine/order/process.py | 14 +++++--------- tests/test_process.py | 17 +---------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/flumine/order/process.py b/flumine/order/process.py index 177aa57f..a316353c 100644 --- a/flumine/order/process.py +++ b/flumine/order/process.py @@ -79,15 +79,11 @@ def process_current_orders( def process_current_order(order: BaseOrder, current_order, log_control) -> None: # update order.update_current_order(current_order) - if order.bet_id is None and current_order.bet_id: - # pickup async orders - if order.async_: - order.responses.placed() - order.bet_id = current_order.bet_id - log_control(OrderEvent(order)) - # pickup FOK orders - elif order.order_type.time_in_force == "FILL_OR_KILL": - order.bet_id = current_order.bet_id + # pickup async orders + if order.async_ and order.bet_id is None and current_order.bet_id: + order.responses.placed() + order.bet_id = current_order.bet_id + log_control(OrderEvent(order)) # update status if order.bet_id and order.status == OrderStatus.PENDING: if order.current_order.status == "EXECUTABLE": diff --git a/tests/test_process.py b/tests/test_process.py index 6cd5fca8..33e71a6a 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -62,7 +62,7 @@ def test_process_current_orders_with_default_sep(self, mock_process_current_orde self.assertEqual(market.blotter._live_orders, []) def test_process_current_order(self): - mock_order = mock.Mock(status=OrderStatus.EXECUTABLE, async_=False) + mock_order = mock.Mock(status=OrderStatus.EXECUTABLE) mock_order.current_order.status = "EXECUTION_COMPLETE" mock_current_order = mock.Mock() mock_log_control = mock.Mock() @@ -84,21 +84,6 @@ def test_process_current_order_async(self, mock_order_event): mock_order_event.assert_called_with(mock_order) mock_log_control.assert_called_with(mock_order_event()) - def test_process_current_order_fill_or_kill(self): - mock_order = mock.Mock( - status=OrderStatus.PENDING, - async_=False, - bet_id=None, - order_type=mock.Mock(time_in_force="FILL_OR_KILL"), - ) - mock_order.current_order.status = "EXECUTION_COMPLETE" - mock_current_order = mock.Mock(bet_id=1234, status="EXECUTION_COMPLETE") - mock_log_control = mock.Mock() - process.process_current_order(mock_order, mock_current_order, mock_log_control) - mock_order.update_current_order.assert_called_with(mock_current_order) - mock_order.execution_complete.assert_called() - self.assertEqual(mock_order.bet_id, 1234) - def test_create_order_from_current(self): mock_add_market = mock.Mock() market_book = mock.Mock()