code: func (o *TickOptions) FindLevel(ticker Ticker, guess int) (int, bool) {
  	minLevel, maxLevel := o.MinLevel, o.MaxLevel
  	if minLevel == 0 && maxLevel == 0 {
  		minLevel, maxLevel = -1000, 1000
  	} else if minLevel > maxLevel {
  		return 0, false
  	}
  	if o.Max < 1 {
  		return 0, false
  	}
  
  	// Start with the initial guess.
  	l := guess
  	if l < minLevel {
  		l = minLevel
  	} else if l > maxLevel {
  		l = maxLevel
  	}
  
  	// Optimize count against o.Max.
  	if ticker.CountTicks(l) <= o.Max {
  		// We're satisfying the o.Max and min/maxLevel
  		// constraints. count is monotonically decreasing, so
  		// decrease level to increase the count until we
  		// violate either o.Max or minLevel.
  		for l--; l >= minLevel && ticker.CountTicks(l) <= o.Max; l-- {
  		}
  		// We went one too far.
  		l++
  	} else {
  		// We're over o.Max. Increase level to decrease the
  		// count until we go below o.Max. This may cause us to
  		// violate maxLevel.
  		for l++; l <= maxLevel && ticker.CountTicks(l) > o.Max; l++ {
  		}
  		if l > maxLevel {
  			// We can't satisfy both o.Max and maxLevel.
  			return 0, false
  		}
  	}
  
  	// At this point l is the lowest value that satisfies the
  	// o.Max, minLevel, and maxLevel constraints.
  
  	return l, true
  }
docs: // FindLevel returns the lowest level that satisfies the constraints
  // given by o:
  //
  // * ticker.CountTicks(level) <= o.Max
  //
  // * o.MinLevel <= level <= o.MaxLevel (if MinLevel and MaxLevel != 0).
  //
  // If the constraints cannot be satisfied, it returns 0, false.
  //
  // guess is the level to start the optimization at.