Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
notebook error?

Anyone know what's going on here? I recall that the Q data run back to 2002, but maybe not 1/1/2002? Or perhaps there's another problem?


pipe = Pipeline(
columns = {
'MyFactor' : RandomFactor(mask=base_universe).zscore(),
'Sector' : Sector()
},
screen=base_universe
)

start_timer = time()
results = run_pipeline(pipe, '2002-01-01', '2018-08-10')
end_timer = time()
results.fillna(value=0);

print "Time to run pipeline %.2f secs" % (end_timer - start_timer)

KeyErrorTraceback (most recent call last)
in ()
8
9 start_timer = time()
---> 10 results = run_pipeline(pipe, '2002-01-01', '2018-08-10')
11 end_timer = time()
12 results.fillna(value=0);

/build/src/qexec_repo/qexec/research/api.py in run_pipeline(pipeline, start_date, end_date, chunksize) 483 pipeline_engine,
484 equity_trading_days,
--> 485 holdout_manager,
486 )
487

/build/src/qexec_repo/qexec/research/_api.pyc in inner_run_pipeline(pipeline, start_date, end_date, chunksize, engine, equity_trading_days, holdout_manager) 734 adjusted_start_date,
735 adjusted_end_date,
--> 736 chunksize=chunksize,
737 )
738

/build/src/qexec_repo/zipline_repo/zipline/pipeline/engine.pyc in run_chunked_pipeline(self, pipeline, start_date, end_date, chunksize) 328 chunksize,
329 )
--> 330 chunks = [self.run_pipeline(pipeline, s, e) for s, e in ranges]
331
332 if len(chunks) == 1:

/build/src/qexec_repo/zipline_repo/zipline/pipeline/engine.pyc in run_pipeline(self, pipeline, start_date, end_date) 309 dates,
310 assets,
--> 311 initial_workspace,
312 )
313

/build/src/qexec_repo/zipline_repo/zipline/pipeline/engine.pyc in compute_chunk(self, graph, dates, assets, initial_workspace) 522 loader = get_loader(term)
523 loaded = loader.load_adjusted_array(
--> 524 to_load, mask_dates, assets, mask,
525 )
526 assert set(loaded) == set(to_load), (

/build/src/qexec_repo/zipline_repo/zipline/pipeline/loaders/equity_pricing_loader.pyc in load_adjusted_array(self, columns, dates, assets, mask) 78 start_date,
79 end_date,
---> 80 assets,
81 )
82 adjustments = self.adjustments_loader.load_adjustments(

/build/src/qexec_repo/qexec/sources/resource_proxy.py in method(self, *args, **kwargs) 249 def method(self, *args, **kwargs):
250 with self.reader as proxied:
--> 251 return getattr(proxied, name)(*args, **kwargs)
252
253 method.name = name

/build/src/qexec_repo/zipline_repo/zipline/data/us_equity_pricing.pyc in load_raw_arrays(self, columns, start_date, end_date, assets) 620 def load_raw_arrays(self, columns, start_date, end_date, assets):
621 # Assumes that the given dates are actually in calendar.
--> 622 start_idx = self.sessions.get_loc(start_date)
623 end_idx = self.sessions.get_loc(end_date)
624 first_rows, last_rows, offsets = self._compute_slices(

/usr/local/lib/python2.7/dist-packages/pandas/tseries/index.pyc in get_loc(self, key, method, tolerance) 1420 # needed to localize naive datetimes
1421 key = Timestamp(key, tz=self.tz)
-> 1422 return Index.get_loc(self, key, method, tolerance)
1423
1424 if isinstance(key, time):

/usr/local/lib/python2.7/dist-packages/pandas/indexes/base.pyc in get_loc(self, key, method, tolerance) 1945 return self._engine.get_loc(key)
1946 except KeyError:
-> 1947 return self._engine.get_loc(self._maybe_cast_indexer(key))
1948
1949 indexer = self.get_indexer([key], method=method, tolerance=tolerance)

pandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:11140)()

pandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:10895)()

KeyError: Timestamp('2001-03-13 00:00:00+0000', tz='UTC')

2 responses

There are a couple of things going on.

First, the 'QTradableStocksUS' filter looks back 200 days to get dollar volume "Liquidity is measured using the 200-day median daily dollar volume" (see https://www.quantopian.com/help#built-in-filters). This is what's generating the timestamp error of 2001-03-13 (ie 200 trading days before 2002-01-01). Remove the 'QTradableStocksUS' filter from both the screen and the factor mask.

Second, the data actually starts on 2002-01-02 since the markets weren't open on New Years day. Since the pipeline uses the previous days data, the earliest pipeline that can run is 2002-01-03.

Make those two changes and the notebook runs.

Thanks Dan - I'll have to sort out the earliest start date when using the QTU.