Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: Timestamp('1990-01-01 00:00:00+0000', tz='UTC') #6

Open
jb33k opened this issue Jun 18, 2021 · 0 comments
Open

KeyError: Timestamp('1990-01-01 00:00:00+0000', tz='UTC') #6

jb33k opened this issue Jun 18, 2021 · 0 comments

Comments

@jb33k
Copy link

jb33k commented Jun 18, 2021

I'm having the weirdest problem with binance_api ingest data. The ingest process works fine but when I try to use the data, I keep getting this date related error. It doesn't happen with quandl data, so it must be something in the binance data. I've been trying to debug this the whole day but I just can't figure out what's wrong.

Init code:

start, end = pd.Timestamp('2017-08-17', tz='UTC'), pd.Timestamp('2021-06-18', tz='UTC')
capital_base = 1e7
performance = run_algorithm(start=start, end=end, initialize=initialize, before_trading_start=before_trading_start, capital_base=capital_base, bundle='binance_api')

Error:

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

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
~\miniconda3\envs\ml4t\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   3079             try:
-> 3080                 return self._engine.get_loc(casted_key)
   3081             except KeyError as err:

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

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

KeyError: Timestamp('1990-01-01 00:00:00+0000', tz='UTC')

The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)
~\miniconda3\envs\ml4t\lib\site-packages\pandas\core\indexes\datetimes.py in get_loc(self, key, method, tolerance)
    685         try:
--> 686             return Index.get_loc(self, key, method, tolerance)
    687         except KeyError as err:

~\miniconda3\envs\ml4t\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   3081             except KeyError as err:
-> 3082                 raise KeyError(key) from err
   3083 

KeyError: Timestamp('1990-01-01 00:00:00+0000', tz='UTC')

The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)
<ipython-input-5-65a6986a7666> in <module>
     34 start, end = pd.Timestamp('2017-08-17', tz='UTC'), pd.Timestamp('2021-06-18', tz='UTC')
     35 capital_base = 1e7
---> 36 performance = run_algorithm(start=start, end=end, initialize=initialize, before_trading_start=before_trading_start, capital_base=capital_base, bundle='binance_api')
     37 performance.to_pickle('single_factor.pickle')

~\miniconda3\envs\ml4t\lib\site-packages\zipline\utils\run_algo.py in run_algorithm(start, end, initialize, capital_base, handle_data, before_trading_start, analyze, data_frequency, bundle, bundle_timestamp, trading_calendar, metrics_set, benchmark_returns, default_extension, extensions, strict_extensions, environ, custom_loader, blotter)
    391     benchmark_spec = BenchmarkSpec.from_returns(benchmark_returns)
    392 
--> 393     return _run(
    394         handle_data=handle_data,
    395         initialize=initialize,

~\miniconda3\envs\ml4t\lib\site-packages\zipline\utils\run_algo.py in _run(handle_data, initialize, before_trading_start, analyze, algofile, algotext, defines, data_frequency, capital_base, bundle, bundle_timestamp, start, end, output, trading_calendar, print_algo, metrics_set, local_namespace, environ, blotter, custom_loader, benchmark_spec)
    159     first_trading_day = bundle_data.equity_minute_bar_reader.first_trading_day
    160 
--> 161     data = DataPortal(
    162         bundle_data.asset_finder,
    163         trading_calendar=trading_calendar,

~\miniconda3\envs\ml4t\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)
    274         # Get the first trading minute
    275         self._first_trading_minute, _ = (
--> 276             self.trading_calendar.open_and_close_for_session(self._first_trading_day)
    277             if self._first_trading_day is not None
    278             else (None, None)

~\miniconda3\envs\ml4t\lib\site-packages\trading_calendars\trading_calendar.py in open_and_close_for_session(self, session_label)
    842         """
    843         return (
--> 844             self.session_open(session_label),
    845             self.session_close(session_label)
    846         )

~\miniconda3\envs\ml4t\lib\site-packages\trading_calendars\trading_calendar.py in session_open(self, session_label)
    867 
    868     def session_open(self, session_label):
--> 869         return self.schedule.at[
    870             session_label,
    871             'market_open'

~\miniconda3\envs\ml4t\lib\site-packages\pandas\core\indexing.py in __getitem__(self, key)
   2154             return self.obj.loc[key]
   2155 
-> 2156         return super().__getitem__(key)
   2157 
   2158     def __setitem__(self, key, value):

~\miniconda3\envs\ml4t\lib\site-packages\pandas\core\indexing.py in __getitem__(self, key)
   2101 
   2102         key = self._convert_key(key)
-> 2103         return self.obj._get_value(*key, takeable=self._takeable)
   2104 
   2105     def __setitem__(self, key, value):

~\miniconda3\envs\ml4t\lib\site-packages\pandas\core\frame.py in _get_value(self, index, col, takeable)
   3142         # use positional
   3143         col = self.columns.get_loc(col)
-> 3144         index = self.index.get_loc(index)
   3145         return self._get_value(index, col, takeable=True)
   3146 

~\miniconda3\envs\ml4t\lib\site-packages\pandas\core\indexes\datetimes.py in get_loc(self, key, method, tolerance)
    686             return Index.get_loc(self, key, method, tolerance)
    687         except KeyError as err:
--> 688             raise KeyError(orig_key) from err
    689 
    690     def _maybe_cast_for_get_loc(self, key) -> Timestamp:

KeyError: Timestamp('1990-01-01 00:00:00+0000', tz='UTC')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant