Collect US Stock Data

To collect end-of-day sample data for US stocks, create a database and specify the FREE universe. We will name the database "usstock-free-1d":

In [1]:
from quantrocket.history import create_usstock_db
create_usstock_db("usstock-free-1d", bar_size="1 day", universe="FREE")
Out[1]:
{'status': 'successfully created quantrocket.v2.history.usstock-free-1d.sqlite'}

This creates an empty database. Next, we need to fill up the database with data. Data collection runs asynchronously (that is, in the background), so it's a good idea to open a terminal for flightlog if you haven't already done so in order to monitor the progress. In the terminal, fire up flightlog:

quantrocket flightlog stream

Then collect the data:

In [2]:
from quantrocket.history import collect_history
collect_history("usstock-free-1d")
Out[2]:
{'status': 'the historical data will be collected asynchronously'}

Use flightlog to monitor the progress:

quantrocket.history: INFO [usstock-free-1d] Collecting FREE history from 2007 to present
quantrocket.history: INFO [usstock-free-1d] Collecting updated FREE securities listings
quantrocket.history: INFO [usstock-free-1d] Collecting additional FREE history from 2020-04 to present
quantrocket.history: INFO [usstock-free-1d] Collected 160 monthly files in quantrocket.v2.history.usstock-free-1d.sqlite

Next Up

Part 2: Universe Selection