Improved algorithm for buying contracts

Due to latency already bought contracts where repeatedly included in the
search resulting in slow speed and hard time buying contracts. Fixed.
updated