aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-04-09 11:52:45 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-04-09 11:52:45 +0200
commit18de421e455ab4b125a6684d703a296562097e6b (patch)
tree1e68454391f91136cfd53360e916d1047c413abb /tests
parentc5a3b4e8c00f8d7bb54b342b1dd43c08bbfbd4db (diff)
downloadTrader-18de421e455ab4b125a6684d703a296562097e6b.tar.gz
Trader-18de421e455ab4b125a6684d703a296562097e6b.tar.zst
Trader-18de421e455ab4b125a6684d703a296562097e6b.zip
Fix ccxt switching currency codes
Diffstat (limited to 'tests')
-rw-r--r--tests/test_ccxt_wrapper.py4
-rw-r--r--tests/test_portfolio.py20
2 files changed, 24 insertions, 0 deletions
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")