Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
clustering example from yesteryear

Here's a clustering example, posted years ago on Quantopian (I don't take credit for the original code). Perhaps it'd be of interest to folks, and could be brought into the modern era with some re-factoring.

4 responses

Jonathan Larkin posted a notebook of the approach above here.

I just tried cloning and running the algo that I posted above and get an error:

Something went wrong. Sorry for the inconvenience. Try using the built-in debugger to analyze your code. If you would like help, send us an email.
TimeoutException: Too much time spent in handle_data and/or scheduled functions. 50 second limit exceeded.
There was a runtime error on line 82.

Anyone know what's going on? It was running just over a year ago, and now it fails...

modified to run in before_trading_start() instead of handle_data()
=> backtest from 2013-10-01 to 2013-10-29 (as it was configured originally) worked for me (pretty fast when running during 'Building', quite slow when running the same from/to as 'Full Backtest')

ignore all other code changes (mess) and comments (silly ideas, I've no idea how the clustering algo really works -- but looks interesting)

Thanks Jon -

Yes, more time in before_trading_start. It is kinda curious, though, that the code was running, and now it doesn't. I'd think any changes to the platform would have improved execution speed, not have reduced it.