I was successfully running zipline manually until it just stopped working for some reason. I have run out of ideas on why. Only thing I changed was updating Matplotlib, but can't see how that could affect it. I am getting an AssertionError: Date 2000-01-03 00:00:00+00:00 not allocated in all_benchmark_returns. Calendar seems to mismatch with benchmark. Please help
Anyway, the code I'm running is the following:
import pytz
from datetime import datetime
from zipline.algorithm import TradingAlgorithm
from zipline.utils.factory import load_bars_from_yahoo
from zipline.api import order, record
# Load data manually from Yahoo! finance
start = datetime(2000, 1, 1, 0, 0, 0, 0, pytz.utc)
end = datetime(2012, 1, 1, 0, 0, 0, 0, pytz.utc)
data = load_bars_from_yahoo(stocks=['AAPL'], start=start,
end=end)
# Define algorithm
def initialize(context):
pass
def handle_data(context, data):
order(symbol('AAPL'), 10)
record(AAPL=data[symbol('AAPL')].price)
# Create algorithm object passing in initialize and
# handle_data functions
algo_obj = TradingAlgorithm(initialize=initialize,
handle_data=handle_data)
# Run algorithm
perf_manual = algo_obj.run(data)
And the console outputs an error as follows:
AAPL
Traceback (most recent call last):
File "C:\Users\...\Zipline_Environment\Z_ManualTest.py", line 28, in <module>
perf_manual = algo_obj.run(data)
File "C:\Python27\lib\site-packages\zipline-0.8.0rc1-py2.7.egg\zipline\algorithm.py", line 483, in run
for perf in self.gen:
File "C:\Python27\lib\site-packages\zipline-0.8.0rc1-py2.7.egg\zipline\gens\tradesimulation.py", line 123, in transform
self.algo.perf_tracker.process_event(event)
File "C:\Python27\lib\site-packages\zipline-0.8.0rc1-py2.7.egg\zipline\finance\performance\tracker.py", line 325, in process_event
% midnight))
AssertionError: Date 2000-01-03 00:00:00+00:00 not allocated in all_benchmark_returns. Calendar seems to mismatch with benchmark.