Exit Position Day Before Earnings Report

I'm trying to create a function to exit all positions held on the day before the stock's next earnings report is released. It looks like I should be able to use the data provided from EventVestor. The built-in BusinessDaysUntilNextEarnings pipeline factor will be equal to 1 when this is the case.

Can you use this factor outside of a pipeline?
- If so, how could I get this factor for the current stocks held. Say this is in a list called "context.current_stocks".
- If not, is there another way to do this? I've looked into adding these factors as output from my pipeline, but apparently you cannot incorporate your current positions in your pipeline (see post).

Thanks!

3 responses

Hi Aaron,

Here is how I do it.

from quantopian.pipeline.data.eventvestor import EarningsCalendar
from quantopian.pipeline.factors.eventvestor import (
)

def make_pipeline():
minprice = USEquityPricing.close.latest > 5
not_announced_acq_target = ~IsAnnouncedAcqTarget()
pipe = Pipeline(screen=Q1500US() & minprice & not_announced_acq_target)
sectors = Sector()
return pipe