def get_exchange(self, account: str) -> ExchangeInterface: account_info = [a for a in self.config['accounts'] if a['name'] == account][0] exchange_opts = dict( name=account_info['name'], api_key=str(account_info['api_key']), secret=str(account_info['secret']).encode(), database=self, msg_aggregator=self.msg_aggregator ) if account_info['exchange'] == 'kraken': exchange = Kraken(**exchange_opts) elif account_info['exchange'] == 'binance': exchange = Binance(**exchange_opts) elif account_info['exchange'] == 'coinbase': exchange = Coinbase(**exchange_opts) elif account_info['exchange'] == 'coinbasepro': exchange = Coinbasepro(**exchange_opts, passphrase=str(account_info['passphrase'])) elif account_info['exchange'] == 'gemini': exchange = Gemini(**exchange_opts) elif account_info['exchange'] == 'bitmex': exchange = Bitmex(**exchange_opts) elif account_info['exchange'] == 'bittrex': exchange = Bittrex(**exchange_opts) elif account_info['exchange'] == 'poloniex': exchange = Poloniex(**exchange_opts) elif account_info['exchange'] == 'bitcoinde': exchange = Bitcoinde(**exchange_opts) elif account_info['exchange'] == 'iconomi': exchange = Iconomi(**exchange_opts) else: raise ValueError("Unknown exchange: " + account_info['exchange']) return exchange
def test_emptry_kraken_balance_response(): """Balance api query returns a response without a result Regression test for: https://github.com/rotki/rotki/issues/2443 """ kraken = Kraken('a', b'YW55IGNhcm5hbCBwbGVhc3VyZS4=', object(), object()) def mock_post(url, data): # pylint: disable=unused-argument return MockResponse(200, '{"error":[]}') with patch.object(kraken.session, 'post', wraps=mock_post): result, msg = kraken.query_balances() assert msg == '' assert result == {}
def test_name(): exchange = Kraken('a', b'a', object(), object()) assert exchange.name == 'kraken'
def test_name(): exchange = Kraken('kraken1', 'a', b'a', object(), object()) assert exchange.location == Location.KRAKEN assert exchange.name == 'kraken1'