def _initialize_markets(self, market_names: List[Tuple[str, str]]): ethereum_rpc_url = global_config_map.get("ethereum_rpc_url").value for market_name, symbol in market_names: if market_name == "ddex" and self.wallet: market = DDEXMarket( wallet=self.wallet, web3_url=ethereum_rpc_url, order_book_tracker_data_source_type= OrderBookTrackerDataSourceType.EXCHANGE_API, symbols=[symbol]) elif market_name == "binance": binance_api_key = global_config_map.get( "binance_api_key").value binance_api_secret = global_config_map.get( "binance_api_secret").value market = BinanceMarket( web3_url=ethereum_rpc_url, binance_api_key=binance_api_key, binance_api_secret=binance_api_secret, order_book_tracker_data_source_type= OrderBookTrackerDataSourceType.EXCHANGE_API, symbols=[symbol]) elif market_name == "radar_relay" and self.wallet: market = RadarRelayMarket(wallet=self.wallet, web3_url=ethereum_rpc_url, symbols=[symbol]) elif market_name == "coinbase_pro": coinbase_pro_api_key = global_config_map.get( "coinbase_pro_api_key").value coinbase_pro_secret_key = global_config_map.get( "coinbase_pro_secret_key").value coinbase_pro_passphrase = global_config_map.get( "coinbase_pro_passphrase").value market = CoinbaseProMarket( web3_url=ethereum_rpc_url, coinbase_pro_api_key=coinbase_pro_api_key, coinbase_pro_secret_key=coinbase_pro_secret_key, coinbase_pro_passphrase=coinbase_pro_passphrase, symbols=[symbol]) else: raise ValueError(f"Market name {market_name} is invalid.") self.markets[market_name]: MarketBase = market
def setUpClass(cls): global MAINNET_RPC_URL cls.clock: Clock = Clock(ClockMode.REALTIME) cls.market: BinanceMarket = BinanceMarket( MAINNET_RPC_URL, conf.binance_api_key, conf.binance_api_secret, order_book_tracker_data_source_type=OrderBookTrackerDataSourceType. EXCHANGE_API, user_stream_tracker_data_source_type=UserStreamTrackerDataSourceType .EXCHANGE_API, symbols=["ZRXETH", "LOOMETH"]) print("Initializing Binance market... this will take about a minute.") cls.ev_loop: asyncio.BaseEventLoop = asyncio.get_event_loop() cls.clock.add_iterator(cls.market) cls.ev_loop.run_until_complete(cls.clock.run_til(time.time() + 1)) cls.ev_loop.run_until_complete(cls.wait_til_ready()) print("Ready.")