def test__create_exchange(self, base_init_mock): base_init_mock.return_value = None context = LiveContext(timeframe=None, conf_dir='tests/unit/context/config', auth_aliases={}) exchange = context.create_exchange('bitfinex', {'parameter': 2}) base_init_mock.assert_called_once_with( {'apiKey': '555', 'enableRateLimit': True, 'parameter': 2}) self.assertTrue(isinstance(exchange, ccxt.bitfinex))
def test__create_exchange__not_in_ccxtpro(self, base_init_mock): base_init_mock.return_value = None context = LiveContext(timeframe=None, conf_dir='tests/unit/context/config', auth_aliases={}) exchange = context.create_exchange('bithumb', {'param': 2}, True) base_init_mock.assert_called_once_with({ 'apiKey': 'abc', 'enableRateLimit': True, 'param': 2 }) self.assertTrue(isinstance(exchange, ccxt.async_support.bithumb))
def test__create_exchange__no_file(self, base_init_mock): base_init_mock.return_value = None context = LiveContext(timeframe=None, conf_dir='/dir', auth_aliases={'binance': 'bb'}) with self.assertLogs('btrccts') as cm: exchange = context.create_exchange('binance', {'parameter': 123}) self.assertEqual( cm.output, ['WARNING:btrccts:Config file for exchange binance does not' ' exist: /dir/bb.json']) base_init_mock.assert_called_once_with({'parameter': 123, 'enableRateLimit': True}) self.assertTrue(isinstance(exchange, ccxt.binance))
def test__create_exchange__merge_config(self, base_init_mock): base_init_mock.return_value = None context = LiveContext(timeframe=None, conf_dir='tests/unit/context/config', auth_aliases={'binance': 'binance_mod'}) exchange = context.create_exchange('binance', {'parameter': 2}) base_init_mock.assert_called_once_with({ 'apiKey': 'testkey', 'secret': 'secret', 'other': True, 'parameter': 2 }) self.assertTrue(isinstance(exchange, ccxt.binance))
def create_exchange__merge_config__template(self, base_init_mock, instance, async_ccxt): base_init_mock.return_value = None context = LiveContext(timeframe=None, conf_dir='tests/unit/context/config', auth_aliases={'binance': 'binance_mod'}) exchange = context.create_exchange('binance', { 'parameter': 2, 'enableRateLimit': False }, async_ccxt=async_ccxt) base_init_mock.assert_called_once_with({ 'apiKey': 'testkey', 'secret': 'secret', 'other': True, 'enableRateLimit': False, 'parameter': 2 }) self.assertTrue(isinstance(exchange, instance))
def create_exchange__not_an_exchange__template(self, async_ccxt): context = LiveContext(timeframe=None, auth_aliases={}, conf_dir='') with self.assertRaises(ValueError) as e: context.create_exchange('not_an_exchange', async_ccxt=async_ccxt) self.assertEqual(str(e.exception), 'Unknown exchange: not_an_exchange')