Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
custom ingestion problem using zipline

Hi,
I have done custom ingest using 500 csv files of BSE India tickers from quandl downloads. Ingestion is done successfully however while using the tickers for backtesting I encountered below error. I appreciate any help!!


---------------------------------------------------------------------------  
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: 852076800000000000

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)  
<ipython-input-14-3547e955cf9b> in <module>  
      7     capital_base=100000, # Set initial capital  
      8     data_frequency = 'daily',  # Set data frequency  
----> 9     bundle= 'bse_data')  
     10 #'random_equities') #'india_stock_data' )#'quandl') #'ac_equities_db' csvdir) # Select bundle

C:\ProgramData\Anaconda3\envs\env_zipline\lib\site-packages\zipline\utils\run_algo.py in run_algorithm(start, end, initialize, capital_base, handle_data, before_trading_start, analyze, data_frequency, data, bundle, bundle_timestamp, trading_calendar, metrics_set, default_extension, extensions, strict_extensions, environ, blotter)  
    428         local_namespace=False,  
    429         environ=environ,  
--> 430         blotter=blotter,  
    431     )

C:\ProgramData\Anaconda3\envs\env_zipline\lib\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             equity_minute_reader=bundle_data.equity_minute_bar_reader,  
    168             equity_daily_reader=bundle_data.equity_daily_bar_reader,  
--> 169             adjustment_reader=bundle_data.adjustment_reader,  
    170         )  
    171 

C:\ProgramData\Anaconda3\envs\env_zipline\lib\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)  
    289                 self._first_trading_day  
    290             )  
--> 291             if self._first_trading_day is not None else (None, None)  
    292         )  
    293 

C:\ProgramData\Anaconda3\envs\env_zipline\lib\site-packages\trading_calendars\trading_calendar.py in open_and_close_for_session(self, session_label)  
    763         # http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#datetime-with-tz  # noqa  
    764         return (  
--> 765             sched.at[session_label, 'market_open'].tz_localize(UTC),  
    766             sched.at[session_label, 'market_close'].tz_localize(UTC),  
    767         )

C:\ProgramData\Anaconda3\envs\env_zipline\lib\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):

C:\ProgramData\Anaconda3\envs\env_zipline\lib\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('1997-01-01 00:00:00+0000', tz='UTC')

1 response

Finally, I could able to resolve all issues and created a custom bundle for BSE 500 India stocks. As used free data from quandl, it requires steps to clean up, date match to XBOM calendar and padding.
Thanks