Apparently, you cannot do it using Quantopian or zipline. But you can get historical data from Interactive Brokers and save them to csv files using IBridgePy easily. Also, you can specify a datetime in past as the ending time of the historical data request.
In the following example, historical data of “SPY” ending by Jun 6th 2017, 9:35AM Eastern Time is requested and 10 minute bars are expected.
Print out the retrieved historical data and a few points need attentions.
There are 10 lines in total as expected.
The time period of market close are skipped.
‹ Is it possible to ignore or block error messages?
I will try my best to make IBridgePy easier to use.