Iterative Binary Search Python Algorithmic Trading