else:
raise NotImplementedError
+ def common_currency_code(self, currency):
+ """
+ Wrapped to avoid the currency translation
+ """
+ return currency
+ def currency_id(self, currency):
+ """
+ Wrapped to avoid the currency translation
+ """
+ return currency
if self.action is None:
return None
ticker = self.market.get_ticker(self.currency, self.base_currency)
+ if ticker is None:
+ self.market.report.log_error("prepare_order",
+ message="Unknown ticker {}/{}".format(self.currency, self.base_currency))
+ return None
self.inverted = ticker["inverted"]
if self.inverted:
ticker = ticker["original"]
create_order.assert_called_once_with("symbol", "type", "side", "amount", price="price", params="params")
+ def test_common_currency_code(self):
+ self.assertEqual("FOO", self.s.common_currency_code("FOO"))
+ def test_currency_id(self):
+ self.assertEqual("FOO", self.s.currency_id("FOO"))
self.assertEqual(0, len(trade.orders))
Order.assert_not_called()
+ self.m.get_ticker.return_value = None
+ with self.subTest(desc="Unknown ticker"):
+ filled_amount.return_value = portfolio.Amount("BTC", "3")
+ compute_value.return_value = D("0.125")
+
+ value_from = portfolio.Amount("BTC", "1")
+ value_from.rate = D("0.1")
+ value_from.linked_to = portfolio.Amount("FOO", "10")
+ value_to = portfolio.Amount("BTC", "10")
+ trade = portfolio.Trade(value_from, value_to, "FOO", self.m)
+
+ trade.prepare_order()
+
+ filled_amount.assert_not_called()
+ compute_value.assert_not_called()
+ self.assertEqual(0, len(trade.orders))
+ Order.assert_not_called()
+ self.m.report.log_error.assert_called_once_with('prepare_order',
+ message='Unknown ticker FOO/BTC')
+
self.m.get_ticker.return_value = { "inverted": False }
with self.subTest(desc="Already filled"):
filled_amount.return_value = portfolio.Amount("FOO", "100")