ENH: Enable TALib transforms to perform on multiple stocks.

The TALib transform only supported operating on the first value
of a given batch transform panel row.

Instead of returning the one value, even if an panel with multiple
sids was provided, return a dictionary that maps stock to TALib
result.
This commit is contained in:
Eddie Hebert
2013-07-10 14:40:58 -04:00
parent 37352210c0
commit eac882b773
2 changed files with 34 additions and 24 deletions
+5 -2
View File
@@ -350,11 +350,14 @@ class TestTALIB(TestCase):
algo = TALIBAlgorithm(talib=zipline_transforms)
algo.run(self.source)
# Test if computed values match those computed by pandas rolling mean.
talib_values = np.array(algo.talib_results[zipline_transforms[0]])
sid = 0
talib_values = np.array([x[sid] for x in
algo.talib_results[zipline_transforms[0]]])
np.testing.assert_array_equal(talib_values,
pd.rolling_mean(self.panel[0]['price'],
10).values)
talib_values = np.array(algo.talib_results[zipline_transforms[1]])
talib_values = np.array([x[sid] for x in
algo.talib_results[zipline_transforms[1]]])
np.testing.assert_array_equal(talib_values,
pd.rolling_mean(self.panel[0]['price'],
25).values)