def get_consolidated_price(self): """ assumes XXX/YYY must be broken into XXX/USD * USD/YYY """ center_price = None original_pair = self.pair try: pair1, pair2 = get_consolidated_pair(self.pair[0], self.pair[1]) self.pair = pair1 pair1_price = self.get_center_price(None) self.pair = pair2 pair2_price = self.get_center_price(None) if pair1_price and pair2_price: center_price = pair1_price * pair2_price print(original_pair, "price is ", center_price) self.pair = original_pair # put original pair back except Exception as e: print(type(e).__name__, e.args, 'Error') return center_price
def test_consolidated_pair(): symbol = 'STEEM:BTS' # pair = 'STEEM:BTS' or STEEM/BTS' pair = split_pair(symbol) pair1, pair2 = get_consolidated_pair(pair[1], pair[0]) print(symbol, '=', pair1, pair2, sep=' ')