TWS API – Solving Incorrect MinTick / Price Increment

Interactive Brokers will sometimes return an error if a programmer is not using the correct minimum tick amount for an order. I ran into this and received the error:

“The price does not conform to the minimum price variation for this contract.”

This was strange to me as the function reqContractDetails returned a minTick amount of 0.0001 for the contract DGLY.  I posted a request for help here and Richard provided the solution:


Each contract details contains a list of market rule ids, one for each exchange in the ‘valid exchanges’ list. A market rule tells you exactly how the minimum tick varies by price. You get the details of the market rule from the reqMarketRule() function.

For example, for DGLY the market rule for all exchanges is the same and has id 557. Calling reqMarketRule(557) in my API test program returns the following:

20200912 14:53:36.070   ==== Market Rule Begin (marketRuleId=557) ====

LowEdge=0, Increment=0.0001

LowEdge=1, Increment=0.01

==== Market Rule End (marketRuleId=557) ====

This shows that for price >= 0 and < 1, the min tick increment is 0.0001. For prices >=1 it is 0.001.

A very handy mechanism!


As a bonus, I am throwing in my function for handling minimum price variations:

def adjustForMinimimumPriceVariation(self, startingOrderPrice, currentContract, allTicks):
    minTick = None
    comparePrice = None
    if 0 < allTicks['lastPrice']:
        comparePrice = allTicks['lastPrice']
        comparePrice = allTicks['bidPrice']

    rules = currentContract.marketRuleIds.split(',')
    exchanges = currentContract.validExchanges.split(',')
    rule = rules[exchanges.index("SMART")]
    joMarketRules = JoMarketRuleId.objects.filter(marketRuleId=rule).order_by('-lowEdge')

    for joMarketRule in joMarketRules:
        if joMarketRule.lowEdge < comparePrice:
            minTick = joMarketRule.increment

    extraToRemove = Decimal(str(startingOrderPrice)) % Decimal(str(minTick))
    startingOrderPrice = Decimal(str(startingOrderPrice)) - extraToRemove
    startingOrderPrice = startingOrderPrice.normalize()
    return startingOrderPrice



Published by

Joel Gross

Joel Gross is the CEO of Coalition Technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *