diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-05-14 08:22:01 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-05-14 08:22:01 +0200 |
commit | e24df7cffc01937a211db2d29f44bccc3d740bd5 (patch) | |
tree | 306e18635e5f36b13641ae9ef8b8be51bdc55ec5 | |
parent | e45c64a5ace2637a9ff290a42cde89e2403ae53d (diff) | |
download | Trader-e24df7cffc01937a211db2d29f44bccc3d740bd5.tar.gz Trader-e24df7cffc01937a211db2d29f44bccc3d740bd5.tar.zst Trader-e24df7cffc01937a211db2d29f44bccc3d740bd5.zip |
Fix orders marked as dust even when closed
-rw-r--r-- | portfolio.py | 2 | ||||
-rw-r--r-- | tests/test_portfolio.py | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/portfolio.py b/portfolio.py index 9b27e26..bed4326 100644 --- a/portfolio.py +++ b/portfolio.py | |||
@@ -582,7 +582,7 @@ class Order: | |||
582 | self.mark_finished_order() | 582 | self.mark_finished_order() |
583 | 583 | ||
584 | def mark_dust_amount_remaining_order(self): | 584 | def mark_dust_amount_remaining_order(self): |
585 | if self.market.ccxt.is_dust_trade(self.remaining_amount().value, self.rate): | 585 | if self.status == "open" and self.market.ccxt.is_dust_trade(self.remaining_amount().value, self.rate): |
586 | self.status = "closed_dust_remaining" | 586 | self.status = "closed_dust_remaining" |
587 | 587 | ||
588 | def remaining_amount(self, refetch=False): | 588 | 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): | |||
832 | 832 | ||
833 | self.m.ccxt.is_dust_trade.return_value = True | 833 | self.m.ccxt.is_dust_trade.return_value = True |
834 | order.mark_dust_amount_remaining_order() | 834 | order.mark_dust_amount_remaining_order() |
835 | self.assertEqual("pending", order.status) | ||
836 | |||
837 | order.status = "open" | ||
838 | order.mark_dust_amount_remaining_order() | ||
835 | self.assertEqual("closed_dust_remaining", order.status) | 839 | self.assertEqual("closed_dust_remaining", order.status) |
836 | 840 | ||
837 | @mock.patch.object(portfolio.Order, "fetch") | 841 | @mock.patch.object(portfolio.Order, "fetch") |