QuantRocket logo
Disclaimer


Borrow Fees Alpha › Part 1: Data Collection


Data Collection¶

Collect US Stock Daily Bundle¶

This tutorial uses the US Stock daily bundle. First create the bundle:

In [1]:
from quantrocket.zipline import create_usstock_bundle
create_usstock_bundle("usstock-1d-bundle", data_frequency="daily")
Out[1]:
{'status': 'success', 'msg': 'successfully created usstock-1d-bundle bundle'}

Then ingest the data:

In [2]:
from quantrocket.zipline import ingest_bundle
ingest_bundle("usstock-1d-bundle")
Out[2]:
{'status': 'the data will be ingested asynchronously'}

Use flightlog to monitor the progress:

quantrocket.zipline: INFO [usstock-1d-bundle] Ingesting daily bars for usstock-1d-bundle bundle
quantrocket.zipline: INFO [usstock-1d-bundle] Ingesting adjustments for usstock-1d-bundle bundle
quantrocket.zipline: INFO [usstock-1d-bundle] Ingesting assets for usstock-1d-bundle bundle
quantrocket.zipline: INFO [usstock-1d-bundle] Completed ingesting data for 24749 securities in usstock-1d-bundle bundle

Collect Borrow Fees¶

Next, collect borrow fees, which are organized by country:

In [3]:
from quantrocket.fundamental import collect_ibkr_borrow_fees
collect_ibkr_borrow_fees(countries="usa")
Out[3]:
{'status': 'the borrow fees data will be collected asynchronously'}

Use flightlog to monitor for completion:

quantrocket.fundamental: INFO Collecting ibkr usa borrow fees data from 2024-05-01 to present
quantrocket.fundamental: INFO Saved 2104318 total ibkr borrow fees records to quantrocket.v2.fundamental.ibkr.stockloan.fees.sqlite

Next Up¶

Part 2: Exploratory Data Analysis