To collect end-of-day sample data for US stocks, create a database and specify free=True
. We will name the database "usstock-free-1d":
from quantrocket.history import create_usstock_db
create_usstock_db("usstock-free-1d", bar_size="1 day", free=True)
{'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. You can start a flightlog terminal from the Launcher menu or by executing the %flightlog
magic command in a notebook:
%flightlog
Then collect the data:
from quantrocket.history import collect_history
collect_history("usstock-free-1d")
{'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