def parse_order(self, order, market=None):
    id = self.safe_string(order, 'order_id')
    timestamp = self.parse8601(self.safe_string(order, 'timestamp'))
    side = self.safe_string(order, 'side')
    type = self.safe_string(order, 'type')
    if ((side != 'buy') and (side != 'sell')):
        side = self.parse_order_side(type)
    symbol = None
    marketId = self.safe_string(order, 'instrument_id')
    if (marketId in self.markets_by_id):
        market = self.markets_by_id[marketId]
        symbol = market['symbol']
    else:
        symbol = marketId
    if (market is not None):
        if (symbol is None):
            symbol = market['symbol']
    amount = self.safe_float(order, 'size')
    filled = self.safe_float_2(order, 'filled_size', 'filled_qty')
    remaining = None
    if (amount is not None):
        if (filled is not None):
            amount = max(amount, filled)
            remaining = max(0, (amount - filled))
    if (type == 'market'):
        remaining = 0
    cost = self.safe_float_2(order, 'filled_notional', 'funds')
    price = self.safe_float(order, 'price')
    average = self.safe_float(order, 'price_avg')
    if (cost is None):
        if ((filled is not None) and (average is not None)):
            cost = (average * filled)
    elif ((average is None) and (filled is not None) and (filled > 0)):
        average = (cost / filled)
    status = self.parse_order_status(self.safe_string(order, 'state'))
    feeCost = self.safe_float(order, 'fee')
    fee = None
    if (feeCost is not None):
        feeCurrency = None
        fee = {'cost': feeCost, 'currency': feeCurrency}
    clientOrderId = self.safe_string(order, 'client_oid')
    if ((clientOrderId is not None) and (len(clientOrderId) < 1)):
        clientOrderId = None
    stopPrice = self.safe_float(order, 'trigger_price')
    return {'info': order, 'id': id, 'clientOrderId': clientOrderId, 'timestamp': timestamp, 'datetime': self.iso8601(timestamp), 'lastTradeTimestamp': None, 'symbol': symbol, 'type': type, 'timeInForce': None, 'postOnly': None, 'side': side, 'price': price, 'stopPrice': stopPrice, 'average': average, 'cost': cost, 'amount': amount, 'filled': filled, 'remaining': remaining, 'status': status, 'fee': fee, 'trades': None}
def parse_order(self, order, market=None):
    id = self.safe_string(order, 'order_id')
    timestamp = self.parse8601(self.safe_string(order, 'timestamp'))
    side = self.safe_string(order, 'side')
    type = self.safe_string(order, 'type')
    if ((side != 'buy') and (side != 'sell')):
        side = self.parse_order_side(type)
    symbol = None
    marketId = self.safe_string(order, 'instrument_id')
    if (marketId in self.markets_by_id):
        market = self.markets_by_id[marketId]
        symbol = market['symbol']
    else:
        symbol = marketId
    if (market is not None):
        if (symbol is None):
            symbol = market['symbol']
    amount = self.safe_float(order, 'size')
    filled = self.safe_float_2(order, 'filled_size', 'filled_qty')
    remaining = None
    if (amount is not None):
        if (filled is not None):
            amount = max(amount, filled)
            remaining = max(0, (amount - filled))
    if (type == 'market'):
        remaining = 0
    cost = self.safe_float_2(order, 'filled_notional', 'funds')
    price = self.safe_float(order, 'price')
    average = self.safe_float(order, 'price_avg')
    if (cost is None):
        if ((filled is not None) and (average is not None)):
            cost = (average * filled)
    elif ((average is None) and (filled is not None) and (filled > 0)):
        average = (cost / filled)
    status = self.parse_order_status(self.safe_string(order, 'state'))
    feeCost = self.safe_float(order, 'fee')
    fee = None
    if (feeCost is not None):
        feeCurrency = None
        fee = {'cost': feeCost, 'currency': feeCurrency}
    clientOrderId = self.safe_string(order, 'client_oid')
    if ((clientOrderId is not None) and (len(clientOrderId) < 1)):
        clientOrderId = None
    stopPrice = self.safe_float(order, 'trigger_price')
    return {'info': order, 'id': id, 'clientOrderId': clientOrderId, 'timestamp': timestamp, 'datetime': self.iso8601(timestamp), 'lastTradeTimestamp': None, 'symbol': symbol, 'type': type, 'timeInForce': None, 'postOnly': None, 'side': side, 'price': price, 'stopPrice': stopPrice, 'average': average, 'cost': cost, 'amount': amount, 'filled': filled, 'remaining': remaining, 'status': status, 'fee': fee, 'trades': None}