mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-02 12:30:45 +08:00
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:
committed by
Eddie Hebert
parent
c1c71398d6
commit
b87d454938
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user