id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
25,800 | quantopian/zipline | zipline/data/minute_bars.py | BcolzMinuteBarWriter.truncate | def truncate(self, date):
"""Truncate data beyond this date in all ctables."""
truncate_slice_end = self.data_len_for_day(date)
glob_path = os.path.join(self._rootdir, "*", "*", "*.bcolz")
sid_paths = sorted(glob(glob_path))
for sid_path in sid_paths:
file_name = os... | python | def truncate(self, date):
"""Truncate data beyond this date in all ctables."""
truncate_slice_end = self.data_len_for_day(date)
glob_path = os.path.join(self._rootdir, "*", "*", "*.bcolz")
sid_paths = sorted(glob(glob_path))
for sid_path in sid_paths:
file_name = os... | [
"def",
"truncate",
"(",
"self",
",",
"date",
")",
":",
"truncate_slice_end",
"=",
"self",
".",
"data_len_for_day",
"(",
"date",
")",
"glob_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_rootdir",
",",
"\"*\"",
",",
"\"*\"",
",",
"\"*.b... | Truncate data beyond this date in all ctables. | [
"Truncate",
"data",
"beyond",
"this",
"date",
"in",
"all",
"ctables",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L856-L883 |
25,801 | quantopian/zipline | zipline/data/minute_bars.py | BcolzMinuteBarReader._minutes_to_exclude | def _minutes_to_exclude(self):
"""
Calculate the minutes which should be excluded when a window
occurs on days which had an early close, i.e. days where the close
based on the regular period of minutes per day and the market close
do not match.
Returns
-------
... | python | def _minutes_to_exclude(self):
"""
Calculate the minutes which should be excluded when a window
occurs on days which had an early close, i.e. days where the close
based on the regular period of minutes per day and the market close
do not match.
Returns
-------
... | [
"def",
"_minutes_to_exclude",
"(",
"self",
")",
":",
"market_opens",
"=",
"self",
".",
"_market_opens",
".",
"values",
".",
"astype",
"(",
"'datetime64[m]'",
")",
"market_closes",
"=",
"self",
".",
"_market_closes",
".",
"values",
".",
"astype",
"(",
"'datetim... | Calculate the minutes which should be excluded when a window
occurs on days which had an early close, i.e. days where the close
based on the regular period of minutes per day and the market close
do not match.
Returns
-------
List of DatetimeIndex representing the minute... | [
"Calculate",
"the",
"minutes",
"which",
"should",
"be",
"excluded",
"when",
"a",
"window",
"occurs",
"on",
"days",
"which",
"had",
"an",
"early",
"close",
"i",
".",
"e",
".",
"days",
"where",
"the",
"close",
"based",
"on",
"the",
"regular",
"period",
"of... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L991-L1013 |
25,802 | quantopian/zipline | zipline/data/minute_bars.py | BcolzMinuteBarReader.get_value | def get_value(self, sid, dt, field):
"""
Retrieve the pricing info for the given sid, dt, and field.
Parameters
----------
sid : int
Asset identifier.
dt : datetime-like
The datetime at which the trade occurred.
field : string
... | python | def get_value(self, sid, dt, field):
"""
Retrieve the pricing info for the given sid, dt, and field.
Parameters
----------
sid : int
Asset identifier.
dt : datetime-like
The datetime at which the trade occurred.
field : string
... | [
"def",
"get_value",
"(",
"self",
",",
"sid",
",",
"dt",
",",
"field",
")",
":",
"if",
"self",
".",
"_last_get_value_dt_value",
"==",
"dt",
".",
"value",
":",
"minute_pos",
"=",
"self",
".",
"_last_get_value_dt_position",
"else",
":",
"try",
":",
"minute_po... | Retrieve the pricing info for the given sid, dt, and field.
Parameters
----------
sid : int
Asset identifier.
dt : datetime-like
The datetime at which the trade occurred.
field : string
The type of pricing data to retrieve.
('open'... | [
"Retrieve",
"the",
"pricing",
"info",
"for",
"the",
"given",
"sid",
"dt",
"and",
"field",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L1098-L1149 |
25,803 | quantopian/zipline | zipline/data/minute_bars.py | BcolzMinuteBarReader._find_position_of_minute | def _find_position_of_minute(self, minute_dt):
"""
Internal method that returns the position of the given minute in the
list of every trading minute since market open of the first trading
day. Adjusts non market minutes to the last close.
ex. this method would return 1 for 2002-... | python | def _find_position_of_minute(self, minute_dt):
"""
Internal method that returns the position of the given minute in the
list of every trading minute since market open of the first trading
day. Adjusts non market minutes to the last close.
ex. this method would return 1 for 2002-... | [
"def",
"_find_position_of_minute",
"(",
"self",
",",
"minute_dt",
")",
":",
"return",
"find_position_of_minute",
"(",
"self",
".",
"_market_open_values",
",",
"self",
".",
"_market_close_values",
",",
"minute_dt",
".",
"value",
"/",
"NANOS_IN_MINUTE",
",",
"self",
... | Internal method that returns the position of the given minute in the
list of every trading minute since market open of the first trading
day. Adjusts non market minutes to the last close.
ex. this method would return 1 for 2002-01-02 9:32 AM Eastern, if
2002-01-02 is the first trading d... | [
"Internal",
"method",
"that",
"returns",
"the",
"position",
"of",
"the",
"given",
"minute",
"in",
"the",
"list",
"of",
"every",
"trading",
"minute",
"since",
"market",
"open",
"of",
"the",
"first",
"trading",
"day",
".",
"Adjusts",
"non",
"market",
"minutes"... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L1203-L1228 |
25,804 | quantopian/zipline | zipline/data/minute_bars.py | H5MinuteBarUpdateWriter.write | def write(self, frames):
"""
Write the frames to the target HDF5 file, using the format used by
``pd.Panel.to_hdf``
Parameters
----------
frames : iter[(int, DataFrame)] or dict[int -> DataFrame]
An iterable or other mapping of sid to the corresponding OHLCV
... | python | def write(self, frames):
"""
Write the frames to the target HDF5 file, using the format used by
``pd.Panel.to_hdf``
Parameters
----------
frames : iter[(int, DataFrame)] or dict[int -> DataFrame]
An iterable or other mapping of sid to the corresponding OHLCV
... | [
"def",
"write",
"(",
"self",
",",
"frames",
")",
":",
"with",
"HDFStore",
"(",
"self",
".",
"_path",
",",
"'w'",
",",
"complevel",
"=",
"self",
".",
"_complevel",
",",
"complib",
"=",
"self",
".",
"_complib",
")",
"as",
"store",
":",
"panel",
"=",
... | Write the frames to the target HDF5 file, using the format used by
``pd.Panel.to_hdf``
Parameters
----------
frames : iter[(int, DataFrame)] or dict[int -> DataFrame]
An iterable or other mapping of sid to the corresponding OHLCV
pricing data. | [
"Write",
"the",
"frames",
"to",
"the",
"target",
"HDF5",
"file",
"using",
"the",
"format",
"used",
"by",
"pd",
".",
"Panel",
".",
"to_hdf"
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L1346-L1363 |
25,805 | quantopian/zipline | zipline/pipeline/loaders/utils.py | next_event_indexer | def next_event_indexer(all_dates,
data_query_cutoff,
all_sids,
event_dates,
event_timestamps,
event_sids):
"""
Construct an index array that, when applied to an array of values, produces
a 2D a... | python | def next_event_indexer(all_dates,
data_query_cutoff,
all_sids,
event_dates,
event_timestamps,
event_sids):
"""
Construct an index array that, when applied to an array of values, produces
a 2D a... | [
"def",
"next_event_indexer",
"(",
"all_dates",
",",
"data_query_cutoff",
",",
"all_sids",
",",
"event_dates",
",",
"event_timestamps",
",",
"event_sids",
")",
":",
"validate_event_metadata",
"(",
"event_dates",
",",
"event_timestamps",
",",
"event_sids",
")",
"out",
... | Construct an index array that, when applied to an array of values, produces
a 2D array containing the values associated with the next event for each
sid at each moment in time.
Locations where no next event was known will be filled with -1.
Parameters
----------
all_dates : ndarray[datetime64[... | [
"Construct",
"an",
"index",
"array",
"that",
"when",
"applied",
"to",
"an",
"array",
"of",
"values",
"produces",
"a",
"2D",
"array",
"containing",
"the",
"values",
"associated",
"with",
"the",
"next",
"event",
"for",
"each",
"sid",
"at",
"each",
"moment",
... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L25-L79 |
25,806 | quantopian/zipline | zipline/pipeline/loaders/utils.py | previous_event_indexer | def previous_event_indexer(data_query_cutoff_times,
all_sids,
event_dates,
event_timestamps,
event_sids):
"""
Construct an index array that, when applied to an array of values, produces
a 2D array con... | python | def previous_event_indexer(data_query_cutoff_times,
all_sids,
event_dates,
event_timestamps,
event_sids):
"""
Construct an index array that, when applied to an array of values, produces
a 2D array con... | [
"def",
"previous_event_indexer",
"(",
"data_query_cutoff_times",
",",
"all_sids",
",",
"event_dates",
",",
"event_timestamps",
",",
"event_sids",
")",
":",
"validate_event_metadata",
"(",
"event_dates",
",",
"event_timestamps",
",",
"event_sids",
")",
"out",
"=",
"np"... | Construct an index array that, when applied to an array of values, produces
a 2D array containing the values associated with the previous event for
each sid at each moment in time.
Locations where no previous event was known will be filled with -1.
Parameters
----------
data_query_cutoff : pd.... | [
"Construct",
"an",
"index",
"array",
"that",
"when",
"applied",
"to",
"an",
"array",
"of",
"values",
"produces",
"a",
"2D",
"array",
"containing",
"the",
"values",
"associated",
"with",
"the",
"previous",
"event",
"for",
"each",
"sid",
"at",
"each",
"moment"... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L82-L138 |
25,807 | quantopian/zipline | zipline/pipeline/loaders/utils.py | last_in_date_group | def last_in_date_group(df,
data_query_cutoff_times,
assets,
reindex=True,
have_sids=True,
extra_groupers=None):
"""
Determine the last piece of information known on each date in the date
index... | python | def last_in_date_group(df,
data_query_cutoff_times,
assets,
reindex=True,
have_sids=True,
extra_groupers=None):
"""
Determine the last piece of information known on each date in the date
index... | [
"def",
"last_in_date_group",
"(",
"df",
",",
"data_query_cutoff_times",
",",
"assets",
",",
"reindex",
"=",
"True",
",",
"have_sids",
"=",
"True",
",",
"extra_groupers",
"=",
"None",
")",
":",
"idx",
"=",
"[",
"data_query_cutoff_times",
"[",
"data_query_cutoff_t... | Determine the last piece of information known on each date in the date
index for each group. Input df MUST be sorted such that the correct last
item is chosen from each group.
Parameters
----------
df : pd.DataFrame
The DataFrame containing the data to be grouped. Must be sorted so that
... | [
"Determine",
"the",
"last",
"piece",
"of",
"information",
"known",
"on",
"each",
"date",
"in",
"the",
"date"
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L141-L213 |
25,808 | quantopian/zipline | zipline/pipeline/loaders/utils.py | ffill_across_cols | def ffill_across_cols(df, columns, name_map):
"""
Forward fill values in a DataFrame with special logic to handle cases
that pd.DataFrame.ffill cannot and cast columns to appropriate types.
Parameters
----------
df : pd.DataFrame
The DataFrame to do forward-filling on.
columns : lis... | python | def ffill_across_cols(df, columns, name_map):
"""
Forward fill values in a DataFrame with special logic to handle cases
that pd.DataFrame.ffill cannot and cast columns to appropriate types.
Parameters
----------
df : pd.DataFrame
The DataFrame to do forward-filling on.
columns : lis... | [
"def",
"ffill_across_cols",
"(",
"df",
",",
"columns",
",",
"name_map",
")",
":",
"df",
".",
"ffill",
"(",
"inplace",
"=",
"True",
")",
"# Fill in missing values specified by each column. This is made",
"# significantly more complex by the fact that we need to work around",
"... | Forward fill values in a DataFrame with special logic to handle cases
that pd.DataFrame.ffill cannot and cast columns to appropriate types.
Parameters
----------
df : pd.DataFrame
The DataFrame to do forward-filling on.
columns : list of BoundColumn
The BoundColumns that correspond ... | [
"Forward",
"fill",
"values",
"in",
"a",
"DataFrame",
"with",
"special",
"logic",
"to",
"handle",
"cases",
"that",
"pd",
".",
"DataFrame",
".",
"ffill",
"cannot",
"and",
"cast",
"columns",
"to",
"appropriate",
"types",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L216-L264 |
25,809 | quantopian/zipline | zipline/pipeline/loaders/utils.py | shift_dates | def shift_dates(dates, start_date, end_date, shift):
"""
Shift dates of a pipeline query back by `shift` days.
load_adjusted_array is called with dates on which the user's algo
will be shown data, which means we need to return the data that would
be known at the start of each date. This is often l... | python | def shift_dates(dates, start_date, end_date, shift):
"""
Shift dates of a pipeline query back by `shift` days.
load_adjusted_array is called with dates on which the user's algo
will be shown data, which means we need to return the data that would
be known at the start of each date. This is often l... | [
"def",
"shift_dates",
"(",
"dates",
",",
"start_date",
",",
"end_date",
",",
"shift",
")",
":",
"try",
":",
"start",
"=",
"dates",
".",
"get_loc",
"(",
"start_date",
")",
"except",
"KeyError",
":",
"if",
"start_date",
"<",
"dates",
"[",
"0",
"]",
":",
... | Shift dates of a pipeline query back by `shift` days.
load_adjusted_array is called with dates on which the user's algo
will be shown data, which means we need to return the data that would
be known at the start of each date. This is often labeled with a
previous date in the underlying data (e.g. at t... | [
"Shift",
"dates",
"of",
"a",
"pipeline",
"query",
"back",
"by",
"shift",
"days",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L267-L330 |
25,810 | quantopian/zipline | zipline/utils/sharedoc.py | format_docstring | def format_docstring(owner_name, docstring, formatters):
"""
Template ``formatters`` into ``docstring``.
Parameters
----------
owner_name : str
The name of the function or class whose docstring is being templated.
Only used for error messages.
docstring : str
The docstri... | python | def format_docstring(owner_name, docstring, formatters):
"""
Template ``formatters`` into ``docstring``.
Parameters
----------
owner_name : str
The name of the function or class whose docstring is being templated.
Only used for error messages.
docstring : str
The docstri... | [
"def",
"format_docstring",
"(",
"owner_name",
",",
"docstring",
",",
"formatters",
")",
":",
"# Build a dict of parameters to a vanilla format() call by searching for",
"# each entry in **formatters and applying any leading whitespace to each",
"# line in the desired substitution.",
"forma... | Template ``formatters`` into ``docstring``.
Parameters
----------
owner_name : str
The name of the function or class whose docstring is being templated.
Only used for error messages.
docstring : str
The docstring to template.
formatters : dict[str -> str]
Parameters ... | [
"Template",
"formatters",
"into",
"docstring",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/sharedoc.py#L35-L82 |
25,811 | quantopian/zipline | zipline/utils/sharedoc.py | templated_docstring | def templated_docstring(**docs):
"""
Decorator allowing the use of templated docstrings.
Examples
--------
>>> @templated_docstring(foo='bar')
... def my_func(self, foo):
... '''{foo}'''
...
>>> my_func.__doc__
'bar'
"""
def decorator(f):
f.__doc__ = format_d... | python | def templated_docstring(**docs):
"""
Decorator allowing the use of templated docstrings.
Examples
--------
>>> @templated_docstring(foo='bar')
... def my_func(self, foo):
... '''{foo}'''
...
>>> my_func.__doc__
'bar'
"""
def decorator(f):
f.__doc__ = format_d... | [
"def",
"templated_docstring",
"(",
"*",
"*",
"docs",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"f",
".",
"__doc__",
"=",
"format_docstring",
"(",
"f",
".",
"__name__",
",",
"f",
".",
"__doc__",
",",
"docs",
")",
"return",
"f",
"return",
"deco... | Decorator allowing the use of templated docstrings.
Examples
--------
>>> @templated_docstring(foo='bar')
... def my_func(self, foo):
... '''{foo}'''
...
>>> my_func.__doc__
'bar' | [
"Decorator",
"allowing",
"the",
"use",
"of",
"templated",
"docstrings",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/sharedoc.py#L85-L101 |
25,812 | quantopian/zipline | zipline/pipeline/pipeline.py | Pipeline.add | def add(self, term, name, overwrite=False):
"""
Add a column.
The results of computing `term` will show up as a column in the
DataFrame produced by running this pipeline.
Parameters
----------
column : zipline.pipeline.Term
A Filter, Factor, or Class... | python | def add(self, term, name, overwrite=False):
"""
Add a column.
The results of computing `term` will show up as a column in the
DataFrame produced by running this pipeline.
Parameters
----------
column : zipline.pipeline.Term
A Filter, Factor, or Class... | [
"def",
"add",
"(",
"self",
",",
"term",
",",
"name",
",",
"overwrite",
"=",
"False",
")",
":",
"self",
".",
"validate_column",
"(",
"name",
",",
"term",
")",
"columns",
"=",
"self",
".",
"columns",
"if",
"name",
"in",
"columns",
":",
"if",
"overwrite... | Add a column.
The results of computing `term` will show up as a column in the
DataFrame produced by running this pipeline.
Parameters
----------
column : zipline.pipeline.Term
A Filter, Factor, or Classifier to add to the pipeline.
name : str
Nam... | [
"Add",
"a",
"column",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L80-L112 |
25,813 | quantopian/zipline | zipline/pipeline/pipeline.py | Pipeline.set_screen | def set_screen(self, screen, overwrite=False):
"""
Set a screen on this Pipeline.
Parameters
----------
filter : zipline.pipeline.Filter
The filter to apply as a screen.
overwrite : bool
Whether to overwrite any existing screen. If overwrite is F... | python | def set_screen(self, screen, overwrite=False):
"""
Set a screen on this Pipeline.
Parameters
----------
filter : zipline.pipeline.Filter
The filter to apply as a screen.
overwrite : bool
Whether to overwrite any existing screen. If overwrite is F... | [
"def",
"set_screen",
"(",
"self",
",",
"screen",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"self",
".",
"_screen",
"is",
"not",
"None",
"and",
"not",
"overwrite",
":",
"raise",
"ValueError",
"(",
"\"set_screen() called with overwrite=False and screen already... | Set a screen on this Pipeline.
Parameters
----------
filter : zipline.pipeline.Filter
The filter to apply as a screen.
overwrite : bool
Whether to overwrite any existing screen. If overwrite is False
and self.screen is not None, we raise an error. | [
"Set",
"a",
"screen",
"on",
"this",
"Pipeline",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L137-L158 |
25,814 | quantopian/zipline | zipline/pipeline/pipeline.py | Pipeline.to_execution_plan | def to_execution_plan(self,
domain,
default_screen,
start_date,
end_date):
"""
Compile into an ExecutionPlan.
Parameters
----------
domain : zipline.pipeline.domain.Domain
... | python | def to_execution_plan(self,
domain,
default_screen,
start_date,
end_date):
"""
Compile into an ExecutionPlan.
Parameters
----------
domain : zipline.pipeline.domain.Domain
... | [
"def",
"to_execution_plan",
"(",
"self",
",",
"domain",
",",
"default_screen",
",",
"start_date",
",",
"end_date",
")",
":",
"if",
"self",
".",
"_domain",
"is",
"not",
"GENERIC",
"and",
"self",
".",
"_domain",
"is",
"not",
"domain",
":",
"raise",
"Assertio... | Compile into an ExecutionPlan.
Parameters
----------
domain : zipline.pipeline.domain.Domain
Domain on which the pipeline will be executed.
default_screen : zipline.pipeline.term.Term
Term to use as a screen if self.screen is None.
all_dates : pd.Datetime... | [
"Compile",
"into",
"an",
"ExecutionPlan",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L160-L199 |
25,815 | quantopian/zipline | zipline/pipeline/pipeline.py | Pipeline._prepare_graph_terms | def _prepare_graph_terms(self, default_screen):
"""Helper for to_graph and to_execution_plan."""
columns = self.columns.copy()
screen = self.screen
if screen is None:
screen = default_screen
columns[SCREEN_NAME] = screen
return columns | python | def _prepare_graph_terms(self, default_screen):
"""Helper for to_graph and to_execution_plan."""
columns = self.columns.copy()
screen = self.screen
if screen is None:
screen = default_screen
columns[SCREEN_NAME] = screen
return columns | [
"def",
"_prepare_graph_terms",
"(",
"self",
",",
"default_screen",
")",
":",
"columns",
"=",
"self",
".",
"columns",
".",
"copy",
"(",
")",
"screen",
"=",
"self",
".",
"screen",
"if",
"screen",
"is",
"None",
":",
"screen",
"=",
"default_screen",
"columns",... | Helper for to_graph and to_execution_plan. | [
"Helper",
"for",
"to_graph",
"and",
"to_execution_plan",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L217-L224 |
25,816 | quantopian/zipline | zipline/pipeline/pipeline.py | Pipeline.show_graph | def show_graph(self, format='svg'):
"""
Render this Pipeline as a DAG.
Parameters
----------
format : {'svg', 'png', 'jpeg'}
Image format to render with. Default is 'svg'.
"""
g = self.to_simple_graph(AssetExists())
if format == 'svg':
... | python | def show_graph(self, format='svg'):
"""
Render this Pipeline as a DAG.
Parameters
----------
format : {'svg', 'png', 'jpeg'}
Image format to render with. Default is 'svg'.
"""
g = self.to_simple_graph(AssetExists())
if format == 'svg':
... | [
"def",
"show_graph",
"(",
"self",
",",
"format",
"=",
"'svg'",
")",
":",
"g",
"=",
"self",
".",
"to_simple_graph",
"(",
"AssetExists",
"(",
")",
")",
"if",
"format",
"==",
"'svg'",
":",
"return",
"g",
".",
"svg",
"elif",
"format",
"==",
"'png'",
":",... | Render this Pipeline as a DAG.
Parameters
----------
format : {'svg', 'png', 'jpeg'}
Image format to render with. Default is 'svg'. | [
"Render",
"this",
"Pipeline",
"as",
"a",
"DAG",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L227-L246 |
25,817 | quantopian/zipline | zipline/pipeline/pipeline.py | Pipeline._output_terms | def _output_terms(self):
"""
A list of terms that are outputs of this pipeline.
Includes all terms registered as data outputs of the pipeline, plus the
screen, if present.
"""
terms = list(six.itervalues(self._columns))
screen = self.screen
if screen is n... | python | def _output_terms(self):
"""
A list of terms that are outputs of this pipeline.
Includes all terms registered as data outputs of the pipeline, plus the
screen, if present.
"""
terms = list(six.itervalues(self._columns))
screen = self.screen
if screen is n... | [
"def",
"_output_terms",
"(",
"self",
")",
":",
"terms",
"=",
"list",
"(",
"six",
".",
"itervalues",
"(",
"self",
".",
"_columns",
")",
")",
"screen",
"=",
"self",
".",
"screen",
"if",
"screen",
"is",
"not",
"None",
":",
"terms",
".",
"append",
"(",
... | A list of terms that are outputs of this pipeline.
Includes all terms registered as data outputs of the pipeline, plus the
screen, if present. | [
"A",
"list",
"of",
"terms",
"that",
"are",
"outputs",
"of",
"this",
"pipeline",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L255-L266 |
25,818 | quantopian/zipline | zipline/pipeline/pipeline.py | Pipeline.domain | def domain(self, default):
"""
Get the domain for this pipeline.
- If an explicit domain was provided at construction time, use it.
- Otherwise, infer a domain from the registered columns.
- If no domain can be inferred, return ``default``.
Parameters
----------... | python | def domain(self, default):
"""
Get the domain for this pipeline.
- If an explicit domain was provided at construction time, use it.
- Otherwise, infer a domain from the registered columns.
- If no domain can be inferred, return ``default``.
Parameters
----------... | [
"def",
"domain",
"(",
"self",
",",
"default",
")",
":",
"# Always compute our inferred domain to ensure that it's compatible",
"# with our explicit domain.",
"inferred",
"=",
"infer_domain",
"(",
"self",
".",
"_output_terms",
")",
"if",
"inferred",
"is",
"GENERIC",
"and",... | Get the domain for this pipeline.
- If an explicit domain was provided at construction time, use it.
- Otherwise, infer a domain from the registered columns.
- If no domain can be inferred, return ``default``.
Parameters
----------
default : zipline.pipeline.Domain
... | [
"Get",
"the",
"domain",
"for",
"this",
"pipeline",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L269-L314 |
25,819 | quantopian/zipline | zipline/pipeline/expression.py | _ensure_element | def _ensure_element(tup, elem):
"""
Create a tuple containing all elements of tup, plus elem.
Returns the new tuple and the index of elem in the new tuple.
"""
try:
return tup, tup.index(elem)
except ValueError:
return tuple(chain(tup, (elem,))), len(tup) | python | def _ensure_element(tup, elem):
"""
Create a tuple containing all elements of tup, plus elem.
Returns the new tuple and the index of elem in the new tuple.
"""
try:
return tup, tup.index(elem)
except ValueError:
return tuple(chain(tup, (elem,))), len(tup) | [
"def",
"_ensure_element",
"(",
"tup",
",",
"elem",
")",
":",
"try",
":",
"return",
"tup",
",",
"tup",
".",
"index",
"(",
"elem",
")",
"except",
"ValueError",
":",
"return",
"tuple",
"(",
"chain",
"(",
"tup",
",",
"(",
"elem",
",",
")",
")",
")",
... | Create a tuple containing all elements of tup, plus elem.
Returns the new tuple and the index of elem in the new tuple. | [
"Create",
"a",
"tuple",
"containing",
"all",
"elements",
"of",
"tup",
"plus",
"elem",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L92-L101 |
25,820 | quantopian/zipline | zipline/pipeline/expression.py | NumericalExpression._compute | def _compute(self, arrays, dates, assets, mask):
"""
Compute our stored expression string with numexpr.
"""
out = full(mask.shape, self.missing_value, dtype=self.dtype)
# This writes directly into our output buffer.
numexpr.evaluate(
self._expr,
lo... | python | def _compute(self, arrays, dates, assets, mask):
"""
Compute our stored expression string with numexpr.
"""
out = full(mask.shape, self.missing_value, dtype=self.dtype)
# This writes directly into our output buffer.
numexpr.evaluate(
self._expr,
lo... | [
"def",
"_compute",
"(",
"self",
",",
"arrays",
",",
"dates",
",",
"assets",
",",
"mask",
")",
":",
"out",
"=",
"full",
"(",
"mask",
".",
"shape",
",",
"self",
".",
"missing_value",
",",
"dtype",
"=",
"self",
".",
"dtype",
")",
"# This writes directly i... | Compute our stored expression string with numexpr. | [
"Compute",
"our",
"stored",
"expression",
"string",
"with",
"numexpr",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L238-L253 |
25,821 | quantopian/zipline | zipline/pipeline/expression.py | NumericalExpression._rebind_variables | def _rebind_variables(self, new_inputs):
"""
Return self._expr with all variables rebound to the indices implied by
new_inputs.
"""
expr = self._expr
# If we have 11+ variables, some of our variable names may be
# substrings of other variable names. For example, ... | python | def _rebind_variables(self, new_inputs):
"""
Return self._expr with all variables rebound to the indices implied by
new_inputs.
"""
expr = self._expr
# If we have 11+ variables, some of our variable names may be
# substrings of other variable names. For example, ... | [
"def",
"_rebind_variables",
"(",
"self",
",",
"new_inputs",
")",
":",
"expr",
"=",
"self",
".",
"_expr",
"# If we have 11+ variables, some of our variable names may be",
"# substrings of other variable names. For example, we might have x_1,",
"# x_10, and x_100. By enumerating in rever... | Return self._expr with all variables rebound to the indices implied by
new_inputs. | [
"Return",
"self",
".",
"_expr",
"with",
"all",
"variables",
"rebound",
"to",
"the",
"indices",
"implied",
"by",
"new_inputs",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L255-L279 |
25,822 | quantopian/zipline | zipline/pipeline/expression.py | NumericalExpression._merge_expressions | def _merge_expressions(self, other):
"""
Merge the inputs of two NumericalExpressions into a single input tuple,
rewriting their respective string expressions to make input names
resolve correctly.
Returns a tuple of (new_self_expr, new_other_expr, new_inputs)
"""
... | python | def _merge_expressions(self, other):
"""
Merge the inputs of two NumericalExpressions into a single input tuple,
rewriting their respective string expressions to make input names
resolve correctly.
Returns a tuple of (new_self_expr, new_other_expr, new_inputs)
"""
... | [
"def",
"_merge_expressions",
"(",
"self",
",",
"other",
")",
":",
"new_inputs",
"=",
"tuple",
"(",
"set",
"(",
"self",
".",
"inputs",
")",
".",
"union",
"(",
"other",
".",
"inputs",
")",
")",
"new_self_expr",
"=",
"self",
".",
"_rebind_variables",
"(",
... | Merge the inputs of two NumericalExpressions into a single input tuple,
rewriting their respective string expressions to make input names
resolve correctly.
Returns a tuple of (new_self_expr, new_other_expr, new_inputs) | [
"Merge",
"the",
"inputs",
"of",
"two",
"NumericalExpressions",
"into",
"a",
"single",
"input",
"tuple",
"rewriting",
"their",
"respective",
"string",
"expressions",
"to",
"make",
"input",
"names",
"resolve",
"correctly",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L281-L292 |
25,823 | quantopian/zipline | zipline/pipeline/expression.py | NumericalExpression.build_binary_op | def build_binary_op(self, op, other):
"""
Compute new expression strings and a new inputs tuple for combining
self and other with a binary operator.
"""
if isinstance(other, NumericalExpression):
self_expr, other_expr, new_inputs = self._merge_expressions(other)
... | python | def build_binary_op(self, op, other):
"""
Compute new expression strings and a new inputs tuple for combining
self and other with a binary operator.
"""
if isinstance(other, NumericalExpression):
self_expr, other_expr, new_inputs = self._merge_expressions(other)
... | [
"def",
"build_binary_op",
"(",
"self",
",",
"op",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"NumericalExpression",
")",
":",
"self_expr",
",",
"other_expr",
",",
"new_inputs",
"=",
"self",
".",
"_merge_expressions",
"(",
"other",
")",
... | Compute new expression strings and a new inputs tuple for combining
self and other with a binary operator. | [
"Compute",
"new",
"expression",
"strings",
"and",
"a",
"new",
"inputs",
"tuple",
"for",
"combining",
"self",
"and",
"other",
"with",
"a",
"binary",
"operator",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L294-L311 |
25,824 | quantopian/zipline | zipline/pipeline/expression.py | NumericalExpression.graph_repr | def graph_repr(self):
"""Short repr to use when rendering Pipeline graphs."""
# Replace any floating point numbers in the expression
# with their scientific notation
final = re.sub(r"[-+]?\d*\.\d+",
lambda x: format(float(x.group(0)), '.2E'),
... | python | def graph_repr(self):
"""Short repr to use when rendering Pipeline graphs."""
# Replace any floating point numbers in the expression
# with their scientific notation
final = re.sub(r"[-+]?\d*\.\d+",
lambda x: format(float(x.group(0)), '.2E'),
... | [
"def",
"graph_repr",
"(",
"self",
")",
":",
"# Replace any floating point numbers in the expression",
"# with their scientific notation",
"final",
"=",
"re",
".",
"sub",
"(",
"r\"[-+]?\\d*\\.\\d+\"",
",",
"lambda",
"x",
":",
"format",
"(",
"float",
"(",
"x",
".",
"g... | Short repr to use when rendering Pipeline graphs. | [
"Short",
"repr",
"to",
"use",
"when",
"rendering",
"Pipeline",
"graphs",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L327-L338 |
25,825 | quantopian/zipline | zipline/utils/paths.py | last_modified_time | def last_modified_time(path):
"""
Get the last modified time of path as a Timestamp.
"""
return pd.Timestamp(os.path.getmtime(path), unit='s', tz='UTC') | python | def last_modified_time(path):
"""
Get the last modified time of path as a Timestamp.
"""
return pd.Timestamp(os.path.getmtime(path), unit='s', tz='UTC') | [
"def",
"last_modified_time",
"(",
"path",
")",
":",
"return",
"pd",
".",
"Timestamp",
"(",
"os",
".",
"path",
".",
"getmtime",
"(",
"path",
")",
",",
"unit",
"=",
"'s'",
",",
"tz",
"=",
"'UTC'",
")"
] | Get the last modified time of path as a Timestamp. | [
"Get",
"the",
"last",
"modified",
"time",
"of",
"path",
"as",
"a",
"Timestamp",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/paths.py#L78-L82 |
25,826 | quantopian/zipline | zipline/utils/paths.py | zipline_root | def zipline_root(environ=None):
"""
Get the root directory for all zipline-managed files.
For testing purposes, this accepts a dictionary to interpret as the os
environment.
Parameters
----------
environ : dict, optional
A dict to interpret as the os environment.
Returns
-... | python | def zipline_root(environ=None):
"""
Get the root directory for all zipline-managed files.
For testing purposes, this accepts a dictionary to interpret as the os
environment.
Parameters
----------
environ : dict, optional
A dict to interpret as the os environment.
Returns
-... | [
"def",
"zipline_root",
"(",
"environ",
"=",
"None",
")",
":",
"if",
"environ",
"is",
"None",
":",
"environ",
"=",
"os",
".",
"environ",
"root",
"=",
"environ",
".",
"get",
"(",
"'ZIPLINE_ROOT'",
",",
"None",
")",
"if",
"root",
"is",
"None",
":",
"roo... | Get the root directory for all zipline-managed files.
For testing purposes, this accepts a dictionary to interpret as the os
environment.
Parameters
----------
environ : dict, optional
A dict to interpret as the os environment.
Returns
-------
root : string
Path to the... | [
"Get",
"the",
"root",
"directory",
"for",
"all",
"zipline",
"-",
"managed",
"files",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/paths.py#L107-L131 |
25,827 | quantopian/zipline | zipline/pipeline/loaders/frame.py | DataFrameLoader.format_adjustments | def format_adjustments(self, dates, assets):
"""
Build a dict of Adjustment objects in the format expected by
AdjustedArray.
Returns a dict of the form:
{
# Integer index into `dates` for the date on which we should
# apply the list of adjustments.
... | python | def format_adjustments(self, dates, assets):
"""
Build a dict of Adjustment objects in the format expected by
AdjustedArray.
Returns a dict of the form:
{
# Integer index into `dates` for the date on which we should
# apply the list of adjustments.
... | [
"def",
"format_adjustments",
"(",
"self",
",",
"dates",
",",
"assets",
")",
":",
"make_adjustment",
"=",
"partial",
"(",
"make_adjustment_from_labels",
",",
"dates",
",",
"assets",
")",
"min_date",
",",
"max_date",
"=",
"dates",
"[",
"[",
"0",
",",
"-",
"1... | Build a dict of Adjustment objects in the format expected by
AdjustedArray.
Returns a dict of the form:
{
# Integer index into `dates` for the date on which we should
# apply the list of adjustments.
1 : [
Float64Multiply(first_row=2, last_row... | [
"Build",
"a",
"dict",
"of",
"Adjustment",
"objects",
"in",
"the",
"format",
"expected",
"by",
"AdjustedArray",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/frame.py#L83-L147 |
25,828 | quantopian/zipline | zipline/pipeline/loaders/frame.py | DataFrameLoader.load_adjusted_array | def load_adjusted_array(self, domain, columns, dates, sids, mask):
"""
Load data from our stored baseline.
"""
if len(columns) != 1:
raise ValueError(
"Can't load multiple columns with DataFrameLoader"
)
column = columns[0]
self._v... | python | def load_adjusted_array(self, domain, columns, dates, sids, mask):
"""
Load data from our stored baseline.
"""
if len(columns) != 1:
raise ValueError(
"Can't load multiple columns with DataFrameLoader"
)
column = columns[0]
self._v... | [
"def",
"load_adjusted_array",
"(",
"self",
",",
"domain",
",",
"columns",
",",
"dates",
",",
"sids",
",",
"mask",
")",
":",
"if",
"len",
"(",
"columns",
")",
"!=",
"1",
":",
"raise",
"ValueError",
"(",
"\"Can't load multiple columns with DataFrameLoader\"",
")... | Load data from our stored baseline. | [
"Load",
"data",
"from",
"our",
"stored",
"baseline",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/frame.py#L149-L181 |
25,829 | quantopian/zipline | zipline/pipeline/loaders/frame.py | DataFrameLoader._validate_input_column | def _validate_input_column(self, column):
"""Make sure a passed column is our column.
"""
if column != self.column and column.unspecialize() != self.column:
raise ValueError("Can't load unknown column %s" % column) | python | def _validate_input_column(self, column):
"""Make sure a passed column is our column.
"""
if column != self.column and column.unspecialize() != self.column:
raise ValueError("Can't load unknown column %s" % column) | [
"def",
"_validate_input_column",
"(",
"self",
",",
"column",
")",
":",
"if",
"column",
"!=",
"self",
".",
"column",
"and",
"column",
".",
"unspecialize",
"(",
")",
"!=",
"self",
".",
"column",
":",
"raise",
"ValueError",
"(",
"\"Can't load unknown column %s\""... | Make sure a passed column is our column. | [
"Make",
"sure",
"a",
"passed",
"column",
"is",
"our",
"column",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/frame.py#L183-L187 |
25,830 | quantopian/zipline | zipline/utils/security_list.py | load_from_directory | def load_from_directory(list_name):
"""
To resolve the symbol in the LEVERAGED_ETF list,
the date on which the symbol was in effect is needed.
Furthermore, to maintain a point in time record of our own maintenance
of the restricted list, we need a knowledge date. Thus, restricted lists
are dict... | python | def load_from_directory(list_name):
"""
To resolve the symbol in the LEVERAGED_ETF list,
the date on which the symbol was in effect is needed.
Furthermore, to maintain a point in time record of our own maintenance
of the restricted list, we need a knowledge date. Thus, restricted lists
are dict... | [
"def",
"load_from_directory",
"(",
"list_name",
")",
":",
"data",
"=",
"{",
"}",
"dir_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"SECURITY_LISTS_DIR",
",",
"list_name",
")",
"for",
"kd_name",
"in",
"listdir",
"(",
"dir_path",
")",
":",
"kd",
"=",
... | To resolve the symbol in the LEVERAGED_ETF list,
the date on which the symbol was in effect is needed.
Furthermore, to maintain a point in time record of our own maintenance
of the restricted list, we need a knowledge date. Thus, restricted lists
are dictionaries of datetime->symbol lists.
new symb... | [
"To",
"resolve",
"the",
"symbol",
"in",
"the",
"LEVERAGED_ETF",
"list",
"the",
"date",
"on",
"which",
"the",
"symbol",
"was",
"in",
"effect",
"is",
"needed",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/security_list.py#L123-L159 |
25,831 | quantopian/zipline | zipline/utils/memoize.py | weak_lru_cache | def weak_lru_cache(maxsize=100):
"""Weak least-recently-used cache decorator.
If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.
Arguments to the cached function must be hashable. Any that are weak-
referenceable will be stored by weak reference. Once... | python | def weak_lru_cache(maxsize=100):
"""Weak least-recently-used cache decorator.
If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.
Arguments to the cached function must be hashable. Any that are weak-
referenceable will be stored by weak reference. Once... | [
"def",
"weak_lru_cache",
"(",
"maxsize",
"=",
"100",
")",
":",
"class",
"desc",
"(",
"lazyval",
")",
":",
"def",
"__get__",
"(",
"self",
",",
"instance",
",",
"owner",
")",
":",
"if",
"instance",
"is",
"None",
":",
"return",
"self",
"try",
":",
"retu... | Weak least-recently-used cache decorator.
If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.
Arguments to the cached function must be hashable. Any that are weak-
referenceable will be stored by weak reference. Once any of the args have
been garbage c... | [
"Weak",
"least",
"-",
"recently",
"-",
"used",
"cache",
"decorator",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/memoize.py#L211-L248 |
25,832 | quantopian/zipline | zipline/pipeline/data/dataset.py | Column.bind | def bind(self, name):
"""
Bind a `Column` object to its name.
"""
return _BoundColumnDescr(
dtype=self.dtype,
missing_value=self.missing_value,
name=name,
doc=self.doc,
metadata=self.metadata,
) | python | def bind(self, name):
"""
Bind a `Column` object to its name.
"""
return _BoundColumnDescr(
dtype=self.dtype,
missing_value=self.missing_value,
name=name,
doc=self.doc,
metadata=self.metadata,
) | [
"def",
"bind",
"(",
"self",
",",
"name",
")",
":",
"return",
"_BoundColumnDescr",
"(",
"dtype",
"=",
"self",
".",
"dtype",
",",
"missing_value",
"=",
"self",
".",
"missing_value",
",",
"name",
"=",
"name",
",",
"doc",
"=",
"self",
".",
"doc",
",",
"m... | Bind a `Column` object to its name. | [
"Bind",
"a",
"Column",
"object",
"to",
"its",
"name",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L49-L59 |
25,833 | quantopian/zipline | zipline/pipeline/data/dataset.py | BoundColumn.specialize | def specialize(self, domain):
"""Specialize ``self`` to a concrete domain.
"""
if domain == self.domain:
return self
return type(self)(
dtype=self.dtype,
missing_value=self.missing_value,
dataset=self._dataset.specialize(domain),
... | python | def specialize(self, domain):
"""Specialize ``self`` to a concrete domain.
"""
if domain == self.domain:
return self
return type(self)(
dtype=self.dtype,
missing_value=self.missing_value,
dataset=self._dataset.specialize(domain),
... | [
"def",
"specialize",
"(",
"self",
",",
"domain",
")",
":",
"if",
"domain",
"==",
"self",
".",
"domain",
":",
"return",
"self",
"return",
"type",
"(",
"self",
")",
"(",
"dtype",
"=",
"self",
".",
"dtype",
",",
"missing_value",
"=",
"self",
".",
"missi... | Specialize ``self`` to a concrete domain. | [
"Specialize",
"self",
"to",
"a",
"concrete",
"domain",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L177-L190 |
25,834 | quantopian/zipline | zipline/pipeline/data/dataset.py | DataSet.get_column | def get_column(cls, name):
"""Look up a column by name.
Parameters
----------
name : str
Name of the column to look up.
Returns
-------
column : zipline.pipeline.data.BoundColumn
Column with the given name.
Raises
------
... | python | def get_column(cls, name):
"""Look up a column by name.
Parameters
----------
name : str
Name of the column to look up.
Returns
-------
column : zipline.pipeline.data.BoundColumn
Column with the given name.
Raises
------
... | [
"def",
"get_column",
"(",
"cls",
",",
"name",
")",
":",
"clsdict",
"=",
"vars",
"(",
"cls",
")",
"try",
":",
"maybe_column",
"=",
"clsdict",
"[",
"name",
"]",
"if",
"not",
"isinstance",
"(",
"maybe_column",
",",
"_BoundColumnDescr",
")",
":",
"raise",
... | Look up a column by name.
Parameters
----------
name : str
Name of the column to look up.
Returns
-------
column : zipline.pipeline.data.BoundColumn
Column with the given name.
Raises
------
AttributeError
If ... | [
"Look",
"up",
"a",
"column",
"by",
"name",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L502-L540 |
25,835 | quantopian/zipline | zipline/pipeline/data/dataset.py | DataSetFamily._make_dataset | def _make_dataset(cls, coords):
"""Construct a new dataset given the coordinates.
"""
class Slice(cls._SliceType):
extra_coords = coords
Slice.__name__ = '%s.slice(%s)' % (
cls.__name__,
', '.join('%s=%r' % item for item in coords.items()),
)
... | python | def _make_dataset(cls, coords):
"""Construct a new dataset given the coordinates.
"""
class Slice(cls._SliceType):
extra_coords = coords
Slice.__name__ = '%s.slice(%s)' % (
cls.__name__,
', '.join('%s=%r' % item for item in coords.items()),
)
... | [
"def",
"_make_dataset",
"(",
"cls",
",",
"coords",
")",
":",
"class",
"Slice",
"(",
"cls",
".",
"_SliceType",
")",
":",
"extra_coords",
"=",
"coords",
"Slice",
".",
"__name__",
"=",
"'%s.slice(%s)'",
"%",
"(",
"cls",
".",
"__name__",
",",
"', '",
".",
... | Construct a new dataset given the coordinates. | [
"Construct",
"a",
"new",
"dataset",
"given",
"the",
"coordinates",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L813-L823 |
25,836 | quantopian/zipline | zipline/pipeline/data/dataset.py | DataSetFamily.slice | def slice(cls, *args, **kwargs):
"""Take a slice of a DataSetFamily to produce a dataset
indexed by asset and date.
Parameters
----------
*args
**kwargs
The coordinates to fix along each extra dimension.
Returns
-------
dataset : Data... | python | def slice(cls, *args, **kwargs):
"""Take a slice of a DataSetFamily to produce a dataset
indexed by asset and date.
Parameters
----------
*args
**kwargs
The coordinates to fix along each extra dimension.
Returns
-------
dataset : Data... | [
"def",
"slice",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"coords",
",",
"hash_key",
"=",
"cls",
".",
"_canonical_key",
"(",
"args",
",",
"kwargs",
")",
"try",
":",
"return",
"cls",
".",
"_slice_cache",
"[",
"hash_key",
"]",
... | Take a slice of a DataSetFamily to produce a dataset
indexed by asset and date.
Parameters
----------
*args
**kwargs
The coordinates to fix along each extra dimension.
Returns
-------
dataset : DataSet
A regular pipeline dataset i... | [
"Take",
"a",
"slice",
"of",
"a",
"DataSetFamily",
"to",
"produce",
"a",
"dataset",
"indexed",
"by",
"asset",
"and",
"date",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L826-L854 |
25,837 | quantopian/zipline | zipline/pipeline/loaders/synthetic.py | PrecomputedLoader.load_adjusted_array | def load_adjusted_array(self, domain, columns, dates, sids, mask):
"""
Load by delegating to sub-loaders.
"""
out = {}
for col in columns:
try:
loader = self._loaders.get(col)
if loader is None:
loader = self._loader... | python | def load_adjusted_array(self, domain, columns, dates, sids, mask):
"""
Load by delegating to sub-loaders.
"""
out = {}
for col in columns:
try:
loader = self._loaders.get(col)
if loader is None:
loader = self._loader... | [
"def",
"load_adjusted_array",
"(",
"self",
",",
"domain",
",",
"columns",
",",
"dates",
",",
"sids",
",",
"mask",
")",
":",
"out",
"=",
"{",
"}",
"for",
"col",
"in",
"columns",
":",
"try",
":",
"loader",
"=",
"self",
".",
"_loaders",
".",
"get",
"(... | Load by delegating to sub-loaders. | [
"Load",
"by",
"delegating",
"to",
"sub",
"-",
"loaders",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L82-L97 |
25,838 | quantopian/zipline | zipline/pipeline/loaders/synthetic.py | SeededRandomLoader._float_values | def _float_values(self, shape):
"""
Return uniformly-distributed floats between -0.0 and 100.0.
"""
return self.state.uniform(low=0.0, high=100.0, size=shape) | python | def _float_values(self, shape):
"""
Return uniformly-distributed floats between -0.0 and 100.0.
"""
return self.state.uniform(low=0.0, high=100.0, size=shape) | [
"def",
"_float_values",
"(",
"self",
",",
"shape",
")",
":",
"return",
"self",
".",
"state",
".",
"uniform",
"(",
"low",
"=",
"0.0",
",",
"high",
"=",
"100.0",
",",
"size",
"=",
"shape",
")"
] | Return uniformly-distributed floats between -0.0 and 100.0. | [
"Return",
"uniformly",
"-",
"distributed",
"floats",
"between",
"-",
"0",
".",
"0",
"and",
"100",
".",
"0",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L170-L174 |
25,839 | quantopian/zipline | zipline/pipeline/loaders/synthetic.py | SeededRandomLoader._int_values | def _int_values(self, shape):
"""
Return uniformly-distributed integers between 0 and 100.
"""
return (self.state.randint(low=0, high=100, size=shape)
.astype('int64')) | python | def _int_values(self, shape):
"""
Return uniformly-distributed integers between 0 and 100.
"""
return (self.state.randint(low=0, high=100, size=shape)
.astype('int64')) | [
"def",
"_int_values",
"(",
"self",
",",
"shape",
")",
":",
"return",
"(",
"self",
".",
"state",
".",
"randint",
"(",
"low",
"=",
"0",
",",
"high",
"=",
"100",
",",
"size",
"=",
"shape",
")",
".",
"astype",
"(",
"'int64'",
")",
")"
] | Return uniformly-distributed integers between 0 and 100. | [
"Return",
"uniformly",
"-",
"distributed",
"integers",
"between",
"0",
"and",
"100",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L176-L181 |
25,840 | quantopian/zipline | zipline/pipeline/loaders/synthetic.py | SeededRandomLoader._datetime_values | def _datetime_values(self, shape):
"""
Return uniformly-distributed dates in 2014.
"""
start = Timestamp('2014', tz='UTC').asm8
offsets = self.state.randint(
low=0,
high=364,
size=shape,
).astype('timedelta64[D]')
return start +... | python | def _datetime_values(self, shape):
"""
Return uniformly-distributed dates in 2014.
"""
start = Timestamp('2014', tz='UTC').asm8
offsets = self.state.randint(
low=0,
high=364,
size=shape,
).astype('timedelta64[D]')
return start +... | [
"def",
"_datetime_values",
"(",
"self",
",",
"shape",
")",
":",
"start",
"=",
"Timestamp",
"(",
"'2014'",
",",
"tz",
"=",
"'UTC'",
")",
".",
"asm8",
"offsets",
"=",
"self",
".",
"state",
".",
"randint",
"(",
"low",
"=",
"0",
",",
"high",
"=",
"364"... | Return uniformly-distributed dates in 2014. | [
"Return",
"uniformly",
"-",
"distributed",
"dates",
"in",
"2014",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L183-L193 |
25,841 | quantopian/zipline | zipline/lib/quantiles.py | quantiles | def quantiles(data, nbins_or_partition_bounds):
"""
Compute rowwise array quantiles on an input.
"""
return apply_along_axis(
qcut,
1,
data,
q=nbins_or_partition_bounds, labels=False,
) | python | def quantiles(data, nbins_or_partition_bounds):
"""
Compute rowwise array quantiles on an input.
"""
return apply_along_axis(
qcut,
1,
data,
q=nbins_or_partition_bounds, labels=False,
) | [
"def",
"quantiles",
"(",
"data",
",",
"nbins_or_partition_bounds",
")",
":",
"return",
"apply_along_axis",
"(",
"qcut",
",",
"1",
",",
"data",
",",
"q",
"=",
"nbins_or_partition_bounds",
",",
"labels",
"=",
"False",
",",
")"
] | Compute rowwise array quantiles on an input. | [
"Compute",
"rowwise",
"array",
"quantiles",
"on",
"an",
"input",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/quantiles.py#L8-L17 |
25,842 | quantopian/zipline | zipline/finance/metrics/tracker.py | MetricsTracker.handle_minute_close | def handle_minute_close(self, dt, data_portal):
"""
Handles the close of the given minute in minute emission.
Parameters
----------
dt : Timestamp
The minute that is ending
Returns
-------
A minute perf packet.
"""
self.sync_l... | python | def handle_minute_close(self, dt, data_portal):
"""
Handles the close of the given minute in minute emission.
Parameters
----------
dt : Timestamp
The minute that is ending
Returns
-------
A minute perf packet.
"""
self.sync_l... | [
"def",
"handle_minute_close",
"(",
"self",
",",
"dt",
",",
"data_portal",
")",
":",
"self",
".",
"sync_last_sale_prices",
"(",
"dt",
",",
"data_portal",
")",
"packet",
"=",
"{",
"'period_start'",
":",
"self",
".",
"_first_session",
",",
"'period_end'",
":",
... | Handles the close of the given minute in minute emission.
Parameters
----------
dt : Timestamp
The minute that is ending
Returns
-------
A minute perf packet. | [
"Handles",
"the",
"close",
"of",
"the",
"given",
"minute",
"in",
"minute",
"emission",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/tracker.py#L204-L243 |
25,843 | quantopian/zipline | zipline/finance/metrics/tracker.py | MetricsTracker.handle_market_open | def handle_market_open(self, session_label, data_portal):
"""Handles the start of each session.
Parameters
----------
session_label : Timestamp
The label of the session that is about to begin.
data_portal : DataPortal
The current data portal.
"""
... | python | def handle_market_open(self, session_label, data_portal):
"""Handles the start of each session.
Parameters
----------
session_label : Timestamp
The label of the session that is about to begin.
data_portal : DataPortal
The current data portal.
"""
... | [
"def",
"handle_market_open",
"(",
"self",
",",
"session_label",
",",
"data_portal",
")",
":",
"ledger",
"=",
"self",
".",
"_ledger",
"ledger",
".",
"start_of_session",
"(",
"session_label",
")",
"adjustment_reader",
"=",
"data_portal",
".",
"adjustment_reader",
"i... | Handles the start of each session.
Parameters
----------
session_label : Timestamp
The label of the session that is about to begin.
data_portal : DataPortal
The current data portal. | [
"Handles",
"the",
"start",
"of",
"each",
"session",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/tracker.py#L245-L275 |
25,844 | quantopian/zipline | zipline/finance/metrics/tracker.py | MetricsTracker.handle_market_close | def handle_market_close(self, dt, data_portal):
"""Handles the close of the given day.
Parameters
----------
dt : Timestamp
The most recently completed simulation datetime.
data_portal : DataPortal
The current data portal.
Returns
-------... | python | def handle_market_close(self, dt, data_portal):
"""Handles the close of the given day.
Parameters
----------
dt : Timestamp
The most recently completed simulation datetime.
data_portal : DataPortal
The current data portal.
Returns
-------... | [
"def",
"handle_market_close",
"(",
"self",
",",
"dt",
",",
"data_portal",
")",
":",
"completed_session",
"=",
"self",
".",
"_current_session",
"if",
"self",
".",
"emission_rate",
"==",
"'daily'",
":",
"# this method is called for both minutely and daily emissions, but",
... | Handles the close of the given day.
Parameters
----------
dt : Timestamp
The most recently completed simulation datetime.
data_portal : DataPortal
The current data portal.
Returns
-------
A daily perf packet. | [
"Handles",
"the",
"close",
"of",
"the",
"given",
"day",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/tracker.py#L277-L328 |
25,845 | quantopian/zipline | zipline/finance/metrics/tracker.py | MetricsTracker.handle_simulation_end | def handle_simulation_end(self, data_portal):
"""
When the simulation is complete, run the full period risk report
and send it out on the results socket.
"""
log.info(
'Simulated {} trading days\n'
'first open: {}\n'
'last close: {}',
... | python | def handle_simulation_end(self, data_portal):
"""
When the simulation is complete, run the full period risk report
and send it out on the results socket.
"""
log.info(
'Simulated {} trading days\n'
'first open: {}\n'
'last close: {}',
... | [
"def",
"handle_simulation_end",
"(",
"self",
",",
"data_portal",
")",
":",
"log",
".",
"info",
"(",
"'Simulated {} trading days\\n'",
"'first open: {}\\n'",
"'last close: {}'",
",",
"self",
".",
"_session_count",
",",
"self",
".",
"_trading_calendar",
".",
"session_op... | When the simulation is complete, run the full period risk report
and send it out on the results socket. | [
"When",
"the",
"simulation",
"is",
"complete",
"run",
"the",
"full",
"period",
"risk",
"report",
"and",
"send",
"it",
"out",
"on",
"the",
"results",
"socket",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/tracker.py#L330-L353 |
25,846 | quantopian/zipline | zipline/extensions.py | create_args | def create_args(args, root):
"""
Encapsulates a set of custom command line arguments in key=value
or key.namespace=value form into a chain of Namespace objects,
where each next level is an attribute of the Namespace object on the
current level
Parameters
----------
args : list
A... | python | def create_args(args, root):
"""
Encapsulates a set of custom command line arguments in key=value
or key.namespace=value form into a chain of Namespace objects,
where each next level is an attribute of the Namespace object on the
current level
Parameters
----------
args : list
A... | [
"def",
"create_args",
"(",
"args",
",",
"root",
")",
":",
"extension_args",
"=",
"{",
"}",
"for",
"arg",
"in",
"args",
":",
"parse_extension_arg",
"(",
"arg",
",",
"extension_args",
")",
"for",
"name",
"in",
"sorted",
"(",
"extension_args",
",",
"key",
"... | Encapsulates a set of custom command line arguments in key=value
or key.namespace=value form into a chain of Namespace objects,
where each next level is an attribute of the Namespace object on the
current level
Parameters
----------
args : list
A list of strings representing arguments i... | [
"Encapsulates",
"a",
"set",
"of",
"custom",
"command",
"line",
"arguments",
"in",
"key",
"=",
"value",
"or",
"key",
".",
"namespace",
"=",
"value",
"form",
"into",
"a",
"chain",
"of",
"Namespace",
"objects",
"where",
"each",
"next",
"level",
"is",
"an",
... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L6-L28 |
25,847 | quantopian/zipline | zipline/extensions.py | parse_extension_arg | def parse_extension_arg(arg, arg_dict):
"""
Converts argument strings in key=value or key.namespace=value form
to dictionary entries
Parameters
----------
arg : str
The argument string to parse, which must be in key=value or
key.namespace=value form.
arg_dict : dict
... | python | def parse_extension_arg(arg, arg_dict):
"""
Converts argument strings in key=value or key.namespace=value form
to dictionary entries
Parameters
----------
arg : str
The argument string to parse, which must be in key=value or
key.namespace=value form.
arg_dict : dict
... | [
"def",
"parse_extension_arg",
"(",
"arg",
",",
"arg_dict",
")",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r'^(([^\\d\\W]\\w*)(\\.[^\\d\\W]\\w*)*)=(.*)$'",
",",
"arg",
")",
"if",
"match",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"invalid extension argume... | Converts argument strings in key=value or key.namespace=value form
to dictionary entries
Parameters
----------
arg : str
The argument string to parse, which must be in key=value or
key.namespace=value form.
arg_dict : dict
The dictionary into which the key/value pair will be... | [
"Converts",
"argument",
"strings",
"in",
"key",
"=",
"value",
"or",
"key",
".",
"namespace",
"=",
"value",
"form",
"to",
"dictionary",
"entries"
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L31-L53 |
25,848 | quantopian/zipline | zipline/extensions.py | update_namespace | def update_namespace(namespace, path, name):
"""
A recursive function that takes a root element, list of namespaces,
and the value being stored, and assigns namespaces to the root object
via a chain of Namespace objects, connected through attributes
Parameters
----------
namespace : Namespa... | python | def update_namespace(namespace, path, name):
"""
A recursive function that takes a root element, list of namespaces,
and the value being stored, and assigns namespaces to the root object
via a chain of Namespace objects, connected through attributes
Parameters
----------
namespace : Namespa... | [
"def",
"update_namespace",
"(",
"namespace",
",",
"path",
",",
"name",
")",
":",
"if",
"len",
"(",
"path",
")",
"==",
"1",
":",
"setattr",
"(",
"namespace",
",",
"path",
"[",
"0",
"]",
",",
"name",
")",
"else",
":",
"if",
"hasattr",
"(",
"namespace... | A recursive function that takes a root element, list of namespaces,
and the value being stored, and assigns namespaces to the root object
via a chain of Namespace objects, connected through attributes
Parameters
----------
namespace : Namespace
The object onto which an attribute will be add... | [
"A",
"recursive",
"function",
"that",
"takes",
"a",
"root",
"element",
"list",
"of",
"namespaces",
"and",
"the",
"value",
"being",
"stored",
"and",
"assigns",
"namespaces",
"to",
"the",
"root",
"object",
"via",
"a",
"chain",
"of",
"Namespace",
"objects",
"co... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L56-L83 |
25,849 | quantopian/zipline | zipline/extensions.py | create_registry | def create_registry(interface):
"""
Create a new registry for an extensible interface.
Parameters
----------
interface : type
The abstract data type for which to create a registry,
which will manage registration of factories for this type.
Returns
-------
interface : ty... | python | def create_registry(interface):
"""
Create a new registry for an extensible interface.
Parameters
----------
interface : type
The abstract data type for which to create a registry,
which will manage registration of factories for this type.
Returns
-------
interface : ty... | [
"def",
"create_registry",
"(",
"interface",
")",
":",
"if",
"interface",
"in",
"custom_types",
":",
"raise",
"ValueError",
"(",
"'there is already a Registry instance '",
"'for the specified type'",
")",
"custom_types",
"[",
"interface",
"]",
"=",
"Registry",
"(",
"in... | Create a new registry for an extensible interface.
Parameters
----------
interface : type
The abstract data type for which to create a registry,
which will manage registration of factories for this type.
Returns
-------
interface : type
The data type specified/decorated... | [
"Create",
"a",
"new",
"registry",
"for",
"an",
"extensible",
"interface",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L244-L263 |
25,850 | quantopian/zipline | zipline/extensions.py | Registry.load | def load(self, name):
"""Construct an object from a registered factory.
Parameters
----------
name : str
Name with which the factory was registered.
"""
try:
return self._factories[name]()
except KeyError:
raise ValueError(
... | python | def load(self, name):
"""Construct an object from a registered factory.
Parameters
----------
name : str
Name with which the factory was registered.
"""
try:
return self._factories[name]()
except KeyError:
raise ValueError(
... | [
"def",
"load",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"return",
"self",
".",
"_factories",
"[",
"name",
"]",
"(",
")",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"\"no %s factory registered under name %r, options are: %r\"",
"%",
"(",
"sel... | Construct an object from a registered factory.
Parameters
----------
name : str
Name with which the factory was registered. | [
"Construct",
"an",
"object",
"from",
"a",
"registered",
"factory",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L110-L124 |
25,851 | quantopian/zipline | zipline/finance/commission.py | PerDollar.calculate | def calculate(self, order, transaction):
"""
Pay commission based on dollar value of shares.
"""
cost_per_share = transaction.price * self.cost_per_dollar
return abs(transaction.amount) * cost_per_share | python | def calculate(self, order, transaction):
"""
Pay commission based on dollar value of shares.
"""
cost_per_share = transaction.price * self.cost_per_dollar
return abs(transaction.amount) * cost_per_share | [
"def",
"calculate",
"(",
"self",
",",
"order",
",",
"transaction",
")",
":",
"cost_per_share",
"=",
"transaction",
".",
"price",
"*",
"self",
".",
"cost_per_dollar",
"return",
"abs",
"(",
"transaction",
".",
"amount",
")",
"*",
"cost_per_share"
] | Pay commission based on dollar value of shares. | [
"Pay",
"commission",
"based",
"on",
"dollar",
"value",
"of",
"shares",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/commission.py#L364-L369 |
25,852 | quantopian/zipline | zipline/finance/metrics/metric.py | _ClassicRiskMetrics.risk_metric_period | def risk_metric_period(cls,
start_session,
end_session,
algorithm_returns,
benchmark_returns,
algorithm_leverages):
"""
Creates a dictionary representing the state of th... | python | def risk_metric_period(cls,
start_session,
end_session,
algorithm_returns,
benchmark_returns,
algorithm_leverages):
"""
Creates a dictionary representing the state of th... | [
"def",
"risk_metric_period",
"(",
"cls",
",",
"start_session",
",",
"end_session",
",",
"algorithm_returns",
",",
"benchmark_returns",
",",
"algorithm_leverages",
")",
":",
"algorithm_returns",
"=",
"algorithm_returns",
"[",
"(",
"algorithm_returns",
".",
"index",
">=... | Creates a dictionary representing the state of the risk report.
Parameters
----------
start_session : pd.Timestamp
Start of period (inclusive) to produce metrics on
end_session : pd.Timestamp
End of period (inclusive) to produce metrics on
algorithm_retur... | [
"Creates",
"a",
"dictionary",
"representing",
"the",
"state",
"of",
"the",
"risk",
"report",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/metric.py#L559-L666 |
25,853 | quantopian/zipline | zipline/assets/roll_finder.py | RollFinder._get_active_contract_at_offset | def _get_active_contract_at_offset(self, root_symbol, dt, offset):
"""
For the given root symbol, find the contract that is considered active
on a specific date at a specific offset.
"""
oc = self.asset_finder.get_ordered_contracts(root_symbol)
session = self.trading_cale... | python | def _get_active_contract_at_offset(self, root_symbol, dt, offset):
"""
For the given root symbol, find the contract that is considered active
on a specific date at a specific offset.
"""
oc = self.asset_finder.get_ordered_contracts(root_symbol)
session = self.trading_cale... | [
"def",
"_get_active_contract_at_offset",
"(",
"self",
",",
"root_symbol",
",",
"dt",
",",
"offset",
")",
":",
"oc",
"=",
"self",
".",
"asset_finder",
".",
"get_ordered_contracts",
"(",
"root_symbol",
")",
"session",
"=",
"self",
".",
"trading_calendar",
".",
"... | For the given root symbol, find the contract that is considered active
on a specific date at a specific offset. | [
"For",
"the",
"given",
"root",
"symbol",
"find",
"the",
"contract",
"that",
"is",
"considered",
"active",
"on",
"a",
"specific",
"date",
"at",
"a",
"specific",
"offset",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/roll_finder.py#L33-L45 |
25,854 | quantopian/zipline | zipline/assets/roll_finder.py | RollFinder.get_rolls | def get_rolls(self, root_symbol, start, end, offset):
"""
Get the rolls, i.e. the session at which to hop from contract to
contract in the chain.
Parameters
----------
root_symbol : str
The root symbol for which to calculate rolls.
start : Timestamp
... | python | def get_rolls(self, root_symbol, start, end, offset):
"""
Get the rolls, i.e. the session at which to hop from contract to
contract in the chain.
Parameters
----------
root_symbol : str
The root symbol for which to calculate rolls.
start : Timestamp
... | [
"def",
"get_rolls",
"(",
"self",
",",
"root_symbol",
",",
"start",
",",
"end",
",",
"offset",
")",
":",
"oc",
"=",
"self",
".",
"asset_finder",
".",
"get_ordered_contracts",
"(",
"root_symbol",
")",
"front",
"=",
"self",
".",
"_get_active_contract_at_offset",
... | Get the rolls, i.e. the session at which to hop from contract to
contract in the chain.
Parameters
----------
root_symbol : str
The root symbol for which to calculate rolls.
start : Timestamp
Start of the date range.
end : Timestamp
En... | [
"Get",
"the",
"rolls",
"i",
".",
"e",
".",
"the",
"session",
"at",
"which",
"to",
"hop",
"from",
"contract",
"to",
"contract",
"in",
"the",
"chain",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/roll_finder.py#L66-L137 |
25,855 | quantopian/zipline | zipline/assets/roll_finder.py | VolumeRollFinder._active_contract | def _active_contract(self, oc, front, back, dt):
r"""
Return the active contract based on the previous trading day's volume.
In the rare case that a double volume switch occurs we treat the first
switch as the roll. Take the following case for example:
| +++++ _____... | python | def _active_contract(self, oc, front, back, dt):
r"""
Return the active contract based on the previous trading day's volume.
In the rare case that a double volume switch occurs we treat the first
switch as the roll. Take the following case for example:
| +++++ _____... | [
"def",
"_active_contract",
"(",
"self",
",",
"oc",
",",
"front",
",",
"back",
",",
"dt",
")",
":",
"front_contract",
"=",
"oc",
".",
"sid_to_contract",
"[",
"front",
"]",
".",
"contract",
"back_contract",
"=",
"oc",
".",
"sid_to_contract",
"[",
"back",
"... | r"""
Return the active contract based on the previous trading day's volume.
In the rare case that a double volume switch occurs we treat the first
switch as the roll. Take the following case for example:
| +++++ _____
| + __ / <--- 'G'
| ... | [
"r",
"Return",
"the",
"active",
"contract",
"based",
"on",
"the",
"previous",
"trading",
"day",
"s",
"volume",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/roll_finder.py#L170-L241 |
25,856 | quantopian/zipline | zipline/lib/adjusted_array.py | _normalize_array | def _normalize_array(data, missing_value):
"""
Coerce buffer data for an AdjustedArray into a standard scalar
representation, returning the coerced array and a dict of argument to pass
to np.view to use when providing a user-facing view of the underlying data.
- float* data is coerced to float64 wi... | python | def _normalize_array(data, missing_value):
"""
Coerce buffer data for an AdjustedArray into a standard scalar
representation, returning the coerced array and a dict of argument to pass
to np.view to use when providing a user-facing view of the underlying data.
- float* data is coerced to float64 wi... | [
"def",
"_normalize_array",
"(",
"data",
",",
"missing_value",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"LabelArray",
")",
":",
"return",
"data",
",",
"{",
"}",
"data_dtype",
"=",
"data",
".",
"dtype",
"if",
"data_dtype",
"in",
"BOOL_DTYPES",
":",
... | Coerce buffer data for an AdjustedArray into a standard scalar
representation, returning the coerced array and a dict of argument to pass
to np.view to use when providing a user-facing view of the underlying data.
- float* data is coerced to float64 with viewtype float64.
- int32, int64, and uint32 are... | [
"Coerce",
"buffer",
"data",
"for",
"an",
"AdjustedArray",
"into",
"a",
"standard",
"scalar",
"representation",
"returning",
"the",
"coerced",
"array",
"and",
"a",
"dict",
"of",
"argument",
"to",
"pass",
"to",
"np",
".",
"view",
"to",
"use",
"when",
"providin... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L84-L136 |
25,857 | quantopian/zipline | zipline/lib/adjusted_array.py | _merge_simple | def _merge_simple(adjustment_lists, front_idx, back_idx):
"""
Merge lists of new and existing adjustments for a given index by appending
or prepending new adjustments to existing adjustments.
Notes
-----
This method is meant to be used with ``toolz.merge_with`` to merge
adjustment mappings.... | python | def _merge_simple(adjustment_lists, front_idx, back_idx):
"""
Merge lists of new and existing adjustments for a given index by appending
or prepending new adjustments to existing adjustments.
Notes
-----
This method is meant to be used with ``toolz.merge_with`` to merge
adjustment mappings.... | [
"def",
"_merge_simple",
"(",
"adjustment_lists",
",",
"front_idx",
",",
"back_idx",
")",
":",
"if",
"len",
"(",
"adjustment_lists",
")",
"==",
"1",
":",
"return",
"list",
"(",
"adjustment_lists",
"[",
"0",
"]",
")",
"else",
":",
"return",
"adjustment_lists",... | Merge lists of new and existing adjustments for a given index by appending
or prepending new adjustments to existing adjustments.
Notes
-----
This method is meant to be used with ``toolz.merge_with`` to merge
adjustment mappings. In case of a collision ``adjustment_lists`` contains
two lists, e... | [
"Merge",
"lists",
"of",
"new",
"and",
"existing",
"adjustments",
"for",
"a",
"given",
"index",
"by",
"appending",
"or",
"prepending",
"new",
"adjustments",
"to",
"existing",
"adjustments",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L139-L170 |
25,858 | quantopian/zipline | zipline/lib/adjusted_array.py | ensure_ndarray | def ensure_ndarray(ndarray_or_adjusted_array):
"""
Return the input as a numpy ndarray.
This is a no-op if the input is already an ndarray. If the input is an
adjusted_array, this extracts a read-only view of its internal data buffer.
Parameters
----------
ndarray_or_adjusted_array : nump... | python | def ensure_ndarray(ndarray_or_adjusted_array):
"""
Return the input as a numpy ndarray.
This is a no-op if the input is already an ndarray. If the input is an
adjusted_array, this extracts a read-only view of its internal data buffer.
Parameters
----------
ndarray_or_adjusted_array : nump... | [
"def",
"ensure_ndarray",
"(",
"ndarray_or_adjusted_array",
")",
":",
"if",
"isinstance",
"(",
"ndarray_or_adjusted_array",
",",
"ndarray",
")",
":",
"return",
"ndarray_or_adjusted_array",
"elif",
"isinstance",
"(",
"ndarray_or_adjusted_array",
",",
"AdjustedArray",
")",
... | Return the input as a numpy ndarray.
This is a no-op if the input is already an ndarray. If the input is an
adjusted_array, this extracts a read-only view of its internal data buffer.
Parameters
----------
ndarray_or_adjusted_array : numpy.ndarray | zipline.data.adjusted_array
Returns
--... | [
"Return",
"the",
"input",
"as",
"a",
"numpy",
"ndarray",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L345-L368 |
25,859 | quantopian/zipline | zipline/lib/adjusted_array.py | _check_window_params | def _check_window_params(data, window_length):
"""
Check that a window of length `window_length` is well-defined on `data`.
Parameters
----------
data : np.ndarray[ndim=2]
The array of data to check.
window_length : int
Length of the desired window.
Returns
-------
... | python | def _check_window_params(data, window_length):
"""
Check that a window of length `window_length` is well-defined on `data`.
Parameters
----------
data : np.ndarray[ndim=2]
The array of data to check.
window_length : int
Length of the desired window.
Returns
-------
... | [
"def",
"_check_window_params",
"(",
"data",
",",
"window_length",
")",
":",
"if",
"window_length",
"<",
"1",
":",
"raise",
"WindowLengthNotPositive",
"(",
"window_length",
"=",
"window_length",
")",
"if",
"window_length",
">",
"data",
".",
"shape",
"[",
"0",
"... | Check that a window of length `window_length` is well-defined on `data`.
Parameters
----------
data : np.ndarray[ndim=2]
The array of data to check.
window_length : int
Length of the desired window.
Returns
-------
None
Raises
------
WindowLengthNotPositive
... | [
"Check",
"that",
"a",
"window",
"of",
"length",
"window_length",
"is",
"well",
"-",
"defined",
"on",
"data",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L371-L400 |
25,860 | quantopian/zipline | zipline/lib/adjusted_array.py | AdjustedArray.update_adjustments | def update_adjustments(self, adjustments, method):
"""
Merge ``adjustments`` with existing adjustments, handling index
collisions according to ``method``.
Parameters
----------
adjustments : dict[int -> list[Adjustment]]
The mapping of row indices to lists of... | python | def update_adjustments(self, adjustments, method):
"""
Merge ``adjustments`` with existing adjustments, handling index
collisions according to ``method``.
Parameters
----------
adjustments : dict[int -> list[Adjustment]]
The mapping of row indices to lists of... | [
"def",
"update_adjustments",
"(",
"self",
",",
"adjustments",
",",
"method",
")",
":",
"try",
":",
"merge_func",
"=",
"_merge_methods",
"[",
"method",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"\"Invalid merge method %s\\n\"",
"\"Valid methods are:... | Merge ``adjustments`` with existing adjustments, handling index
collisions according to ``method``.
Parameters
----------
adjustments : dict[int -> list[Adjustment]]
The mapping of row indices to lists of adjustments that should be
appended to existing adjustment... | [
"Merge",
"adjustments",
"with",
"existing",
"adjustments",
"handling",
"index",
"collisions",
"according",
"to",
"method",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L209-L236 |
25,861 | quantopian/zipline | zipline/lib/adjusted_array.py | AdjustedArray._iterator_type | def _iterator_type(self):
"""
The iterator produced when `traverse` is called on this Array.
"""
if isinstance(self._data, LabelArray):
return LabelWindow
return CONCRETE_WINDOW_TYPES[self._data.dtype] | python | def _iterator_type(self):
"""
The iterator produced when `traverse` is called on this Array.
"""
if isinstance(self._data, LabelArray):
return LabelWindow
return CONCRETE_WINDOW_TYPES[self._data.dtype] | [
"def",
"_iterator_type",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_data",
",",
"LabelArray",
")",
":",
"return",
"LabelWindow",
"return",
"CONCRETE_WINDOW_TYPES",
"[",
"self",
".",
"_data",
".",
"dtype",
"]"
] | The iterator produced when `traverse` is called on this Array. | [
"The",
"iterator",
"produced",
"when",
"traverse",
"is",
"called",
"on",
"this",
"Array",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L253-L259 |
25,862 | quantopian/zipline | zipline/lib/adjusted_array.py | AdjustedArray.traverse | def traverse(self,
window_length,
offset=0,
perspective_offset=0):
"""
Produce an iterator rolling windows rows over our data.
Each emitted window will have `window_length` rows.
Parameters
----------
window_length : int... | python | def traverse(self,
window_length,
offset=0,
perspective_offset=0):
"""
Produce an iterator rolling windows rows over our data.
Each emitted window will have `window_length` rows.
Parameters
----------
window_length : int... | [
"def",
"traverse",
"(",
"self",
",",
"window_length",
",",
"offset",
"=",
"0",
",",
"perspective_offset",
"=",
"0",
")",
":",
"data",
"=",
"self",
".",
"_data",
".",
"copy",
"(",
")",
"_check_window_params",
"(",
"data",
",",
"window_length",
")",
"retur... | Produce an iterator rolling windows rows over our data.
Each emitted window will have `window_length` rows.
Parameters
----------
window_length : int
The number of rows in each emitted window.
offset : int, optional
Number of rows to skip before the first... | [
"Produce",
"an",
"iterator",
"rolling",
"windows",
"rows",
"over",
"our",
"data",
".",
"Each",
"emitted",
"window",
"will",
"have",
"window_length",
"rows",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L261-L289 |
25,863 | quantopian/zipline | zipline/lib/adjusted_array.py | AdjustedArray.inspect | def inspect(self):
"""
Return a string representation of the data stored in this array.
"""
return dedent(
"""\
Adjusted Array ({dtype}):
Data:
{data!r}
Adjustments:
{adjustments}
"""
).format(
... | python | def inspect(self):
"""
Return a string representation of the data stored in this array.
"""
return dedent(
"""\
Adjusted Array ({dtype}):
Data:
{data!r}
Adjustments:
{adjustments}
"""
).format(
... | [
"def",
"inspect",
"(",
"self",
")",
":",
"return",
"dedent",
"(",
"\"\"\"\\\n Adjusted Array ({dtype}):\n\n Data:\n {data!r}\n\n Adjustments:\n {adjustments}\n \"\"\"",
")",
".",
"format",
"(",
"dtype",
"=",
"self",
... | Return a string representation of the data stored in this array. | [
"Return",
"a",
"string",
"representation",
"of",
"the",
"data",
"stored",
"in",
"this",
"array",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L291-L309 |
25,864 | quantopian/zipline | zipline/lib/adjusted_array.py | AdjustedArray.update_labels | def update_labels(self, func):
"""
Map a function over baseline and adjustment values in place.
Note that the baseline data values must be a LabelArray.
"""
if not isinstance(self.data, LabelArray):
raise TypeError(
'update_labels only supported if da... | python | def update_labels(self, func):
"""
Map a function over baseline and adjustment values in place.
Note that the baseline data values must be a LabelArray.
"""
if not isinstance(self.data, LabelArray):
raise TypeError(
'update_labels only supported if da... | [
"def",
"update_labels",
"(",
"self",
",",
"func",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"data",
",",
"LabelArray",
")",
":",
"raise",
"TypeError",
"(",
"'update_labels only supported if data is of type LabelArray.'",
")",
"# Map the baseline values.",... | Map a function over baseline and adjustment values in place.
Note that the baseline data values must be a LabelArray. | [
"Map",
"a",
"function",
"over",
"baseline",
"and",
"adjustment",
"values",
"in",
"place",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L311-L328 |
25,865 | quantopian/zipline | zipline/finance/controls.py | TradingControl.handle_violation | def handle_violation(self, asset, amount, datetime, metadata=None):
"""
Handle a TradingControlViolation, either by raising or logging and
error with information about the failure.
If dynamic information should be displayed as well, pass it in via
`metadata`.
"""
... | python | def handle_violation(self, asset, amount, datetime, metadata=None):
"""
Handle a TradingControlViolation, either by raising or logging and
error with information about the failure.
If dynamic information should be displayed as well, pass it in via
`metadata`.
"""
... | [
"def",
"handle_violation",
"(",
"self",
",",
"asset",
",",
"amount",
",",
"datetime",
",",
"metadata",
"=",
"None",
")",
":",
"constraint",
"=",
"self",
".",
"_constraint_msg",
"(",
"metadata",
")",
"if",
"self",
".",
"on_error",
"==",
"'fail'",
":",
"ra... | Handle a TradingControlViolation, either by raising or logging and
error with information about the failure.
If dynamic information should be displayed as well, pass it in via
`metadata`. | [
"Handle",
"a",
"TradingControlViolation",
"either",
"by",
"raising",
"or",
"logging",
"and",
"error",
"with",
"information",
"about",
"the",
"failure",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L79-L99 |
25,866 | quantopian/zipline | zipline/finance/controls.py | MaxOrderCount.validate | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if we've already placed self.max_count orders today.
"""
algo_date = algo_datetime.date()
# Reset order c... | python | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if we've already placed self.max_count orders today.
"""
algo_date = algo_datetime.date()
# Reset order c... | [
"def",
"validate",
"(",
"self",
",",
"asset",
",",
"amount",
",",
"portfolio",
",",
"algo_datetime",
",",
"algo_current_data",
")",
":",
"algo_date",
"=",
"algo_datetime",
".",
"date",
"(",
")",
"# Reset order count if it's a new day.",
"if",
"self",
".",
"curre... | Fail if we've already placed self.max_count orders today. | [
"Fail",
"if",
"we",
"ve",
"already",
"placed",
"self",
".",
"max_count",
"orders",
"today",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L119-L137 |
25,867 | quantopian/zipline | zipline/finance/controls.py | RestrictedListOrder.validate | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if the asset is in the restricted_list.
"""
if self.restrictions.is_restricted(asset, algo_datetime):
... | python | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if the asset is in the restricted_list.
"""
if self.restrictions.is_restricted(asset, algo_datetime):
... | [
"def",
"validate",
"(",
"self",
",",
"asset",
",",
"amount",
",",
"portfolio",
",",
"algo_datetime",
",",
"algo_current_data",
")",
":",
"if",
"self",
".",
"restrictions",
".",
"is_restricted",
"(",
"asset",
",",
"algo_datetime",
")",
":",
"self",
".",
"ha... | Fail if the asset is in the restricted_list. | [
"Fail",
"if",
"the",
"asset",
"is",
"in",
"the",
"restricted_list",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L154-L164 |
25,868 | quantopian/zipline | zipline/finance/controls.py | MaxOrderSize.validate | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if the magnitude of the given order exceeds either self.max_shares
or self.max_notional.
"""
if self.asse... | python | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if the magnitude of the given order exceeds either self.max_shares
or self.max_notional.
"""
if self.asse... | [
"def",
"validate",
"(",
"self",
",",
"asset",
",",
"amount",
",",
"portfolio",
",",
"algo_datetime",
",",
"algo_current_data",
")",
":",
"if",
"self",
".",
"asset",
"is",
"not",
"None",
"and",
"self",
".",
"asset",
"!=",
"asset",
":",
"return",
"if",
"... | Fail if the magnitude of the given order exceeds either self.max_shares
or self.max_notional. | [
"Fail",
"if",
"the",
"magnitude",
"of",
"the",
"given",
"order",
"exceeds",
"either",
"self",
".",
"max_shares",
"or",
"self",
".",
"max_notional",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L199-L223 |
25,869 | quantopian/zipline | zipline/finance/controls.py | MaxPositionSize.validate | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if the given order would cause the magnitude of our position to be
greater in shares than self.max_shares or greater in do... | python | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if the given order would cause the magnitude of our position to be
greater in shares than self.max_shares or greater in do... | [
"def",
"validate",
"(",
"self",
",",
"asset",
",",
"amount",
",",
"portfolio",
",",
"algo_datetime",
",",
"algo_current_data",
")",
":",
"if",
"self",
".",
"asset",
"is",
"not",
"None",
"and",
"self",
".",
"asset",
"!=",
"asset",
":",
"return",
"current_... | Fail if the given order would cause the magnitude of our position to be
greater in shares than self.max_shares or greater in dollar value than
self.max_notional. | [
"Fail",
"if",
"the",
"given",
"order",
"would",
"cause",
"the",
"magnitude",
"of",
"our",
"position",
"to",
"be",
"greater",
"in",
"shares",
"than",
"self",
".",
"max_shares",
"or",
"greater",
"in",
"dollar",
"value",
"than",
"self",
".",
"max_notional",
"... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L257-L287 |
25,870 | quantopian/zipline | zipline/finance/controls.py | LongOnly.validate | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if we would hold negative shares of asset after completing this
order.
"""
if portfolio.positions[asset].a... | python | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if we would hold negative shares of asset after completing this
order.
"""
if portfolio.positions[asset].a... | [
"def",
"validate",
"(",
"self",
",",
"asset",
",",
"amount",
",",
"portfolio",
",",
"algo_datetime",
",",
"algo_current_data",
")",
":",
"if",
"portfolio",
".",
"positions",
"[",
"asset",
"]",
".",
"amount",
"+",
"amount",
"<",
"0",
":",
"self",
".",
"... | Fail if we would hold negative shares of asset after completing this
order. | [
"Fail",
"if",
"we",
"would",
"hold",
"negative",
"shares",
"of",
"asset",
"after",
"completing",
"this",
"order",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L298-L309 |
25,871 | quantopian/zipline | zipline/finance/controls.py | AssetDateBounds.validate | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if the algo has passed this Asset's end_date, or before the
Asset's start date.
"""
# If the order is for ... | python | def validate(self,
asset,
amount,
portfolio,
algo_datetime,
algo_current_data):
"""
Fail if the algo has passed this Asset's end_date, or before the
Asset's start date.
"""
# If the order is for ... | [
"def",
"validate",
"(",
"self",
",",
"asset",
",",
"amount",
",",
"portfolio",
",",
"algo_datetime",
",",
"algo_current_data",
")",
":",
"# If the order is for 0 shares, then silently pass through.",
"if",
"amount",
"==",
"0",
":",
"return",
"normalized_algo_dt",
"=",... | Fail if the algo has passed this Asset's end_date, or before the
Asset's start date. | [
"Fail",
"if",
"the",
"algo",
"has",
"passed",
"this",
"Asset",
"s",
"end_date",
"or",
"before",
"the",
"Asset",
"s",
"start",
"date",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L321-L354 |
25,872 | quantopian/zipline | zipline/finance/controls.py | MaxLeverage.validate | def validate(self,
_portfolio,
_account,
_algo_datetime,
_algo_current_data):
"""
Fail if the leverage is greater than the allowed leverage.
"""
if _account.leverage > self.max_leverage:
self.fail() | python | def validate(self,
_portfolio,
_account,
_algo_datetime,
_algo_current_data):
"""
Fail if the leverage is greater than the allowed leverage.
"""
if _account.leverage > self.max_leverage:
self.fail() | [
"def",
"validate",
"(",
"self",
",",
"_portfolio",
",",
"_account",
",",
"_algo_datetime",
",",
"_algo_current_data",
")",
":",
"if",
"_account",
".",
"leverage",
">",
"self",
".",
"max_leverage",
":",
"self",
".",
"fail",
"(",
")"
] | Fail if the leverage is greater than the allowed leverage. | [
"Fail",
"if",
"the",
"leverage",
"is",
"greater",
"than",
"the",
"allowed",
"leverage",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L424-L433 |
25,873 | quantopian/zipline | zipline/finance/controls.py | MinLeverage.validate | def validate(self,
_portfolio,
account,
algo_datetime,
_algo_current_data):
"""
Make validation checks if we are after the deadline.
Fail if the leverage is less than the min leverage.
"""
if (algo_datetime > sel... | python | def validate(self,
_portfolio,
account,
algo_datetime,
_algo_current_data):
"""
Make validation checks if we are after the deadline.
Fail if the leverage is less than the min leverage.
"""
if (algo_datetime > sel... | [
"def",
"validate",
"(",
"self",
",",
"_portfolio",
",",
"account",
",",
"algo_datetime",
",",
"_algo_current_data",
")",
":",
"if",
"(",
"algo_datetime",
">",
"self",
".",
"deadline",
"and",
"account",
".",
"leverage",
"<",
"self",
".",
"min_leverage",
")",
... | Make validation checks if we are after the deadline.
Fail if the leverage is less than the min leverage. | [
"Make",
"validation",
"checks",
"if",
"we",
"are",
"after",
"the",
"deadline",
".",
"Fail",
"if",
"the",
"leverage",
"is",
"less",
"than",
"the",
"min",
"leverage",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L463-L474 |
25,874 | quantopian/zipline | zipline/assets/asset_db_migrations.py | alter_columns | def alter_columns(op, name, *columns, **kwargs):
"""Alter columns from a table.
Parameters
----------
name : str
The name of the table.
*columns
The new columns to have.
selection_string : str, optional
The string to use in the selection. If not provided, it will select ... | python | def alter_columns(op, name, *columns, **kwargs):
"""Alter columns from a table.
Parameters
----------
name : str
The name of the table.
*columns
The new columns to have.
selection_string : str, optional
The string to use in the selection. If not provided, it will select ... | [
"def",
"alter_columns",
"(",
"op",
",",
"name",
",",
"*",
"columns",
",",
"*",
"*",
"kwargs",
")",
":",
"selection_string",
"=",
"kwargs",
".",
"pop",
"(",
"'selection_string'",
",",
"None",
")",
"if",
"kwargs",
":",
"raise",
"TypeError",
"(",
"'alter_co... | Alter columns from a table.
Parameters
----------
name : str
The name of the table.
*columns
The new columns to have.
selection_string : str, optional
The string to use in the selection. If not provided, it will select all
of the new columns from the old table.
... | [
"Alter",
"columns",
"from",
"a",
"table",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_db_migrations.py#L13-L61 |
25,875 | quantopian/zipline | zipline/assets/asset_db_migrations.py | downgrade | def downgrade(engine, desired_version):
"""Downgrades the assets db at the given engine to the desired version.
Parameters
----------
engine : Engine
An SQLAlchemy engine to the assets database.
desired_version : int
The desired resulting version for the assets database.
"""
... | python | def downgrade(engine, desired_version):
"""Downgrades the assets db at the given engine to the desired version.
Parameters
----------
engine : Engine
An SQLAlchemy engine to the assets database.
desired_version : int
The desired resulting version for the assets database.
"""
... | [
"def",
"downgrade",
"(",
"engine",
",",
"desired_version",
")",
":",
"# Check the version of the db at the engine",
"with",
"engine",
".",
"begin",
"(",
")",
"as",
"conn",
":",
"metadata",
"=",
"sa",
".",
"MetaData",
"(",
"conn",
")",
"metadata",
".",
"reflect... | Downgrades the assets db at the given engine to the desired version.
Parameters
----------
engine : Engine
An SQLAlchemy engine to the assets database.
desired_version : int
The desired resulting version for the assets database. | [
"Downgrades",
"the",
"assets",
"db",
"at",
"the",
"given",
"engine",
"to",
"the",
"desired",
"version",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_db_migrations.py#L65-L109 |
25,876 | quantopian/zipline | zipline/assets/asset_db_migrations.py | downgrades | def downgrades(src):
"""Decorator for marking that a method is a downgrade to a version to the
previous version.
Parameters
----------
src : int
The version this downgrades from.
Returns
-------
decorator : callable[(callable) -> callable]
The decorator to apply.
""... | python | def downgrades(src):
"""Decorator for marking that a method is a downgrade to a version to the
previous version.
Parameters
----------
src : int
The version this downgrades from.
Returns
-------
decorator : callable[(callable) -> callable]
The decorator to apply.
""... | [
"def",
"downgrades",
"(",
"src",
")",
":",
"def",
"_",
"(",
"f",
")",
":",
"destination",
"=",
"src",
"-",
"1",
"@",
"do",
"(",
"operator",
".",
"setitem",
"(",
"_downgrade_methods",
",",
"destination",
")",
")",
"@",
"wraps",
"(",
"f",
")",
"def",... | Decorator for marking that a method is a downgrade to a version to the
previous version.
Parameters
----------
src : int
The version this downgrades from.
Returns
-------
decorator : callable[(callable) -> callable]
The decorator to apply. | [
"Decorator",
"for",
"marking",
"that",
"a",
"method",
"is",
"a",
"downgrade",
"to",
"a",
"version",
"to",
"the",
"previous",
"version",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_db_migrations.py#L133-L158 |
25,877 | quantopian/zipline | zipline/assets/asset_db_migrations.py | _downgrade_v1 | def _downgrade_v1(op):
"""
Downgrade assets db by removing the 'tick_size' column and renaming the
'multiplier' column.
"""
# Drop indices before batch
# This is to prevent index collision when creating the temp table
op.drop_index('ix_futures_contracts_root_symbol')
op.drop_index('ix_fu... | python | def _downgrade_v1(op):
"""
Downgrade assets db by removing the 'tick_size' column and renaming the
'multiplier' column.
"""
# Drop indices before batch
# This is to prevent index collision when creating the temp table
op.drop_index('ix_futures_contracts_root_symbol')
op.drop_index('ix_fu... | [
"def",
"_downgrade_v1",
"(",
"op",
")",
":",
"# Drop indices before batch",
"# This is to prevent index collision when creating the temp table",
"op",
".",
"drop_index",
"(",
"'ix_futures_contracts_root_symbol'",
")",
"op",
".",
"drop_index",
"(",
"'ix_futures_contracts_symbol'",... | Downgrade assets db by removing the 'tick_size' column and renaming the
'multiplier' column. | [
"Downgrade",
"assets",
"db",
"by",
"removing",
"the",
"tick_size",
"column",
"and",
"renaming",
"the",
"multiplier",
"column",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_db_migrations.py#L162-L189 |
25,878 | quantopian/zipline | zipline/assets/asset_db_migrations.py | _downgrade_v2 | def _downgrade_v2(op):
"""
Downgrade assets db by removing the 'auto_close_date' column.
"""
# Drop indices before batch
# This is to prevent index collision when creating the temp table
op.drop_index('ix_equities_fuzzy_symbol')
op.drop_index('ix_equities_company_symbol')
# Execute batc... | python | def _downgrade_v2(op):
"""
Downgrade assets db by removing the 'auto_close_date' column.
"""
# Drop indices before batch
# This is to prevent index collision when creating the temp table
op.drop_index('ix_equities_fuzzy_symbol')
op.drop_index('ix_equities_company_symbol')
# Execute batc... | [
"def",
"_downgrade_v2",
"(",
"op",
")",
":",
"# Drop indices before batch",
"# This is to prevent index collision when creating the temp table",
"op",
".",
"drop_index",
"(",
"'ix_equities_fuzzy_symbol'",
")",
"op",
".",
"drop_index",
"(",
"'ix_equities_company_symbol'",
")",
... | Downgrade assets db by removing the 'auto_close_date' column. | [
"Downgrade",
"assets",
"db",
"by",
"removing",
"the",
"auto_close_date",
"column",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_db_migrations.py#L193-L212 |
25,879 | quantopian/zipline | zipline/assets/asset_db_migrations.py | _downgrade_v3 | def _downgrade_v3(op):
"""
Downgrade assets db by adding a not null constraint on
``equities.first_traded``
"""
op.create_table(
'_new_equities',
sa.Column(
'sid',
sa.Integer,
unique=True,
nullable=False,
primary_key=True,
... | python | def _downgrade_v3(op):
"""
Downgrade assets db by adding a not null constraint on
``equities.first_traded``
"""
op.create_table(
'_new_equities',
sa.Column(
'sid',
sa.Integer,
unique=True,
nullable=False,
primary_key=True,
... | [
"def",
"_downgrade_v3",
"(",
"op",
")",
":",
"op",
".",
"create_table",
"(",
"'_new_equities'",
",",
"sa",
".",
"Column",
"(",
"'sid'",
",",
"sa",
".",
"Integer",
",",
"unique",
"=",
"True",
",",
"nullable",
"=",
"False",
",",
"primary_key",
"=",
"True... | Downgrade assets db by adding a not null constraint on
``equities.first_traded`` | [
"Downgrade",
"assets",
"db",
"by",
"adding",
"a",
"not",
"null",
"constraint",
"on",
"equities",
".",
"first_traded"
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_db_migrations.py#L216-L260 |
25,880 | quantopian/zipline | zipline/assets/asset_db_migrations.py | _downgrade_v4 | def _downgrade_v4(op):
"""
Downgrades assets db by copying the `exchange_full` column to `exchange`,
then dropping the `exchange_full` column.
"""
op.drop_index('ix_equities_fuzzy_symbol')
op.drop_index('ix_equities_company_symbol')
op.execute("UPDATE equities SET exchange = exchange_full")... | python | def _downgrade_v4(op):
"""
Downgrades assets db by copying the `exchange_full` column to `exchange`,
then dropping the `exchange_full` column.
"""
op.drop_index('ix_equities_fuzzy_symbol')
op.drop_index('ix_equities_company_symbol')
op.execute("UPDATE equities SET exchange = exchange_full")... | [
"def",
"_downgrade_v4",
"(",
"op",
")",
":",
"op",
".",
"drop_index",
"(",
"'ix_equities_fuzzy_symbol'",
")",
"op",
".",
"drop_index",
"(",
"'ix_equities_company_symbol'",
")",
"op",
".",
"execute",
"(",
"\"UPDATE equities SET exchange = exchange_full\"",
")",
"with",... | Downgrades assets db by copying the `exchange_full` column to `exchange`,
then dropping the `exchange_full` column. | [
"Downgrades",
"assets",
"db",
"by",
"copying",
"the",
"exchange_full",
"column",
"to",
"exchange",
"then",
"dropping",
"the",
"exchange_full",
"column",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/asset_db_migrations.py#L264-L282 |
25,881 | quantopian/zipline | zipline/finance/metrics/core.py | _make_metrics_set_core | def _make_metrics_set_core():
"""Create a family of metrics sets functions that read from the same
metrics set mapping.
Returns
-------
metrics_sets : mappingproxy
The mapping of metrics sets to load functions.
register : callable
The function which registers new metrics sets in... | python | def _make_metrics_set_core():
"""Create a family of metrics sets functions that read from the same
metrics set mapping.
Returns
-------
metrics_sets : mappingproxy
The mapping of metrics sets to load functions.
register : callable
The function which registers new metrics sets in... | [
"def",
"_make_metrics_set_core",
"(",
")",
":",
"_metrics_sets",
"=",
"{",
"}",
"# Expose _metrics_sets through a proxy so that users cannot mutate this",
"# accidentally. Users may go through `register` to update this which will",
"# warn when trampling another metrics set.",
"metrics_sets"... | Create a family of metrics sets functions that read from the same
metrics set mapping.
Returns
-------
metrics_sets : mappingproxy
The mapping of metrics sets to load functions.
register : callable
The function which registers new metrics sets in the ``metrics_sets``
mapping... | [
"Create",
"a",
"family",
"of",
"metrics",
"sets",
"functions",
"that",
"read",
"from",
"the",
"same",
"metrics",
"set",
"mapping",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/core.py#L6-L103 |
25,882 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | validate_column_specs | def validate_column_specs(events, columns):
"""
Verify that the columns of ``events`` can be used by a
EarningsEstimatesLoader to serve the BoundColumns described by
`columns`.
"""
required = required_estimates_fields(columns)
received = set(events.columns)
missing = required - received
... | python | def validate_column_specs(events, columns):
"""
Verify that the columns of ``events`` can be used by a
EarningsEstimatesLoader to serve the BoundColumns described by
`columns`.
"""
required = required_estimates_fields(columns)
received = set(events.columns)
missing = required - received
... | [
"def",
"validate_column_specs",
"(",
"events",
",",
"columns",
")",
":",
"required",
"=",
"required_estimates_fields",
"(",
"columns",
")",
"received",
"=",
"set",
"(",
"events",
".",
"columns",
")",
"missing",
"=",
"required",
"-",
"received",
"if",
"missing"... | Verify that the columns of ``events`` can be used by a
EarningsEstimatesLoader to serve the BoundColumns described by
`columns`. | [
"Verify",
"that",
"the",
"columns",
"of",
"events",
"can",
"be",
"used",
"by",
"a",
"EarningsEstimatesLoader",
"to",
"serve",
"the",
"BoundColumns",
"described",
"by",
"columns",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L74-L92 |
25,883 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | EarningsEstimatesLoader.get_requested_quarter_data | def get_requested_quarter_data(self,
zero_qtr_data,
zeroth_quarter_idx,
stacked_last_per_qtr,
num_announcements,
dates):
"""
Sele... | python | def get_requested_quarter_data(self,
zero_qtr_data,
zeroth_quarter_idx,
stacked_last_per_qtr,
num_announcements,
dates):
"""
Sele... | [
"def",
"get_requested_quarter_data",
"(",
"self",
",",
"zero_qtr_data",
",",
"zeroth_quarter_idx",
",",
"stacked_last_per_qtr",
",",
"num_announcements",
",",
"dates",
")",
":",
"zero_qtr_data_idx",
"=",
"zero_qtr_data",
".",
"index",
"requested_qtr_idx",
"=",
"pd",
"... | Selects the requested data for each date.
Parameters
----------
zero_qtr_data : pd.DataFrame
The 'time zero' data for each calendar date per sid.
zeroth_quarter_idx : pd.Index
An index of calendar dates, sid, and normalized quarters, for only
the rows... | [
"Selects",
"the",
"requested",
"data",
"for",
"each",
"date",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L190-L253 |
25,884 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | EarningsEstimatesLoader.get_split_adjusted_asof_idx | def get_split_adjusted_asof_idx(self, dates):
"""
Compute the index in `dates` where the split-adjusted-asof-date
falls. This is the date up to which, and including which, we will
need to unapply all adjustments for and then re-apply them as they
come in. After this date, adjustm... | python | def get_split_adjusted_asof_idx(self, dates):
"""
Compute the index in `dates` where the split-adjusted-asof-date
falls. This is the date up to which, and including which, we will
need to unapply all adjustments for and then re-apply them as they
come in. After this date, adjustm... | [
"def",
"get_split_adjusted_asof_idx",
"(",
"self",
",",
"dates",
")",
":",
"split_adjusted_asof_idx",
"=",
"dates",
".",
"searchsorted",
"(",
"self",
".",
"_split_adjusted_asof",
")",
"# The split-asof date is after the date index.",
"if",
"split_adjusted_asof_idx",
"==",
... | Compute the index in `dates` where the split-adjusted-asof-date
falls. This is the date up to which, and including which, we will
need to unapply all adjustments for and then re-apply them as they
come in. After this date, adjustments are applied as normal.
Parameters
----------... | [
"Compute",
"the",
"index",
"in",
"dates",
"where",
"the",
"split",
"-",
"adjusted",
"-",
"asof",
"-",
"date",
"falls",
".",
"This",
"is",
"the",
"date",
"up",
"to",
"which",
"and",
"including",
"which",
"we",
"will",
"need",
"to",
"unapply",
"all",
"ad... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L255-L280 |
25,885 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | EarningsEstimatesLoader.collect_overwrites_for_sid | def collect_overwrites_for_sid(self,
group,
dates,
requested_qtr_data,
last_per_qtr,
sid_idx,
columns,
... | python | def collect_overwrites_for_sid(self,
group,
dates,
requested_qtr_data,
last_per_qtr,
sid_idx,
columns,
... | [
"def",
"collect_overwrites_for_sid",
"(",
"self",
",",
"group",
",",
"dates",
",",
"requested_qtr_data",
",",
"last_per_qtr",
",",
"sid_idx",
",",
"columns",
",",
"all_adjustments_for_sid",
",",
"sid",
")",
":",
"# If data was requested for only 1 date, there can never be... | Given a sid, collect all overwrites that should be applied for this
sid at each quarter boundary.
Parameters
----------
group : pd.DataFrame
The data for `sid`.
dates : pd.DatetimeIndex
The calendar dates for which estimates data is requested.
req... | [
"Given",
"a",
"sid",
"collect",
"all",
"overwrites",
"that",
"should",
"be",
"applied",
"for",
"this",
"sid",
"at",
"each",
"quarter",
"boundary",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L282-L353 |
25,886 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | EarningsEstimatesLoader.merge_into_adjustments_for_all_sids | def merge_into_adjustments_for_all_sids(self,
all_adjustments_for_sid,
col_to_all_adjustments):
"""
Merge adjustments for a particular sid into a dictionary containing
adjustments for all sids.
Param... | python | def merge_into_adjustments_for_all_sids(self,
all_adjustments_for_sid,
col_to_all_adjustments):
"""
Merge adjustments for a particular sid into a dictionary containing
adjustments for all sids.
Param... | [
"def",
"merge_into_adjustments_for_all_sids",
"(",
"self",
",",
"all_adjustments_for_sid",
",",
"col_to_all_adjustments",
")",
":",
"for",
"col_name",
"in",
"all_adjustments_for_sid",
":",
"if",
"col_name",
"not",
"in",
"col_to_all_adjustments",
":",
"col_to_all_adjustments... | Merge adjustments for a particular sid into a dictionary containing
adjustments for all sids.
Parameters
----------
all_adjustments_for_sid : dict[int -> AdjustedArray]
All adjustments for a particular sid.
col_to_all_adjustments : dict[int -> AdjustedArray]
... | [
"Merge",
"adjustments",
"for",
"a",
"particular",
"sid",
"into",
"a",
"dictionary",
"containing",
"adjustments",
"for",
"all",
"sids",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L406-L429 |
25,887 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | EarningsEstimatesLoader.get_adjustments | def get_adjustments(self,
zero_qtr_data,
requested_qtr_data,
last_per_qtr,
dates,
assets,
columns,
**kwargs):
"""
Creates an AdjustedArr... | python | def get_adjustments(self,
zero_qtr_data,
requested_qtr_data,
last_per_qtr,
dates,
assets,
columns,
**kwargs):
"""
Creates an AdjustedArr... | [
"def",
"get_adjustments",
"(",
"self",
",",
"zero_qtr_data",
",",
"requested_qtr_data",
",",
"last_per_qtr",
",",
"dates",
",",
"assets",
",",
"columns",
",",
"*",
"*",
"kwargs",
")",
":",
"zero_qtr_data",
".",
"sort_index",
"(",
"inplace",
"=",
"True",
")",... | Creates an AdjustedArray from the given estimates data for the given
dates.
Parameters
----------
zero_qtr_data : pd.DataFrame
The 'time zero' data for each calendar date per sid.
requested_qtr_data : pd.DataFrame
The requested quarter data for each calen... | [
"Creates",
"an",
"AdjustedArray",
"from",
"the",
"given",
"estimates",
"data",
"for",
"the",
"given",
"dates",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L431-L490 |
25,888 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | EarningsEstimatesLoader.create_overwrites_for_quarter | def create_overwrites_for_quarter(self,
col_to_overwrites,
next_qtr_start_idx,
last_per_qtr,
quarters_with_estimates_for_sid,
requ... | python | def create_overwrites_for_quarter(self,
col_to_overwrites,
next_qtr_start_idx,
last_per_qtr,
quarters_with_estimates_for_sid,
requ... | [
"def",
"create_overwrites_for_quarter",
"(",
"self",
",",
"col_to_overwrites",
",",
"next_qtr_start_idx",
",",
"last_per_qtr",
",",
"quarters_with_estimates_for_sid",
",",
"requested_quarter",
",",
"sid",
",",
"sid_idx",
",",
"columns",
")",
":",
"for",
"col",
"in",
... | Add entries to the dictionary of columns to adjustments for the given
sid and the given quarter.
Parameters
----------
col_to_overwrites : dict [column_name -> list of ArrayAdjustment]
A dictionary mapping column names to all overwrites for those
columns.
... | [
"Add",
"entries",
"to",
"the",
"dictionary",
"of",
"columns",
"to",
"adjustments",
"for",
"the",
"given",
"sid",
"and",
"the",
"given",
"quarter",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L492-L563 |
25,889 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | EarningsEstimatesLoader.get_last_data_per_qtr | def get_last_data_per_qtr(self,
assets_with_data,
columns,
dates,
data_query_cutoff_times):
"""
Determine the last piece of information we know for each column on each
date in ... | python | def get_last_data_per_qtr(self,
assets_with_data,
columns,
dates,
data_query_cutoff_times):
"""
Determine the last piece of information we know for each column on each
date in ... | [
"def",
"get_last_data_per_qtr",
"(",
"self",
",",
"assets_with_data",
",",
"columns",
",",
"dates",
",",
"data_query_cutoff_times",
")",
":",
"# Get a DataFrame indexed by date with a MultiIndex of columns of",
"# [self.estimates.columns, normalized_quarters, sid], where each cell",
... | Determine the last piece of information we know for each column on each
date in the index for each sid and quarter.
Parameters
----------
assets_with_data : pd.Index
Index of all assets that appear in the raw data given to the
loader.
columns : iterable o... | [
"Determine",
"the",
"last",
"piece",
"of",
"information",
"we",
"know",
"for",
"each",
"column",
"on",
"each",
"date",
"in",
"the",
"index",
"for",
"each",
"sid",
"and",
"quarter",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L667-L725 |
25,890 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | PreviousEarningsEstimatesLoader.get_zeroth_quarter_idx | def get_zeroth_quarter_idx(self, stacked_last_per_qtr):
"""
Filters for releases that are on or after each simulation date and
determines the previous quarter by picking out the most recent
release relative to each date in the index.
Parameters
----------
stacked... | python | def get_zeroth_quarter_idx(self, stacked_last_per_qtr):
"""
Filters for releases that are on or after each simulation date and
determines the previous quarter by picking out the most recent
release relative to each date in the index.
Parameters
----------
stacked... | [
"def",
"get_zeroth_quarter_idx",
"(",
"self",
",",
"stacked_last_per_qtr",
")",
":",
"previous_releases_per_date",
"=",
"stacked_last_per_qtr",
".",
"loc",
"[",
"stacked_last_per_qtr",
"[",
"EVENT_DATE_FIELD_NAME",
"]",
"<=",
"stacked_last_per_qtr",
".",
"index",
".",
"... | Filters for releases that are on or after each simulation date and
determines the previous quarter by picking out the most recent
release relative to each date in the index.
Parameters
----------
stacked_last_per_qtr : pd.DataFrame
A DataFrame with index of calendar ... | [
"Filters",
"for",
"releases",
"that",
"are",
"on",
"or",
"after",
"each",
"simulation",
"date",
"and",
"determines",
"the",
"previous",
"quarter",
"by",
"picking",
"out",
"the",
"most",
"recent",
"release",
"relative",
"to",
"each",
"date",
"in",
"the",
"ind... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L810-L838 |
25,891 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | SplitAdjustedEstimatesLoader.get_adjustments_for_sid | def get_adjustments_for_sid(self,
group,
dates,
requested_qtr_data,
last_per_qtr,
sid_to_idx,
columns,
... | python | def get_adjustments_for_sid(self,
group,
dates,
requested_qtr_data,
last_per_qtr,
sid_to_idx,
columns,
... | [
"def",
"get_adjustments_for_sid",
"(",
"self",
",",
"group",
",",
"dates",
",",
"requested_qtr_data",
",",
"last_per_qtr",
",",
"sid_to_idx",
",",
"columns",
",",
"col_to_all_adjustments",
",",
"split_adjusted_asof_idx",
"=",
"None",
",",
"split_adjusted_cols_for_group"... | Collects both overwrites and adjustments for a particular sid.
Parameters
----------
split_adjusted_asof_idx : int
The integer index of the date on which the data was split-adjusted.
split_adjusted_cols_for_group : list of str
The names of requested columns that ... | [
"Collects",
"both",
"overwrites",
"and",
"adjustments",
"for",
"a",
"particular",
"sid",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L907-L965 |
25,892 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | SplitAdjustedEstimatesLoader.get_adjustments | def get_adjustments(self,
zero_qtr_data,
requested_qtr_data,
last_per_qtr,
dates,
assets,
columns,
**kwargs):
"""
Calculates both split ... | python | def get_adjustments(self,
zero_qtr_data,
requested_qtr_data,
last_per_qtr,
dates,
assets,
columns,
**kwargs):
"""
Calculates both split ... | [
"def",
"get_adjustments",
"(",
"self",
",",
"zero_qtr_data",
",",
"requested_qtr_data",
",",
"last_per_qtr",
",",
"dates",
",",
"assets",
",",
"columns",
",",
"*",
"*",
"kwargs",
")",
":",
"split_adjusted_cols_for_group",
"=",
"[",
"self",
".",
"name_map",
"["... | Calculates both split adjustments and overwrites for all sids. | [
"Calculates",
"both",
"split",
"adjustments",
"and",
"overwrites",
"for",
"all",
"sids",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L967-L996 |
25,893 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | SplitAdjustedEstimatesLoader.determine_end_idx_for_adjustment | def determine_end_idx_for_adjustment(self,
adjustment_ts,
dates,
upper_bound,
requested_quarter,
sid_estimates):
... | python | def determine_end_idx_for_adjustment(self,
adjustment_ts,
dates,
upper_bound,
requested_quarter,
sid_estimates):
... | [
"def",
"determine_end_idx_for_adjustment",
"(",
"self",
",",
"adjustment_ts",
",",
"dates",
",",
"upper_bound",
",",
"requested_quarter",
",",
"sid_estimates",
")",
":",
"end_idx",
"=",
"upper_bound",
"# Find the next newest kd that happens on or after",
"# the date of this a... | Determines the date until which the adjustment at the given date
index should be applied for the given quarter.
Parameters
----------
adjustment_ts : pd.Timestamp
The timestamp at which the adjustment occurs.
dates : pd.DatetimeIndex
The calendar dates ov... | [
"Determines",
"the",
"date",
"until",
"which",
"the",
"adjustment",
"at",
"the",
"given",
"date",
"index",
"should",
"be",
"applied",
"for",
"the",
"given",
"quarter",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L998-L1051 |
25,894 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | SplitAdjustedEstimatesLoader.collect_pre_split_asof_date_adjustments | def collect_pre_split_asof_date_adjustments(
self,
split_adjusted_asof_date_idx,
sid_idx,
pre_adjustments,
requested_split_adjusted_columns
):
"""
Collect split adjustments that occur before the
split-adjusted-asof-date. All those a... | python | def collect_pre_split_asof_date_adjustments(
self,
split_adjusted_asof_date_idx,
sid_idx,
pre_adjustments,
requested_split_adjusted_columns
):
"""
Collect split adjustments that occur before the
split-adjusted-asof-date. All those a... | [
"def",
"collect_pre_split_asof_date_adjustments",
"(",
"self",
",",
"split_adjusted_asof_date_idx",
",",
"sid_idx",
",",
"pre_adjustments",
",",
"requested_split_adjusted_columns",
")",
":",
"col_to_split_adjustments",
"=",
"{",
"}",
"if",
"len",
"(",
"pre_adjustments",
"... | Collect split adjustments that occur before the
split-adjusted-asof-date. All those adjustments must first be
UN-applied at the first date index and then re-applied on the
appropriate dates in order to match point in time share pricing data.
Parameters
----------
split_a... | [
"Collect",
"split",
"adjustments",
"that",
"occur",
"before",
"the",
"split",
"-",
"adjusted",
"-",
"asof",
"-",
"date",
".",
"All",
"those",
"adjustments",
"must",
"first",
"be",
"UN",
"-",
"applied",
"at",
"the",
"first",
"date",
"index",
"and",
"then",
... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L1053-L1115 |
25,895 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | SplitAdjustedEstimatesLoader.collect_post_asof_split_adjustments | def collect_post_asof_split_adjustments(self,
post_adjustments,
requested_qtr_data,
sid,
sid_idx,
si... | python | def collect_post_asof_split_adjustments(self,
post_adjustments,
requested_qtr_data,
sid,
sid_idx,
si... | [
"def",
"collect_post_asof_split_adjustments",
"(",
"self",
",",
"post_adjustments",
",",
"requested_qtr_data",
",",
"sid",
",",
"sid_idx",
",",
"sid_estimates",
",",
"requested_split_adjusted_columns",
")",
":",
"col_to_split_adjustments",
"=",
"{",
"}",
"if",
"post_adj... | Collect split adjustments that occur after the
split-adjusted-asof-date. Each adjustment needs to be applied to all
dates on which knowledge for the requested quarter was older than the
date of the adjustment.
Parameters
----------
post_adjustments : tuple(list(float), l... | [
"Collect",
"split",
"adjustments",
"that",
"occur",
"after",
"the",
"split",
"-",
"adjusted",
"-",
"asof",
"-",
"date",
".",
"Each",
"adjustment",
"needs",
"to",
"be",
"applied",
"to",
"all",
"dates",
"on",
"which",
"knowledge",
"for",
"the",
"requested",
... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L1117-L1215 |
25,896 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | SplitAdjustedEstimatesLoader.merge_split_adjustments_with_overwrites | def merge_split_adjustments_with_overwrites(
self,
pre,
post,
overwrites,
requested_split_adjusted_columns
):
"""
Merge split adjustments with the dict containing overwrites.
Parameters
----------
pre : dict[str -> dict[int -> list]]
... | python | def merge_split_adjustments_with_overwrites(
self,
pre,
post,
overwrites,
requested_split_adjusted_columns
):
"""
Merge split adjustments with the dict containing overwrites.
Parameters
----------
pre : dict[str -> dict[int -> list]]
... | [
"def",
"merge_split_adjustments_with_overwrites",
"(",
"self",
",",
"pre",
",",
"post",
",",
"overwrites",
",",
"requested_split_adjusted_columns",
")",
":",
"for",
"column_name",
"in",
"requested_split_adjusted_columns",
":",
"# We can do a merge here because the timestamps in... | Merge split adjustments with the dict containing overwrites.
Parameters
----------
pre : dict[str -> dict[int -> list]]
The adjustments that occur before the split-adjusted-asof-date.
post : dict[str -> dict[int -> list]]
The adjustments that occur after the spli... | [
"Merge",
"split",
"adjustments",
"with",
"the",
"dict",
"containing",
"overwrites",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L1294-L1336 |
25,897 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | PreviousSplitAdjustedEarningsEstimatesLoader.collect_split_adjustments | def collect_split_adjustments(self,
adjustments_for_sid,
requested_qtr_data,
dates,
sid,
sid_idx,
sid_estimates,
... | python | def collect_split_adjustments(self,
adjustments_for_sid,
requested_qtr_data,
dates,
sid,
sid_idx,
sid_estimates,
... | [
"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... | Collect split adjustments for previous quarters and apply them to the
given dictionary of splits for the given sid. Since overwrites just
replace all estimates before the new quarter with NaN, we don't need to
worry about re-applying split adjustments.
Parameters
----------
... | [
"Collect",
"split",
"adjustments",
"for",
"previous",
"quarters",
"and",
"apply",
"them",
"to",
"the",
"given",
"dictionary",
"of",
"splits",
"for",
"the",
"given",
"sid",
".",
"Since",
"overwrites",
"just",
"replace",
"all",
"estimates",
"before",
"the",
"new... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L1342-L1401 |
25,898 | quantopian/zipline | zipline/pipeline/loaders/earnings_estimates.py | NextSplitAdjustedEarningsEstimatesLoader.collect_split_adjustments | def collect_split_adjustments(self,
adjustments_for_sid,
requested_qtr_data,
dates,
sid,
sid_idx,
sid_estimates,
... | python | def collect_split_adjustments(self,
adjustments_for_sid,
requested_qtr_data,
dates,
sid,
sid_idx,
sid_estimates,
... | [
"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... | Collect split adjustments for future quarters. Re-apply adjustments
that would be overwritten by overwrites. Merge split adjustments with
overwrites into the given dictionary of splits for the given sid.
Parameters
----------
adjustments_for_sid : dict[str -> dict[int -> list]]
... | [
"Collect",
"split",
"adjustments",
"for",
"future",
"quarters",
".",
"Re",
"-",
"apply",
"adjustments",
"that",
"would",
"be",
"overwritten",
"by",
"overwrites",
".",
"Merge",
"split",
"adjustments",
"with",
"overwrites",
"into",
"the",
"given",
"dictionary",
"o... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/earnings_estimates.py#L1407-L1534 |
25,899 | quantopian/zipline | zipline/pipeline/factors/basic.py | _ExponentialWeightedFactor.from_span | def from_span(cls, inputs, window_length, span, **kwargs):
"""
Convenience constructor for passing `decay_rate` in terms of `span`.
Forwards `decay_rate` as `1 - (2.0 / (1 + span))`. This provides the
behavior equivalent to passing `span` to pandas.ewma.
Examples
-----... | python | def from_span(cls, inputs, window_length, span, **kwargs):
"""
Convenience constructor for passing `decay_rate` in terms of `span`.
Forwards `decay_rate` as `1 - (2.0 / (1 + span))`. This provides the
behavior equivalent to passing `span` to pandas.ewma.
Examples
-----... | [
"def",
"from_span",
"(",
"cls",
",",
"inputs",
",",
"window_length",
",",
"span",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"span",
"<=",
"1",
":",
"raise",
"ValueError",
"(",
"\"`span` must be a positive number. %s was passed.\"",
"%",
"span",
")",
"decay_rate... | Convenience constructor for passing `decay_rate` in terms of `span`.
Forwards `decay_rate` as `1 - (2.0 / (1 + span))`. This provides the
behavior equivalent to passing `span` to pandas.ewma.
Examples
--------
.. code-block:: python
# Equivalent to:
# ... | [
"Convenience",
"constructor",
"for",
"passing",
"decay_rate",
"in",
"terms",
"of",
"span",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/factors/basic.py#L198-L240 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.