Closed playingwithpy closed 3 years ago
I was also stumbled upon this issue, it seem to be fixed after installing pandas version 1.1.5
.
Duplicate of https://github.com/stefan-jansen/zipline-reloaded/issues/29; temporarily addressed by https://github.com/stefan-jansen/zipline-reloaded/pull/47. We will work on the root cause and lift the pandas version constraint asap.
Dear Zipline Maintainers,
Before I tell you about my issue, let me describe my environment:
Environment
Pycharm 2021.2 CE
Operating System == Linux 5.11.0-7620-generic x86_64 GNU/Linux Python Version == Python 3.7.11 Python Bitness == 64 Installed Via == pip install zipline-reloaded
Now that you know a little about me, let me tell you about the issue I am having:
Description of Issue
When I go to import zipline, I get the error: TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType'
The above error occurs in the file '/venv/lib/python3.7/site-packages/trading_calendars/calendar_helpers.py'
The specific line of code causing the issue is: NP_NAT = np.array([pd.NaT], dtype=np.int64)[0]
What did you expect to happen? zipline would be imported without issue.
What happened instead? The full trace: Traceback (most recent call last): File "/venv/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in
import zipline
File "/pycharm-community-2021.2/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, kwargs)
File "/venv/lib/python3.7/site-packages/zipline/init.py", line 21, in
from trading_calendars import get_calendar
File "/pycharm-community-2021.2/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, *kwargs)
File "/PycharmProjects/ziplineReloaded/venv/lib/python3.7/site-packages/trading_calendars/init.py", line 16, in
from .trading_calendar import TradingCalendar
File "/pycharm-community-2021.2/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, args, kwargs)
File "/PycharmProjects/ziplineReloaded/venv/lib/python3.7/site-packages/trading_calendars/trading_calendar.py", line 33, in
from .calendar_helpers import (
File "/pycharm-community-2021.2/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/PycharmProjects/ziplineReloaded/venv/lib/python3.7/site-packages/trading_calendars/calendar_helpers.py", line 7, in
NP_NAT = np.array([pd.NaT], dtype=np.int64)[0] # Original line from Classic Zipline.
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType'
Here is how you can reproduce this issue on your machine:
Reproduction Steps
What steps have you taken to resolve this already?
I searched online for info about NaT and how to convert this data type to int64 as per my limited understanding of what this line tries to do.
I tried simply omitting "dtype=np.int64" from the line in question. This change allowed me to import zipline without problems. However it causes "RuntimeWarning: overflow encountered in long_scalars NANOSECONDS_PER_MINUTE," when attempting to ingest a custom data bundle. I can provide more info on this if needed.
...
Anything else?
NaT means "Not a Time Object" yes? Is the point of this line to simply create a blank time or datetime object as a place holder? Thank you very much in advance for any assistance that can be shared. ...
Sincerely, playingwithpy