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 create_test_poloniex( database: DBHandler, msg_aggregator: MessagesAggregator, ) -> Poloniex: return Poloniex( api_key=make_api_key(), secret=make_api_secret(), database=database, msg_aggregator=msg_aggregator, )
def test_query_trade_history_not_shared_cache(data_dir): """Test that having 2 different poloniex instances does not use same cache Regression test for https://github.com/rotkehlchenio/rotkehlchen/issues/232 We are using poloniex as an example here. Essentially tests all exchange caches. """ def first_trades(currency_pair, start, end): # pylint: disable=unused-argument return { 'BTC_ETH': [{ 'date': '2018-10-16 18:05:17', 'rate': '0.06935244', 'amount': '1.40308443', 'total': '0.09730732', 'fee': '0.00100000', 'type': 'sell', 'category': 'exchange' }] } def second_trades(currency_pair, start, end): # pylint: disable=unused-argument return { 'BTC_ETH': [{ 'date': '2018-10-16 18:05:17', 'rate': '0.06935244', 'amount': '2.5', 'total': '0.09730732', 'fee': '0.00100000', 'type': 'sell', 'category': 'exchange' }] } messages_aggregator = MessagesAggregator() end_ts = 99999999999 first_user_dir = os.path.join(data_dir, 'first') os.mkdir(first_user_dir) second_user_dir = os.path.join(data_dir, 'second') os.mkdir(second_user_dir) a = Poloniex(b'', b'', first_user_dir, messages_aggregator) with patch.object(a, 'return_trade_history', side_effect=first_trades): result1 = a.query_trade_history(0, end_ts, end_ts) b = Poloniex(b'', b'', second_user_dir, messages_aggregator) with patch.object(b, 'return_trade_history', side_effect=second_trades): result2 = b.query_trade_history(0, end_ts, end_ts) assert result1[0].amount == FVal('1.40308443') assert result2[0].amount == FVal('2.5')
def test_name(): exchange = Poloniex('a', b'a', object(), object()) assert exchange.name == 'poloniex'
def test_name(): exchange = Poloniex('poloniex1', 'a', b'a', object(), object()) assert exchange.location == Location.POLONIEX assert exchange.name == 'poloniex1'