ENH: Adapt history() to work on zipline.

This commit is contained in:
twiecki
2014-03-17 11:34:53 +09:00
parent c9b1a3f1c7
commit e261438d01
9 changed files with 841 additions and 77 deletions
+20
View File
@@ -506,3 +506,23 @@ def handle_data(context, data):
**self.zipline_test_config)
output, _ = drain_zipline(self, zipline)
class TestHistory(TestCase):
def test_history(self):
history_algo = """
from zipline.api import history, add_history
def initialize(context):
add_history(10, '1d', 'price')
def handle_data(context, data):
df = history(10, '1d', 'price')
"""
start = pd.Timestamp('1991-01-01', tz='UTC')
end = pd.Timestamp('1991-01-15', tz='UTC')
source = RandomWalkSource(start=start,
end=end)
algo = TradingAlgorithm(script=history_algo, data_frequency='minute')
output = algo.run(source)
self.assertIsNot(output, None)