+
+ def test_amount_to_precision(self):
+ self.s.markets = {
+ "FOO": {
+ "precision": {
+ "price": 5,
+ "amount": 6,
+ }
+ },
+ "BAR": {
+ "precision": {
+ "price": 7,
+ "amount": 8,
+ }
+ }
+ }
+ self.assertEqual("0.0001", self.s.amount_to_precision("FOO", D("0.0001")))
+ self.assertEqual("0.0000001", self.s.amount_to_precision("BAR", D("0.0000001")))
+ self.assertEqual("0.000001", self.s.amount_to_precision("FOO", D("0.000001")))
+
+ def test_price_to_precision(self):
+ self.s.markets = {
+ "FOO": {
+ "precision": {
+ "price": 5,
+ "amount": 6,
+ }
+ },
+ "BAR": {
+ "precision": {
+ "price": 7,
+ "amount": 8,
+ }
+ }
+ }
+ self.assertEqual("0.0001", self.s.price_to_precision("FOO", D("0.0001")))
+ 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")))
+
+ def test_fetch_nth_order_book(self):
+ with mock.patch.object(self.s, "fetch_order_book") as t:
+ t.return_value = {
+ "asks": [
+ [1.269e-05, 781.23105917],
+ [1.271e-05, 108.83577689],
+ [1.276e-05, 19162.15732141],
+ [1.277e-05, 34.13657561],
+ [1.28e-05, 95.14285714],
+ [1.281e-05, 11.13909862],
+ [1.282e-05, 43.42379871],
+ [1.284e-05, 493.67767887],
+ [1.288e-05, 6179.57843281],
+ [1.289e-05, 235.16250589]
+ ],
+ "bids": [
+ [1.266e-05, 3496.42283539],
+ [1.23e-05, 9.02439024],
+ [1.229e-05, 3244.25987796],
+ [1.228e-05, 6692.16061185],
+ [1.207e-05, 9.19635459],
+ [1.206e-05, 4711.05943978],
+ [1.194e-05, 84.67400508],
+ [1.168e-05, 61.75268779],
+ [1.165e-05, 9.52789699],
+ [1.157e-05, 16.4900605]
+ ]
+ }
+ self.assertAlmostEqual(D("0.00001289"), self.s.fetch_nth_order_book("BTC/HUC", "ask", 10), 8)
+ t.assert_called_once_with("BTC/HUC", limit=10)
+ self.assertAlmostEqual(D("0.00001157"), self.s.fetch_nth_order_book("BTC/HUC", "bid", 10), 8)