BUG: Add bar kwarg to batch_transform.

Before the change to the RollingPanel, window_length
specified the number of days that should be in a window.

The previous commit broke this if data was minute resolution.

By passing bar='minute' to the batch_transform we internally
multiply the window_length by 60*6.5 to have a full day.

Also adds a (still rudamentary) test for batch_transform
with minute data.
This commit is contained in:
Thomas Wiecki
2013-05-13 16:42:58 -04:00
committed by Eddie Hebert
parent c1c71398d6
commit b87d454938
4 changed files with 75 additions and 4 deletions
+23
View File
@@ -28,6 +28,7 @@ from zipline.sources.data_source import DataSource
import zipline.utils.factory as factory
from zipline.test_algorithms import (BatchTransformAlgorithm,
BatchTransformAlgorithmMinute,
batch_transform,
ReturnPriceBatchTransform)
@@ -125,6 +126,28 @@ class TestChangeOfSids(TestCase):
self.assertEqual(df[last_elem][last_elem], last_elem)
class TestBatchTransformMinutely(TestCase):
def setUp(self):
start = pd.datetime(1990, 1, 3, 0, 0, 0, 0, pytz.utc)
end = pd.datetime(1990, 1, 8, 0, 0, 0, 0, pytz.utc)
self.sim_params = factory.create_simulation_parameters(
start=start,
end=end,
)
self.sim_params.emission_rate = 'daily'
self.sim_params.data_frequency = 'minute'
setup_logger(self)
self.source, self.df = \
factory.create_test_df_source(bars='minute')
def test_core(self):
algo = BatchTransformAlgorithmMinute(sim_params=self.sim_params)
algo.run(self.source)
wl = int(algo.window_length * 6.5 * 60)
for bt in algo.history[wl:]:
self.assertEqual(len(bt), wl)
class TestBatchTransform(TestCase):
def setUp(self):
self.sim_params = factory.create_simulation_parameters(