async def test_get_exchange(self):
        config = await self.init_default()

        exchange_manager_binance = ExchangeManager(config, "binance")
        await exchange_manager_binance.initialize()
        Exchanges.instance().add_exchange(exchange_manager_binance, "")

        exchange_manager_bitmex = ExchangeManager(config, "bitmex")
        await exchange_manager_bitmex.initialize()
        Exchanges.instance().add_exchange(exchange_manager_bitmex, "")

        exchange_manager_poloniex = ExchangeManager(config, "poloniex")
        await exchange_manager_poloniex.initialize()
        Exchanges.instance().add_exchange(exchange_manager_poloniex, "")

        assert Exchanges.instance().get_exchanges_list(
            "binance")[0].exchange_manager is exchange_manager_binance
        assert Exchanges.instance().get_exchanges_list(
            "bitmex")[0].exchange_manager is exchange_manager_bitmex
        assert Exchanges.instance().get_exchanges_list(
            "poloniex")[0].exchange_manager is exchange_manager_poloniex

        with pytest.raises(KeyError):
            assert Exchanges.instance().get_exchanges_list("test")

        await exchange_manager_binance.stop()
        await exchange_manager_bitmex.stop()
        await exchange_manager_poloniex.stop()
        cancel_ccxt_throttle_task()
        # let updaters gracefully shutdown
        await wait_asyncio_next_cycle()
Example #2
0
    async def test_traded_pairs_with_add(self):
        config = load_test_config()
        config[CONFIG_CRYPTO_CURRENCIES] = {
            "Bitcoin": {
                "pairs": "*",
                "quote": "BTC",
                "add": ["BTC/USDT"]
            }
        }

        _, exchange_manager = await self.init_default(config=config)

        assert "ICX/BTC" in exchange_manager.exchange_config.traded_cryptocurrencies[
            "Bitcoin"]
        assert "NEO/BTC" in exchange_manager.exchange_config.traded_cryptocurrencies[
            "Bitcoin"]
        assert "VEN/BTC" in exchange_manager.exchange_config.traded_cryptocurrencies[
            "Bitcoin"]
        assert "XLM/BTC" in exchange_manager.exchange_config.traded_cryptocurrencies[
            "Bitcoin"]
        assert "ONT/BTC" in exchange_manager.exchange_config.traded_cryptocurrencies[
            "Bitcoin"]
        assert "BTC/USDT" in exchange_manager.exchange_config.traded_cryptocurrencies[
            "Bitcoin"]
        assert "ETH/USDT" not in exchange_manager.exchange_config.traded_cryptocurrencies[
            "Bitcoin"]
        assert "NEO/BNB" not in exchange_manager.exchange_config.traded_cryptocurrencies[
            "Bitcoin"]
        cancel_ccxt_throttle_task()
        await exchange_manager.stop()
    async def test_add_exchange(self):
        config = await self.init_default()

        exchange_manager_binance = ExchangeManager(config, "binance")
        await exchange_manager_binance.initialize()
        Exchanges.instance().add_exchange(exchange_manager_binance, "")

        exchange_manager_bitmex = ExchangeManager(config, "bitmex")
        await exchange_manager_bitmex.initialize()
        Exchanges.instance().add_exchange(exchange_manager_bitmex, "")

        exchange_manager_poloniex = ExchangeManager(config, "poloniex")
        await exchange_manager_poloniex.initialize()
        Exchanges.instance().add_exchange(exchange_manager_poloniex, "")

        assert "binance" in Exchanges.instance().exchanges
        assert "bitmex" in Exchanges.instance().exchanges
        assert "poloniex" in Exchanges.instance().exchanges
        assert "test" not in Exchanges.instance().exchanges

        await exchange_manager_binance.stop()
        await exchange_manager_bitmex.stop()
        await exchange_manager_poloniex.stop()
        cancel_ccxt_throttle_task()
        # let updaters gracefully shutdown
        await wait_asyncio_next_cycle()
async def test_create_basic(exchange_builder):
    exchange_builder.disable_trading_mode()
    exchange_manager = await exchange_builder.build()

    assert exchange_manager is not None
    assert exchange_manager.exchange_name == "bitmex"

    cancel_ccxt_throttle_task()
    await exchange_manager.stop()
Example #5
0
    async def test_traded_pairs(self):
        config = load_test_config()
        config[CONFIG_CRYPTO_CURRENCIES] = {
            "Neo": {
                "pairs": ["NEO/BTC"]
            },
            "Ethereum": {
                "pairs": ["ETH/USDT"]
            },
            "Icon": {
                "pairs": ["ICX/BTC"]
            }
        }

        _, exchange_manager = await self.init_default(config=config)

        assert exchange_manager.exchange_config.traded_cryptocurrencies == {
            "Ethereum": ["ETH/USDT"],
            "Icon": ["ICX/BTC"],
            "Neo": ["NEO/BTC"]
        }
        cancel_ccxt_throttle_task()
        await exchange_manager.stop()
    async def test_create_exchange(self):
        # simulated
        config, exchange_manager = await self.init_default(simulated=True)

        assert exchange_manager is not None
        assert exchange_manager.exchange_name is TestExchangeManager.EXCHANGE_NAME

        assert exchange_manager.config is config

        assert isinstance(exchange_manager.exchange, RestExchange)
        await exchange_manager.stop()

        # real
        config, exchange_manager = await self.init_default(simulated=False)

        assert exchange_manager is not None
        assert exchange_manager.exchange_name is TestExchangeManager.EXCHANGE_NAME

        assert exchange_manager.config is config

        assert isinstance(exchange_manager.exchange, RestExchange)
        cancel_ccxt_throttle_task()
        await exchange_manager.stop()
async def test_stop(backtesting_trader):
    _, exchange_manager, trader_inst = backtesting_trader
    await exchange_manager.exchange.stop()
    cancel_ccxt_throttle_task()
    assert not exchange_manager.exchange.backtesting
    assert not exchange_manager.exchange.exchange_importers
Example #8
0
 async def stop(exchange_manager):
     cancel_ccxt_throttle_task()
     await exchange_manager.stop()
     # let updaters gracefully shutdown
     await wait_asyncio_next_cycle()
Example #9
0
 async def stop(exchange_manager):
     cancel_ccxt_throttle_task()
     await exchange_manager.stop()
    async def test_ready(self):
        _, exchange_manager = await self.init_default()

        assert exchange_manager.is_ready
        cancel_ccxt_throttle_task()
        await exchange_manager.stop()