id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
16,600 | quantopian/zipline | quantopian_zipline/zipline/pipeline/hooks/no.py | zipline.pipeline.hooks.no.NoHooks | from interface import implements
from .iface import PipelineHooks
from zipline.utils.compat import contextmanager
class NoHooks(implements(PipelineHooks)):
"""A PipelineHooks that defines no-op methods for all available hooks.
"""
@contextmanager
def running_pipeline(self, pipeline, start_date, end_da... |
class NoHooks(implements(PipelineHooks)):
'''A PipelineHooks that defines no-op methods for all available hooks.
'''
@contextmanager
def running_pipeline(self, pipeline, start_date, end_date):
pass
@contextmanager
def computing_chunk(self, terms, start_date, end_date):
pass
... | 9 | 1 | 2 | 0 | 2 | 0 | 1 | 0.15 | 1 | 0 | 0 | 0 | 4 | 0 | 4 | 4 | 18 | 3 | 13 | 9 | 4 | 2 | 9 | 5 | 4 | 1 | 1 | 0 | 4 |
16,601 | quantopian/zipline | quantopian_zipline/zipline/pipeline/hooks/progress.py | zipline.pipeline.hooks.progress.IPythonWidgetProgressPublisher | from zipline.utils.string_formatting import bulleted_list
class IPythonWidgetProgressPublisher(object):
"""A progress publisher that publishes to an IPython/Jupyter widget.
"""
def __init__(self):
missing = []
if not HAVE_WIDGETS:
missing.append('ipywidgets')
elif not H... |
class IPythonWidgetProgressPublisher(object):
'''A progress publisher that publishes to an IPython/Jupyter widget.
'''
def __init__(self):
pass
def publish(self, model):
pass
def _ensure_displayed(self):
pass
def _stop_displaying(self):
pass
@staticmethod... | 11 | 2 | 20 | 2 | 15 | 3 | 3 | 0.2 | 1 | 3 | 1 | 0 | 5 | 7 | 7 | 7 | 165 | 24 | 118 | 28 | 107 | 24 | 64 | 26 | 55 | 6 | 1 | 2 | 20 |
16,602 | quantopian/zipline | quantopian_zipline/zipline/pipeline/hooks/progress.py | zipline.pipeline.hooks.progress.ProgressHooks | from zipline.utils.compat import contextmanager, escape_html
from interface import implements
from .iface import PipelineHooks
class ProgressHooks(implements(PipelineHooks)):
"""
Hooks implementation for displaying progress.
Parameters
----------
publisher_factory : callable
Function produ... |
class ProgressHooks(implements(PipelineHooks)):
'''
Hooks implementation for displaying progress.
Parameters
----------
publisher_factory : callable
Function producing a new object with a ``publish()`` method that takes
a ``ProgressModel`` and publishes progress to a consumer.
'... | 16 | 3 | 8 | 0 | 7 | 1 | 1 | 0.28 | 1 | 3 | 2 | 0 | 7 | 5 | 9 | 9 | 97 | 11 | 67 | 21 | 51 | 19 | 54 | 15 | 44 | 3 | 1 | 2 | 12 |
16,603 | quantopian/zipline | quantopian_zipline/zipline/pipeline/hooks/progress.py | zipline.pipeline.hooks.progress.ProgressModel | import time
class ProgressModel(object):
"""
Model object for tracking progress of a Pipeline execution.
Parameters
----------
nterms : int
Number of terms in the execution plan of the Pipeline being run.
start_date : pd.Timestamp
Start date of the range over which ``plan`` wil... |
class ProgressModel(object):
'''
Model object for tracking progress of a Pipeline execution.
Parameters
----------
nterms : int
Number of terms in the execution plan of the Pipeline being run.
start_date : pd.Timestamp
Start date of the range over which ``plan`` will be computed... | 22 | 1 | 6 | 1 | 4 | 1 | 1 | 0.73 | 1 | 2 | 0 | 0 | 15 | 13 | 15 | 15 | 149 | 28 | 70 | 38 | 48 | 51 | 60 | 32 | 44 | 2 | 1 | 1 | 18 |
16,604 | quantopian/zipline | quantopian_zipline/zipline/pipeline/hooks/progress.py | zipline.pipeline.hooks.progress.TestingProgressPublisher | from collections import namedtuple
class TestingProgressPublisher(object):
"""A progress publisher that records a trace of model states for testing.
"""
TraceState = namedtuple('TraceState', ['state', 'percent_complete', 'execution_bounds', 'current_chunk_bounds', 'current_work'])
def __init__(self):
... |
class TestingProgressPublisher(object):
'''A progress publisher that records a trace of model states for testing.
'''
def __init__(self):
pass
def publish(self, model):
pass | 3 | 1 | 6 | 0 | 6 | 0 | 1 | 0.1 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 2 | 24 | 2 | 20 | 5 | 17 | 2 | 6 | 5 | 3 | 1 | 1 | 0 | 2 |
16,605 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/base.py | zipline.pipeline.loaders.base.PipelineLoader | from interface import default, Interface
class PipelineLoader(Interface):
"""Interface for PipelineLoaders.
"""
def load_adjusted_array(self, domain, columns, dates, sids, mask):
"""
Load data for ``columns`` as AdjustedArrays.
Parameters
----------
domain : ziplin... |
class PipelineLoader(Interface):
'''Interface for PipelineLoaders.
'''
def load_adjusted_array(self, domain, columns, dates, sids, mask):
'''
Load data for ``columns`` as AdjustedArrays.
Parameters
----------
domain : zipline.pipeline.domain.Domain
The d... | 5 | 3 | 16 | 2 | 2 | 13 | 1 | 4.67 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 2 | 39 | 5 | 6 | 4 | 1 | 28 | 4 | 3 | 1 | 1 | 1 | 0 | 2 |
16,606 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/core.py | zipline.pipeline.loaders.blaze.core.BlazeLoader | from interface import implements
from zipline.pipeline.common import AD_FIELD_NAME, SID_FIELD_NAME, TS_FIELD_NAME
from toolz import complement, compose, first, flip, groupby, memoize, merge
from weakref import WeakKeyDictionary
from zipline.utils.pandas_utils import ignore_pandas_nan_categorical_warning
from six import... |
class BlazeLoader(implements(PipelineLoader)):
'''A PipelineLoader for datasets constructed with ``from_blaze``.
Parameters
----------
dsmap : mapping, optional
An initial mapping of datasets to ``ExprData`` objects.
NOTE: Further mutations to this map will not be reflected by this
... | 16 | 4 | 18 | 2 | 10 | 6 | 2 | 0.61 | 1 | 9 | 2 | 0 | 11 | 2 | 12 | 12 | 244 | 32 | 132 | 47 | 101 | 80 | 55 | 31 | 41 | 5 | 1 | 1 | 20 |
16,607 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/core.py | zipline.pipeline.loaders.blaze.core.ExprData | class ExprData(object):
"""A pair of expressions and data resources. The expressions will be
computed using the resources as the starting scope.
Parameters
----------
expr : Expr
The baseline values.
deltas : Expr, optional
The deltas for the data.
checkpoints : Expr, option... | class ExprData(object):
'''A pair of expressions and data resources. The expressions will be
computed using the resources as the starting scope.
Parameters
----------
expr : Expr
The baseline values.
deltas : Expr, optional
The deltas for the data.
checkpoints : Expr, optiona... | 11 | 1 | 8 | 0 | 7 | 0 | 1 | 0.25 | 1 | 3 | 0 | 0 | 7 | 4 | 8 | 8 | 86 | 10 | 61 | 22 | 46 | 15 | 33 | 16 | 24 | 2 | 1 | 1 | 11 |
16,608 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/core.py | zipline.pipeline.loaders.blaze.core.InvalidField | from abc import ABCMeta, abstractproperty
from six import with_metaclass, PY2, itervalues, iteritems
class InvalidField(with_metaclass(ABCMeta)):
"""A field that raises an exception indicating that the
field was invalid.
Parameters
----------
field : str
The name of the field.
type_ : ... |
class InvalidField(with_metaclass(ABCMeta)):
'''A field that raises an exception indicating that the
field was invalid.
Parameters
----------
field : str
The name of the field.
type_ : dshape
The shape of the field.
'''
@abstractproperty
def error_format(self):
... | 5 | 1 | 3 | 0 | 3 | 0 | 1 | 0.91 | 1 | 2 | 0 | 2 | 3 | 2 | 3 | 3 | 23 | 3 | 11 | 7 | 6 | 10 | 8 | 6 | 4 | 1 | 1 | 0 | 3 |
16,609 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/core.py | zipline.pipeline.loaders.blaze.core.NoMetaDataWarning | class NoMetaDataWarning(UserWarning):
"""Warning used to signal that no deltas or checkpoints could be found and
none were provided.
Parameters
----------
expr : Expr
The expression that was searched.
field : {'deltas', 'checkpoints'}
The field that was looked up.
"""
... | class NoMetaDataWarning(UserWarning):
'''Warning used to signal that no deltas or checkpoints could be found and
none were provided.
Parameters
----------
expr : Expr
The expression that was searched.
field : {'deltas', 'checkpoints'}
The field that was looked up.
'''
d... | 3 | 1 | 4 | 0 | 4 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 2 | 2 | 2 | 14 | 20 | 2 | 9 | 5 | 6 | 9 | 6 | 5 | 3 | 1 | 5 | 0 | 2 |
16,610 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/core.py | zipline.pipeline.loaders.blaze.core.NonNumpyField | class NonNumpyField(InvalidField):
error_format = "field '{field}' was a non numpy compatible type: '{type_}'" | class NonNumpyField(InvalidField):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 4 | 0 | 4 | 2 | 3 | 0 | 2 | 2 | 1 | 0 | 2 | 0 | 0 |
16,611 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/core.py | zipline.pipeline.loaders.blaze.core.NonPipelineField | class NonPipelineField(InvalidField):
error_format = "field '{field}' was a non Pipeline API compatible type: '{type_}'" | class NonPipelineField(InvalidField):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 4 | 0 | 4 | 2 | 3 | 0 | 2 | 2 | 1 | 0 | 2 | 0 | 0 |
16,612 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/estimates.py | zipline.pipeline.loaders.blaze.estimates.BlazeEstimatesLoader | from zipline.pipeline.loaders.earnings_estimates import NextEarningsEstimatesLoader, PreviousEarningsEstimatesLoader, required_estimates_fields, metadata_columns, PreviousSplitAdjustedEarningsEstimatesLoader, NextSplitAdjustedEarningsEstimatesLoader
from interface import implements
from zipline.pipeline.loaders.blaze.u... |
class BlazeEstimatesLoader(implements(PipelineLoader)):
'''An abstract pipeline loader for the estimates datasets that loads
data from a blaze expression.
Parameters
----------
expr : Expr
The expression representing the data to load.
columns : dict[str -> str]
A dict mapping Bo... | 3 | 1 | 23 | 2 | 21 | 1 | 2 | 0.65 | 1 | 2 | 0 | 3 | 2 | 4 | 2 | 2 | 92 | 11 | 49 | 17 | 41 | 32 | 15 | 12 | 12 | 3 | 1 | 1 | 4 |
16,613 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/estimates.py | zipline.pipeline.loaders.blaze.estimates.BlazeNextEstimatesLoader | from zipline.pipeline.loaders.earnings_estimates import NextEarningsEstimatesLoader, PreviousEarningsEstimatesLoader, required_estimates_fields, metadata_columns, PreviousSplitAdjustedEarningsEstimatesLoader, NextSplitAdjustedEarningsEstimatesLoader
class BlazeNextEstimatesLoader(BlazeEstimatesLoader):
loader = Ne... |
class BlazeNextEstimatesLoader(BlazeEstimatesLoader):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 2 | 0 | 0 |
16,614 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/estimates.py | zipline.pipeline.loaders.blaze.estimates.BlazeNextSplitAdjustedEstimatesLoader | from zipline.pipeline.loaders.earnings_estimates import NextEarningsEstimatesLoader, PreviousEarningsEstimatesLoader, required_estimates_fields, metadata_columns, PreviousSplitAdjustedEarningsEstimatesLoader, NextSplitAdjustedEarningsEstimatesLoader
class BlazeNextSplitAdjustedEstimatesLoader(BlazeSplitAdjustedEstimat... |
class BlazeNextSplitAdjustedEstimatesLoader(BlazeSplitAdjustedEstimatesLoader):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 3 | 0 | 0 |
16,615 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/estimates.py | zipline.pipeline.loaders.blaze.estimates.BlazePreviousEstimatesLoader | from zipline.pipeline.loaders.earnings_estimates import NextEarningsEstimatesLoader, PreviousEarningsEstimatesLoader, required_estimates_fields, metadata_columns, PreviousSplitAdjustedEarningsEstimatesLoader, NextSplitAdjustedEarningsEstimatesLoader
class BlazePreviousEstimatesLoader(BlazeEstimatesLoader):
loader ... |
class BlazePreviousEstimatesLoader(BlazeEstimatesLoader):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 2 | 0 | 0 |
16,616 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/estimates.py | zipline.pipeline.loaders.blaze.estimates.BlazePreviousSplitAdjustedEstimatesLoader | from zipline.pipeline.loaders.earnings_estimates import NextEarningsEstimatesLoader, PreviousEarningsEstimatesLoader, required_estimates_fields, metadata_columns, PreviousSplitAdjustedEarningsEstimatesLoader, NextSplitAdjustedEarningsEstimatesLoader
class BlazePreviousSplitAdjustedEstimatesLoader(BlazeSplitAdjustedEst... |
class BlazePreviousSplitAdjustedEstimatesLoader(BlazeSplitAdjustedEstimatesLoader):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 4 | 0 | 4 | 4 | 1 | 0 | 2 | 2 | 1 | 0 | 3 | 0 | 0 |
16,617 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/estimates.py | zipline.pipeline.loaders.blaze.estimates.BlazeSplitAdjustedEstimatesLoader | from zipline.pipeline.loaders.blaze.utils import load_raw_data
from zipline.pipeline.loaders.earnings_estimates import NextEarningsEstimatesLoader, PreviousEarningsEstimatesLoader, required_estimates_fields, metadata_columns, PreviousSplitAdjustedEarningsEstimatesLoader, NextSplitAdjustedEarningsEstimatesLoader
class ... |
class BlazeSplitAdjustedEstimatesLoader(BlazeEstimatesLoader):
def __init__(self, expr, columns, split_adjustments_loader, split_adjusted_column_names, split_adjusted_asof, **kwargs):
pass
def load_adjusted_array(self, domain, columns, dates, sids, mask):
pass | 3 | 0 | 24 | 2 | 22 | 1 | 1 | 0.02 | 1 | 1 | 0 | 2 | 2 | 4 | 2 | 4 | 49 | 4 | 44 | 16 | 35 | 1 | 11 | 9 | 8 | 1 | 2 | 0 | 2 |
16,618 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/blaze/events.py | zipline.pipeline.loaders.blaze.events.BlazeEventsLoader | from zipline.pipeline.loaders.base import PipelineLoader
from interface import implements
from zipline.pipeline.common import SID_FIELD_NAME, TS_FIELD_NAME, EVENT_DATE_FIELD_NAME
from .core import bind_expression_to_resources
from zipline.pipeline.loaders.events import EventsLoader, required_event_fields
from zipline.p... |
class BlazeEventsLoader(implements(PipelineLoader)):
'''An abstract pipeline loader for the events datasets that loads
data from a blaze expression.
Parameters
----------
expr : Expr
The expression representing the data to load.
next_value_columns : dict[BoundColumn -> raw column name]
... | 3 | 1 | 21 | 2 | 20 | 0 | 2 | 0.65 | 1 | 3 | 1 | 0 | 2 | 4 | 2 | 2 | 82 | 11 | 43 | 16 | 35 | 28 | 14 | 11 | 11 | 3 | 1 | 1 | 4 |
16,619 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/earnings_estimates.py | zipline.pipeline.loaders.earnings_estimates.EarningsEstimatesLoader | from abc import abstractmethod, abstractproperty
from zipline.pipeline.loaders.base import PipelineLoader
from zipline.pipeline.common import EVENT_DATE_FIELD_NAME, FISCAL_QUARTER_FIELD_NAME, FISCAL_YEAR_FIELD_NAME, SID_FIELD_NAME, TS_FIELD_NAME
from zipline.pipeline.loaders.utils import ffill_across_cols, last_in_date... |
class EarningsEstimatesLoader(implements(PipelineLoader)):
'''
An abstract pipeline loader for estimates data that can load data a
variable number of quarters forwards/backwards from calendar dates
depending on the `num_announcements` attribute of the columns' dataset.
If split adjustments are to b... | 20 | 9 | 38 | 2 | 21 | 15 | 2 | 0.8 | 1 | 10 | 1 | 3 | 15 | 4 | 15 | 15 | 621 | 44 | 321 | 113 | 247 | 256 | 102 | 55 | 86 | 5 | 1 | 2 | 30 |
16,620 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/earnings_estimates.py | zipline.pipeline.loaders.earnings_estimates.NextEarningsEstimatesLoader | from zipline.pipeline.common import EVENT_DATE_FIELD_NAME, FISCAL_QUARTER_FIELD_NAME, FISCAL_YEAR_FIELD_NAME, SID_FIELD_NAME, TS_FIELD_NAME
class NextEarningsEstimatesLoader(EarningsEstimatesLoader):
searchsorted_side = 'right'
def create_overwrite_for_estimate(self, column, column_name, last_per_qtr, next_qt... |
class NextEarningsEstimatesLoader(EarningsEstimatesLoader):
def create_overwrite_for_estimate(self, column, column_name, last_per_qtr, next_qtr_start_idx, requested_quarter, sid, sid_idx, col_to_split_adjustments=None, split_adjusted_asof_idx=None):
pass
def get_shifted_qtrs(self, zero_qtrs, num_anno... | 4 | 1 | 17 | 1 | 11 | 6 | 1 | 0.53 | 1 | 0 | 0 | 1 | 3 | 0 | 3 | 18 | 57 | 5 | 34 | 15 | 21 | 18 | 9 | 6 | 5 | 1 | 2 | 0 | 3 |
16,621 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/earnings_estimates.py | zipline.pipeline.loaders.earnings_estimates.NextSplitAdjustedEarningsEstimatesLoader | from zipline.lib.adjustment import Datetime641DArrayOverwrite, Datetime64Overwrite, Float641DArrayOverwrite, Float64Multiply, Float64Overwrite
class NextSplitAdjustedEarningsEstimatesLoader(SplitAdjustedEstimatesLoader, NextEarningsEstimatesLoader):
def collect_split_adjustments(self, adjustments_for_sid, request... |
class NextSplitAdjustedEarningsEstimatesLoader(SplitAdjustedEstimatesLoader, NextEarningsEstimatesLoader):
def collect_split_adjustments(self, adjustments_for_sid, requested_qtr_data, dates, sid, sid_idx, sid_estimates, split_adjusted_asof_idx, pre_adjustments, post_adjustments, requested_split_adjusted_columns):... | 2 | 1 | 128 | 3 | 76 | 49 | 8 | 0.62 | 2 | 1 | 0 | 0 | 1 | 0 | 1 | 29 | 131 | 3 | 79 | 23 | 65 | 49 | 16 | 10 | 14 | 8 | 3 | 5 | 8 |
16,622 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/earnings_estimates.py | zipline.pipeline.loaders.earnings_estimates.PreviousEarningsEstimatesLoader | from zipline.pipeline.common import EVENT_DATE_FIELD_NAME, FISCAL_QUARTER_FIELD_NAME, FISCAL_YEAR_FIELD_NAME, SID_FIELD_NAME, TS_FIELD_NAME
class PreviousEarningsEstimatesLoader(EarningsEstimatesLoader):
searchsorted_side = 'left'
def create_overwrite_for_estimate(self, column, column_name, dates, next_qtr_st... |
class PreviousEarningsEstimatesLoader(EarningsEstimatesLoader):
def create_overwrite_for_estimate(self, column, column_name, dates, next_qtr_start_idx, requested_quarter, sid, sid_idx, col_to_split_adjustments=None, split_adjusted_asof_idx=None, split_dict=None):
pass
def get_shifted_qtrs(self, zero_... | 4 | 1 | 16 | 1 | 9 | 6 | 1 | 0.62 | 1 | 0 | 0 | 1 | 3 | 0 | 3 | 18 | 52 | 5 | 29 | 16 | 15 | 18 | 9 | 6 | 5 | 1 | 2 | 0 | 3 |
16,623 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/earnings_estimates.py | zipline.pipeline.loaders.earnings_estimates.PreviousSplitAdjustedEarningsEstimatesLoader | class PreviousSplitAdjustedEarningsEstimatesLoader(SplitAdjustedEstimatesLoader, PreviousEarningsEstimatesLoader):
def collect_split_adjustments(self, adjustments_for_sid, requested_qtr_data, dates, sid, sid_idx, sid_estimates, split_adjusted_asof_idx, pre_adjustments, post_adjustments, requested_split_adjusted_co... | class PreviousSplitAdjustedEarningsEstimatesLoader(SplitAdjustedEstimatesLoader, PreviousEarningsEstimatesLoader):
def collect_split_adjustments(self, adjustments_for_sid, requested_qtr_data, dates, sid, sid_idx, sid_estimates, split_adjusted_asof_idx, pre_adjustments, post_adjustments, requested_split_adjusted_co... | 2 | 1 | 60 | 1 | 28 | 31 | 1 | 1 | 2 | 0 | 0 | 0 | 1 | 0 | 1 | 29 | 63 | 1 | 31 | 16 | 17 | 31 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
16,624 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/earnings_estimates.py | zipline.pipeline.loaders.earnings_estimates.SplitAdjustedEstimatesLoader | from abc import abstractmethod, abstractproperty
from zipline.pipeline.common import EVENT_DATE_FIELD_NAME, FISCAL_QUARTER_FIELD_NAME, FISCAL_YEAR_FIELD_NAME, SID_FIELD_NAME, TS_FIELD_NAME
import pandas as pd
import numpy as np
from zipline.lib.adjustment import Datetime641DArrayOverwrite, Datetime64Overwrite, Float641... |
class SplitAdjustedEstimatesLoader(EarningsEstimatesLoader):
'''
Estimates loader that loads data that needs to be split-adjusted.
Parameters
----------
split_adjustments_loader : SQLiteAdjustmentReader
The loader to use for reading split adjustments.
split_adjusted_column_names : itera... | 12 | 8 | 45 | 2 | 28 | 16 | 3 | 0.6 | 1 | 7 | 0 | 2 | 10 | 4 | 10 | 25 | 479 | 25 | 283 | 120 | 206 | 171 | 91 | 53 | 80 | 8 | 2 | 6 | 30 |
16,625 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/equity_pricing_loader.py | zipline.pipeline.loaders.equity_pricing_loader.EquityPricingLoader | from ..data.equity_pricing import EquityPricing
from zipline.data.fx import ExplodingFXRateReader
from zipline.lib.adjusted_array import AdjustedArray
from .utils import shift_dates
from collections import defaultdict
from zipline.utils.numpy_utils import repeat_first_axis
from numpy import iinfo, uint32, multiply
from... |
class EquityPricingLoader(implements(PipelineLoader)):
'''A PipelineLoader for loading daily OHLCV data.
Parameters
----------
raw_price_reader : zipline.data.session_bars.SessionBarReader
Reader providing raw prices.
adjustments_reader : zipline.data.adjustments.SQLiteAdjustmentReader
... | 9 | 4 | 27 | 3 | 14 | 10 | 2 | 0.85 | 1 | 5 | 3 | 0 | 5 | 3 | 6 | 6 | 183 | 27 | 85 | 36 | 73 | 72 | 48 | 31 | 41 | 5 | 1 | 2 | 14 |
16,626 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/events.py | zipline.pipeline.loaders.events.EventsLoader | from toolz import groupby, merge
from zipline.pipeline.loaders.frame import DataFrameLoader
import numpy as np
from zipline.pipeline.loaders.utils import next_event_indexer, previous_event_indexer
from interface import implements
from zipline.pipeline.common import EVENT_DATE_FIELD_NAME, SID_FIELD_NAME, TS_FIELD_NAME
i... |
class EventsLoader(implements(PipelineLoader)):
'''
Base class for PipelineLoaders that supports loading the next and previous
value of an event field.
Does not currently support adjustments.
Parameters
----------
events : pd.DataFrame
A DataFrame representing events (e.g. share buy... | 11 | 2 | 17 | 2 | 13 | 3 | 2 | 0.44 | 1 | 2 | 1 | 0 | 8 | 3 | 8 | 8 | 199 | 28 | 119 | 44 | 86 | 52 | 45 | 22 | 34 | 3 | 1 | 2 | 16 |
16,627 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/frame.py | zipline.pipeline.loaders.frame.DataFrameLoader | from .base import PipelineLoader
from zipline.lib.adjusted_array import AdjustedArray
from functools import partial
from zipline.lib.adjustment import make_adjustment_from_labels
from zipline.utils.numpy_utils import as_column
from interface import implements
from numpy import ix_, zeros
from pandas import DataFrame, D... |
class DataFrameLoader(implements(PipelineLoader)):
'''
A PipelineLoader that reads its input from DataFrames.
Mostly useful for testing, but can also be used for real work if your data
fits in memory.
Parameters
----------
column : zipline.pipeline.data.BoundColumn
The column whose ... | 5 | 4 | 31 | 4 | 17 | 10 | 3 | 0.9 | 1 | 4 | 1 | 0 | 4 | 8 | 4 | 4 | 156 | 23 | 70 | 31 | 65 | 63 | 51 | 31 | 46 | 4 | 1 | 2 | 10 |
16,628 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/synthetic.py | zipline.pipeline.loaders.synthetic.EyeLoader | from numpy import arange, array, eye, float64, full, iinfo, nan, uint32
class EyeLoader(PrecomputedLoader):
"""
A PrecomputedLoader that emits arrays containing 1s on the diagonal and 0s
elsewhere.
Parameters
----------
columns : list[BoundColumn]
Columns that this loader should know a... |
class EyeLoader(PrecomputedLoader):
'''
A PrecomputedLoader that emits arrays containing 1s on the diagonal and 0s
elsewhere.
Parameters
----------
columns : list[BoundColumn]
Columns that this loader should know about.
dates : iterable[datetime-like]
Same as PrecomputedLoad... | 2 | 1 | 7 | 0 | 7 | 0 | 1 | 1.5 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 3 | 21 | 1 | 8 | 3 | 6 | 12 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
16,629 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/synthetic.py | zipline.pipeline.loaders.synthetic.NullAdjustmentReader | from numpy import arange, array, eye, float64, full, iinfo, nan, uint32
from pandas import DataFrame, Timestamp
from zipline.data.adjustments import SQLiteAdjustmentReader, SQLiteAdjustmentWriter
from sqlite3 import connect as sqlite3_connect
class NullAdjustmentReader(SQLiteAdjustmentReader):
"""
A SQLiteAdju... |
class NullAdjustmentReader(SQLiteAdjustmentReader):
'''
A SQLiteAdjustmentReader that stores no adjustments and uses in-memory
SQLite.
'''
def __init__(self):
pass | 2 | 1 | 18 | 0 | 18 | 0 | 1 | 0.21 | 1 | 3 | 1 | 0 | 1 | 0 | 1 | 13 | 24 | 1 | 19 | 6 | 17 | 4 | 8 | 6 | 6 | 1 | 2 | 0 | 1 |
16,630 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/synthetic.py | zipline.pipeline.loaders.synthetic.PrecomputedLoader | from interface import implements
from six import iteritems
from .base import PipelineLoader
from pandas import DataFrame, Timestamp
from .frame import DataFrameLoader
class PrecomputedLoader(implements(PipelineLoader)):
"""
Synthetic PipelineLoader that uses a pre-computed array for each column.
Parameter... |
class PrecomputedLoader(implements(PipelineLoader)):
'''
Synthetic PipelineLoader that uses a pre-computed array for each column.
Parameters
----------
values : dict
Map from column to values to use for that column.
Values can be anything that can be passed as the first positional
... | 3 | 2 | 16 | 1 | 14 | 2 | 3 | 0.72 | 1 | 3 | 1 | 3 | 2 | 1 | 2 | 2 | 54 | 4 | 29 | 10 | 26 | 21 | 18 | 10 | 15 | 4 | 1 | 3 | 6 |
16,631 | quantopian/zipline | quantopian_zipline/zipline/pipeline/loaders/synthetic.py | zipline.pipeline.loaders.synthetic.SeededRandomLoader | from zipline.utils.numpy_utils import bool_dtype, datetime64ns_dtype, float64_dtype, int64_dtype, object_dtype
from pandas import DataFrame, Timestamp
from numpy.random import RandomState
class SeededRandomLoader(PrecomputedLoader):
"""
A PrecomputedLoader that emits arrays randomly-generated with a given seed... |
class SeededRandomLoader(PrecomputedLoader):
'''
A PrecomputedLoader that emits arrays randomly-generated with a given seed.
Parameters
----------
seed : int
Seed for numpy.random.RandomState.
columns : list[BoundColumn]
Columns that this loader should know about.
dates : it... | 10 | 7 | 7 | 0 | 5 | 3 | 1 | 0.89 | 1 | 3 | 0 | 0 | 8 | 1 | 8 | 10 | 81 | 10 | 38 | 15 | 28 | 34 | 22 | 14 | 13 | 1 | 2 | 0 | 8 |
16,632 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.AliasedMixin | class AliasedMixin(SingleInputMixin, UniversalMixin):
"""
Mixin for aliased terms.
"""
def __new__(cls, term, name):
return super(AliasedMixin, cls).__new__(cls, inputs=(term,), outputs=term.outputs, window_length=0, name=name, dtype=term.dtype, missing_value=term.missing_value, ndim=term.ndim,... | class AliasedMixin(SingleInputMixin, UniversalMixin):
'''
Mixin for aliased terms.
'''
def __new__(cls, term, name):
pass
def _init(self, name, *args, **kwargs):
pass
@classmethod
def _static_identity(cls, name, *args, **kwargs):
pass
def _compute(self, inputs,... | 12 | 2 | 4 | 0 | 4 | 0 | 1 | 0.11 | 2 | 2 | 0 | 0 | 5 | 1 | 8 | 26 | 49 | 7 | 38 | 13 | 26 | 4 | 18 | 10 | 9 | 1 | 3 | 0 | 8 |
16,633 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.ConstantMixin | from zipline.lib.labelarray import LabelArray, labelarray_where
from numpy import array, full, recarray, searchsorted, vstack, where
class ConstantMixin(StandardOutputs, UniversalMixin):
"""Universal mixin for terms that produce a known constant value.
"""
window_length = 0
inputs = ()
params = ('c... |
class ConstantMixin(StandardOutputs, UniversalMixin):
'''Universal mixin for terms that produce a known constant value.
'''
def _compute(self, inputs, assets, dates, mask):
pass
@staticmethod
def _universal_mixin_type():
pass
@staticmethod
def _universal_mixin_specializatio... | 6 | 1 | 5 | 0 | 5 | 0 | 1 | 0.1 | 2 | 2 | 1 | 0 | 1 | 0 | 3 | 21 | 25 | 3 | 20 | 11 | 14 | 2 | 14 | 9 | 10 | 2 | 3 | 1 | 4 |
16,634 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.CustomTermMixin | from .term import Term
from numpy import array, full, recarray, searchsorted, vstack, where
from .sentinels import NotSpecified
from zipline.utils.context_tricks import nop_context
class CustomTermMixin(Term):
"""
Mixin for user-defined rolling-window Terms.
Implements `_compute` in terms of a user-define... |
class CustomTermMixin(Term):
'''
Mixin for user-defined rolling-window Terms.
Implements `_compute` in terms of a user-defined `compute` function, which
is mapped over the input windows.
Used by CustomFactor, CustomFilter, CustomClassifier, etc.
'''
def __new__(cls, inputs=NotSpecified, ou... | 7 | 5 | 19 | 2 | 13 | 4 | 2 | 0.37 | 1 | 6 | 0 | 6 | 6 | 0 | 6 | 20 | 127 | 19 | 79 | 35 | 64 | 29 | 44 | 27 | 37 | 4 | 2 | 2 | 13 |
16,635 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.DownsampledMixin | from zipline.errors import WindowLengthNotPositive, UnsupportedDataType, NonExistentAssetInTimeFrame, NoFurtherDataError
from zipline.utils.input_validation import expect_dtypes, expect_types
from pandas import NaT as pd_NaT
from numpy import array, full, recarray, searchsorted, vstack, where
from .term import Term
fro... |
class DownsampledMixin(StandardOutputs, UniversalMixin):
'''Universal mixin for downsampled terms.
A downsampled term is a wrapper around the "real" term that performs actual
computation. The downsampler is responsible for calling the real term's
`compute` method at selected intervals and forward-filli... | 17 | 3 | 17 | 1 | 10 | 5 | 2 | 0.59 | 2 | 8 | 1 | 0 | 4 | 2 | 7 | 25 | 198 | 25 | 109 | 36 | 88 | 64 | 61 | 28 | 49 | 6 | 3 | 3 | 19 |
16,636 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.IfElseMixin | from zipline.utils.numpy_utils import bool_dtype
from numpy import array, full, recarray, searchsorted, vstack, where
from zipline.utils.input_validation import expect_dtypes, expect_types
from zipline.lib.labelarray import LabelArray, labelarray_where
class IfElseMixin(UniversalMixin):
"""Universal mixin for type... |
class IfElseMixin(UniversalMixin):
'''Universal mixin for types returned by Filter.if_else.
'''
@expect_dtypes(condition=bool_dtype)
def __new__(cls, condition, if_true, if_false):
pass
def _compute(self, inputs, assets, dates, mask):
pass
@staticmethod
def _universal_mixin... | 8 | 1 | 6 | 0 | 6 | 0 | 1 | 0.07 | 1 | 2 | 0 | 0 | 2 | 0 | 4 | 21 | 33 | 4 | 27 | 9 | 19 | 2 | 12 | 6 | 7 | 2 | 3 | 1 | 5 |
16,637 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.LatestMixin | class LatestMixin(SingleInputMixin):
"""
Common behavior for :attr:`zipline.pipeline.data.BoundColumn.latest`.
Given a :class:`~zipline.pipeline.data.DataSet` named ``MyData`` with a
column ``col`` of numeric dtype, the following expression:
.. code-block:: python
factor = MyData.col.lates... | class LatestMixin(SingleInputMixin):
'''
Common behavior for :attr:`zipline.pipeline.data.BoundColumn.latest`.
Given a :class:`~zipline.pipeline.data.DataSet` named ``MyData`` with a
column ``col`` of numeric dtype, the following expression:
.. code-block:: python
factor = MyData.col.latest
... | 4 | 1 | 5 | 0 | 5 | 0 | 1 | 1.12 | 1 | 3 | 0 | 6 | 3 | 1 | 3 | 18 | 48 | 12 | 17 | 6 | 13 | 19 | 10 | 5 | 6 | 2 | 3 | 1 | 4 |
16,638 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.PositiveWindowLengthMixin | from .term import Term
from zipline.errors import WindowLengthNotPositive, UnsupportedDataType, NonExistentAssetInTimeFrame, NoFurtherDataError
class PositiveWindowLengthMixin(Term):
"""
Validation mixin enforcing that a Term gets a positive WindowLength
"""
def _validate(self):
super(Positive... |
class PositiveWindowLengthMixin(Term):
'''
Validation mixin enforcing that a Term gets a positive WindowLength
'''
def _validate(self):
pass | 2 | 1 | 4 | 0 | 4 | 0 | 2 | 0.6 | 1 | 2 | 1 | 6 | 1 | 0 | 1 | 15 | 8 | 0 | 5 | 2 | 3 | 3 | 5 | 2 | 3 | 2 | 2 | 1 | 2 |
16,639 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.RestrictedDTypeMixin | from .sentinels import NotSpecified
from .term import Term
from zipline.errors import WindowLengthNotPositive, UnsupportedDataType, NonExistentAssetInTimeFrame, NoFurtherDataError
class RestrictedDTypeMixin(Term):
"""
Validation mixin enforcing that a term has a specific dtype.
"""
ALLOWED_DTYPES = Not... |
class RestrictedDTypeMixin(Term):
'''
Validation mixin enforcing that a term has a specific dtype.
'''
def _validate(self):
pass | 2 | 1 | 12 | 1 | 11 | 0 | 2 | 0.23 | 1 | 3 | 1 | 6 | 1 | 0 | 1 | 15 | 18 | 2 | 13 | 3 | 11 | 3 | 7 | 3 | 5 | 2 | 2 | 1 | 2 |
16,640 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.SingleInputMixin | from .term import Term
class SingleInputMixin(Term):
"""
Validation mixin enforcing that a Term gets a length-1 inputs list.
"""
def _validate(self):
super(SingleInputMixin, self)._validate()
num_inputs = len(self.inputs)
if num_inputs != 1:
raise ValueError('{typen... |
class SingleInputMixin(Term):
'''
Validation mixin enforcing that a Term gets a length-1 inputs list.
'''
def _validate(self):
pass | 2 | 1 | 11 | 0 | 11 | 0 | 2 | 0.25 | 1 | 3 | 0 | 29 | 1 | 0 | 1 | 15 | 15 | 0 | 12 | 3 | 10 | 3 | 6 | 3 | 4 | 2 | 2 | 1 | 2 |
16,641 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.SliceMixin | from numpy import array, full, recarray, searchsorted, vstack, where
from zipline.errors import WindowLengthNotPositive, UnsupportedDataType, NonExistentAssetInTimeFrame, NoFurtherDataError
class SliceMixin(UniversalMixin):
"""Universal mixin for taking columnar slices of terms.
Parameters
----------
... |
class SliceMixin(UniversalMixin):
'''Universal mixin for taking columnar slices of terms.
Parameters
----------
term : zipline.pipeline.Term
The term from which to extract a column of data.
asset : zipline.assets.Asset
The asset corresponding to the column of `term` to be extracted.... | 13 | 2 | 6 | 0 | 5 | 1 | 1 | 0.36 | 1 | 2 | 1 | 0 | 5 | 1 | 8 | 25 | 70 | 10 | 44 | 16 | 31 | 16 | 22 | 12 | 13 | 2 | 3 | 1 | 9 |
16,642 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.StandardOutputs | from .sentinels import NotSpecified
from .term import Term
class StandardOutputs(Term):
"""
Validation mixin enforcing that a Term cannot produce non-standard outputs.
"""
def _validate(self):
super(StandardOutputs, self)._validate()
if self.outputs is not NotSpecified:
rai... |
class StandardOutputs(Term):
'''
Validation mixin enforcing that a Term cannot produce non-standard outputs.
'''
def _validate(self):
pass | 2 | 1 | 10 | 0 | 10 | 0 | 2 | 0.27 | 1 | 3 | 0 | 9 | 1 | 0 | 1 | 15 | 14 | 0 | 11 | 2 | 9 | 3 | 5 | 2 | 3 | 2 | 2 | 1 | 2 |
16,643 | quantopian/zipline | quantopian_zipline/zipline/pipeline/mixins.py | zipline.pipeline.mixins.UniversalMixin | from abc import abstractmethod
from .term import Term
class UniversalMixin(Term):
"""
Base class for "universal" mixins.
Universal mixins are used to implement expressions that need separate
subclasses for each of the ComputableTerm subclasses (Factor, Filter, and
Classifier). Such expressions are... |
class UniversalMixin(Term):
'''
Base class for "universal" mixins.
Universal mixins are used to implement expressions that need separate
subclasses for each of the ComputableTerm subclasses (Factor, Filter, and
Classifier). Such expressions are usually return types of methods of
ComputableTerm,... | 9 | 2 | 8 | 0 | 6 | 2 | 1 | 0.58 | 1 | 3 | 0 | 5 | 0 | 0 | 3 | 17 | 44 | 6 | 24 | 11 | 15 | 14 | 15 | 8 | 11 | 2 | 2 | 1 | 4 |
16,644 | quantopian/zipline | quantopian_zipline/zipline/pipeline/pipeline.py | zipline.pipeline.pipeline.Pipeline | from zipline.errors import UnsupportedPipelineOutput
from .graph import ExecutionPlan, TermGraph, SCREEN_NAME
from .term import AssetExists, ComputableTerm, Term
from .domain import Domain, GENERIC, infer_domain
from .filters import Filter
from zipline.utils.input_validation import expect_element, expect_types, optiona... |
class Pipeline(object):
'''
A Pipeline object represents a collection of named expressions to be
compiled and executed by a PipelineEngine.
A Pipeline has two important attributes: 'columns', a dictionary of named
:class:`~zipline.pipeline.Term` instances, and 'screen', a
:class:`~zipline.pipel... | 25 | 12 | 20 | 2 | 8 | 10 | 2 | 1.23 | 1 | 10 | 5 | 0 | 12 | 3 | 13 | 13 | 316 | 42 | 123 | 45 | 90 | 151 | 71 | 27 | 57 | 5 | 1 | 2 | 31 |
16,645 | quantopian/zipline | quantopian_zipline/zipline/pipeline/term.py | zipline.pipeline.term.AssetExists | from numpy import array, dtype as dtype_class, ndarray
from zipline.utils.numpy_utils import bool_dtype, categorical_dtype, datetime64ns_dtype, default_missing_value_for_dtype, float64_dtype
class AssetExists(Term):
"""
Pseudo-filter describing whether or not an asset existed on a given day.
This is the de... |
class AssetExists(Term):
'''
Pseudo-filter describing whether or not an asset existed on a given day.
This is the default mask for all terms that haven't been passed a mask
explicitly.
This is morally a Filter, in the sense that it produces a boolean value for
every asset on every date. We don... | 3 | 1 | 4 | 0 | 4 | 0 | 1 | 0.87 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 16 | 34 | 6 | 15 | 10 | 12 | 13 | 12 | 10 | 9 | 1 | 2 | 0 | 2 |
16,646 | quantopian/zipline | quantopian_zipline/zipline/pipeline/term.py | zipline.pipeline.term.ComputableTerm | from .sentinels import NotSpecified
from zipline.utils.sharedoc import templated_docstring, PIPELINE_ALIAS_NAME_DOC, PIPELINE_DOWNSAMPLING_FREQUENCY_DOC
from numpy import array, dtype as dtype_class, ndarray
from .downsample_helpers import expect_downsample_frequency
from zipline.utils.input_validation import expect_ty... |
class ComputableTerm(Term):
'''
A Term that should be computed from a tuple of inputs.
This is the base class for :class:`zipline.pipeline.Factor`,
:class:`zipline.pipeline.Filter`, and :class:`zipline.pipeline.Classifier`.
'''
def __new__(cls, inputs=inputs, outputs=outputs, window_length... | 33 | 12 | 19 | 3 | 9 | 7 | 2 | 0.76 | 1 | 20 | 14 | 7 | 17 | 2 | 20 | 34 | 428 | 75 | 201 | 67 | 150 | 152 | 118 | 42 | 91 | 12 | 2 | 3 | 48 |
16,647 | quantopian/zipline | quantopian_zipline/zipline/pipeline/term.py | zipline.pipeline.term.InputDates | from numpy import array, dtype as dtype_class, ndarray
from zipline.utils.numpy_utils import bool_dtype, categorical_dtype, datetime64ns_dtype, default_missing_value_for_dtype, float64_dtype
class InputDates(Term):
"""
1-Dimensional term providing date labels for other term inputs.
This term is guaranteed... |
class InputDates(Term):
'''
1-Dimensional term providing date labels for other term inputs.
This term is guaranteed to be available as an input for any term computed
by SimplePipelineEngine.run_pipeline().
'''
def __repr__(self):
pass
def _compute(self, today, assets, out):
... | 3 | 1 | 4 | 0 | 4 | 0 | 1 | 0.29 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 16 | 26 | 4 | 17 | 12 | 14 | 5 | 14 | 12 | 11 | 1 | 2 | 0 | 2 |
16,648 | quantopian/zipline | quantopian_zipline/zipline/pipeline/term.py | zipline.pipeline.term.LoadableTerm | from zipline.utils.memoize import classlazyval, lazyval
class LoadableTerm(Term):
"""
A Term that should be loaded from an external resource by a PipelineLoader.
This is the base class for :class:`zipline.pipeline.data.BoundColumn`.
"""
windowed = False
inputs = ()
@lazyval
def depend... |
class LoadableTerm(Term):
'''
A Term that should be loaded from an external resource by a PipelineLoader.
This is the base class for :class:`zipline.pipeline.data.BoundColumn`.
'''
@lazyval
def dependencies(self):
pass | 3 | 1 | 2 | 0 | 2 | 0 | 1 | 0.67 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 15 | 12 | 2 | 6 | 5 | 3 | 4 | 5 | 4 | 3 | 1 | 2 | 0 | 1 |
16,649 | quantopian/zipline | quantopian_zipline/zipline/pipeline/term.py | zipline.pipeline.term.Term | from six import with_metaclass
from zipline.utils.input_validation import expect_types
from collections import Mapping
from .sentinels import NotSpecified
from weakref import WeakValueDictionary
from zipline.assets import Asset
from numpy import array, dtype as dtype_class, ndarray
from .domain import Domain, GENERIC, ... |
class Term(with_metaclass(ABCMeta, object)):
'''
Base class for objects that can appear in the compute graph of a
:class:`zipline.pipeline.Pipeline`.
Notes
-----
Most Pipeline API users only interact with :class:`Term` via subclasses:
- :class:`~zipline.pipeline.data.BoundColumn`
- :cla... | 22 | 14 | 20 | 2 | 10 | 9 | 2 | 0.98 | 1 | 10 | 3 | 10 | 12 | 1 | 14 | 14 | 349 | 48 | 152 | 57 | 112 | 149 | 85 | 33 | 69 | 7 | 1 | 3 | 28 |
16,650 | quantopian/zipline | quantopian_zipline/zipline/pipeline/visualize.py | zipline.pipeline.visualize.NoIPython | class NoIPython(Exception):
pass | class NoIPython(Exception):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
16,651 | quantopian/zipline | quantopian_zipline/zipline/protocol.py | zipline.protocol.Account | class Account(object):
"""
The account object tracks information about the trading account. The
values are updated as the algorithm runs and its keys remain unchanged.
If connected to a broker, one can update these values with the trading
account values as reported by the broker.
"""
def __... | class Account(object):
'''
The account object tracks information about the trading account. The
values are updated as the algorithm runs and its keys remain unchanged.
If connected to a broker, one can update these values with the trading
account values as reported by the broker.
'''
def __... | 4 | 1 | 8 | 0 | 8 | 0 | 1 | 0.2 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 3 | 58 | 4 | 45 | 6 | 41 | 9 | 25 | 6 | 21 | 1 | 1 | 0 | 3 |
16,652 | quantopian/zipline | quantopian_zipline/zipline/protocol.py | zipline.protocol.MutableView | class MutableView(object):
"""A mutable view over an "immutable" object.
Parameters
----------
ob : any
The object to take a view over.
"""
__slots__ = ('_mutable_view_ob',)
def __init__(self, ob):
object.__setattr__(self, '_mutable_view_ob', ob)
def __getattr__(self, ... | class MutableView(object):
'''A mutable view over an "immutable" object.
Parameters
----------
ob : any
The object to take a view over.
'''
def __init__(self, ob):
pass
def __getattr__(self, attr):
pass
def __setattr__(self, attr, value):
pass
def ... | 5 | 1 | 2 | 0 | 2 | 0 | 1 | 0.8 | 1 | 1 | 0 | 0 | 4 | 1 | 4 | 4 | 23 | 5 | 10 | 7 | 5 | 8 | 10 | 6 | 5 | 1 | 1 | 0 | 4 |
16,653 | quantopian/zipline | quantopian_zipline/zipline/protocol.py | zipline.protocol.Portfolio | import pandas as pd
class Portfolio(object):
"""Object providing read-only access to current portfolio state.
Parameters
----------
start_date : pd.Timestamp
The start date for the period being recorded.
capital_base : float
The starting value for the portfolio. This will be used a... |
class Portfolio(object):
'''Object providing read-only access to current portfolio state.
Parameters
----------
start_date : pd.Timestamp
The start date for the period being recorded.
capital_base : float
The starting value for the portfolio. This will be used as the starting
... | 8 | 2 | 7 | 0 | 6 | 1 | 1 | 0.68 | 1 | 4 | 2 | 0 | 5 | 0 | 5 | 5 | 83 | 9 | 44 | 11 | 36 | 30 | 23 | 9 | 17 | 1 | 1 | 0 | 5 |
16,654 | quantopian/zipline | quantopian_zipline/zipline/protocol.py | zipline.protocol.Position | class Position(object):
"""
A position held by an algorithm.
Attributes
----------
asset : zipline.assets.Asset
The held asset.
amount : int
Number of shares held. Short positions are represented with negative
values.
cost_basis : float
Average price at which... | class Position(object):
'''
A position held by an algorithm.
Attributes
----------
asset : zipline.assets.Asset
The held asset.
amount : int
Number of shares held. Short positions are represented with negative
values.
cost_basis : float
Average price at which ... | 7 | 1 | 4 | 0 | 4 | 0 | 1 | 0.65 | 1 | 1 | 0 | 0 | 5 | 0 | 5 | 5 | 58 | 7 | 31 | 9 | 24 | 20 | 13 | 8 | 7 | 1 | 1 | 0 | 5 |
16,655 | quantopian/zipline | quantopian_zipline/zipline/protocol.py | zipline.protocol.Positions | from warnings import warn
from .assets import Asset
from ._protocol import BarData, InnerPosition
class Positions(dict):
"""A dict-like object containing the algorithm's current positions.
"""
def __missing__(self, key):
if isinstance(key, Asset):
return Position(InnerPosition(key))
... |
class Positions(dict):
'''A dict-like object containing the algorithm's current positions.
'''
def __missing__(self, key):
pass | 2 | 1 | 11 | 1 | 10 | 0 | 3 | 0.18 | 1 | 4 | 2 | 0 | 1 | 0 | 1 | 28 | 15 | 2 | 11 | 2 | 9 | 2 | 7 | 2 | 5 | 3 | 2 | 1 | 3 |
16,656 | quantopian/zipline | quantopian_zipline/zipline/sources/benchmark_source.py | zipline.sources.benchmark_source.BenchmarkSource | from zipline.errors import InvalidBenchmarkAsset, BenchmarkAssetNotAvailableTooEarly, BenchmarkAssetNotAvailableTooLate
import pandas as pd
class BenchmarkSource(object):
def __init__(self, benchmark_asset, trading_calendar, sessions, data_portal, emission_rate='daily', benchmark_returns=None):
self.bench... |
class BenchmarkSource(object):
def __init__(self, benchmark_asset, trading_calendar, sessions, data_portal, emission_rate='daily', benchmark_returns=None):
pass
def get_value(self, dt):
'''Look up the returns for a given dt.
Parameters
----------
dt : datetime
... | 11 | 4 | 35 | 4 | 19 | 11 | 2 | 0.57 | 1 | 7 | 3 | 0 | 6 | 6 | 8 | 8 | 288 | 41 | 157 | 43 | 134 | 90 | 59 | 28 | 50 | 5 | 1 | 2 | 19 |
16,657 | quantopian/zipline | quantopian_zipline/zipline/sources/requests_csv.py | zipline.sources.requests_csv.FetcherCSVRedirectError | from textwrap import dedent
from zipline.errors import MultipleSymbolsFound, SymbolNotFound, ZiplineError
class FetcherCSVRedirectError(ZiplineError):
msg = dedent(' Attempt to fetch_csv from a redirected url. {url}\n must be changed to {new_url}\n ')
def __init__(self, *args, **kwargs):
... |
class FetcherCSVRedirectError(ZiplineError):
def __init__(self, *args, **kwargs):
pass | 2 | 0 | 6 | 1 | 5 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 3 | 1 | 14 | 14 | 2 | 12 | 6 | 10 | 0 | 7 | 6 | 5 | 1 | 4 | 0 | 1 |
16,658 | quantopian/zipline | quantopian_zipline/zipline/sources/requests_csv.py | zipline.sources.requests_csv.FetcherEvent | from zipline.protocol import DATASOURCE_TYPE, Event
class FetcherEvent(Event):
pass |
class FetcherEvent(Event):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
16,659 | quantopian/zipline | quantopian_zipline/zipline/sources/requests_csv.py | zipline.sources.requests_csv.PandasCSV | from abc import ABCMeta, abstractmethod
from six import StringIO, iteritems, with_metaclass
from zipline.errors import MultipleSymbolsFound, SymbolNotFound, ZiplineError
import warnings
import numpy
import pandas as pd
from zipline.protocol import DATASOURCE_TYPE, Event
from zipline.assets import Equity
import pytz
cl... | null | 13 | 2 | 33 | 4 | 21 | 8 | 4 | 0.37 | 1 | 13 | 3 | 1 | 8 | 15 | 9 | 9 | 312 | 46 | 194 | 65 | 165 | 72 | 124 | 46 | 114 | 12 | 1 | 3 | 38 |
16,660 | quantopian/zipline | quantopian_zipline/zipline/sources/requests_csv.py | zipline.sources.requests_csv.PandasRequestsCSV | from six import StringIO, iteritems, with_metaclass
import hashlib
import pandas as pd
import requests
from pandas import read_csv
class PandasRequestsCSV(PandasCSV):
MAX_DOCUMENT_SIZE = 1024 * 1024 * 100
CONTENT_CHUNK_SIZE = 4096
def __init__(self, url, pre_func, post_func, asset_finder, trading_day, sta... |
class PandasRequestsCSV(PandasCSV):
def __init__(self, url, pre_func, post_func, asset_finder, trading_day, start_date, end_date, date_column, date_format, timezone, symbol, mask, symbol_column, data_frequency, country_code, special_params_checker=None, **kwargs):
pass
@property
def requests_kwarg... | 6 | 0 | 33 | 4 | 25 | 4 | 3 | 0.17 | 1 | 5 | 1 | 0 | 4 | 7 | 4 | 13 | 142 | 22 | 103 | 42 | 80 | 17 | 51 | 24 | 46 | 7 | 2 | 2 | 13 |
16,661 | quantopian/zipline | quantopian_zipline/zipline/utils/api_support.py | zipline.utils.api_support.ZiplineAPI | from zipline.utils.algo_instance import get_algo_instance, set_algo_instance
class ZiplineAPI(object):
"""
Context manager for making an algorithm instance available to zipline API
functions within a scoped block.
"""
def __init__(self, algo_instance):
self.algo_instance = algo_instance
... |
class ZiplineAPI(object):
'''
Context manager for making an algorithm instance available to zipline API
functions within a scoped block.
'''
def __init__(self, algo_instance):
pass
def __enter__(self):
'''
Set the given algo instance, storing any previously-existing in... | 4 | 3 | 4 | 0 | 2 | 2 | 1 | 1.25 | 1 | 0 | 0 | 0 | 3 | 2 | 3 | 3 | 21 | 3 | 8 | 6 | 4 | 10 | 8 | 6 | 4 | 1 | 1 | 0 | 3 |
16,662 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.AnyDefault | @singleton
class AnyDefault(object):
def __str__(self):
return 'Argument.any_default'
__repr__ = __str__ | @singleton
class AnyDefault(object):
def __str__(self):
pass | 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
16,663 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.Argument | from collections import namedtuple
from zipline.utils.compat import getargspec
from six.moves import map, zip_longest
class Argument(namedtuple('Argument', ['name', 'default'])):
"""
An argument to a function.
Argument.no_default is a value representing no default to the argument.
Argument.ignore is a ... |
class Argument(namedtuple('Argument', ['name', 'default'])):
'''
An argument to a function.
Argument.no_default is a value representing no default to the argument.
Argument.ignore is a value that says you should ignore the default value.
'''
def __new__(cls, name=ignore, default=ignore):
... | 13 | 2 | 5 | 0 | 4 | 1 | 1 | 0.28 | 1 | 5 | 0 | 0 | 6 | 0 | 9 | 14 | 71 | 11 | 47 | 19 | 34 | 13 | 30 | 16 | 20 | 3 | 1 | 1 | 12 |
16,664 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.BadCallable | from zipline.errors import ZiplineError
from itertools import chain
class BadCallable(TypeError, AssertionError, ZiplineError):
"""
The given callable is not structured in the expected way.
"""
_lambda_name = (lambda: None).__name__
def __init__(self, callable_, args, starargs, kwargs):
se... |
class BadCallable(TypeError, AssertionError, ZiplineError):
'''
The given callable is not structured in the expected way.
'''
def __init__(self, callable_, args, starargs, kwargs):
pass
def format_callable(self):
pass
@property
def msg(self):
pass | 5 | 1 | 9 | 1 | 8 | 0 | 1 | 0.11 | 3 | 2 | 0 | 8 | 3 | 5 | 3 | 18 | 36 | 5 | 28 | 13 | 23 | 3 | 17 | 12 | 13 | 2 | 4 | 1 | 4 |
16,665 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.Ignore | @singleton
class Ignore(object):
def __str__(self):
return 'Argument.ignore'
__repr__ = __str__ | @singleton
class Ignore(object):
def __str__(self):
pass | 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
16,666 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.MismatchedArguments | class MismatchedArguments(BadCallable):
"""
The argument lists are of the same lengths, but not in the correct order.
"""
def __str__(self):
return '%s accepts mismatched parameters' % self.format_callable() | class MismatchedArguments(BadCallable):
'''
The argument lists are of the same lengths, but not in the correct order.
'''
def __str__(self):
pass | 2 | 1 | 2 | 0 | 2 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 19 | 6 | 0 | 3 | 2 | 1 | 3 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
16,667 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.NoDefault | @singleton
class NoDefault(object):
def __str__(self):
return 'Argument.no_default'
__repr__ = __str__ | @singleton
class NoDefault(object):
def __str__(self):
pass | 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
16,668 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.NoKwargs | class NoKwargs(BadCallable):
def __str__(self):
return '%s does not allow for **kwargs' % self.format_callable() | class NoKwargs(BadCallable):
def __str__(self):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 19 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
16,669 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.NoStarargs | class NoStarargs(BadCallable):
def __str__(self):
return '%s does not allow for *args' % self.format_callable() | class NoStarargs(BadCallable):
def __str__(self):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 19 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
16,670 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.NotCallable | class NotCallable(BadCallable):
"""
The provided 'callable' is not actually a callable.
"""
def __init__(self, callable_):
self.callable_ = callable_
def __str__(self):
return '%s is not callable' % self.format_callable()
def format_callable(self):
try:
ret... | class NotCallable(BadCallable):
'''
The provided 'callable' is not actually a callable.
'''
def __init__(self, callable_):
pass
def __str__(self):
pass
def format_callable(self):
pass | 4 | 1 | 3 | 0 | 3 | 0 | 1 | 0.3 | 1 | 2 | 0 | 0 | 3 | 1 | 3 | 21 | 15 | 2 | 10 | 5 | 6 | 3 | 10 | 5 | 6 | 2 | 5 | 1 | 4 |
16,671 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.NotEnoughArguments | from six.moves import map, zip_longest
class NotEnoughArguments(BadCallable):
"""
The callback does not accept enough arguments.
"""
def __init__(self, callable_, args, starargs, kwargs, missing_args):
super(NotEnoughArguments, self).__init__(callable_, args, starargs, kwargs)
self.mis... |
class NotEnoughArguments(BadCallable):
'''
The callback does not accept enough arguments.
'''
def __init__(self, callable_, args, starargs, kwargs, missing_args):
pass
def __str__(self):
pass | 3 | 1 | 6 | 0 | 6 | 0 | 2 | 0.23 | 1 | 4 | 0 | 0 | 2 | 1 | 2 | 20 | 17 | 1 | 13 | 5 | 10 | 3 | 7 | 5 | 4 | 2 | 5 | 0 | 3 |
16,672 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.TooManyArguments | class TooManyArguments(BadCallable):
"""
The callback cannot be called by passing the expected number of arguments.
"""
def __str__(self):
return '%s accepts too many arguments' % self.format_callable() | class TooManyArguments(BadCallable):
'''
The callback cannot be called by passing the expected number of arguments.
'''
def __str__(self):
pass | 2 | 1 | 2 | 0 | 2 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 19 | 6 | 0 | 3 | 2 | 1 | 3 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
16,673 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.UnexpectedKwargs | class UnexpectedKwargs(BadCallable):
def __str__(self):
return '%s should not allow for **kwargs' % self.format_callable() | class UnexpectedKwargs(BadCallable):
def __str__(self):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 19 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
16,674 | quantopian/zipline | quantopian_zipline/zipline/utils/argcheck.py | zipline.utils.argcheck.UnexpectedStarargs | class UnexpectedStarargs(BadCallable):
def __str__(self):
return '%s should not allow for *args' % self.format_callable() | class UnexpectedStarargs(BadCallable):
def __str__(self):
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 19 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
16,675 | quantopian/zipline | quantopian_zipline/zipline/utils/cache.py | zipline.utils.cache.CachedObject | class CachedObject(object):
"""
A simple struct for maintaining a cached object with an expiration date.
Parameters
----------
value : object
The object to cache.
expires : datetime-like
Expiration date of `value`. The cache is considered invalid for dates
**strictly gre... | class CachedObject(object):
'''
A simple struct for maintaining a cached object with an expiration date.
Parameters
----------
value : object
The object to cache.
expires : datetime-like
Expiration date of `value`. The cache is considered invalid for dates
**strictly grea... | 6 | 4 | 7 | 1 | 3 | 4 | 1 | 2.71 | 1 | 1 | 1 | 0 | 3 | 2 | 4 | 4 | 59 | 7 | 14 | 9 | 8 | 38 | 13 | 8 | 8 | 2 | 1 | 1 | 5 |
16,676 | quantopian/zipline | quantopian_zipline/zipline/utils/cache.py | zipline.utils.cache.Expired | class Expired(Exception):
"""Marks that a :class:`CachedObject` has expired.
""" | class Expired(Exception):
'''Marks that a :class:`CachedObject` has expired.
'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 3 | 0 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 0 | 3 | 0 | 0 |
16,677 | quantopian/zipline | quantopian_zipline/zipline/utils/cache.py | zipline.utils.cache.ExpiringCache | class ExpiringCache(object):
"""
A cache of multiple CachedObjects, which returns the wrapped the value
or raises and deletes the CachedObject if the value has expired.
Parameters
----------
cache : dict-like, optional
An instance of a dict-like object which needs to support at least:
... | class ExpiringCache(object):
'''
A cache of multiple CachedObjects, which returns the wrapped the value
or raises and deletes the CachedObject if the value has expired.
Parameters
----------
cache : dict-like, optional
An instance of a dict-like object which needs to support at least:
... | 4 | 3 | 16 | 2 | 5 | 9 | 2 | 3.44 | 1 | 3 | 2 | 0 | 3 | 2 | 3 | 3 | 82 | 11 | 16 | 6 | 12 | 55 | 15 | 6 | 11 | 2 | 1 | 1 | 5 |
16,678 | quantopian/zipline | quantopian_zipline/zipline/utils/cache.py | zipline.utils.cache.dataframe_cache | from shutil import rmtree, move
from .context_tricks import nop_context
import pandas as pd
from .paths import ensure_directory
import pickle
import errno
from .compat import PY2
from collections import MutableMapping
from functools import partial
import os
from tempfile import mkdtemp, NamedTemporaryFile
class datafr... | null | 12 | 1 | 7 | 0 | 6 | 0 | 2 | 0.43 | 1 | 10 | 1 | 0 | 11 | 6 | 11 | 11 | 117 | 18 | 69 | 27 | 53 | 30 | 56 | 19 | 44 | 7 | 1 | 3 | 23 |
16,679 | quantopian/zipline | quantopian_zipline/zipline/utils/cache.py | zipline.utils.cache.working_dir | from tempfile import mkdtemp, NamedTemporaryFile
from distutils import dir_util
import os
from shutil import rmtree, move
from .paths import ensure_directory
class working_dir(object):
"""A context manager for managing a temporary directory that will be moved
to a non-temporary location if no exceptions are ra... |
class working_dir(object):
'''A context manager for managing a temporary directory that will be moved
to a non-temporary location if no exceptions are raised in the context.
Parameters
----------
final_path : str
The location to move the file when committing.
*args, **kwargs
For... | 7 | 4 | 6 | 0 | 3 | 2 | 1 | 1.56 | 1 | 0 | 0 | 0 | 6 | 2 | 6 | 6 | 55 | 9 | 18 | 10 | 11 | 28 | 18 | 10 | 11 | 2 | 1 | 1 | 7 |
16,680 | quantopian/zipline | quantopian_zipline/zipline/utils/cache.py | zipline.utils.cache.working_file | from shutil import rmtree, move
from tempfile import mkdtemp, NamedTemporaryFile
class working_file(object):
"""A context manager for managing a temporary file that will be moved
to a non-temporary location if no exceptions are raised in the context.
Parameters
----------
final_path : str
... |
class working_file(object):
'''A context manager for managing a temporary file that will be moved
to a non-temporary location if no exceptions are raised in the context.
Parameters
----------
final_path : str
The location to move the file when committing.
*args, **kwargs
Forward... | 7 | 3 | 4 | 0 | 3 | 1 | 1 | 1.19 | 1 | 0 | 0 | 0 | 5 | 2 | 5 | 5 | 41 | 6 | 16 | 9 | 9 | 19 | 15 | 8 | 9 | 2 | 1 | 1 | 6 |
16,681 | quantopian/zipline | quantopian_zipline/zipline/utils/classproperty.py | zipline.utils.classproperty.classproperty | class classproperty(object):
"""Class property
"""
def __init__(self, fget):
self.fget = fget
def __get__(self, instance, owner):
return self.fget(owner) | class classproperty(object):
'''Class property
'''
def __init__(self, fget):
pass
def __get__(self, instance, owner):
pass | 3 | 1 | 2 | 0 | 2 | 0 | 1 | 0.4 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 2 | 8 | 1 | 5 | 4 | 2 | 2 | 5 | 4 | 2 | 1 | 1 | 0 | 2 |
16,682 | quantopian/zipline | quantopian_zipline/zipline/utils/cli.py | zipline.utils.cli.Date | class Date(_DatetimeParam):
"""A click parameter that parses the value into datetime.date objects.
Parameters
----------
tz : timezone-coercable, optional
The timezone to parse the string as.
By default the timezone will be infered from the string or naiive.
as_timestamp : bool, opt... | class Date(_DatetimeParam):
'''A click parameter that parses the value into datetime.date objects.
Parameters
----------
tz : timezone-coercable, optional
The timezone to parse the string as.
By default the timezone will be infered from the string or naiive.
as_timestamp : bool, opti... | 3 | 1 | 3 | 0 | 3 | 0 | 2 | 1.43 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 6 | 19 | 2 | 7 | 5 | 4 | 10 | 7 | 5 | 4 | 2 | 1 | 0 | 3 |
16,683 | quantopian/zipline | quantopian_zipline/zipline/utils/cli.py | zipline.utils.cli.Time | class Time(_DatetimeParam):
"""A click parameter that parses the value into timetime.time objects.
Parameters
----------
tz : timezone-coercable, optional
The timezone to parse the string as.
By default the timezone will be infered from the string or naiive.
"""
def parser(self... | class Time(_DatetimeParam):
'''A click parameter that parses the value into timetime.time objects.
Parameters
----------
tz : timezone-coercable, optional
The timezone to parse the string as.
By default the timezone will be infered from the string or naiive.
'''
def pars... | 2 | 1 | 2 | 0 | 2 | 0 | 1 | 2.33 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 5 | 11 | 1 | 3 | 2 | 1 | 7 | 3 | 2 | 1 | 1 | 1 | 0 | 1 |
16,684 | quantopian/zipline | quantopian_zipline/zipline/utils/cli.py | zipline.utils.cli.Timedelta | import pandas as pd
class Timedelta(_DatetimeParam):
"""A click parameter that parses values into pd.Timedelta objects.
Parameters
----------
unit : {'D', 'h', 'm', 's', 'ms', 'us', 'ns'}, optional
Denotes the unit of the input if the input is an integer.
"""
def __init__(self, unit='... |
class Timedelta(_DatetimeParam):
'''A click parameter that parses values into pd.Timedelta objects.
Parameters
----------
unit : {'D', 'h', 'm', 's', 'ms', 'us', 'ns'}, optional
Denotes the unit of the input if the input is an integer.
'''
def __init__(self, unit='ns'):
pass
... | 3 | 1 | 2 | 0 | 2 | 0 | 1 | 1.2 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 6 | 13 | 2 | 5 | 4 | 2 | 6 | 5 | 4 | 2 | 1 | 1 | 0 | 2 |
16,685 | quantopian/zipline | quantopian_zipline/zipline/utils/cli.py | zipline.utils.cli.Timestamp | class Timestamp(_DatetimeParam):
"""A click parameter that parses the value into pandas.Timestamp objects.
Parameters
----------
tz : timezone-coercable, optional
The timezone to parse the string as.
By default the timezone will be infered from the string or naiive.
""" | class Timestamp(_DatetimeParam):
'''A click parameter that parses the value into pandas.Timestamp objects.
Parameters
----------
tz : timezone-coercable, optional
The timezone to parse the string as.
By default the timezone will be infered from the string or naiive.
'''
p... | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 7 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 9 | 1 | 1 | 1 | 0 | 7 | 1 | 1 | 0 | 0 | 1 | 0 | 0 |
16,686 | quantopian/zipline | quantopian_zipline/zipline/utils/cli.py | zipline.utils.cli._DatetimeParam | import click
import pandas as pd
class _DatetimeParam(click.ParamType):
def __init__(self, tz=None):
self.tz = tz
def parser(self, value):
return pd.Timestamp(value, tz=self.tz)
@property
def name(self):
return type(self).__name__.upper()
def convert(self, value, param, ... |
class _DatetimeParam(click.ParamType):
def __init__(self, tz=None):
pass
def parser(self, value):
pass
@property
def name(self):
pass
def convert(self, value, param, ctx):
pass | 6 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 0 | 2 | 0 | 4 | 4 | 1 | 4 | 4 | 20 | 3 | 17 | 7 | 11 | 0 | 12 | 6 | 7 | 2 | 0 | 1 | 5 |
16,687 | quantopian/zipline | quantopian_zipline/zipline/utils/data.py | zipline.utils.data.MutableIndexRollingPanel | import pandas as pd
from copy import deepcopy
import numpy as np
class MutableIndexRollingPanel(object):
"""
A version of RollingPanel that exists for backwards compatibility with
batch_transform. This is a copy to allow behavior of RollingPanel to drift
away from this without breaking this class.
... |
class MutableIndexRollingPanel(object):
'''
A version of RollingPanel that exists for backwards compatibility with
batch_transform. This is a copy to allow behavior of RollingPanel to drift
away from this without breaking this class.
This code should be considered frozen, and should not be used in ... | 12 | 6 | 12 | 2 | 6 | 4 | 1 | 0.65 | 1 | 3 | 0 | 0 | 11 | 9 | 11 | 11 | 148 | 29 | 72 | 34 | 60 | 47 | 63 | 34 | 51 | 4 | 1 | 1 | 16 |
16,688 | quantopian/zipline | quantopian_zipline/zipline/utils/data.py | zipline.utils.data.RollingPanel | from copy import deepcopy
import numpy as np
import datetime
import pandas as pd
class RollingPanel(object):
"""
Preallocation strategies for rolling window over expanding data set
Restrictions: major_axis can only be a DatetimeIndex for now
"""
def __init__(self, window, items, sids, cap_multipl... |
class RollingPanel(object):
'''
Preallocation strategies for rolling window over expanding data set
Restrictions: major_axis can only be a DatetimeIndex for now
'''
def __init__(self, window, items, sids, cap_multiple=2, dtype=np.float64, initial_dates=None):
pass
@property
def cap... | 21 | 7 | 12 | 2 | 9 | 2 | 2 | 0.21 | 1 | 4 | 0 | 0 | 15 | 8 | 15 | 15 | 214 | 43 | 141 | 53 | 114 | 30 | 100 | 43 | 83 | 7 | 1 | 1 | 30 |
16,689 | quantopian/zipline | quantopian_zipline/zipline/utils/dummy.py | zipline.utils.dummy.DummyMapping | class DummyMapping(object):
"""
Dummy object used to provide a mapping interface for singular values.
"""
def __init__(self, value):
self._value = value
def __getitem__(self, key):
return self._value | class DummyMapping(object):
'''
Dummy object used to provide a mapping interface for singular values.
'''
def __init__(self, value):
pass
def __getitem__(self, key):
pass | 3 | 1 | 2 | 0 | 2 | 0 | 1 | 0.6 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 2 | 9 | 1 | 5 | 4 | 2 | 3 | 5 | 4 | 2 | 1 | 1 | 0 | 2 |
16,690 | quantopian/zipline | quantopian_zipline/zipline/utils/events.py | zipline.utils.events.ComposedRule | class ComposedRule(StatelessRule):
"""
A rule that composes the results of two rules with some composing function.
The composing function should be a binary function that accepts the results
first(dt) and second(dt) as positional arguments.
For example, operator.and_.
If lazy=True, then the lazy... | class ComposedRule(StatelessRule):
'''
A rule that composes the results of two rules with some composing function.
The composing function should be a binary function that accepts the results
first(dt) and second(dt) as positional arguments.
For example, operator.and_.
If lazy=True, then the lazy... | 9 | 3 | 6 | 0 | 4 | 2 | 1 | 0.87 | 1 | 1 | 0 | 0 | 4 | 3 | 5 | 9 | 48 | 5 | 23 | 12 | 14 | 20 | 15 | 9 | 9 | 2 | 3 | 1 | 6 |
16,691 | quantopian/zipline | quantopian_zipline/zipline/utils/events.py | zipline.utils.events.Event | from collections import namedtuple
class Event(namedtuple('Event', ['rule', 'callback'])):
"""
An event is a pairing of an EventRule and a callable that will be invoked
with the current algorithm context, data, and datetime only when the rule
is triggered.
"""
def __new__(cls, rule, callback=N... |
class Event(namedtuple('Event', ['rule', 'callback'])):
'''
An event is a pairing of an EventRule and a callable that will be invoked
with the current algorithm context, data, and datetime only when the rule
is triggered.
'''
def __new__(cls, rule, callback=None):
pass
def handle_... | 3 | 2 | 5 | 0 | 3 | 2 | 2 | 1.14 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 7 | 16 | 1 | 7 | 3 | 4 | 8 | 7 | 3 | 4 | 2 | 1 | 1 | 3 |
16,692 | quantopian/zipline | quantopian_zipline/zipline/utils/events.py | zipline.utils.events.EventRule | from abc import ABCMeta, abstractmethod
import six
class EventRule(six.with_metaclass(ABCMeta)):
"""A rule defining when a scheduled function should execute.
"""
_cal = None
@property
def cal(self):
return self._cal
@cal.setter
def cal(self, value):
self._cal = value
... |
class EventRule(six.with_metaclass(ABCMeta)):
'''A rule defining when a scheduled function should execute.
'''
@property
def cal(self):
pass
@cal.setter
def cal(self):
pass
@abstractmethod
def should_trigger(self, dt):
'''
Checks if the rule should tr... | 7 | 2 | 3 | 0 | 2 | 1 | 1 | 0.73 | 1 | 1 | 0 | 2 | 3 | 0 | 3 | 3 | 22 | 3 | 11 | 8 | 4 | 8 | 8 | 5 | 4 | 1 | 1 | 0 | 3 |
16,693 | quantopian/zipline | quantopian_zipline/zipline/utils/events.py | zipline.utils.events.StatefulRule | class StatefulRule(EventRule):
"""
A stateful rule has state.
This rule will give different results for the same datetimes depending
on the internal state that this holds.
StatefulRules wrap other rules as state transformers.
"""
def __init__(self, rule=None):
self.rule = rule or Al... | class StatefulRule(EventRule):
'''
A stateful rule has state.
This rule will give different results for the same datetimes depending
on the internal state that this holds.
StatefulRules wrap other rules as state transformers.
'''
def __init__(self, rule=None):
pass
@property
... | 6 | 1 | 2 | 0 | 2 | 0 | 1 | 0.78 | 1 | 1 | 1 | 2 | 3 | 1 | 3 | 6 | 18 | 2 | 9 | 7 | 3 | 7 | 7 | 5 | 3 | 1 | 2 | 0 | 3 |
16,694 | quantopian/zipline | quantopian_zipline/zipline/utils/events.py | zipline.utils.events.TradingDayOfMonthRule | from zipline.utils.memoize import lazyval
from abc import ABCMeta, abstractmethod
import numpy as np
from zipline.utils.input_validation import preprocess
import six
import pandas as pd
class TradingDayOfMonthRule(six.with_metaclass(ABCMeta, StatelessRule)):
@preprocess(n=lossless_float_to_int('TradingDayOfMonthR... |
class TradingDayOfMonthRule(six.with_metaclass(ABCMeta, StatelessRule)):
@preprocess(n=lossless_float_to_int('TradingDayOfMonthRule'))
def __init__(self, n, invert):
pass
def should_trigger(self, dt):
pass
@lazyval
def execution_period_values(self):
pass | 6 | 0 | 7 | 0 | 6 | 1 | 2 | 0.1 | 1 | 2 | 0 | 2 | 3 | 1 | 3 | 3 | 26 | 3 | 21 | 9 | 15 | 2 | 13 | 7 | 9 | 3 | 1 | 1 | 5 |
16,695 | quantopian/zipline | quantopian_zipline/zipline/utils/events.py | zipline.utils.events.TradingDayOfWeekRule | import six
import numpy as np
from zipline.utils.memoize import lazyval
from zipline.utils.input_validation import preprocess
from abc import ABCMeta, abstractmethod
import pandas as pd
class TradingDayOfWeekRule(six.with_metaclass(ABCMeta, StatelessRule)):
@preprocess(n=lossless_float_to_int('TradingDayOfWeekRul... |
class TradingDayOfWeekRule(six.with_metaclass(ABCMeta, StatelessRule)):
@preprocess(n=lossless_float_to_int('TradingDayOfWeekRule'))
def __init__(self, n, invert):
pass
def should_trigger(self, dt):
pass
@lazyval
def execution_period_values(self):
pass | 6 | 0 | 6 | 0 | 5 | 1 | 2 | 0.17 | 1 | 2 | 0 | 2 | 3 | 1 | 3 | 3 | 24 | 3 | 18 | 9 | 12 | 3 | 11 | 7 | 7 | 3 | 1 | 1 | 5 |
16,696 | quantopian/zipline | quantopian_zipline/zipline/utils/events.py | zipline.utils.events.calendars | from zipline.utils.sentinel import sentinel
class calendars(object):
US_EQUITIES = sentinel('US_EQUITIES')
US_FUTURES = sentinel('US_FUTURES') |
class calendars(object):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
16,697 | quantopian/zipline | quantopian_zipline/zipline/utils/events.py | zipline.utils.events.date_rules | class date_rules(object):
"""
Factories for date-based :func:`~zipline.api.schedule_function` rules.
See Also
--------
:func:`~zipline.api.schedule_function`
"""
@staticmethod
def every_day():
"""Create a rule that triggers every day.
Returns
-------
ru... | class date_rules(object):
'''
Factories for date-based :func:`~zipline.api.schedule_function` rules.
See Also
--------
:func:`~zipline.api.schedule_function`
'''
@staticmethod
def every_day():
'''Create a rule that triggers every day.
Returns
-------
rule ... | 11 | 6 | 13 | 1 | 2 | 10 | 1 | 3.38 | 1 | 5 | 5 | 0 | 0 | 0 | 5 | 5 | 83 | 13 | 16 | 11 | 5 | 54 | 11 | 6 | 5 | 1 | 1 | 0 | 5 |
16,698 | quantopian/zipline | quantopian_zipline/zipline/utils/events.py | zipline.utils.events.time_rules | class time_rules(object):
"""Factories for time-based :func:`~zipline.api.schedule_function` rules.
See Also
--------
:func:`~zipline.api.schedule_function`
"""
@staticmethod
def market_open(offset=None, hours=None, minutes=None):
"""
Create a rule that triggers at a fixed ... | null | 5 | 3 | 31 | 5 | 2 | 24 | 1 | 6.63 | 1 | 2 | 2 | 0 | 0 | 0 | 2 | 2 | 75 | 14 | 8 | 6 | 3 | 53 | 6 | 4 | 3 | 1 | 1 | 0 | 2 |
16,699 | quantopian/zipline | quantopian_zipline/zipline/utils/exploding_object.py | zipline.utils.exploding_object.NamedExplodingObject | class NamedExplodingObject(object):
"""An object which has no attributes but produces a more informative
error message when accessed.
Parameters
----------
name : str
The name of the object. This will appear in the error messages.
Notes
-----
One common use for this object is s... | class NamedExplodingObject(object):
'''An object which has no attributes but produces a more informative
error message when accessed.
Parameters
----------
name : str
The name of the object. This will appear in the error messages.
Notes
-----
One common use for this object is so ... | 4 | 1 | 7 | 0 | 6 | 1 | 2 | 0.68 | 1 | 2 | 0 | 0 | 3 | 2 | 3 | 3 | 36 | 4 | 19 | 7 | 15 | 13 | 9 | 7 | 5 | 2 | 1 | 0 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.