Pandas timestamp error while using csvdir - please help

87 views
Skip to first unread message

Ramesh Ramasamy

unread,
Jan 8, 2018, 11:34:56 PM1/8/18
to Zipline Python Opensource Backtester
Hello,

Attachments are csvdir.py, extension.py, calendar (it's not complete but it should work), and calendar utility files. Input data looks like this:

                             open   high     low   close  volume
time
2017-01-02 09:08:00+05:30  472.00  472.0  472.00  472.00    4911
2017-01-02 09:16:00+05:30  472.00  473.0  471.35  472.00   28096
2017-01-02 09:17:00+05:30  472.00  473.0  472.00  472.85   16635
2017-01-02 09:18:00+05:30  472.60  473.0  471.00  471.00   12274
2017-01-02 09:19:00+05:30  470.95  471.7  470.45  471.50   15372


When I run ingest function, I'm getting this error:

Traceback (most recent call last):
 
File "C:\Users\Ramesh\anaconda3\envs\py35\Scripts\zipline-script.py", line 11, in <module>
    load_entry_point
('zipline==1.1.1+213.g503fd34', 'console_scripts', 'zipline')()
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\click\core.py", line 722, in __call__
   
return self.main(*args, **kwargs)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\click\core.py", line 697, in main
    rv
= self.invoke(ctx)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\click\core.py", line 1066, in invoke
   
return _process_result(sub_ctx.command.invoke(sub_ctx))
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\click\core.py", line 895, in invoke
   
return ctx.invoke(self.callback, **ctx.params)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\click\core.py", line 535, in invoke
   
return callback(*args, **kwargs)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\zipline\__main__.py", line 323, in ingest
    show_progress
,
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\zipline\data\bundles\core.py", line 451, in ingest
    pth
.data_path([name, timestr], environ=environ),
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\zipline\data\bundles\csvdir.py", line 110, in ingest
    dfMetadata
.iloc[iSid] = start_date, end_date, ac_date, S
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\pandas\core\indexing.py", line 132, in __setitem__
   
self._setitem_with_indexer(indexer, value)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\pandas\core\indexing.py", line 531, in _setitem_with_indexer
    setter
(item, v)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\pandas\core\indexing.py", line 461, in setter
    s
._data = s._data.setitem(indexer=pi, value=v)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\pandas\core\internals.py", line 2917, in setitem
   
return self.apply('setitem', **kwargs)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\pandas\core\internals.py", line 2890, in apply
    applied
= getattr(b, f)(**kwargs)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\pandas\core\internals.py", line 642, in setitem
    values
, _, value, _ = self._try_coerce_args(self.values, value)
 
File "C:\Users\Ramesh\anaconda3\envs\py35\lib\site-packages\pandas\core\internals.py", line 2094, in _try_coerce_args
   
raise TypeError("cannot coerce a Timestamp with a tz on a "
TypeError: cannot coerce a Timestamp with a tz on a naive Block


If I remove timestamp aware (line 68 and 70 of csvdir.py) this works, but I don't want to do that since my data is in IST, not UST. 

Please help.


Best,
Ramesh
calendar_utils.py
exchange_calendar_nse.py
csvdir.py
extension.py

Vithal Patil

unread,
Feb 24, 2018, 6:17:42 PM2/24/18
to Zipline Python Opensource Backtester
Hi,

Can you please let me know where did you edit the extension.py  in your anaconda setup.

Adrian Cheung

unread,
Mar 3, 2018, 12:34:27 AM3/3/18
to Zipline Python Opensource Backtester
HI, Vithal

The location as below for Win10:

C:\Users\user\.zipline

Please be aware that the folder is with a dot in front of zipline (.zipline).


Regards
Adrian
Reply all
Reply to author
Forward
0 new messages