Error During Bundle Ingestion for Zipline

Hi guys,
I’ve recently installed zipline reloaded on my local python environment, but got the same error message " AttributeError: ‘NoneType’ object has no attribute ‘base’ " when ever I try to ingest both default and customized bundles.
I’m using conda on windows.

If anybody could take a look and give me some suggestions of what possibly went wrong, I would really appreciate your help.

Thanks!

Details:

(zip) PS C:\Users\kelvi> zipline ingest -b quandl
Traceback (most recent call last):
File “C:\Users\kelvi\anaconda3\envs\zip\Scripts\zipline-script.py”, line 10, in
sys.exit(main())
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\click\core.py”, line 1130, in call
return self.main(*args, **kwargs)
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\click\core.py”, line 1055, in main
rv = self.invoke(ctx)
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\click\core.py”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\click\core.py”, line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\click\core.py”, line 760, in invoke
return _callback(*args, **kwargs)
File "C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\zipline_main
.py", line 389, in ingest
bundles_module.ingest(
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\zipline\data\bundles\core.py”, line 415, in ingest
daily_bar_writer.write(())
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\zipline\data\bcolz_daily_bars.py”, line 209, in write
return self._write_internal(it, assets)
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\zipline\data\bcolz_daily_bars.py”, line 250, in _write_internal
columns = {
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\zipline\data\bcolz_daily_bars.py”, line 251, in
k: carray(array([], dtype=uint32_dtype))
File “bcolz/carray_ext.pyx”, line 1063, in bcolz.carray_ext.carray.cinit
self._create_carray(array, cparams, dtype, dflt,
File “bcolz/carray_ext.pyx”, line 1132, in bcolz.carray_ext.carray.create_carray
array
= utils.to_ndarray(array, dtype)
File “C:\Users\kelvi\anaconda3\envs\zip\lib\site-packages\bcolz\utils.py”, line 113, in to_ndarray
if array.dtype != dtype.base:
AttributeError: ‘NoneType’ object has no attribute ‘base’

I’m seeing this too. Currently trying to work through it. I figure there should be a way to feed zipline a dataframe, which I can get easily enough from yfinance. Give this page a read:
https://zipline.ml4trading.io/bundles.html

I am still working through it myself. Looks like you can take a dataframe, rename the columns to the expected names and then ingest. Another useful reference:

@Kay, I’m starting to use zipline, and I’ve got precisely the same error. Did you manage to solve it?

when it comes to ingest custom data, it is a bit complicated.

  • You need to check the trading calendar first - there will a folder name TradingCalendar where you install Zipline (I assume that you are not using the US data).
  • Then, you need to check your data (csv files) to make sure they are in the right format (I suggest that you may create a trading calendar in then reindex your data - this process is to match your data - OHLC with date, time … of your trading calendar).
  • Finally, edit the extension file, the start date and end date that matches with your data.

I am having the same issue on Python 3.8.13 on Windows.

Same problem here. Previously I ingested a custom bundle successfully. After setting up a new environment on a new Windows machine today and using my code I found this error. It doesn’t even seem to occur with the custom code itself but before it even gets there.

Since it worked before, I can only speculate at this point, that the new installation introduced some new package versions that are not compatible. Would someone be willing to try set up a new environment with conda figuring out the dependencies and check if their ingest code still runs?

I could post my environment list but I am new here and not sure if it’s helpful at this point. Python is 3.8.13, Zipline 2.2.0.

I have also a very similar error. Tried to install zipline-reloaded on different computers and OS (ubuntu desktop, ubuntu server, macOS). Always the same error.
It already occurs, if you just type “zipline”…
Would be great, if someone can give a hint to the solution :slight_smile:

I’m surprised there is STILL no solution given.
For me, dumb editing of the utils.py file in
/usr/local/lib/python3.8/dist-packages/bcolz
worked:

replace lines from 113

        if array.dtype != dtype.base:
            raise TypeError("dtypes do not match")
        return array

with

    if dtype:
        if array.dtype != dtype.base:
            raise TypeError("dtypes do not match")
        return array
    else:
        return array

Bcolz seems to be freaking out on an empty write of line 415 of zipline\data\bundles\core.py:

            # Do an empty write to ensure that the daily ctables exist
            # when we create the SQLiteAdjustmentWriter below. The
            # SQLiteAdjustmentWriter needs to open the daily ctables so
            # that it can compute the adjustment ratios for the dividends.

            daily_bar_writer.write(())
1 Like

I used the above code you presented and it did solve it temporarily but it appeared later on during the data ingestion.

i was able to solve it by modifying your code .

bcolz/utils.py
if dtype:
if type(array) == np.ndarray and len(array.strides) and array.strides[0] == 0:
if array.dtype != dtype.base:
raise TypeError(“dtypes do not match”)
return array
else:
return array

2 Likes