ENH: Added DataPanelSource.

This commit is contained in:
Thomas Wiecki
2012-12-13 12:55:05 -05:00
parent bbc8050c81
commit 775c564ea1
6 changed files with 129 additions and 7 deletions
+11 -1
View File
@@ -20,7 +20,9 @@ import numpy as np
from zipline.utils.test_utils import setup_logger
import zipline.utils.factory as factory
from zipline.test_algorithms import TestRegisterTransformAlgorithm
from zipline.sources import SpecificEquityTrades, DataFrameSource
from zipline.sources import (SpecificEquityTrades,
DataFrameSource,
DataPanelSource)
from zipline.transforms import MovingAverage
@@ -42,6 +44,9 @@ class TestTransformAlgorithm(TestCase):
self.df_source, self.df = \
factory.create_test_df_source(self.trading_environment)
self.panel_source, self.panel = \
factory.create_test_panel_source(self.trading_environment)
def test_source_as_input(self):
algo = TestRegisterTransformAlgorithm(sids=[133])
algo.run(self.source)
@@ -64,6 +69,11 @@ class TestTransformAlgorithm(TestCase):
algo.run(self.df)
assert isinstance(algo.sources[0], DataFrameSource)
def test_panel_as_input(self):
algo = TestRegisterTransformAlgorithm(sids=[0, 1])
algo.run(self.panel)
assert isinstance(algo.sources[0], DataPanelSource)
def test_run_twice(self):
algo = TestRegisterTransformAlgorithm(sids=[0, 1])
res1 = algo.run(self.df)