MAINT: Use TradingCalendar objects for bundles (#1397)

* MAINT: Use TradingCalendar objects for bundles

Instead of trading days, opens, and closes, register now takes a
TradingCalendar object, along with a start_session and end_session. The
ingest function is now passed these values instead as well.

* Accept calendar name in addition to the actual object

* Updates bundles documentation for changes

* Fix typo in docs

* Use class formatting

* Force start_session and end_session within the bounds of the calendar

* Use UTC timestamps in test_core

* Document Trading Calendar API in appendix.rst
This commit is contained in:
Andrew Daniels
2016-08-17 13:37:07 -04:00
committed by GitHub
parent deac07d264
commit 440806ad60
8 changed files with 142 additions and 75 deletions
+19
View File
@@ -261,6 +261,24 @@ Asset Metadata
.. autoclass:: zipline.assets.AssetConvertible
:members:
Trading Calendar API
~~~~~~~~~~~~~~~~~~~~
.. autofunction:: zipline.utils.calendars.get_calendar
.. autoclass:: zipline.utils.calendars.TradingCalendar
:members:
.. autofunction:: zipline.utils.calendars.register_calendar
.. autofunction:: zipline.utils.calendars.register_calendar_type
.. autofunction:: zipline.utils.calendars.deregister_calendar
.. autofunction:: zipline.utils.calendars.clear_calendars
Data API
~~~~~~~~
@@ -318,6 +336,7 @@ Bundles
.. autofunction:: zipline.data.bundles.yahoo_equities
Utilities
~~~~~~~~~
+17 -3
View File
@@ -216,6 +216,8 @@ The signature of the ingest function should be:
daily_bar_writer,
adjustment_writer,
calendar,
start_session,
end_session,
cache,
show_progress,
output_dir)
@@ -300,9 +302,21 @@ have.
``calendar``
````````````
``calendar`` is a ``pandas.DatetimeIndex`` object holding all of the trading
days that the bundle should load data for. The calendar is provided to help some
bundles generate queries for the days needed.
``calendar`` is an instance of
:class:`zipline.utils.calendars.TradingCalendar`. The calendar is provided to
help some bundles generate queries for the days needed.
``start_session``
````````````
``start_session`` is a :class:`pandas.Timestamp` object indicating the first
day that the bundle should load data for.
``end_session``
````````````
``end_session`` is a :class:`pandas.Timestamp` object indicating the last day
that the bundle should load data for.
``cache``
`````````