From 14360ca4b8737c9ff1c26fceaa6a19efa5f689e5 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Fri, 26 Feb 2016 14:50:38 -0500 Subject: [PATCH] DOC: Minor docstring tweaks. --- etc/requirements_dev.txt | 1 + zipline/pipeline/data/dataset.py | 4 ++-- zipline/pipeline/factors/events.py | 29 +++++++++++++++++++++++++---- zipline/pipeline/factors/factor.py | 8 ++++---- zipline/pipeline/factors/latest.py | 3 +++ 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/etc/requirements_dev.txt b/etc/requirements_dev.txt index 5f36f1db..c28726cc 100644 --- a/etc/requirements_dev.txt +++ b/etc/requirements_dev.txt @@ -1,4 +1,5 @@ # Testing +coverage==4.0.3 nose==1.3.7 nose-parameterized==0.5.0 nose-ignore-docstring==0.2 diff --git a/zipline/pipeline/data/dataset.py b/zipline/pipeline/data/dataset.py index 2207a70b..cf88d1f0 100644 --- a/zipline/pipeline/data/dataset.py +++ b/zipline/pipeline/data/dataset.py @@ -100,8 +100,8 @@ class BoundColumn(Term): The dtype of data produced when this column is loaded. latest : zipline.pipeline.data.Factor or zipline.pipeline.data.Filter A Filter/Factor computing the most recently known value of this column - on each date. Produces a Filter if self.dtype == np.bool_, otherwise - produces a Factor. + on each date. Produces a Filter if self.dtype == ``np.bool_``, + otherwise produces a Factor. dataset : zipline.pipeline.data.DataSet The dataset to which this column is bound. name : str diff --git a/zipline/pipeline/factors/events.py b/zipline/pipeline/factors/events.py index cee82d2d..9efd517f 100644 --- a/zipline/pipeline/factors/events.py +++ b/zipline/pipeline/factors/events.py @@ -89,9 +89,18 @@ class BusinessDaysUntilNextEarnings(BusinessDaysUntilNextEvents): Factor returning the number of **business days** (not trading days!) until the next known earnings date for each asset. + Assets that announced or will announce earnings on the day of ``compute`` + will produce a value of 0.0. Assets that will announce the event on the + next upcoming business day will produce a value of 1.0. + + Assets for which the date of the next earnings announcement is ``NaT`` will + produce a value of ``NaN``. This most commonly occurs because many + companies do not publish the exact date of their upcoming earnings + announcements until a few weeks before the announcement. + See Also -------- - zipline.pipeline.factors.BusinessDaysSincePreviousEarnings + BusinessDaysSincePreviousEarnings """ inputs = [EarningsCalendar.next_announcement] @@ -101,9 +110,21 @@ class BusinessDaysSincePreviousEarnings(BusinessDaysSincePreviousEvents): Factor returning the number of **business days** (not trading days!) since the most recent earnings date for each asset. + Assets that announced or will announce earnings on the day of ``compute`` + will produce a value of 0.0. Assets that will announce the event on the + next upcoming business day will produce a value of 1.0. + + Assets which announced or will announce the earnings today will produce a + value of 0.0. Assets that announced the on the previous business day will + produce a value of 1.0. + + Assets for which the previous earnings date is `NaT` will produce a value + of `NaN`. This will happen in the interval between IPO and first earnings + for most companies. + See Also -------- - zipline.pipeline.factors.BusinessDaysUntilNextEarnings + BusinessDaysUntilNextEarnings """ inputs = [EarningsCalendar.previous_announcement] @@ -117,7 +138,7 @@ class BusinessDaysSincePreviousCashBuybackAuth( See Also -------- - zipline.pipeline.factors.BusinessDaysSincePreviousCashBuybackAuth + BusinessDaysSincePreviousCashBuybackAuth """ inputs = [CashBuybackAuthorizations.previous_announcement_date] @@ -132,6 +153,6 @@ class BusinessDaysSincePreviousShareBuybackAuth( See Also -------- - zipline.pipeline.factors.BusinessDaysSincePreviousShareBuybackAuth + BusinessDaysSincePreviousShareBuybackAuth """ inputs = [ShareBuybackAuthorizations.previous_announcement_date] diff --git a/zipline/pipeline/factors/factor.py b/zipline/pipeline/factors/factor.py index 2fa8875e..31649dec 100644 --- a/zipline/pipeline/factors/factor.py +++ b/zipline/pipeline/factors/factor.py @@ -455,10 +455,10 @@ class Factor(CompositeTerm): Return True for assets falling below this percentile in the data. mask : zipline.pipeline.Filter, optional A Filter representing assets to consider when percentile - thresholds. If mask is supplied, percentile cutoffs are computed - each day using only assets for which `mask` returns True, and - assets not passing `mask` will produce False in the output of this - filter as well. + calculating thresholds. If mask is supplied, percentile cutoffs + are computed each day using only assets for which ``mask`` returns + True. Assets for which ``mask`` produces False will produce False + in the output of this Factor as well. Returns ------- diff --git a/zipline/pipeline/factors/latest.py b/zipline/pipeline/factors/latest.py index 0b134f9b..4a7e3092 100644 --- a/zipline/pipeline/factors/latest.py +++ b/zipline/pipeline/factors/latest.py @@ -8,6 +8,9 @@ from ..mixins import SingleInputMixin class Latest(SingleInputMixin, CustomFactor): """ Factor producing the most recently-known value of `inputs[0]` on each day. + + The `.latest` attribute of DataSet columns returns an instance of this + Factor. """ window_length = 1