Since high borrow fee stocks tend to decline but the high borrow fees destroy the profitability of shorting them, perhaps a more appealing way to use borrow fee data is to exclude stocks with high borrow fees from long strategies. Next, we use Zipline to test this approach.
The strategy is implemented in avoid-high-borrow.py.
Execute the following cell to move the strategy file to the /codeload/zipline
directory:
# make directory if doesn't exist
!mkdir -p /codeload/zipline
!mv avoid-high-borrow.py /codeload/zipline/
Using similar code as the Alphalens analysis earlier, the Zipline strategy creates a Pipeline of midcap stocks (defined as stocks in the 50th-75th percentile by dollar volume) that excludes stocks with borrow fees above 0.3%:
MAX_BORROW_FEE = 0.3
def make_pipeline():
"""
Create a pipeline that filters by dollar volume and borrow fee.
"""
# limit initial universe to common stocks
universe = master.SecuritiesMaster.usstock_SecurityType2.latest.eq("Common Stock")
screen = AverageDollarVolume(window_length=90).percentile_between(50, 75)
if MAX_BORROW_FEE:
screen &= (ibkr.BorrowFees.FeeRate.latest <= MAX_BORROW_FEE)
pipeline = Pipeline(
initial_universe=universe,
screen=screen
)
...
The results of the Pipeline screen are purchased in an equal-weighted, long-only portfolio and rebalanced monthly.