quantopian/zipline — pull request #31 by richafrank (2012-11-27 17:30:53+00:00)
Title: Slippage model bug

The open orders list that gets passed to the slippage model was getting out of sync with the time/state of the user's algo. This is because there is a generator pipeline something like:

date-sorted events -> slippage -> grouping by date -> algo

Grouping by date will pull from the pipline lazily, but it needs to know when the current group is full in order to pass it on to the algo. Thus, it pulls the first of the next day's events, and then passes the current day's group to the algo. The algo is now on the current day and updates the open orders, but the first of the next day's slippage results has already been pulled from the generator and was created using yesterday's open orders.

So I moved the grouping earlier in the pipeline:

date-sorted events -> grouping by date -> slippage -> algo

We're a little less lazy by grouping earlier, but I don't think that should impact the performance. Any worries?