def nearest_price(price, cutoffs=CUTOFFS):
if price <= MIN_PRICE:<EOL><INDENT>return MIN_PRICE<EOL><DEDENT>if price > MAX_PRICE:<EOL><INDENT>return MAX_PRICE<EOL><DEDENT>price = as_dec(price)<EOL>for cutoff, step in cutoffs:<EOL><INDENT>if price < cutoff:<EOL><INDENT>break<EOL><DEDENT><DEDENT>step = as_dec(step)<EOL>return float((price * step).quantize(<NUM_LIT:2>, ROUND_HALF_UP) / step)<EOL>
Returns the nearest Betfair odds value to price.

    Adapted from Anton Zemlyanov's AlgoTrader project (MIT licensed).
    https://github.com/AlgoTrader/betfair-sports-api/blob/master/lib/betfair_price.js

    :param float price: Approximate Betfair price (i.e. decimal odds value)
    :param tuple cutoffs: Optional tuple of (cutoff, step) pairs
    :returns: The nearest Befair price
    :rtype: float