def ib_commission(quantity, price):
    """Compute the commission charged by Interactive Brokers."""
    c = 0.005 * quantity
    maximum =  0.005 * quantity * price
    minimum = 1.0

    if c < minimum:
        # The commission may not be less than one dollar.
        c = minimum
    elif c > maximum:
        # The commission may not exceed more than 0.005% of the total value of
        # the position.
        c = maximum

    return c