A feature of self-serve data is that it will always 'forward fill'. It seems the CSV data file is structured something like this. With 24-30 stocks, but generally similar. (Do correct me if that's not the case)
DATE SYMBOL WEIGHT
1-15-2015, AAA, 25
1-15-2015, AAB, 25
1-15-2015, AAC, 25
1-15-2015, AAD, 25
5-15-2015, BBA, 50
5-15-2015, BBB, 50
It appears the intent is to open positions for AAA, AAB, AAC, AAD on 1-15-2015 with weights of .25. Then, on 5-15-2015, close those positions and open BBA, BBB with weights of .50. However, since data is forward filled, what will happen is AAA, AAB, AAC, AAD will still have weights of .25 on 5-15-2015 and will not close. The new securities will be appended but existing securities will never change.
So, assuming this is the challenge, what to do? The most straight forward approach is to modify the CSV file. If that is an option, then the format something like this would work as intended.
DATE SYMBOL WEIGHT
1-15-2015, AAA, 25
1-15-2015, AAB, 25
1-15-2015, AAC, 25
1-15-2015, AAD, 25
5-15-2015, AAA, 00
5-15-2015, AAB, 00
5-15-2015, AAC, 00
5-15-2015, AAD, 00
5-15-2015, BBA, 50
5-15-2015, BBB, 50
If modifying the CSV file isn't an option then one could select just those weights with 'asof_dates' equal to the max date. Something like this
def before_trading_start(context,data):
pipe_data = pipeline_output('my_pipeline')
latest_update = pipe_data.date.max()
context.weights = pipe_data.query('date == @latest_update').weights
Hope I interpreted the problem correctly.