':type bid: Bid'

def insert_bid(self, bid):

    assert isinstance(bid, Bid), type(bid)
    if ((not self._bids.tick_exists(bid.order_id)) and bid.is_valid()):
        self._bids.insert_tick(bid)
        timeout_delay = ((float(bid.timestamp) + float(bid.timeout)) - time.time())
        task = deferLater(reactor, timeout_delay, self.timeout_bid, bid.order_id)
        self.register_task(('bid_%s_timeout' % bid.order_id), task)
        return task.addErrback(self.on_timeout_error)
    return fail(Failure(RuntimeError('bid    invalid'))).addErrback(self.on_invalid_tick_insert)
