Regarding your #3 above, the problem with handle_data timing out, you could consider extending your computations over multiple calls to handle_data. If I understand, you want to compare each security in a set of N securities to SPY. So, could you just compare M of the securities, per call to handle_data (M < N)? For example, do 10 comparisons per call, and in 10 calls, you'll have cycled through 100 securities. Another approach would be to use a timer, and do as many comparisons as you can within the allotted time for a call to handle_data (~50 seconds).
Ideally, it should be possible to properly handle the time-out error, but I think this is a fatal error that can't be managed, and your backtest/algo will crash. But maybe someone has a clever way of making it work.