From 1902674cbeaa4dc0cdc31e6f0f7a548b3fa7f38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Tue, 1 May 2018 16:02:00 +0200 Subject: =?UTF-8?q?Don=E2=80=99t=20close=20dust=20remaining=20orders=20bef?= =?UTF-8?q?ore=20end=20of=20trade.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://git.immae.eu/mantisbt/view.php?id=41 --- tests/test_ccxt_wrapper.py | 4 ++++ tests/test_portfolio.py | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_ccxt_wrapper.py b/tests/test_ccxt_wrapper.py index 9ddfbc1..c326f0a 100644 --- a/tests/test_ccxt_wrapper.py +++ b/tests/test_ccxt_wrapper.py @@ -545,3 +545,7 @@ class poloniexETest(unittest.TestCase): self.assertEqual("0.0000001", self.s.price_to_precision("BAR", D("0.0000001"))) self.assertEqual("0", self.s.price_to_precision("FOO", D("0.000001"))) + def test_is_dust_trade(self): + self.assertTrue(self.s.is_dust_trade(D("0.0000009"), D("1000"))) + self.assertTrue(self.s.is_dust_trade(D("0.000001"), D("10"))) + self.assertFalse(self.s.is_dust_trade(D("0.000001"), D("100"))) diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index 4d78996..969f5d4 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -823,14 +823,16 @@ class OrderTest(WebMockTestCase): order.cancel() self.m.ccxt.cancel_order.assert_not_called() - def test_dust_amount_remaining(self): + def test_mark_dust_amount_remaining(self): order = portfolio.Order("buy", portfolio.Amount("ETH", 10), D("0.1"), "BTC", "long", self.m, "trade") - order.remaining_amount = mock.Mock(return_value=portfolio.Amount("ETH", 1)) - self.assertFalse(order.dust_amount_remaining()) + self.m.ccxt.is_dust_trade.return_value = False + order.mark_dust_amount_remaining_order() + self.assertEqual("pending", order.status) - order.remaining_amount = mock.Mock(return_value=portfolio.Amount("ETH", D("0.0001"))) - self.assertTrue(order.dust_amount_remaining()) + self.m.ccxt.is_dust_trade.return_value = True + order.mark_dust_amount_remaining_order() + self.assertEqual("closed_dust_remaining", order.status) @mock.patch.object(portfolio.Order, "fetch") @mock.patch.object(portfolio.Order, "filled_amount", return_value=portfolio.Amount("ETH", 1)) @@ -965,6 +967,7 @@ class OrderTest(WebMockTestCase): "status": "foo", "datetime": "timestamp" } + self.m.ccxt.is_dust_trade.return_value = False order.fetch() self.m.ccxt.fetch_order.assert_called_once_with(45) -- cgit v1.2.3