quantopian/zipline — pull request #112 by wesm (2013-03-22 03:22:32+00:00)
Title: Rolling panel data structure

This should be a good start for managing an iterative collection of DataFrames. Currently it's only:

- DatetimeIndex as the major axis of the panel (the index of each DataFrame)
- Fairly unsafe if the user might persist panels between calls to `get_current`

The performance on a pretty vanilla example (collection of 20 x 5 DataFrames, window size 100, 200 total periods). This is the time to construct the panels at each window for the full sample:

```
In [4]: %time f(option='naive')
CPU times: user 3.52 s, sys: 0.01 s, total: 3.53 s
Wall time: 3.52 s

In [5]: timeit f(option='clever')
10 loops, best of 3: 40.9 ms per loop
```

I think this is a good general strategy. Could be generalized for heterogeneous panels etc. if you wanted.