Backtesting against current day's trading data after market close

104 views
Skip to first unread message

Adam Zeldis

unread,
Sep 13, 2016, 2:16:22 AM9/13/16
to Zipline Python Opensource Backtester
I am trying to run my algorithm against the market data that was generated today.  I successfully am able to pull the latest data via a "zipline ingest -b quandl" command.  However, when I attempt to run my algorithm with today (9/12/2016) as an end date, I receive the error below.  I attempted updating my ~/.zipline/^GSPC_benchmark.csv with today's market close data but to no avail.  Has anyone been able to run their algoirthm with the data from the current day after the market close using Quandl?  Any help would be much appreciated.

zipline run -f ./algos/zipline/rotation.py --bundle quandl --start 2016-9-2 --end 2016-9-12 -o ./result.pickle


Traceback (most recent call last):

  File "/usr/local/bin/zipline", line 11, in <module>

    sys.exit(main())

  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__

    return self.main(*args, **kwargs)

  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 696, in main

    rv = self.invoke(ctx)

  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke

    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke

    return ctx.invoke(self.callback, **ctx.params)

  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke

    return callback(*args, **kwargs)

  File "/usr/local/lib/python2.7/site-packages/zipline/__main__.py", line 97, in _

    return f(*args, **kwargs)

  File "/usr/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func

    return f(get_current_context(), *args, **kwargs)

  File "/usr/local/lib/python2.7/site-packages/zipline/__main__.py", line 240, in run

    environ=os.environ,

  File "/usr/local/lib/python2.7/site-packages/zipline/utils/run_algo.py", line 180, in _run

    overwrite_sim_params=False,

  File "/usr/local/lib/python2.7/site-packages/zipline/algorithm.py", line 688, in run

    for perf in self.get_generator():

  File "/usr/local/lib/python2.7/site-packages/zipline/gens/tradesimulation.py", line 228, in transform

    handle_benchmark(normalize_date(dt))

  File "/usr/local/lib/python2.7/site-packages/zipline/gens/tradesimulation.py", line 188, in handle_benchmark

    benchmark_source.get_value(date)

  File "/usr/local/lib/python2.7/site-packages/zipline/sources/benchmark_source.py", line 73, in get_value

    return self._precalculated_series.loc[dt]

  File "/usr/local/lib/python2.7/site-packages/pandas/core/indexing.py", line 1227, in __getitem__

    return self._getitem_axis(key, axis=0)

  File "/usr/local/lib/python2.7/site-packages/pandas/core/indexing.py", line 1371, in _getitem_axis

    self._has_valid_type(key, axis)

  File "/usr/local/lib/python2.7/site-packages/pandas/core/indexing.py", line 1333, in _has_valid_type

    error()

  File "/usr/local/lib/python2.7/site-packages/pandas/core/indexing.py", line 1320, in error

    (key, self.obj._get_axis_name(axis)))

KeyError: 'the label [2016-09-12 00:00:00+00:00] is not in the [index]'

Adam03

unread,
Dec 12, 2016, 8:52:13 AM12/12/16
to Zipline Python Opensource Backtester
I am running into a similar error, i posted to stackoverflow with nothing:


any thoughts as to why ?  it seems to run on a delay...

Ed Bartosh

unread,
Dec 12, 2016, 9:27:47 AM12/12/16
to Adam03, Zipline Python Opensource Backtester
Hi Adam,

Did you ingest the bundle when market was already closed?

Can you show me the output of this command on the moment of ingesting?

$ python -c 'from zipline.utils.calendars.exchange_calendar_nyse import NYSEExchangeCalendar; print NYSEExchangeCalendar().last_session'

Regards,

Ed


--
You received this message because you are subscribed to the Google Groups "Zipline Python Opensource Backtester" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zipline+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
BR,
Ed
Reply all
Reply to author
Forward
0 new messages