]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/commitdiff
Run prepared orders after disappeared order
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 7 May 2018 10:50:43 +0000 (12:50 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 7 May 2018 10:51:05 +0000 (12:51 +0200)
market.py
tests/test_market.py

index 3b6543ad051411d6c97f879244127fd6c661198d..b521ea922b004bfedff4e7f82fe04671b571226c 100644 (file)
--- 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")
 
index 02116387a1f4298926c56c911a64b4816517b75e..6a9ea764c97de2e45b622cf976a7c1c92d48d1d1 100644 (file)
@@ -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):