def test_exchanges(): symbol = 'BTC/USD' exchanges = ['gecko', 'bitfinex', 'kraken', 'gdax', 'binance', 'waves'] for exchange in exchanges: price_feed = PriceFeed(exchange, symbol) price_feed.filter_symbols() center_price = price_feed.get_center_price(None) print("Center price: {}".format(center_price)) if center_price is None: # Try USDT center_price = price_feed.get_center_price('USDT') print("Try again, USD/USDT center price: {}".format(center_price))
def get_external_market_center_price(self, external_price_source): """ Get center price from an external market for current market pair :param external_price_source: External market name :return: Center price as float """ self.log.debug('inside get_external_mcp, exchange: {} '.format( external_price_source)) self.log.debug('market: {} '.format(self.external_market)) price_feed = PriceFeed(external_price_source, self.external_market) price_feed.filter_symbols() center_price = price_feed.get_center_price(None) self.log.debug('PriceFeed: {}'.format(center_price)) if center_price is None: # Try USDT center_price = price_feed.get_center_price("USDT") self.log.debug( 'Substitute USD/USDT center price: {}'.format(center_price)) if center_price is None: # Try consolidated center_price = price_feed.get_consolidated_price() self.log.debug( 'Consolidated center price: {}'.format(center_price)) return center_price
def test_consolidated_pair(): symbol = 'STEEM/BTS' # STEEM/USD * USD/BTS = STEEM/BTS price_feed = PriceFeed('gecko', symbol) center_price = price_feed.get_consolidated_price() print(center_price)