We will backtest the trading strategy using the SPY ETF. The data collection process consists of collecting US Stocks listings, then collecting 1 minute bars for SPY.
First, collect US Stock listings:
from quantrocket.master import collect_usstock_listings
collect_usstock_listings()
Next, we look up the Sid (security ID) for SPY. We use the command line interface because less typing is required.
Prefixing a line with ! allows running terminal commands from inside a notebook.
!quantrocket master get --symbols 'SPY' --sec-types 'ETF' --fields 'Sid' 'Symbol' 'Exchange' --json | json2yaml
Next, we create a Zipline bundle for collecting 1-min bars for SPY:
from quantrocket.zipline import create_usstock_bundle
create_usstock_bundle("usstock-1min")
Then collect the data for SPY:
from quantrocket.zipline import ingest_bundle
ingest_bundle("usstock-1min", sids="FIBBG000BDTBL9")
Monitor flightlog for completion:
quantrocket.zipline: INFO [usstock-1min] Collecting minute bars for 1 securities in usstock-1min bundle
quantrocket.zipline: INFO [usstock-1min] Collecting daily bars for usstock-1min bundle
quantrocket.zipline: INFO [usstock-1min] Collecting adjustments for usstock-1min bundle
quantrocket.zipline: INFO [usstock-1min] Collecting assets for usstock-1min bundle
quantrocket.zipline: INFO [usstock-1min] Completed collecting data for 1 securities in usstock-1min bundle