def fetch_orders_by_state(self, state, symbol=None, since=None, limit=None, params={}):
    if (symbol is None):
        raise ArgumentsRequired((self.id + ' fetchOrdersByState() requires a symbol argument'))
    self.load_markets()
    market = self.market(symbol)
    type = None
    if (market['futures'] or market['swap']):
        type = market['type']
    else:
        defaultType = self.safe_string_2(self.options, 'fetchOrder', 'defaultType', market['type'])
        type = self.safe_string(params, 'type', defaultType)
    if (type is None):
        raise ArgumentsRequired((self.id + " fetchOrdersByState() requires a type parameter(one of 'spot', 'margin', 'futures', 'swap')."))
    request = {'instrument_id': market['id'], 'state': state}
    method = (type + 'GetOrders')
    if (market['futures'] or market['swap']):
        method += 'InstrumentId'
    query = self.omit(params, 'type')
    response = getattr(self, method)(self.extend(request, query))
    orders = None
    if (market['swap'] or market['futures']):
        orders = self.safe_value(response, 'order_info', [])
    else:
        orders = response
        responseLength = len(response)
        if (responseLength < 1):
            return []
        if (responseLength > 1):
            before = self.safe_value(response[1], 'before')
            if (before is not None):
                orders = response[0]
    return self.parse_orders(orders, market, since, limit)
def fetch_orders_by_state(self, state, symbol=None, since=None, limit=None, params={}):
    if (symbol is None):
        raise ArgumentsRequired((self.id + ' fetchOrdersByState() requires a symbol argument'))
    self.load_markets()
    market = self.market(symbol)
    type = None
    if (market['futures'] or market['swap']):
        type = market['type']
    else:
        defaultType = self.safe_string_2(self.options, 'fetchOrder', 'defaultType', market['type'])
        type = self.safe_string(params, 'type', defaultType)
    if (type is None):
        raise ArgumentsRequired((self.id + " fetchOrdersByState() requires a type parameter(one of 'spot', 'margin', 'futures', 'swap')."))
    request = {'instrument_id': market['id'], 'state': state}
    method = (type + 'GetOrders')
    if (market['futures'] or market['swap']):
        method += 'InstrumentId'
    query = self.omit(params, 'type')
    response = getattr(self, method)(self.extend(request, query))
    orders = None
    if (market['swap'] or market['futures']):
        orders = self.safe_value(response, 'order_info', [])
    else:
        orders = response
        responseLength = len(response)
        if (responseLength < 1):
            return []
        if (responseLength > 1):
            before = self.safe_value(response[1], 'before')
            if (before is not None):
                orders = response[0]
    return self.parse_orders(orders, market, since, limit)