From: Ismaƫl Bouya Date: Mon, 14 May 2018 06:22:01 +0000 (+0200) Subject: Fix orders marked as dust even when closed X-Git-Tag: v1.8.3^2 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git;a=commitdiff_plain;h=e24df7cffc01937a211db2d29f44bccc3d740bd5 Fix orders marked as dust even when closed --- diff --git a/portfolio.py b/portfolio.py index 9b27e26..bed4326 100644 --- a/portfolio.py +++ b/portfolio.py @@ -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): diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index 6ca3327..bc69921 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -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")