The data collection process consists of collecting US stock listings, creating a universe of leveraged ETFs, then collecting 1 minute bars for the leveraged ETFs.
First collect US Stock listings:
from quantrocket.master import collect_usstock_listings
collect_usstock_listings()
{'status': 'success', 'msg': 'successfully loaded US stock listings'}
Next we download a CSV of several leveraged ETFs:
from quantrocket.master import download_master_file
download_master_file(
"leveraged_etfs.csv",
exchanges="ARCX",
sec_types="ETF",
symbols=[
"SPXL", # DIREXION DLY S&P 500 BULL 3X
"TNA", # DIREXION DLY SM CAP BULL 3X
"ERX", # DIREXION DLY ENERGY BULL 3X
"TMF", # DRX DLY 20+ YR TREAS BULL 3X
"UPRO", # PROSHARES ULTRAPRO S&P 500
"DRN", # DRX DLY REAL ESTATE BULL 3X
"YINN", # DRX DLY FTSE CHINA BULL 3X
"UDOW", # PROSHARES ULTRAPRO DOW30
"URTY", # PROSHARES ULTRAPRO RUSS2000
"FAS", # DIREXION DAILY FIN BULL 3X
"EDC", # DIREXION DLY EMG MKT BULL 3X
"RUSL", # DIREXION DLY RUSSIA BULL 3X
"JNUG", # DIREXION DLY JR GOLD BULL 3X
"NUGT", # DRX DLY GOLD MINERS BULL 3X
])
Then upload the CSV to create the "leveraged-etf" universe:
from quantrocket.master import create_universe
create_universe("leveraged-etf", infilepath_or_buffer="leveraged_etfs.csv")
{'code': 'leveraged-etf', 'provided': 14, 'inserted': 14, 'total_after_insert': 14}
Next, we create a Zipline bundle for collecting 1-min bars.
from quantrocket.zipline import create_usstock_bundle
create_usstock_bundle("usstock-1min")
{'status': 'success', 'msg': 'successfully created usstock-1min bundle'}
Then collect the data for the leveraged ETFs:
from quantrocket.zipline import ingest_bundle
ingest_bundle("usstock-1min", universes="leveraged-etf")
{'status': 'the data will be ingested asynchronously'}
Monitor flightlog for completion:
quantrocket.zipline: INFO [usstock-1min] Collecting minute bars for 14 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 14 securities in usstock-1min bundle