Hello,
I'm trying to get minute data custom bundles from cvs files to work in zipline 1.0.2, python 2.7, OSX Sierra 10.12. I've combined the suggestions from Ed B and Richard P to make something that works for me.
First, thanks for that, I've been trying to get cvs minute data working with bundles for some time on the side, and it's really good to see the ingestion working. This is my first post here, but I've been reading and studying posts for quite some time.
The problem i've having is in I think the timezone info, but I'm not sure. The simplest initial csv data I ingest is from google, so it looks like:
bash-3.2$ head ../csvdir/AAL.csv
ts,o,h,l,c,v
2016-10-05 09:31:00+00:00,37.76,37.82,37.75,37.82,11000.0
2016-10-05 09:32:00+00:00,37.58,37.76,37.55,37.76,16475.0
2016-10-05 09:33:00+00:00,37.485,37.56,37.45,37.53,20764.0
2016-10-05 09:34:00+00:00,37.62,37.64,37.485,37.485,42301.0
2016-10-05 09:35:00+00:00,37.63,37.64,37.57,37.62,28904.0
2016-10-05 09:36:00+00:00,37.667,37.68,37.6,37.63,73997.0
2016-10-05 09:37:00+00:00,37.66,37.71,37.64,37.65,22911.0
2016-10-05 09:38:00+00:00,37.65,37.66,37.59,37.66,16055.0
2016-10-05 09:39:00+00:00,37.7,37.73,37.65,37.65,11555.0
bash-3.2$
The ingestion works much along the same lines as your csvdir and viacsv codes from your recent posts. And the result is an ingested bundle.
bash-3.2$ zipline bundles
quandl <no ingestions>
quantopian-quandl <no ingestions>
sharkwave-m 2016-10-26 15:50:07.242376
bash-3.2$ pwd
Note the timezone is not explicitly addressed in those csv ingestion routines, and the google data is clearly US/Eastern. The problem I'm having in a simple algo to just test buy orders is (please excuse the full dump, but it's best):
bash-3.2$ zipline run -f test_sharkwave.py --bundle sharkwave-m -s 2016-10-06 -e 2016-10-25
get_datetime 2016-10-06 20:00:00+00:00 iNumEqt= 160
Ordering 0.00625 of AAL
Traceback (most recent call last):
File "//anaconda/bin/zipline", line 11, in <module>
load_entry_point('zipline==1.0.2', 'console_scripts', 'zipline')()
File "/anaconda/lib/python2.7/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/anaconda/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/anaconda/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/anaconda/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/anaconda/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/anaconda/lib/python2.7/site-packages/zipline/__main__.py", line 97, in _
return f(*args, **kwargs)
File "/anaconda/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/anaconda/lib/python2.7/site-packages/zipline/__main__.py", line 240, in run
environ=os.environ,
File "/anaconda/lib/python2.7/site-packages/zipline/utils/run_algo.py", line 180, in _run
overwrite_sim_params=False,
File "/anaconda/lib/python2.7/site-packages/zipline/algorithm.py", line 688, in run
for perf in self.get_generator():
File "/anaconda/lib/python2.7/site-packages/zipline/gens/tradesimulation.py", line 220, in transform
for capital_change_packet in every_bar(dt):
File "/anaconda/lib/python2.7/site-packages/zipline/gens/tradesimulation.py", line 133, in every_bar
handle_data(algo, current_data, dt_to_use)
File "/anaconda/lib/python2.7/site-packages/zipline/utils/events.py", line 184, in handle_data
dt,
File "/anaconda/lib/python2.7/site-packages/zipline/utils/events.py", line 203, in handle_data
self.callback(context, data)
File "/anaconda/lib/python2.7/site-packages/zipline/algorithm.py", line 459, in handle_data
self._handle_data(self, data)
File "test_sharkwave.py", line 11, in handle_data
order_target_percent(S,fW)
File "/anaconda/lib/python2.7/site-packages/zipline/utils/api_support.py", line 51, in wrapped
return getattr(get_algo_instance(), f.__name__)(*args, **kwargs)
File "/anaconda/lib/python2.7/site-packages/zipline/utils/api_support.py", line 120, in wrapped_method
return method(self, *args, **kwargs)
File "/anaconda/lib/python2.7/site-packages/zipline/algorithm.py", line 1983, in order_target_percent
style=style)
File "/anaconda/lib/python2.7/site-packages/zipline/utils/api_support.py", line 120, in wrapped_method
return method(self, *args, **kwargs)
File "/anaconda/lib/python2.7/site-packages/zipline/algorithm.py", line 1916, in order_target_value
target_amount = self._calculate_order_value_amount(asset, target)
File "/anaconda/lib/python2.7/site-packages/zipline/algorithm.py", line 1332, in _calculate_order_value_amount
self.trading_client.current_data.current(asset, "price")
File "zipline/_protocol.pyx", line 124, in zipline._protocol.check_parameters.__call__.assert_keywords_and_call (zipline/_protocol.c:2816)
File "zipline/_protocol.pyx", line 328, in zipline._protocol.BarData.current (zipline/_protocol.c:4246)
File "/anaconda/lib/python2.7/site-packages/zipline/data/data_portal.py", line 407, in get_spot_value
return self._get_daily_data(asset, field, session_label)
File "/anaconda/lib/python2.7/site-packages/zipline/data/data_portal.py", line 600, in _get_daily_data
asset, found_dt, "close"
File "/anaconda/lib/python2.7/site-packages/zipline/data/dispatch_bar_reader.py", line 84, in get_value
return r.get_value(sid, dt, field)
File "/anaconda/lib/python2.7/site-packages/zipline/data/us_equity_pricing.py", line 707, in get_value
ix = self.sid_day_index(sid, day)
File "/anaconda/lib/python2.7/site-packages/zipline/data/us_equity_pricing.py", line 675, in sid_day_index
offset = day_loc - self._calendar_offsets[sid]
KeyError: Equity(0, symbol=u'AAL', asset_name='', exchange=u'YAHOO', start_date=Timestamp('2016-10-05 09:31:00+0000', tz='UTC'), end_date=Timestamp('2016-10-25 16:00:00+0000', tz='UTC'), first_traded=None, auto_close_date=Timestamp('2016-10-26 16:00:00+0000', tz='UTC'), exchange_full=u'YAHOO')
bash-3.2$
So, the exchange I set is 'YAHOO', which may be the problem (Ed B, I didn't find code for register_calendar_alias, can you clarify?), but the timestamps and timezones seem mismatched.
In any case, thanks in advance, getting tired of beating my head against the bricks alone, thought to try posting.
Dylan