From af928d32483535a817b62a68f2dcb215f48ed29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 7 May 2018 12:50:43 +0200 Subject: Run prepared orders after disappeared order --- market.py | 4 +++- tests/test_market.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/market.py b/market.py index 3b6543a..b521ea9 100644 --- a/market.py +++ b/market.py @@ -201,8 +201,10 @@ class Market: if status == "error_disappeared": self.report.log_error("follow_orders", message="{} disappeared, recreating it".format(order)) - order.trade.prepare_order( + new_order = order.trade.prepare_order( compute_value=order.trade.tick_actions_recreate(tick)) + new_order.run() + self.report.log_order(order, tick, new_order=new_order) self.report.log_stage("follow_orders_end") diff --git a/tests/test_market.py b/tests/test_market.py index 0211638..6a9ea76 100644 --- a/tests/test_market.py +++ b/tests/test_market.py @@ -381,12 +381,16 @@ class MarketTest(WebMockTestCase): order_mock2.trade = trade_mock trade_mock.tick_actions_recreate.return_value = "tick1" + new_order_mock = mock.Mock() + trade_mock.prepare_order.return_value = new_order_mock m.follow_orders() trade_mock.tick_actions_recreate.assert_called_once_with(2) trade_mock.prepare_order.assert_called_once_with(compute_value="tick1") m.report.log_error.assert_called_once_with("follow_orders", message=mock.ANY) + m.report.log_order.assert_called_with(order_mock2, 2, new_order=new_order_mock) + new_order_mock.run.assert_called_once_with() @mock.patch.object(market.BalanceStore, "fetch_balances") def test_move_balance(self, fetch_balances): -- cgit v1.2.3