diff options
-rw-r--r-- | ccxt_wrapper.py | 10 | ||||
-rw-r--r-- | portfolio.py | 4 | ||||
-rw-r--r-- | tests/test_ccxt_wrapper.py | 4 | ||||
-rw-r--r-- | tests/test_portfolio.py | 20 |
4 files changed, 38 insertions, 0 deletions
diff --git a/ccxt_wrapper.py b/ccxt_wrapper.py index 366586c..d2c9b4c 100644 --- a/ccxt_wrapper.py +++ b/ccxt_wrapper.py | |||
@@ -391,4 +391,14 @@ class poloniexE(poloniex): | |||
391 | else: | 391 | else: |
392 | raise NotImplementedError | 392 | raise NotImplementedError |
393 | 393 | ||
394 | def common_currency_code(self, currency): | ||
395 | """ | ||
396 | Wrapped to avoid the currency translation | ||
397 | """ | ||
398 | return currency | ||
394 | 399 | ||
400 | def currency_id(self, currency): | ||
401 | """ | ||
402 | Wrapped to avoid the currency translation | ||
403 | """ | ||
404 | return currency | ||
diff --git a/portfolio.py b/portfolio.py index 146ee79..1067b0b 100644 --- a/portfolio.py +++ b/portfolio.py | |||
@@ -311,6 +311,10 @@ class Trade: | |||
311 | if self.action is None: | 311 | if self.action is None: |
312 | return None | 312 | return None |
313 | ticker = self.market.get_ticker(self.currency, self.base_currency) | 313 | ticker = self.market.get_ticker(self.currency, self.base_currency) |
314 | if ticker is None: | ||
315 | self.market.report.log_error("prepare_order", | ||
316 | message="Unknown ticker {}/{}".format(self.currency, self.base_currency)) | ||
317 | return None | ||
314 | self.inverted = ticker["inverted"] | 318 | self.inverted = ticker["inverted"] |
315 | if self.inverted: | 319 | if self.inverted: |
316 | ticker = ticker["original"] | 320 | ticker = ticker["original"] |
diff --git a/tests/test_ccxt_wrapper.py b/tests/test_ccxt_wrapper.py index f07674e..18feab3 100644 --- a/tests/test_ccxt_wrapper.py +++ b/tests/test_ccxt_wrapper.py | |||
@@ -477,4 +477,8 @@ class poloniexETest(unittest.TestCase): | |||
477 | 477 | ||
478 | create_order.assert_called_once_with("symbol", "type", "side", "amount", price="price", params="params") | 478 | create_order.assert_called_once_with("symbol", "type", "side", "amount", price="price", params="params") |
479 | 479 | ||
480 | def test_common_currency_code(self): | ||
481 | self.assertEqual("FOO", self.s.common_currency_code("FOO")) | ||
480 | 482 | ||
483 | def test_currency_id(self): | ||
484 | self.assertEqual("FOO", self.s.currency_id("FOO")) | ||
diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index 2a42d0c..14dc995 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py | |||
@@ -218,6 +218,26 @@ class TradeTest(WebMockTestCase): | |||
218 | self.assertEqual(0, len(trade.orders)) | 218 | self.assertEqual(0, len(trade.orders)) |
219 | Order.assert_not_called() | 219 | Order.assert_not_called() |
220 | 220 | ||
221 | self.m.get_ticker.return_value = None | ||
222 | with self.subTest(desc="Unknown ticker"): | ||
223 | filled_amount.return_value = portfolio.Amount("BTC", "3") | ||
224 | compute_value.return_value = D("0.125") | ||
225 | |||
226 | value_from = portfolio.Amount("BTC", "1") | ||
227 | value_from.rate = D("0.1") | ||
228 | value_from.linked_to = portfolio.Amount("FOO", "10") | ||
229 | value_to = portfolio.Amount("BTC", "10") | ||
230 | trade = portfolio.Trade(value_from, value_to, "FOO", self.m) | ||
231 | |||
232 | trade.prepare_order() | ||
233 | |||
234 | filled_amount.assert_not_called() | ||
235 | compute_value.assert_not_called() | ||
236 | self.assertEqual(0, len(trade.orders)) | ||
237 | Order.assert_not_called() | ||
238 | self.m.report.log_error.assert_called_once_with('prepare_order', | ||
239 | message='Unknown ticker FOO/BTC') | ||
240 | |||
221 | self.m.get_ticker.return_value = { "inverted": False } | 241 | self.m.get_ticker.return_value = { "inverted": False } |
222 | with self.subTest(desc="Already filled"): | 242 | with self.subTest(desc="Already filled"): |
223 | filled_amount.return_value = portfolio.Amount("FOO", "100") | 243 | filled_amount.return_value = portfolio.Amount("FOO", "100") |