From e24df7cffc01937a211db2d29f44bccc3d740bd5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 14 May 2018 08:22:01 +0200 Subject: [PATCH] Fix orders marked as dust even when closed --- portfolio.py | 2 +- tests/test_portfolio.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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") -- 2.41.0