From 6b1cdb692949bcf6e997085bab5e88f583911566 Mon Sep 17 00:00:00 2001 From: Jean Bredeche Date: Wed, 27 Apr 2016 16:19:13 -0400 Subject: [PATCH] DOC: Updated whatsnew with Q2 information. --- docs/source/appendix.rst | 9 ++++++++ docs/source/whatsnew/1.0.0.txt | 42 ++++++++++++++++++++++++++++++++++ zipline/data/data_portal.py | 33 ++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/docs/source/appendix.rst b/docs/source/appendix.rst index 96696bac..b5792fd5 100644 --- a/docs/source/appendix.rst +++ b/docs/source/appendix.rst @@ -15,6 +15,12 @@ The following methods are available for use in the ``initialize``, In all listed functions, the ``self`` argument is implicitly the currently-executing :class:`~zipline.algorithm.TradingAlgorithm` instance. +Data Object +``````````` + +.. autoclass:: zipline.protocol.BarData + :members: + Scheduling Functions ```````````````````` @@ -271,6 +277,9 @@ Readers .. autoclass:: zipline.assets.AssetFinderCachedEquities :members: +.. autoclass:: zipline.data.data_portal.DataPortal + :members: + Bundles ``````` .. autofunction:: zipline.data.bundles.register diff --git a/docs/source/whatsnew/1.0.0.txt b/docs/source/whatsnew/1.0.0.txt index 2aa6de05..65dd6e0f 100644 --- a/docs/source/whatsnew/1.0.0.txt +++ b/docs/source/whatsnew/1.0.0.txt @@ -12,6 +12,45 @@ Development Highlights ~~~~~~~~~~ +Zipline 1.0 Rewrite (:issue:`1105`) +``````````````````````````````````` + +We have rewritten a lot of Zipline and its basic concepts in order to improve +runtime performance. At the same time, we've introduced several new APIs. + +At a high level, earlier versions of Zipline simulations pulled from a +multiplexed stream of data sources, which were merged via heapq. This stream was +fed to the main simulation loop, driving the clock forward. This strong +dependency on reading all the data made it difficult to optimize simulation +performance because there was no connection between the amount of data we +fetched and the amount of data actually used by the algorithm. + +Now, we only fetch data when the algorithm needs it. A new class, +:class:`~zipline.data.data_portal.DataPortal`, dispatches data requests to +various data sources and returns the requested values. This makes the runtime of +a simulation scale much more closely with the complexity of the algorithm, +rather than with the number of assets provided by the data sources. + +Instead of the data stream driving the clock, now simulations iterate through a +pre-calculated set of day or minute timestamps. The timestamps are emitted by +:class:`~zipline.gens.sim_engine.MinuteSimulationClock` and +:class:`~zipline.gens.sim_engine.DailySimulationClock`, and consumed by the main +loop in :meth:`~zipline.gens.tradesimulation.AlgorithmSimulator.transform`. + +We've retired the ``data[sid(N)]`` and ``history`` APIs, replacing them with +several methods on the :class:`~zipline.protocol.BarData` object: +:meth:`zipline.protocol.BarData.current`, +:meth:`zipline.protocol.BarData.history`, +:meth:`zipline.protocol.BarData.can_trade`, and +:meth:`zipline.protocol.BarData.is_stale`. Old APIs will continue to work for +now, but will issue deprecation warnings. + +You can now pass in an adjustments source to the +:class:`~zipline.data.data_portal.DataPortal`, and we will apply adjustments to +the pricing data when looking backwards at data. Prices and volumes for +execution and presented to the algorithm in data.current are the as-traded value +of the asset. + New Entry Points (:issue:`1173` and :issue:`1178`) `````````````````````````````````````````````````` @@ -131,6 +170,9 @@ Enhancements implements the Bollinger Bands technical indicator: https://en.wikipedia.org/wiki/Bollinger_Bands (:issue:`1199`). +* Fetcher has been moved from Quantopian internal code into Zipline + (:issue:`1105`). + Experimental Features ~~~~~~~~~~~~~~~~~~~~~ diff --git a/zipline/data/data_portal.py b/zipline/data/data_portal.py index 09e8994b..6f6cda37 100644 --- a/zipline/data/data_portal.py +++ b/zipline/data/data_portal.py @@ -459,6 +459,39 @@ class DailyHistoryAggregator(object): class DataPortal(object): + """Interface to all of the data that a zipline simulation needs. + + This is used by the simulation runner to answer questions about the data, + like getting the prices of assets on a given day or to service history + calls. + + Parameters + ---------- + env : TradingEnvironment + The trading environment for the simulation. This includes the trading + calendar and benchmark data. + equity_daily_reader : BcolzDailyBarReader, optional + The daily bar ready for equities. This will be used to service + daily data backtests or daily history calls in a minute backetest. + If a daily bar reader is not provided but a minute bar reader is, + the minutes will be rolled up to serve the daily requests. + equity_minute_reader : BcolzMinuteBarReader, optional + The minute bar reader for equities. This will be used to service + minute data backtests or minute history calls. This can be used + to serve daily calls if no daily bar reader is provided. + future_daily_reader : BcolzDailyBarReader, optional + The daily bar ready for futures. This will be used to service + daily data backtests or daily history calls in a minute backetest. + If a daily bar reader is not provided but a minute bar reader is, + the minutes will be rolled up to serve the daily requests. + future_minute_reader : BcolzMinuteBarReader, optional + The minute bar reader for futures. This will be used to service + minute data backtests or minute history calls. This can be used + to serve daily calls if no daily bar reader is provided. + adjustment_reader : SQLiteAdjustmentWriter, optional + The adjustment reader. This is used to apply splits, dividends, and + other adjustment data to the raw data from the readers. + """ def __init__(self, env, equity_daily_reader=None,