def match(self, order):
    size = Decimal(order['size'])
    price = Decimal(order['price'])
    if (order['side'] == 'buy'):
        bids = self.get_bids(price)
        if (not bids):
            return
        assert (bids[0]['id'] == order['maker_order_id'])
        if (bids[0]['size'] == size):
            self.set_bids(price, bids[1:])
        else:
            bids[0]['size'] -= size
            self.set_bids(price, bids)
    else:
        asks = self.get_asks(price)
        if (not asks):
            return
        assert (asks[0]['id'] == order['maker_order_id'])
        if (asks[0]['size'] == size):
            self.set_asks(price, asks[1:])
        else:
            asks[0]['size'] -= size
            self.set_asks(price, asks)
def match(self, order):
    size = Decimal(order['size'])
    price = Decimal(order['price'])
    if (order['side'] == 'buy'):
        bids = self.get_bids(price)
        if (not bids):
            return
        assert (bids[0]['id'] == order['maker_order_id'])
        if (bids[0]['size'] == size):
            self.set_bids(price, bids[1:])
        else:
            bids[0]['size'] -= size
            self.set_bids(price, bids)
    else:
        asks = self.get_asks(price)
        if (not asks):
            return
        assert (asks[0]['id'] == order['maker_order_id'])
        if (asks[0]['size'] == size):
            self.set_asks(price, asks[1:])
        else:
            asks[0]['size'] -= size
            self.set_asks(price, asks)