]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/commitdiff
Fix orders marked as dust even when closed
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 14 May 2018 06:22:01 +0000 (08:22 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 14 May 2018 06:22:01 +0000 (08:22 +0200)
portfolio.py
tests/test_portfolio.py

index 9b27e261d0bfa93ab511e2c692cfc10f3ecd61f8..bed43261d70d127c1e4aca08b5b3baf9e9bbdfef 100644 (file)
@@ -582,7 +582,7 @@ class Order:
         self.mark_finished_order()
 
     def mark_dust_amount_remaining_order(self):
-        if self.market.ccxt.is_dust_trade(self.remaining_amount().value, self.rate):
+        if self.status == "open" and self.market.ccxt.is_dust_trade(self.remaining_amount().value, self.rate):
             self.status = "closed_dust_remaining"
 
     def remaining_amount(self, refetch=False):
index 6ca3327318b210cc6f624a3c5e2046313c7550ec..bc69921fe01f58b649492ccbafdcb500eebcb0ce 100644 (file)
@@ -832,6 +832,10 @@ class OrderTest(WebMockTestCase):
 
         self.m.ccxt.is_dust_trade.return_value = True
         order.mark_dust_amount_remaining_order()
+        self.assertEqual("pending", order.status)
+
+        order.status = "open"
+        order.mark_dust_amount_remaining_order()
         self.assertEqual("closed_dust_remaining", order.status)
 
     @mock.patch.object(portfolio.Order, "fetch")