Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
code for getting minute data into before_trading_start

Here's code for getting a trailing window of minute data into before_trading_start, including the closing prices from the prior day. Seems sorta circuitous, but this is the only way I could code it. Maybe pipeline could be used to pull in the closing price from the prior day, in a more elegant fashion (e.g. a numpy vector)?

4 responses

Here's an incremental improvement. Arrays are pre-allocated, and by inspection of the output, one can confirm that it is working.

Here's another incremental improvement (thanks to Alan Coppola on https://www.quantopian.com/posts/get-data-as-vector-instead-of-scalar).

Wow, that is clean code. Thank you for sharing Grant. Following and testing (found from your post here: https://www.quantopian.com/posts/pipeline-classifiers-are-here#5704dbaaf3b71d2097000158).

Thanks Marc,

There is a more general case with a dynamic universe. I haven't sorted that one out yet. The fundamental problem, I think, is that the analyses would be done in before_trading_start on the prior day's universe, then the universe would be updated, doing an add/drop for the current day. But the analyses would have been done on the prior universe, so orders opening new positions for stocks no longer in data would fail. But maybe I haven't thought everything through carefully enough...

Grant