Skip to content

Commit

Permalink
Reverts changes to process.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lunswor committed Aug 16, 2023
1 parent 0487c72 commit f52d21a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
14 changes: 5 additions & 9 deletions flumine/order/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
17 changes: 1 addition & 16 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit f52d21a

Please sign in to comment.