TST: Added tests for new order methods.

This commit is contained in:
Thomas Wiecki
2013-08-08 15:53:09 -04:00
parent 48486c9814
commit b1fdebfb7c
3 changed files with 23 additions and 9 deletions
+21 -7
View File
@@ -21,7 +21,13 @@ from zipline.utils.test_utils import setup_logger
import zipline.utils.factory as factory
from zipline.test_algorithms import (TestRegisterTransformAlgorithm,
RecordAlgorithm,
TestOrderAlgorithm)
TestOrderAlgorithm,
TestOrderValueAlgorithm,
TestTargetAlgorithm,
TestOrderPercentAlgorithm,
TestTargetPercentAlgorithm,
TestTargetValueAlgorithm)
from zipline.sources import (SpecificEquityTrades,
DataFrameSource,
DataPanelSource)
@@ -166,9 +172,17 @@ class TestTransformAlgorithm(TestCase):
self.assertEqual(algo.data_frequency, 'minute')
self.assertEqual(algo.annualizer, 10)
def test_orders_executed(self):
algo = TestOrderAlgorithm(
sim_params=self.sim_params,
data_frequency='daily'
)
algo.run(self.df)
def test_order_methods(self):
AlgoClasses = [TestOrderAlgorithm,
TestOrderValueAlgorithm,
TestTargetAlgorithm,
TestOrderPercentAlgorithm,
TestTargetPercentAlgorithm,
TestTargetValueAlgorithm]
for AlgoClass in AlgoClasses:
algo = AlgoClass(
sim_params=self.sim_params,
data_frequency='daily'
)
algo.run(self.df)
+1 -1
View File
@@ -231,7 +231,7 @@ class TestBatchTransform(TestCase):
# consecutive (of window length) numbers up till the end.
for i in range(algo.window_length, len(test_history)):
np.testing.assert_array_equal(
range(i - algo.window_length + 1, i + 1),
range(i - algo.window_length + 2, i + 2d),
test_history[i].values.flatten()
)
+1 -1
View File
@@ -326,7 +326,7 @@ def create_test_df_source(sim_params=None, bars='daily'):
if i >= market_open and i <= market_close:
new_index.append(i)
index = new_index
x = np.arange(0, len(index))
x = np.arange(1, len(index) + 1)
df = pd.DataFrame(x, index=index, columns=[0])