def initPairs(self,assets): try: if self.pairs: for pair in self.pairs: #construct marketDepth for this pair marketDepth = MarketDepth(u.getPairUrl(pair,self.url_depth), self.regex_bid_ask,self.index_bid,self.index_ask, self.regex_price_volume,self.index_price,self.index_volume) self.pairs.update({pair:marketDepth}) else: l = re.findall(self.regex_info,u.getHttpResponse(self.url_info)) self.pairs = {} for i in l: #case where pair has no separation (ie: 'BTCUSD') if type(i) is bytes: pair = u.deducePair(i.decode().lower(),assets) #case where pair has separation (ie: 'BTC-USD' or 'BTC_USD' or 'BTC/USD') if type(i) is tuple: pair = (i[0].decode() + '-' + i[1].decode()).lower() #construct marketDepth for this pair marketDepth = MarketDepth(u.getPairUrl(pair,self.url_depth), self.regex_bid_ask,self.index_bid,self.index_ask, self.regex_price_volume,self.index_price,self.index_volume) self.pairs.update({pair:marketDepth}) return 0,'' except Exception as e: return -1,str(e)
#getAssetsFromXml print('test getAssetsFromXml: ') assets = u.getAssetsFromXml('assets.xml') print('#assets: ' + str(len(assets))) print('--------------------------------------') #getPairsFilterFromXml print('test getPairsFilterFromXml: ') pairs = u.getPairsFilterFromXml('pairs_filter.xml') print('#pairs: ' + str(len(pairs))) print('--------------------------------------') #deducePair print('test deducePair: ') print(u.deducePair('BTCUSD',assets)) print('--------------------------------------') #getPairUrl print('test getPairUrl: ') print(u.getPairUrl('btc-usd','https://btc-e.com/api/3/depth/%asset1%_%asset2%')) print(u.getPairUrl('btc-uro','https://poloniex.com/public?command=returnOrderBook&currencyPair=%ASSET1%_%ASSET2%&depth=50')) print('--------------------------------------') #init all exchanges print('initExchangesConcurrency: ') u.initExchangesConcurrency(exchanges,assets,logger) print('--------------------------------------') #getAssetsFromPair print('getAssetsFromPair: ')