Thanks, I understand now.
It seems I dug a hole for myself: I obtain historical SPY data up until the current day in
data.history and attach this data to the context so my custom factor can use it in calculations. The problem is that the SPY data is retrieved only at the beginning of a pipeline chunk, meaning every day in that chunk the custom factor can only use SPY data up until the first day of the chunk...
I guess what I'm doing wasn't how custom factors are meant to be used, but I'd say it's not the most far-fetched scenario either, think e.g. of obtaining futures data or doing more sophisticated calculations that need to be shared among multiple custom factors.
Now a workaround for me, I guess, would be to include the SPY in the pipeline besides the Q1500US, but then I have to make sure it's excluded from the 'real' pipeline calculations.
In essence, it seems to me that the implementation details are leaking through the abstraction of the simulation. Do you have any advice on how to deal with this other than limiting my custom factors to pipeline data?