Exemple #1
0
    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
Exemple #2
0
def create_test_bitcoinde(
    database: DBHandler,
    msg_aggregator: MessagesAggregator,
) -> Bitcoinde:
    return Bitcoinde(
        api_key=make_api_key(),
        secret=make_api_secret(),
        database=database,
        msg_aggregator=msg_aggregator,
    )
Exemple #3
0
def test_name():
    exchange = Bitcoinde('a', b'a', object(), object())
    assert exchange.name == 'bitcoinde'
Exemple #4
0
def test_location():
    exchange = Bitcoinde('bitcoinde1', 'a', b'a', object(), object())
    assert exchange.location == Location.BITCOINDE
    assert exchange.name == 'bitcoinde1'