Неверная временная метка будущего Python Zipline Quandl - PullRequest
0 голосов
/ 21 октября 2018

Я установил Zipline для тестирования с использованием последней версии репо:

$ git clone git@github.com: quantopian / zipline.git

$ pip install zipline /

Затем установил пакет QUANDL для данных, используя:

$ QUANDL_API_KEY = wK2niUu6v79IqfbpdQT9 zipline ingest -b quandl

Однако, когда я запускаю пример из документации, я получаю эту ошибку:

Я бегу:

%zipline --start 2014-1-1 --end 2016-1-1 -o dma.pickle

Я получаю:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/trading_calendars/utils/memoize.py in __get__(self, instance, owner)
     46         try:
---> 47             return self._cache[instance]
     48         except KeyError:

~/anaconda3/lib/python3.6/weakref.py in __getitem__(self, key)
    393     def __getitem__(self, key):
--> 394         return self.data[ref(key)]
    395 

KeyError: <weakref at 0x7fd3aed36d68; to 'BcolzMinuteBarReader' at 0x7fd3aed9f3c8>

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()

KeyError: 1571616000000000000

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-125-743468e1c8bb> in <module>()
----> 1 get_ipython().run_line_magic('zipline', '--start 2014-1-1 --end 2016-1-1 -o dma.pickle --trading-calendar NYSE --bundle-timestamp 2016-01-01')

~/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2093                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2094             with self.builtin_trap:
-> 2095                 result = fn(*args,**kwargs)
   2096             return result
   2097 

~/anaconda3/lib/python3.6/site-packages/zipline/__main__.py in zipline_magic(line, cell)
    309             '%s%%zipline' % ((cell or '') and '%'),
    310             # don't use system exit and propogate errors to the caller
--> 311             standalone_mode=False,
    312         )
    313     except SystemExit as e:

~/anaconda3/lib/python3.6/site-packages/click/core.py in main(self, args, prog_name, complete_var, standalone_mode, **extra)
    695             try:
    696                 with self.make_context(prog_name, args, **extra) as ctx:
--> 697                     rv = self.invoke(ctx)
    698                     if not standalone_mode:
    699                         return rv

~/anaconda3/lib/python3.6/site-packages/click/core.py in invoke(self, ctx)
    893         """
    894         if self.callback is not None:
--> 895             return ctx.invoke(self.callback, **ctx.params)
    896 
    897 

~/anaconda3/lib/python3.6/site-packages/click/core.py in invoke(*args, **kwargs)
    533         with augment_usage_errors(self):
    534             with ctx:
--> 535                 return callback(*args, **kwargs)
    536 
    537     def forward(*args, **kwargs):

~/anaconda3/lib/python3.6/site-packages/click/decorators.py in new_func(*args, **kwargs)
     15     """
     16     def new_func(*args, **kwargs):
---> 17         return f(get_current_context(), *args, **kwargs)
     18     return update_wrapper(new_func, f)
     19 

~/anaconda3/lib/python3.6/site-packages/zipline/__main__.py in run(ctx, algofile, algotext, define, data_frequency, capital_base, bundle, bundle_timestamp, start, end, output, trading_calendar, print_algo, metrics_set, local_namespace, blotter)
    274         environ=os.environ,
    275         blotter=blotter,
--> 276         benchmark_returns=None,
    277     )
    278 

~/anaconda3/lib/python3.6/site-packages/zipline/utils/run_algo.py in _run(handle_data, initialize, before_trading_start, analyze, algofile, algotext, defines, data_frequency, capital_base, data, bundle, bundle_timestamp, start, end, output, trading_calendar, print_algo, metrics_set, local_namespace, environ, blotter)
    167             "No PipelineLoader registered for column %s." % column
    168         )
--> 169 
    170     if isinstance(metrics_set, six.string_types):
    171         try:

~/anaconda3/lib/python3.6/site-packages/zipline/data/data_portal.py in __init__(self, asset_finder, trading_calendar, first_trading_day, equity_daily_reader, equity_minute_reader, future_daily_reader, future_minute_reader, adjustment_reader, last_available_session, last_available_minute, minute_history_prefetch_length, daily_history_prefetch_length)
    190             last_minutes = [
    191                 reader.last_available_dt
--> 192                 for reader in [equity_minute_reader, future_minute_reader]
    193                 if reader is not None
    194             ]

~/anaconda3/lib/python3.6/site-packages/zipline/data/data_portal.py in <listcomp>(.0)
    191                 reader.last_available_dt
    192                 for reader in [equity_minute_reader, future_minute_reader]
--> 193                 if reader is not None
    194             ]
    195             if last_minutes:

~/anaconda3/lib/python3.6/site-packages/trading_calendars/utils/memoize.py in __get__(self, instance, owner)
     47             return self._cache[instance]
     48         except KeyError:
---> 49             self._cache[instance] = val = self._get(instance)
     50             return val
     51 

~/anaconda3/lib/python3.6/site-packages/zipline/data/minute_bars.py in last_available_dt(self)
    971     @lazyval
    972     def last_available_dt(self):
--> 973         _, close = self.calendar.open_and_close_for_session(self._end_session)
    974         return close
    975 

~/anaconda3/lib/python3.6/site-packages/trading_calendars/trading_calendar.py in open_and_close_for_session(self, session_label)
    741         # http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#datetime-with-tz  # noqa
    742         return (
--> 743             sched.at[session_label, 'market_open'].tz_localize('UTC'),
    744             sched.at[session_label, 'market_close'].tz_localize('UTC'),
    745         )

~/anaconda3/lib/python3.6/site-packages/pandas/core/indexing.py in __getitem__(self, key)
   1867 
   1868         key = self._convert_key(key)
-> 1869         return self.obj._get_value(*key, takeable=self._takeable)
   1870 
   1871     def __setitem__(self, key, value):

~/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in _get_value(self, index, col, takeable)
   1983 
   1984         try:
-> 1985             return engine.get_value(series._values, index)
   1986         except (TypeError, ValueError):
   1987 

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_value()

pandas/_libs/index.pyx in pandas._libs.index.DatetimeEngine.get_loc()

KeyError: Timestamp('2019-10-21 00:00:00+0000', tz='UTC')

Что может быть не так?

...