stefan-jansen / zipline-reloaded

Zipline, a Pythonic Algorithmic Trading Library
https://zipline.ml4trading.io
Apache License 2.0
1.12k stars 208 forks source link

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NaTType' #40

Closed playingwithpy closed 3 years ago

playingwithpy commented 3 years ago

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]

Here is how you can reproduce this issue on your machine:

Reproduction Steps

  1. Compile python 3.7.11 from source after installing the dependencies outlined at https://zipline.ml4trading.io/install.html
  2. sudo make altinstall
  3. Create new project venv in Pycharm CE
  4. pip install zipline-reloaded as described at https://zipline.ml4trading.io/#installation ...

What steps have you taken to resolve this already?

  1. 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.

  2. 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.

    1. Tried pasting the full TypeError message into stackoverflow but I couldn't find a fix or similar issue thread.

...

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

RiseT commented 3 years ago

Duplicate of https://github.com/stefan-jansen/zipline-reloaded/issues/29

complexsum commented 3 years ago

I was also stumbled upon this issue, it seem to be fixed after installing pandas version 1.1.5.

stefan-jansen commented 3 years ago

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.