def parse_margin_balance(self, response):
    result = {'info': response}
    for i in range(0, len(response)):
        balance = response[i]
        marketId = self.safe_string(balance, 'instrument_id')
        market = self.safe_value(self.markets_by_id, marketId)
        symbol = None
        if (market is None):
            (baseId, quoteId) = marketId.split('-')
            base = self.safe_currency_code(baseId)
            quote = self.safe_currency_code(quoteId)
            symbol = ((base + '/') + quote)
        else:
            symbol = market['symbol']
        omittedBalance = self.omit(balance, ['instrument_id', 'liquidation_price', 'product_id', 'risk_rate', 'margin_ratio', 'maint_margin_ratio', 'tiers'])
        keys = list(omittedBalance.keys())
        accounts = {}
        for k in range(0, len(keys)):
            key = keys[k]
            marketBalance = balance[key]
            if (key.find(':') >= 0):
                parts = key.split(':')
                currencyId = parts[1]
                code = self.safe_currency_code(currencyId)
                account = self.account()
                account['total'] = self.safe_float(marketBalance, 'balance')
                account['used'] = self.safe_float(marketBalance, 'hold')
                account['free'] = self.safe_float(marketBalance, 'available')
                accounts[code] = account
            else:
                raise NotSupported((self.id + ' margin balance response format has changed!'))
        result[symbol] = self.parse_balance(accounts)
    return result
def parse_margin_balance(self, response):
    result = {'info': response}
    for i in range(0, len(response)):
        balance = response[i]
        marketId = self.safe_string(balance, 'instrument_id')
        market = self.safe_value(self.markets_by_id, marketId)
        symbol = None
        if (market is None):
            (baseId, quoteId) = marketId.split('-')
            base = self.safe_currency_code(baseId)
            quote = self.safe_currency_code(quoteId)
            symbol = ((base + '/') + quote)
        else:
            symbol = market['symbol']
        omittedBalance = self.omit(balance, ['instrument_id', 'liquidation_price', 'product_id', 'risk_rate', 'margin_ratio', 'maint_margin_ratio', 'tiers'])
        keys = list(omittedBalance.keys())
        accounts = {}
        for k in range(0, len(keys)):
            key = keys[k]
            marketBalance = balance[key]
            if (key.find(':') >= 0):
                parts = key.split(':')
                currencyId = parts[1]
                code = self.safe_currency_code(currencyId)
                account = self.account()
                account['total'] = self.safe_float(marketBalance, 'balance')
                account['used'] = self.safe_float(marketBalance, 'hold')
                account['free'] = self.safe_float(marketBalance, 'available')
                accounts[code] = account
            else:
                raise NotSupported((self.id + ' margin balance response format has changed!'))
        result[symbol] = self.parse_balance(accounts)
    return result