Hi Nathan,
Thank you for your response.
I implemented a try and except block over each
sector_XXX_long_diff
variable to set these variables to zero if an error occurs.
try:
sector_101_weights = (sector_101_long_diff / sector_101_long_diff.abs().sum()) * context.target_weight
except TypeError:
log.info("There are no stocks in Sector 101 that meet the pipeline criteria.")
sector_101_weights = 0
try:
sector_102_weights = (sector_102_long_diff / sector_102_long_diff.abs().sum()) * context.target_weight
except TypeError:
log.info("There are no stocks in Sector 102 that meet the pipeline criteria.")
sector_102_weights = 0
I no longer get the error so I think this solved my problem.
Thanks so much!