Open pratiksgith opened 4 years ago
I've been trying to run minute-level backtests with some issues that appear similar to yours. I've got it to work now but my output has a strange quality. Even though I have minute level data like you do:
2020-05-08 09:44:00+00:00 2020-05-08 09:45:00+00:00 2020-05-08 09:46:00+00:00
My output zeros out everything but the day, tossing the hour and minute detail out (again, same as yours). So, for a given trading day, I've got a series of +400 lines of results that all share the same timestamp (that day's date). Did you figure out a way to pull through the hour/minute level detail through to the output level? Output:
2020-05-08 00:00:00+00:00 2020-05-08 00:00:00+00:00 2020-05-08 00:00:00+00:00
Hi @tstevens02127, how were you able to avoid the KeyError: 0 error when running data.history?
If I recall correctly, yes, I was able to avoid that KeyError
I am attempting to use zipline locally again with minute data. I've only gotten daily data to work. Could someone provide a link to a minute data .csv file with the correct formatting?
Dear Zipline Maintainers,
Before I tell you about my issue, let me describe my environment:
Environment
Now that you know a little about me, let me tell you about the issue I am having:
Description of Issue
What did you expect to happen? I expected to get minute by minute historical price of selected stock
What happened instead? Following error thrown on jupyter notebook
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\IPython\core\interactiveshell.py in run_cell_magic(self, magic_name, line, cell) 2357 with self.builtin_trap: 2358 args = (magic_arg_s, cell) -> 2359 result = fn(*args, **kwargs) 2360 return result 2361
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\zipline__main__.py in zipline_magic(line, cell) 309 '%s%%zipline' % ((cell or '') and '%'), 310 # don't use system exit and propogate errors to the caller --> 311 standalone_mode=False, 312 ) 313 except SystemExit as e:
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\click\core.py in main(self, args, prog_name, complete_var, standalone_mode, extra) 715 try: 716 with self.make_context(prog_name, args, extra) as ctx: --> 717 rv = self.invoke(ctx) 718 if not standalone_mode: 719 return rv
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\click\core.py in invoke(self, ctx) 954 _maybe_show_deprecated_notice(self) 955 if self.callback is not None: --> 956 return ctx.invoke(self.callback, **ctx.params) 957 958
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\click\core.py in invoke(*args, kwargs) 553 with augment_usage_errors(self): 554 with ctx: --> 555 return callback(*args, *kwargs) 556 557 def forward(args, kwargs):
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\click\decorators.py in new_func(*args, kwargs) 15 """ 16 def new_func(*args, *kwargs): ---> 17 return f(get_current_context(), args, kwargs) 18 return update_wrapper(new_func, f) 19
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\zipline__main__.py in run(ctx, algofile, algotext, define, data_frequency, capital_base, bundle, bundle_timestamp, start, end, output, trading_calendar, print_algo, metrics_set, local_namespace, blotter) 274 local_namespace=local_namespace, 275 environ=os.environ, --> 276 blotter=blotter, 277 ) 278
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\zipline\utils\run_algo.py in _run(handle_data, initialize, before_trading_start, analyze, algofile, algotext, defines, data_frequency, capital_base, data, bundle, bundle_timestamp, start, end, output, trading_calendar, print_algo, metrics_set, local_namespace, environ, blotter) 227 ).run( 228 data, --> 229 overwrite_sim_params=False, 230 ) 231
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\zipline\algorithm.py in run(self, data, overwrite_sim_params) 754 try: 755 perfs = [] --> 756 for perf in self.get_generator(): 757 perfs.append(perf) 758
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\zipline\gens\tradesimulation.py in transform(self) 204 for dt, action in self.clock: 205 if action == BAR: --> 206 for capital_change_packet in every_bar(dt): 207 yield capital_change_packet 208 elif action == SESSION_START:
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\zipline\gens\tradesimulation.py in every_bar(dt_to_use, current_data, handle_data) 132 metrics_tracker.process_commission(commission) 133 --> 134 handle_data(algo, current_data, dt_to_use) 135 136 # grab any new orders from the blotter, then clear the list.
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\zipline\utils\events.py in handle_data(self, context, data, dt) 214 context, 215 data, --> 216 dt, 217 ) 218
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\zipline\utils\events.py in handle_data(self, context, data, dt) 233 """ 234 if self.rule.should_trigger(dt): --> 235 self.callback(context, data) 236 237
c:\users\user.name\appdata\local\continuum\miniconda3\envs\env_zipline\lib\site-packages\zipline\algorithm.py in handle_data(self, data) 467 def handle_data(self, data): 468 if self._handle_data: --> 469 self._handle_data(self, data) 470 471 def analyze(self, perf):