Data Collection - US Stocks

Our machine learning strategy will run on the universe of all US stocks.

Start by collecting US stock data from Sharadar. Fundamental and price data are collected separately but can be run simultaneously.

Collect Sharadar fundamentals

To collect the fundamentals:

In [1]:
from quantrocket.fundamental import collect_sharadar_fundamentals
collect_sharadar_fundamentals(country="US")
Out[1]:
{'status': 'the fundamental data will be collected asynchronously'}

This runs in the background, monitor flightlog for a completion message:

quantrocket.fundamental: INFO Collecting Sharadar US fundamentals
quantrocket.fundamental: INFO Collecting updated Sharadar US securities listings
quantrocket.fundamental: INFO Finished collecting Sharadar US fundamentals

Collect Sharadar prices

First, create a database for Sharadar stock prices:

In [2]:
from quantrocket.history import create_sharadar_db
create_sharadar_db("sharadar-us-stk-1d", sec_type="STK", country="US")
Out[2]:
{'status': 'successfully created quantrocket.v2.history.sharadar-us-stk-1d.sqlite'}

Then collect the data:

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

This runs in the background, monitor flightlog for a completion message:

quantrocket.history: INFO [sharadar-us-stk-1d] Collecting Sharadar US STK prices
quantrocket.history: INFO [sharadar-us-stk-1d] Collecting updated Sharadar US securities listings
quantrocket.history: INFO [sharadar-us-stk-1d] Finished collecting Sharadar US STK prices