def set_markets(self, markets, currencies=None):
    values = (list(markets.values()) if (type(markets) is dict) else markets)
    for i in range(0, len(values)):
        values[i] = self.extend(self.fees['trading'], {'precision': self.precision, 'limits': self.limits}, values[i])
    self.markets = self.index_by(values, 'symbol')
    self.markets_by_id = self.index_by(values, 'id')
    self.marketsById = self.markets_by_id
    self.symbols = sorted(list(self.markets.keys()))
    self.ids = sorted(list(self.markets_by_id.keys()))
    if currencies:
        self.currencies = self.deep_extend(currencies, self.currencies)
    else:
        base_currencies = [{'id': (market['baseId'] if ('baseId' in market) else market['base']), 'numericId': (market['baseNumericId'] if ('baseNumericId' in market) else None), 'code': market['base'], 'precision': ((market['precision']['base'] if ('base' in market['precision']) else (market['precision']['amount'] if ('amount' in market['precision']) else None)) if ('precision' in market) else 8)} for market in values if ('base' in market)]
        quote_currencies = [{'id': (market['quoteId'] if ('quoteId' in market) else market['quote']), 'numericId': (market['quoteNumericId'] if ('quoteNumericId' in market) else None), 'code': market['quote'], 'precision': ((market['precision']['quote'] if ('quote' in market['precision']) else (market['precision']['price'] if ('price' in market['precision']) else None)) if ('precision' in market) else 8)} for market in values if ('quote' in market)]
        currencies = self.sort_by((base_currencies + quote_currencies), 'code')
        self.currencies = self.deep_extend(self.index_by(currencies, 'code'), self.currencies)
    self.currencies_by_id = self.index_by(list(self.currencies.values()), 'id')
    return self.markets
def set_markets(self, markets, currencies=None):
    values = (list(markets.values()) if (type(markets) is dict) else markets)
    for i in range(0, len(values)):
        values[i] = self.extend(self.fees['trading'], {'precision': self.precision, 'limits': self.limits}, values[i])
    self.markets = self.index_by(values, 'symbol')
    self.markets_by_id = self.index_by(values, 'id')
    self.marketsById = self.markets_by_id
    self.symbols = sorted(list(self.markets.keys()))
    self.ids = sorted(list(self.markets_by_id.keys()))
    if currencies:
        self.currencies = self.deep_extend(currencies, self.currencies)
    else:
        base_currencies = [{'id': (market['baseId'] if ('baseId' in market) else market['base']), 'numericId': (market['baseNumericId'] if ('baseNumericId' in market) else None), 'code': market['base'], 'precision': ((market['precision']['base'] if ('base' in market['precision']) else (market['precision']['amount'] if ('amount' in market['precision']) else None)) if ('precision' in market) else 8)} for market in values if ('base' in market)]
        quote_currencies = [{'id': (market['quoteId'] if ('quoteId' in market) else market['quote']), 'numericId': (market['quoteNumericId'] if ('quoteNumericId' in market) else None), 'code': market['quote'], 'precision': ((market['precision']['quote'] if ('quote' in market['precision']) else (market['precision']['price'] if ('price' in market['precision']) else None)) if ('precision' in market) else 8)} for market in values if ('quote' in market)]
        currencies = self.sort_by((base_currencies + quote_currencies), 'code')
        self.currencies = self.deep_extend(self.index_by(currencies, 'code'), self.currencies)
    self.currencies_by_id = self.index_by(list(self.currencies.values()), 'id')
    return self.markets