partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
convert_cols
Adapt OHLCV columns into uint32 columns. Parameters ---------- cols : dict A dict mapping each column name (open, high, low, close, volume) to a float column to convert to uint32. scale_factor : int Factor to use to scale float values before converting to uint32. sid : int ...
zipline/data/minute_bars.py
def convert_cols(cols, scale_factor, sid, invalid_data_behavior): """Adapt OHLCV columns into uint32 columns. Parameters ---------- cols : dict A dict mapping each column name (open, high, low, close, volume) to a float column to convert to uint32. scale_factor : int Factor ...
def convert_cols(cols, scale_factor, sid, invalid_data_behavior): """Adapt OHLCV columns into uint32 columns. Parameters ---------- cols : dict A dict mapping each column name (open, high, low, close, volume) to a float column to convert to uint32. scale_factor : int Factor ...
[ "Adapt", "OHLCV", "columns", "into", "uint32", "columns", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L116-L180
[ "def", "convert_cols", "(", "cols", ",", "scale_factor", ",", "sid", ",", "invalid_data_behavior", ")", ":", "scaled_opens", "=", "(", "np", ".", "nan_to_num", "(", "cols", "[", "'open'", "]", ")", "*", "scale_factor", ")", ".", "round", "(", ")", "scale...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarMetadata.write
Write the metadata to a JSON file in the rootdir. Values contained in the metadata are: version : int The value of FORMAT_VERSION of this class. ohlc_ratio : int The default ratio by which to multiply the pricing data to convert the floats from floats to an ...
zipline/data/minute_bars.py
def write(self, rootdir): """ Write the metadata to a JSON file in the rootdir. Values contained in the metadata are: version : int The value of FORMAT_VERSION of this class. ohlc_ratio : int The default ratio by which to multiply the pricing data to ...
def write(self, rootdir): """ Write the metadata to a JSON file in the rootdir. Values contained in the metadata are: version : int The value of FORMAT_VERSION of this class. ohlc_ratio : int The default ratio by which to multiply the pricing data to ...
[ "Write", "the", "metadata", "to", "a", "JSON", "file", "in", "the", "rootdir", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L280-L349
[ "def", "write", "(", "self", ",", "rootdir", ")", ":", "calendar", "=", "self", ".", "calendar", "slicer", "=", "calendar", ".", "schedule", ".", "index", ".", "slice_indexer", "(", "self", ".", "start_session", ",", "self", ".", "end_session", ",", ")",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.open
Open an existing ``rootdir`` for writing. Parameters ---------- end_session : Timestamp (optional) When appending, the intended new ``end_session``.
zipline/data/minute_bars.py
def open(cls, rootdir, end_session=None): """ Open an existing ``rootdir`` for writing. Parameters ---------- end_session : Timestamp (optional) When appending, the intended new ``end_session``. """ metadata = BcolzMinuteBarMetadata.read(rootdir) ...
def open(cls, rootdir, end_session=None): """ Open an existing ``rootdir`` for writing. Parameters ---------- end_session : Timestamp (optional) When appending, the intended new ``end_session``. """ metadata = BcolzMinuteBarMetadata.read(rootdir) ...
[ "Open", "an", "existing", "rootdir", "for", "writing", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L482-L501
[ "def", "open", "(", "cls", ",", "rootdir", ",", "end_session", "=", "None", ")", ":", "metadata", "=", "BcolzMinuteBarMetadata", ".", "read", "(", "rootdir", ")", "return", "BcolzMinuteBarWriter", "(", "rootdir", ",", "metadata", ".", "calendar", ",", "metad...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.sidpath
Parameters ---------- sid : int Asset identifier. Returns ------- out : string Full path to the bcolz rootdir for the given sid.
zipline/data/minute_bars.py
def sidpath(self, sid): """ Parameters ---------- sid : int Asset identifier. Returns ------- out : string Full path to the bcolz rootdir for the given sid. """ sid_subdir = _sid_subdir_path(sid) return join(self._r...
def sidpath(self, sid): """ Parameters ---------- sid : int Asset identifier. Returns ------- out : string Full path to the bcolz rootdir for the given sid. """ sid_subdir = _sid_subdir_path(sid) return join(self._r...
[ "Parameters", "----------", "sid", ":", "int", "Asset", "identifier", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L518-L531
[ "def", "sidpath", "(", "self", ",", "sid", ")", ":", "sid_subdir", "=", "_sid_subdir_path", "(", "sid", ")", "return", "join", "(", "self", ".", "_rootdir", ",", "sid_subdir", ")" ]
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.last_date_in_output_for_sid
Parameters ---------- sid : int Asset identifier. Returns ------- out : pd.Timestamp The midnight of the last date written in to the output for the given sid.
zipline/data/minute_bars.py
def last_date_in_output_for_sid(self, sid): """ Parameters ---------- sid : int Asset identifier. Returns ------- out : pd.Timestamp The midnight of the last date written in to the output for the given sid. """ ...
def last_date_in_output_for_sid(self, sid): """ Parameters ---------- sid : int Asset identifier. Returns ------- out : pd.Timestamp The midnight of the last date written in to the output for the given sid. """ ...
[ "Parameters", "----------", "sid", ":", "int", "Asset", "identifier", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L533-L558
[ "def", "last_date_in_output_for_sid", "(", "self", ",", "sid", ")", ":", "sizes_path", "=", "\"{0}/close/meta/sizes\"", ".", "format", "(", "self", ".", "sidpath", "(", "sid", ")", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "sizes_path", ")",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter._init_ctable
Create empty ctable for given path. Parameters ---------- path : string The path to rootdir of the new ctable.
zipline/data/minute_bars.py
def _init_ctable(self, path): """ Create empty ctable for given path. Parameters ---------- path : string The path to rootdir of the new ctable. """ # Only create the containing subdir on creation. # This is not to be confused with the `.bcolz...
def _init_ctable(self, path): """ Create empty ctable for given path. Parameters ---------- path : string The path to rootdir of the new ctable. """ # Only create the containing subdir on creation. # This is not to be confused with the `.bcolz...
[ "Create", "empty", "ctable", "for", "given", "path", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L560-L597
[ "def", "_init_ctable", "(", "self", ",", "path", ")", ":", "# Only create the containing subdir on creation.", "# This is not to be confused with the `.bcolz` directory, but is the", "# directory up one level from the `.bcolz` directories.", "sid_containing_dirname", "=", "os", ".", "p...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter._ensure_ctable
Ensure that a ctable exists for ``sid``, then return it.
zipline/data/minute_bars.py
def _ensure_ctable(self, sid): """Ensure that a ctable exists for ``sid``, then return it.""" sidpath = self.sidpath(sid) if not os.path.exists(sidpath): return self._init_ctable(sidpath) return bcolz.ctable(rootdir=sidpath, mode='a')
def _ensure_ctable(self, sid): """Ensure that a ctable exists for ``sid``, then return it.""" sidpath = self.sidpath(sid) if not os.path.exists(sidpath): return self._init_ctable(sidpath) return bcolz.ctable(rootdir=sidpath, mode='a')
[ "Ensure", "that", "a", "ctable", "exists", "for", "sid", "then", "return", "it", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L599-L604
[ "def", "_ensure_ctable", "(", "self", ",", "sid", ")", ":", "sidpath", "=", "self", ".", "sidpath", "(", "sid", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "sidpath", ")", ":", "return", "self", ".", "_init_ctable", "(", "sidpath", ")", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.pad
Fill sid container with empty data through the specified date. If the last recorded trade is not at the close, then that day will be padded with zeros until its close. Any day after that (up to and including the specified date) will be padded with `minute_per_day` worth of zeros ...
zipline/data/minute_bars.py
def pad(self, sid, date): """ Fill sid container with empty data through the specified date. If the last recorded trade is not at the close, then that day will be padded with zeros until its close. Any day after that (up to and including the specified date) will be padded with `...
def pad(self, sid, date): """ Fill sid container with empty data through the specified date. If the last recorded trade is not at the close, then that day will be padded with zeros until its close. Any day after that (up to and including the specified date) will be padded with `...
[ "Fill", "sid", "container", "with", "empty", "data", "through", "the", "specified", "date", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L618-L659
[ "def", "pad", "(", "self", ",", "sid", ",", "date", ")", ":", "table", "=", "self", ".", "_ensure_ctable", "(", "sid", ")", "last_date", "=", "self", ".", "last_date_in_output_for_sid", "(", "sid", ")", "tds", "=", "self", ".", "_session_labels", "if", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.set_sid_attrs
Write all the supplied kwargs as attributes of the sid's file.
zipline/data/minute_bars.py
def set_sid_attrs(self, sid, **kwargs): """Write all the supplied kwargs as attributes of the sid's file. """ table = self._ensure_ctable(sid) for k, v in kwargs.items(): table.attrs[k] = v
def set_sid_attrs(self, sid, **kwargs): """Write all the supplied kwargs as attributes of the sid's file. """ table = self._ensure_ctable(sid) for k, v in kwargs.items(): table.attrs[k] = v
[ "Write", "all", "the", "supplied", "kwargs", "as", "attributes", "of", "the", "sid", "s", "file", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L661-L666
[ "def", "set_sid_attrs", "(", "self", ",", "sid", ",", "*", "*", "kwargs", ")", ":", "table", "=", "self", ".", "_ensure_ctable", "(", "sid", ")", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "table", ".", "attrs", "[", "k", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.write
Write a stream of minute data. Parameters ---------- data : iterable[(int, pd.DataFrame)] The data to write. Each element should be a tuple of sid, data where data has the following format: columns : ('open', 'high', 'low', 'close', 'volume') ...
zipline/data/minute_bars.py
def write(self, data, show_progress=False, invalid_data_behavior='warn'): """Write a stream of minute data. Parameters ---------- data : iterable[(int, pd.DataFrame)] The data to write. Each element should be a tuple of sid, data where data has the following form...
def write(self, data, show_progress=False, invalid_data_behavior='warn'): """Write a stream of minute data. Parameters ---------- data : iterable[(int, pd.DataFrame)] The data to write. Each element should be a tuple of sid, data where data has the following form...
[ "Write", "a", "stream", "of", "minute", "data", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L668-L697
[ "def", "write", "(", "self", ",", "data", ",", "show_progress", "=", "False", ",", "invalid_data_behavior", "=", "'warn'", ")", ":", "ctx", "=", "maybe_show_progress", "(", "data", ",", "show_progress", "=", "show_progress", ",", "item_show_func", "=", "lambda...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.write_sid
Write the OHLCV data for the given sid. If there is no bcolz ctable yet created for the sid, create it. If the length of the bcolz ctable is not exactly to the date before the first day provided, fill the ctable with 0s up to that date. Parameters ---------- sid : int ...
zipline/data/minute_bars.py
def write_sid(self, sid, df, invalid_data_behavior='warn'): """ Write the OHLCV data for the given sid. If there is no bcolz ctable yet created for the sid, create it. If the length of the bcolz ctable is not exactly to the date before the first day provided, fill the ctable with...
def write_sid(self, sid, df, invalid_data_behavior='warn'): """ Write the OHLCV data for the given sid. If there is no bcolz ctable yet created for the sid, create it. If the length of the bcolz ctable is not exactly to the date before the first day provided, fill the ctable with...
[ "Write", "the", "OHLCV", "data", "for", "the", "given", "sid", ".", "If", "there", "is", "no", "bcolz", "ctable", "yet", "created", "for", "the", "sid", "create", "it", ".", "If", "the", "length", "of", "the", "bcolz", "ctable", "is", "not", "exactly",...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L699-L730
[ "def", "write_sid", "(", "self", ",", "sid", ",", "df", ",", "invalid_data_behavior", "=", "'warn'", ")", ":", "cols", "=", "{", "'open'", ":", "df", ".", "open", ".", "values", ",", "'high'", ":", "df", ".", "high", ".", "values", ",", "'low'", ":...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.write_cols
Write the OHLCV data for the given sid. If there is no bcolz ctable yet created for the sid, create it. If the length of the bcolz ctable is not exactly to the date before the first day provided, fill the ctable with 0s up to that date. Parameters ---------- sid : int ...
zipline/data/minute_bars.py
def write_cols(self, sid, dts, cols, invalid_data_behavior='warn'): """ Write the OHLCV data for the given sid. If there is no bcolz ctable yet created for the sid, create it. If the length of the bcolz ctable is not exactly to the date before the first day provided, fill the cta...
def write_cols(self, sid, dts, cols, invalid_data_behavior='warn'): """ Write the OHLCV data for the given sid. If there is no bcolz ctable yet created for the sid, create it. If the length of the bcolz ctable is not exactly to the date before the first day provided, fill the cta...
[ "Write", "the", "OHLCV", "data", "for", "the", "given", "sid", ".", "If", "there", "is", "no", "bcolz", "ctable", "yet", "created", "for", "the", "sid", "create", "it", ".", "If", "the", "length", "of", "the", "bcolz", "ctable", "is", "not", "exactly",...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L732-L760
[ "def", "write_cols", "(", "self", ",", "sid", ",", "dts", ",", "cols", ",", "invalid_data_behavior", "=", "'warn'", ")", ":", "if", "not", "all", "(", "len", "(", "dts", ")", "==", "len", "(", "cols", "[", "name", "]", ")", "for", "name", "in", "...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter._write_cols
Internal method for `write_cols` and `write`. Parameters ---------- sid : int The asset identifier for the data being written. dts : datetime64 array The dts corresponding to values in cols. cols : dict of str -> np.array dict of market data w...
zipline/data/minute_bars.py
def _write_cols(self, sid, dts, cols, invalid_data_behavior): """ Internal method for `write_cols` and `write`. Parameters ---------- sid : int The asset identifier for the data being written. dts : datetime64 array The dts corresponding to values...
def _write_cols(self, sid, dts, cols, invalid_data_behavior): """ Internal method for `write_cols` and `write`. Parameters ---------- sid : int The asset identifier for the data being written. dts : datetime64 array The dts corresponding to values...
[ "Internal", "method", "for", "write_cols", "and", "write", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L762-L844
[ "def", "_write_cols", "(", "self", ",", "sid", ",", "dts", ",", "cols", ",", "invalid_data_behavior", ")", ":", "table", "=", "self", ".", "_ensure_ctable", "(", "sid", ")", "tds", "=", "self", ".", "_session_labels", "input_first_day", "=", "self", ".", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.data_len_for_day
Return the number of data points up to and including the provided day.
zipline/data/minute_bars.py
def data_len_for_day(self, day): """ Return the number of data points up to and including the provided day. """ day_ix = self._session_labels.get_loc(day) # Add one to the 0-indexed day_ix to get the number of days. num_days = day_ix + 1 return num_days * ...
def data_len_for_day(self, day): """ Return the number of data points up to and including the provided day. """ day_ix = self._session_labels.get_loc(day) # Add one to the 0-indexed day_ix to get the number of days. num_days = day_ix + 1 return num_days * ...
[ "Return", "the", "number", "of", "data", "points", "up", "to", "and", "including", "the", "provided", "day", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L846-L854
[ "def", "data_len_for_day", "(", "self", ",", "day", ")", ":", "day_ix", "=", "self", ".", "_session_labels", ".", "get_loc", "(", "day", ")", "# Add one to the 0-indexed day_ix to get the number of days.", "num_days", "=", "day_ix", "+", "1", "return", "num_days", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarWriter.truncate
Truncate data beyond this date in all ctables.
zipline/data/minute_bars.py
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 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...
[ "Truncate", "data", "beyond", "this", "date", "in", "all", "ctables", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L856-L883
[ "def", "truncate", "(", "self", ",", "date", ")", ":", "truncate_slice_end", "=", "self", ".", "data_len_for_day", "(", "date", ")", "glob_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_rootdir", ",", "\"*\"", ",", "\"*\"", ",", "\"*.b...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarReader._minutes_to_exclude
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...
zipline/data/minute_bars.py
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): """ 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 ------- ...
[ "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...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L991-L1013
[ "def", "_minutes_to_exclude", "(", "self", ")", ":", "market_opens", "=", "self", ".", "_market_opens", ".", "values", ".", "astype", "(", "'datetime64[m]'", ")", "market_closes", "=", "self", ".", "_market_closes", ".", "values", ".", "astype", "(", "'datetim...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarReader._minute_exclusion_tree
Build an interval tree keyed by the start and end of each range of positions should be dropped from windows. (These are the minutes between an early close and the minute which would be the close based on the regular period if there were no early close.) The value of each node is the same...
zipline/data/minute_bars.py
def _minute_exclusion_tree(self): """ Build an interval tree keyed by the start and end of each range of positions should be dropped from windows. (These are the minutes between an early close and the minute which would be the close based on the regular period if there were no ea...
def _minute_exclusion_tree(self): """ Build an interval tree keyed by the start and end of each range of positions should be dropped from windows. (These are the minutes between an early close and the minute which would be the close based on the regular period if there were no ea...
[ "Build", "an", "interval", "tree", "keyed", "by", "the", "start", "and", "end", "of", "each", "range", "of", "positions", "should", "be", "dropped", "from", "windows", ".", "(", "These", "are", "the", "minutes", "between", "an", "early", "close", "and", ...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L1016-L1045
[ "def", "_minute_exclusion_tree", "(", "self", ")", ":", "itree", "=", "IntervalTree", "(", ")", "for", "market_open", ",", "early_close", "in", "self", ".", "_minutes_to_exclude", "(", ")", ":", "start_pos", "=", "self", ".", "_find_position_of_minute", "(", "...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarReader._exclusion_indices_for_range
Returns ------- List of tuples of (start, stop) which represent the ranges of minutes which should be excluded when a market minute window is requested.
zipline/data/minute_bars.py
def _exclusion_indices_for_range(self, start_idx, end_idx): """ Returns ------- List of tuples of (start, stop) which represent the ranges of minutes which should be excluded when a market minute window is requested. """ itree = self._minute_exclusion_tree ...
def _exclusion_indices_for_range(self, start_idx, end_idx): """ Returns ------- List of tuples of (start, stop) which represent the ranges of minutes which should be excluded when a market minute window is requested. """ itree = self._minute_exclusion_tree ...
[ "Returns", "-------", "List", "of", "tuples", "of", "(", "start", "stop", ")", "which", "represent", "the", "ranges", "of", "minutes", "which", "should", "be", "excluded", "when", "a", "market", "minute", "window", "is", "requested", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L1047-L1062
[ "def", "_exclusion_indices_for_range", "(", "self", ",", "start_idx", ",", "end_idx", ")", ":", "itree", "=", "self", ".", "_minute_exclusion_tree", "if", "itree", ".", "overlaps", "(", "start_idx", ",", "end_idx", ")", ":", "ranges", "=", "[", "]", "interva...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarReader.get_value
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'...
zipline/data/minute_bars.py
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): """ 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 ...
[ "Retrieve", "the", "pricing", "info", "for", "the", "given", "sid", "dt", "and", "field", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L1098-L1149
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarReader._find_position_of_minute
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...
zipline/data/minute_bars.py
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): """ 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-...
[ "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"...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L1203-L1228
[ "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", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BcolzMinuteBarReader.load_raw_arrays
Parameters ---------- fields : list of str 'open', 'high', 'low', 'close', or 'volume' start_dt: Timestamp Beginning of the window range. end_dt: Timestamp End of the window range. sids : list of int The asset identifiers in the window....
zipline/data/minute_bars.py
def load_raw_arrays(self, fields, start_dt, end_dt, sids): """ Parameters ---------- fields : list of str 'open', 'high', 'low', 'close', or 'volume' start_dt: Timestamp Beginning of the window range. end_dt: Timestamp End of the window ra...
def load_raw_arrays(self, fields, start_dt, end_dt, sids): """ Parameters ---------- fields : list of str 'open', 'high', 'low', 'close', or 'volume' start_dt: Timestamp Beginning of the window range. end_dt: Timestamp End of the window ra...
[ "Parameters", "----------", "fields", ":", "list", "of", "str", "open", "high", "low", "close", "or", "volume", "start_dt", ":", "Timestamp", "Beginning", "of", "the", "window", "range", ".", "end_dt", ":", "Timestamp", "End", "of", "the", "window", "range",...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L1230-L1291
[ "def", "load_raw_arrays", "(", "self", ",", "fields", ",", "start_dt", ",", "end_dt", ",", "sids", ")", ":", "start_idx", "=", "self", ".", "_find_position_of_minute", "(", "start_dt", ")", "end_idx", "=", "self", ".", "_find_position_of_minute", "(", "end_dt"...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
H5MinuteBarUpdateWriter.write
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.
zipline/data/minute_bars.py
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): """ 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 ...
[ "Write", "the", "frames", "to", "the", "target", "HDF5", "file", "using", "the", "format", "used", "by", "pd", ".", "Panel", ".", "to_hdf" ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/minute_bars.py#L1346-L1363
[ "def", "write", "(", "self", ",", "frames", ")", ":", "with", "HDFStore", "(", "self", ".", "_path", ",", "'w'", ",", "complevel", "=", "self", ".", "_complevel", ",", "complib", "=", "self", ".", "_complib", ")", "as", "store", ":", "panel", "=", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
next_event_indexer
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[...
zipline/pipeline/loaders/utils.py
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): """ Construct an index array that, when applied to an array of values, produces a 2D a...
[ "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", ...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L25-L79
[ "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", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
previous_event_indexer
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....
zipline/pipeline/loaders/utils.py
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): """ Construct an index array that, when applied to an array of values, produces a 2D array con...
[ "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"...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L82-L138
[ "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"...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
last_in_date_group
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 ...
zipline/pipeline/loaders/utils.py
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): """ Determine the last piece of information known on each date in the date index...
[ "Determine", "the", "last", "piece", "of", "information", "known", "on", "each", "date", "in", "the", "date" ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L141-L213
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
ffill_across_cols
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 ...
zipline/pipeline/loaders/utils.py
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): """ 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...
[ "Forward", "fill", "values", "in", "a", "DataFrame", "with", "special", "logic", "to", "handle", "cases", "that", "pd", ".", "DataFrame", ".", "ffill", "cannot", "and", "cast", "columns", "to", "appropriate", "types", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L216-L264
[ "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", "...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
shift_dates
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...
zipline/pipeline/loaders/utils.py
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): """ 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...
[ "Shift", "dates", "of", "a", "pipeline", "query", "back", "by", "shift", "days", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/utils.py#L267-L330
[ "def", "shift_dates", "(", "dates", ",", "start_date", ",", "end_date", ",", "shift", ")", ":", "try", ":", "start", "=", "dates", ".", "get_loc", "(", "start_date", ")", "except", "KeyError", ":", "if", "start_date", "<", "dates", "[", "0", "]", ":", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
format_docstring
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 ...
zipline/utils/sharedoc.py
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): """ 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...
[ "Template", "formatters", "into", "docstring", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/sharedoc.py#L35-L82
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
templated_docstring
Decorator allowing the use of templated docstrings. Examples -------- >>> @templated_docstring(foo='bar') ... def my_func(self, foo): ... '''{foo}''' ... >>> my_func.__doc__ 'bar'
zipline/utils/sharedoc.py
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): """ 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...
[ "Decorator", "allowing", "the", "use", "of", "templated", "docstrings", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/sharedoc.py#L85-L101
[ "def", "templated_docstring", "(", "*", "*", "docs", ")", ":", "def", "decorator", "(", "f", ")", ":", "f", ".", "__doc__", "=", "format_docstring", "(", "f", ".", "__name__", ",", "f", ".", "__doc__", ",", "docs", ")", "return", "f", "return", "deco...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
Pipeline.add
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...
zipline/pipeline/pipeline.py
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): """ 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...
[ "Add", "a", "column", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L80-L112
[ "def", "add", "(", "self", ",", "term", ",", "name", ",", "overwrite", "=", "False", ")", ":", "self", ".", "validate_column", "(", "name", ",", "term", ")", "columns", "=", "self", ".", "columns", "if", "name", "in", "columns", ":", "if", "overwrite...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
Pipeline.set_screen
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.
zipline/pipeline/pipeline.py
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): """ 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...
[ "Set", "a", "screen", "on", "this", "Pipeline", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L137-L158
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
Pipeline.to_execution_plan
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...
zipline/pipeline/pipeline.py
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): """ Compile into an ExecutionPlan. Parameters ---------- domain : zipline.pipeline.domain.Domain ...
[ "Compile", "into", "an", "ExecutionPlan", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L160-L199
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
Pipeline._prepare_graph_terms
Helper for to_graph and to_execution_plan.
zipline/pipeline/pipeline.py
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): """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
[ "Helper", "for", "to_graph", "and", "to_execution_plan", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L217-L224
[ "def", "_prepare_graph_terms", "(", "self", ",", "default_screen", ")", ":", "columns", "=", "self", ".", "columns", ".", "copy", "(", ")", "screen", "=", "self", ".", "screen", "if", "screen", "is", "None", ":", "screen", "=", "default_screen", "columns",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
Pipeline.show_graph
Render this Pipeline as a DAG. Parameters ---------- format : {'svg', 'png', 'jpeg'} Image format to render with. Default is 'svg'.
zipline/pipeline/pipeline.py
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'): """ 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': ...
[ "Render", "this", "Pipeline", "as", "a", "DAG", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L227-L246
[ "def", "show_graph", "(", "self", ",", "format", "=", "'svg'", ")", ":", "g", "=", "self", ".", "to_simple_graph", "(", "AssetExists", "(", ")", ")", "if", "format", "==", "'svg'", ":", "return", "g", ".", "svg", "elif", "format", "==", "'png'", ":",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
Pipeline._output_terms
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.
zipline/pipeline/pipeline.py
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): """ 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...
[ "A", "list", "of", "terms", "that", "are", "outputs", "of", "this", "pipeline", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L255-L266
[ "def", "_output_terms", "(", "self", ")", ":", "terms", "=", "list", "(", "six", ".", "itervalues", "(", "self", ".", "_columns", ")", ")", "screen", "=", "self", ".", "screen", "if", "screen", "is", "not", "None", ":", "terms", ".", "append", "(", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
Pipeline.domain
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 ...
zipline/pipeline/pipeline.py
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): """ 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 ----------...
[ "Get", "the", "domain", "for", "this", "pipeline", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/pipeline.py#L269-L314
[ "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",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
_ensure_element
Create a tuple containing all elements of tup, plus elem. Returns the new tuple and the index of elem in the new tuple.
zipline/pipeline/expression.py
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): """ 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)
[ "Create", "a", "tuple", "containing", "all", "elements", "of", "tup", "plus", "elem", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L92-L101
[ "def", "_ensure_element", "(", "tup", ",", "elem", ")", ":", "try", ":", "return", "tup", ",", "tup", ".", "index", "(", "elem", ")", "except", "ValueError", ":", "return", "tuple", "(", "chain", "(", "tup", ",", "(", "elem", ",", ")", ")", ")", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
NumericalExpression._validate
Ensure that our expression string has variables of the form x_0, x_1, ... x_(N - 1), where N is the length of our inputs.
zipline/pipeline/expression.py
def _validate(self): """ Ensure that our expression string has variables of the form x_0, x_1, ... x_(N - 1), where N is the length of our inputs. """ variable_names, _unused = getExprNames(self._expr, {}) expr_indices = [] for name in variable_names: ...
def _validate(self): """ Ensure that our expression string has variables of the form x_0, x_1, ... x_(N - 1), where N is the length of our inputs. """ variable_names, _unused = getExprNames(self._expr, {}) expr_indices = [] for name in variable_names: ...
[ "Ensure", "that", "our", "expression", "string", "has", "variables", "of", "the", "form", "x_0", "x_1", "...", "x_", "(", "N", "-", "1", ")", "where", "N", "is", "the", "length", "of", "our", "inputs", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L213-L236
[ "def", "_validate", "(", "self", ")", ":", "variable_names", ",", "_unused", "=", "getExprNames", "(", "self", ".", "_expr", ",", "{", "}", ")", "expr_indices", "=", "[", "]", "for", "name", "in", "variable_names", ":", "if", "name", "==", "'inf'", ":"...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
NumericalExpression._compute
Compute our stored expression string with numexpr.
zipline/pipeline/expression.py
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): """ 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...
[ "Compute", "our", "stored", "expression", "string", "with", "numexpr", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L238-L253
[ "def", "_compute", "(", "self", ",", "arrays", ",", "dates", ",", "assets", ",", "mask", ")", ":", "out", "=", "full", "(", "mask", ".", "shape", ",", "self", ".", "missing_value", ",", "dtype", "=", "self", ".", "dtype", ")", "# This writes directly i...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
NumericalExpression._rebind_variables
Return self._expr with all variables rebound to the indices implied by new_inputs.
zipline/pipeline/expression.py
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): """ 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, ...
[ "Return", "self", ".", "_expr", "with", "all", "variables", "rebound", "to", "the", "indices", "implied", "by", "new_inputs", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L255-L279
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
NumericalExpression._merge_expressions
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)
zipline/pipeline/expression.py
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): """ 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", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L281-L292
[ "def", "_merge_expressions", "(", "self", ",", "other", ")", ":", "new_inputs", "=", "tuple", "(", "set", "(", "self", ".", "inputs", ")", ".", "union", "(", "other", ".", "inputs", ")", ")", "new_self_expr", "=", "self", ".", "_rebind_variables", "(", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
NumericalExpression.build_binary_op
Compute new expression strings and a new inputs tuple for combining self and other with a binary operator.
zipline/pipeline/expression.py
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): """ 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) ...
[ "Compute", "new", "expression", "strings", "and", "a", "new", "inputs", "tuple", "for", "combining", "self", "and", "other", "with", "a", "binary", "operator", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L294-L311
[ "def", "build_binary_op", "(", "self", ",", "op", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "NumericalExpression", ")", ":", "self_expr", ",", "other_expr", ",", "new_inputs", "=", "self", ".", "_merge_expressions", "(", "other", ")", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
NumericalExpression.graph_repr
Short repr to use when rendering Pipeline graphs.
zipline/pipeline/expression.py
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): """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'), ...
[ "Short", "repr", "to", "use", "when", "rendering", "Pipeline", "graphs", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/expression.py#L327-L338
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
last_modified_time
Get the last modified time of path as a Timestamp.
zipline/utils/paths.py
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): """ Get the last modified time of path as a Timestamp. """ return pd.Timestamp(os.path.getmtime(path), unit='s', tz='UTC')
[ "Get", "the", "last", "modified", "time", "of", "path", "as", "a", "Timestamp", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/paths.py#L78-L82
[ "def", "last_modified_time", "(", "path", ")", ":", "return", "pd", ".", "Timestamp", "(", "os", ".", "path", ".", "getmtime", "(", "path", ")", ",", "unit", "=", "'s'", ",", "tz", "=", "'UTC'", ")" ]
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
zipline_root
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...
zipline/utils/paths.py
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): """ 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 -...
[ "Get", "the", "root", "directory", "for", "all", "zipline", "-", "managed", "files", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/paths.py#L107-L131
[ "def", "zipline_root", "(", "environ", "=", "None", ")", ":", "if", "environ", "is", "None", ":", "environ", "=", "os", ".", "environ", "root", "=", "environ", ".", "get", "(", "'ZIPLINE_ROOT'", ",", "None", ")", "if", "root", "is", "None", ":", "roo...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
DataFrameLoader.format_adjustments
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...
zipline/pipeline/loaders/frame.py
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): """ 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. ...
[ "Build", "a", "dict", "of", "Adjustment", "objects", "in", "the", "format", "expected", "by", "AdjustedArray", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/frame.py#L83-L147
[ "def", "format_adjustments", "(", "self", ",", "dates", ",", "assets", ")", ":", "make_adjustment", "=", "partial", "(", "make_adjustment_from_labels", ",", "dates", ",", "assets", ")", "min_date", ",", "max_date", "=", "dates", "[", "[", "0", ",", "-", "1...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
DataFrameLoader.load_adjusted_array
Load data from our stored baseline.
zipline/pipeline/loaders/frame.py
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): """ Load data from our stored baseline. """ if len(columns) != 1: raise ValueError( "Can't load multiple columns with DataFrameLoader" ) column = columns[0] self._v...
[ "Load", "data", "from", "our", "stored", "baseline", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/frame.py#L149-L181
[ "def", "load_adjusted_array", "(", "self", ",", "domain", ",", "columns", ",", "dates", ",", "sids", ",", "mask", ")", ":", "if", "len", "(", "columns", ")", "!=", "1", ":", "raise", "ValueError", "(", "\"Can't load multiple columns with DataFrameLoader\"", ")...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
DataFrameLoader._validate_input_column
Make sure a passed column is our column.
zipline/pipeline/loaders/frame.py
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): """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)
[ "Make", "sure", "a", "passed", "column", "is", "our", "column", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/frame.py#L183-L187
[ "def", "_validate_input_column", "(", "self", ",", "column", ")", ":", "if", "column", "!=", "self", ".", "column", "and", "column", ".", "unspecialize", "(", ")", "!=", "self", ".", "column", ":", "raise", "ValueError", "(", "\"Can't load unknown column %s\""...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
load_from_directory
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...
zipline/utils/security_list.py
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): """ 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...
[ "To", "resolve", "the", "symbol", "in", "the", "LEVERAGED_ETF", "list", "the", "date", "on", "which", "the", "symbol", "was", "in", "effect", "is", "needed", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/security_list.py#L123-L159
[ "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", "=", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
_weak_lru_cache
Users should only access the lru_cache through its public API: cache_info, cache_clear The internals of the lru_cache are encapsulated for thread safety and to allow the implementation to change.
zipline/utils/memoize.py
def _weak_lru_cache(maxsize=100): """ Users should only access the lru_cache through its public API: cache_info, cache_clear The internals of the lru_cache are encapsulated for thread safety and to allow the implementation to change. """ def decorating_function( user_function, tu...
def _weak_lru_cache(maxsize=100): """ Users should only access the lru_cache through its public API: cache_info, cache_clear The internals of the lru_cache are encapsulated for thread safety and to allow the implementation to change. """ def decorating_function( user_function, tu...
[ "Users", "should", "only", "access", "the", "lru_cache", "through", "its", "public", "API", ":", "cache_info", "cache_clear", "The", "internals", "of", "the", "lru_cache", "are", "encapsulated", "for", "thread", "safety", "and", "to", "allow", "the", "implementa...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/memoize.py#L44-L120
[ "def", "_weak_lru_cache", "(", "maxsize", "=", "100", ")", ":", "def", "decorating_function", "(", "user_function", ",", "tuple", "=", "tuple", ",", "sorted", "=", "sorted", ",", "len", "=", "len", ",", "KeyError", "=", "KeyError", ")", ":", "hits", ",",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
weak_lru_cache
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...
zipline/utils/memoize.py
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): """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...
[ "Weak", "least", "-", "recently", "-", "used", "cache", "decorator", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/memoize.py#L211-L248
[ "def", "weak_lru_cache", "(", "maxsize", "=", "100", ")", ":", "class", "desc", "(", "lazyval", ")", ":", "def", "__get__", "(", "self", ",", "instance", ",", "owner", ")", ":", "if", "instance", "is", "None", ":", "return", "self", "try", ":", "retu...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
is_final
Checks if `name` is a `final` object in the given `mro`. We need to check the mro because we need to directly go into the __dict__ of the classes. Because `final` objects are descriptor, we need to grab them _BEFORE_ the `__call__` is invoked.
zipline/utils/final.py
def is_final(name, mro): """ Checks if `name` is a `final` object in the given `mro`. We need to check the mro because we need to directly go into the __dict__ of the classes. Because `final` objects are descriptor, we need to grab them _BEFORE_ the `__call__` is invoked. """ return any(isin...
def is_final(name, mro): """ Checks if `name` is a `final` object in the given `mro`. We need to check the mro because we need to directly go into the __dict__ of the classes. Because `final` objects are descriptor, we need to grab them _BEFORE_ the `__call__` is invoked. """ return any(isin...
[ "Checks", "if", "name", "is", "a", "final", "object", "in", "the", "given", "mro", ".", "We", "need", "to", "check", "the", "mro", "because", "we", "need", "to", "directly", "go", "into", "the", "__dict__", "of", "the", "classes", ".", "Because", "fina...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/final.py#L20-L28
[ "def", "is_final", "(", "name", ",", "mro", ")", ":", "return", "any", "(", "isinstance", "(", "getattr", "(", "c", ",", "'__dict__'", ",", "{", "}", ")", ".", "get", "(", "name", ")", ",", "final", ")", "for", "c", "in", "bases_mro", "(", "mro",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
Column.bind
Bind a `Column` object to its name.
zipline/pipeline/data/dataset.py
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): """ 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, )
[ "Bind", "a", "Column", "object", "to", "its", "name", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L49-L59
[ "def", "bind", "(", "self", ",", "name", ")", ":", "return", "_BoundColumnDescr", "(", "dtype", "=", "self", ".", "dtype", ",", "missing_value", "=", "self", ".", "missing_value", ",", "name", "=", "name", ",", "doc", "=", "self", ".", "doc", ",", "m...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
BoundColumn.specialize
Specialize ``self`` to a concrete domain.
zipline/pipeline/data/dataset.py
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): """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), ...
[ "Specialize", "self", "to", "a", "concrete", "domain", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L177-L190
[ "def", "specialize", "(", "self", ",", "domain", ")", ":", "if", "domain", "==", "self", ".", "domain", ":", "return", "self", "return", "type", "(", "self", ")", "(", "dtype", "=", "self", ".", "dtype", ",", "missing_value", "=", "self", ".", "missi...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
DataSet.get_column
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 ...
zipline/pipeline/data/dataset.py
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): """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 ------ ...
[ "Look", "up", "a", "column", "by", "name", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L502-L540
[ "def", "get_column", "(", "cls", ",", "name", ")", ":", "clsdict", "=", "vars", "(", "cls", ")", "try", ":", "maybe_column", "=", "clsdict", "[", "name", "]", "if", "not", "isinstance", "(", "maybe_column", ",", "_BoundColumnDescr", ")", ":", "raise", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
DataSetFamily._make_dataset
Construct a new dataset given the coordinates.
zipline/pipeline/data/dataset.py
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): """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()), ) ...
[ "Construct", "a", "new", "dataset", "given", "the", "coordinates", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L813-L823
[ "def", "_make_dataset", "(", "cls", ",", "coords", ")", ":", "class", "Slice", "(", "cls", ".", "_SliceType", ")", ":", "extra_coords", "=", "coords", "Slice", ".", "__name__", "=", "'%s.slice(%s)'", "%", "(", "cls", ".", "__name__", ",", "', '", ".", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
DataSetFamily.slice
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...
zipline/pipeline/data/dataset.py
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): """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...
[ "Take", "a", "slice", "of", "a", "DataSetFamily", "to", "produce", "a", "dataset", "indexed", "by", "asset", "and", "date", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/data/dataset.py#L826-L854
[ "def", "slice", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "coords", ",", "hash_key", "=", "cls", ".", "_canonical_key", "(", "args", ",", "kwargs", ")", "try", ":", "return", "cls", ".", "_slice_cache", "[", "hash_key", "]", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
expected_bar_value
Check that the raw value for an asset/date/column triple is as expected. Used by tests to verify data written by a writer.
zipline/pipeline/loaders/synthetic.py
def expected_bar_value(asset_id, date, colname): """ Check that the raw value for an asset/date/column triple is as expected. Used by tests to verify data written by a writer. """ from_asset = asset_id * 100000 from_colname = OHLCV.index(colname) * 1000 from_date = (date - PSEUDO_EPOCH)...
def expected_bar_value(asset_id, date, colname): """ Check that the raw value for an asset/date/column triple is as expected. Used by tests to verify data written by a writer. """ from_asset = asset_id * 100000 from_colname = OHLCV.index(colname) * 1000 from_date = (date - PSEUDO_EPOCH)...
[ "Check", "that", "the", "raw", "value", "for", "an", "asset", "/", "date", "/", "column", "triple", "is", "as", "expected", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L319-L329
[ "def", "expected_bar_value", "(", "asset_id", ",", "date", ",", "colname", ")", ":", "from_asset", "=", "asset_id", "*", "100000", "from_colname", "=", "OHLCV", ".", "index", "(", "colname", ")", "*", "1000", "from_date", "=", "(", "date", "-", "PSEUDO_EPO...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
expected_bar_values_2d
Return an 2D array containing cls.expected_value(asset_id, date, colname) for each date/asset pair in the inputs. Missing locs are filled with 0 for volume and NaN for price columns: - Values before/after an asset's lifetime. - Values for asset_ids not contained in asset_info. - Locs d...
zipline/pipeline/loaders/synthetic.py
def expected_bar_values_2d(dates, assets, asset_info, colname, holes=None): """ Return an 2D array containing cls.expected_value(asset_id, date, colname) for each date/asset pair in the inputs. M...
def expected_bar_values_2d(dates, assets, asset_info, colname, holes=None): """ Return an 2D array containing cls.expected_value(asset_id, date, colname) for each date/asset pair in the inputs. M...
[ "Return", "an", "2D", "array", "containing", "cls", ".", "expected_value", "(", "asset_id", "date", "colname", ")", "for", "each", "date", "/", "asset", "pair", "in", "the", "inputs", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L344-L392
[ "def", "expected_bar_values_2d", "(", "dates", ",", "assets", ",", "asset_info", ",", "colname", ",", "holes", "=", "None", ")", ":", "if", "colname", "==", "'volume'", ":", "dtype", "=", "uint32", "missing", "=", "0", "else", ":", "dtype", "=", "float64...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
PrecomputedLoader.load_adjusted_array
Load by delegating to sub-loaders.
zipline/pipeline/loaders/synthetic.py
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): """ Load by delegating to sub-loaders. """ out = {} for col in columns: try: loader = self._loaders.get(col) if loader is None: loader = self._loader...
[ "Load", "by", "delegating", "to", "sub", "-", "loaders", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L82-L97
[ "def", "load_adjusted_array", "(", "self", ",", "domain", ",", "columns", ",", "dates", ",", "sids", ",", "mask", ")", ":", "out", "=", "{", "}", "for", "col", "in", "columns", ":", "try", ":", "loader", "=", "self", ".", "_loaders", ".", "get", "(...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
SeededRandomLoader.values
Make a random array of shape (len(dates), len(sids)) with ``dtype``.
zipline/pipeline/loaders/synthetic.py
def values(self, dtype, dates, sids): """ Make a random array of shape (len(dates), len(sids)) with ``dtype``. """ shape = (len(dates), len(sids)) return { datetime64ns_dtype: self._datetime_values, float64_dtype: self._float_values, int64_dtyp...
def values(self, dtype, dates, sids): """ Make a random array of shape (len(dates), len(sids)) with ``dtype``. """ shape = (len(dates), len(sids)) return { datetime64ns_dtype: self._datetime_values, float64_dtype: self._float_values, int64_dtyp...
[ "Make", "a", "random", "array", "of", "shape", "(", "len", "(", "dates", ")", "len", "(", "sids", "))", "with", "dtype", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L147-L158
[ "def", "values", "(", "self", ",", "dtype", ",", "dates", ",", "sids", ")", ":", "shape", "=", "(", "len", "(", "dates", ")", ",", "len", "(", "sids", ")", ")", "return", "{", "datetime64ns_dtype", ":", "self", ".", "_datetime_values", ",", "float64_...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
SeededRandomLoader._float_values
Return uniformly-distributed floats between -0.0 and 100.0.
zipline/pipeline/loaders/synthetic.py
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 uniformly-distributed floats between -0.0 and 100.0. """ return self.state.uniform(low=0.0, high=100.0, size=shape)
[ "Return", "uniformly", "-", "distributed", "floats", "between", "-", "0", ".", "0", "and", "100", ".", "0", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L170-L174
[ "def", "_float_values", "(", "self", ",", "shape", ")", ":", "return", "self", ".", "state", ".", "uniform", "(", "low", "=", "0.0", ",", "high", "=", "100.0", ",", "size", "=", "shape", ")" ]
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
SeededRandomLoader._int_values
Return uniformly-distributed integers between 0 and 100.
zipline/pipeline/loaders/synthetic.py
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 uniformly-distributed integers between 0 and 100. """ return (self.state.randint(low=0, high=100, size=shape) .astype('int64'))
[ "Return", "uniformly", "-", "distributed", "integers", "between", "0", "and", "100", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L176-L181
[ "def", "_int_values", "(", "self", ",", "shape", ")", ":", "return", "(", "self", ".", "state", ".", "randint", "(", "low", "=", "0", ",", "high", "=", "100", ",", "size", "=", "shape", ")", ".", "astype", "(", "'int64'", ")", ")" ]
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
SeededRandomLoader._datetime_values
Return uniformly-distributed dates in 2014.
zipline/pipeline/loaders/synthetic.py
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): """ 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 +...
[ "Return", "uniformly", "-", "distributed", "dates", "in", "2014", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/synthetic.py#L183-L193
[ "def", "_datetime_values", "(", "self", ",", "shape", ")", ":", "start", "=", "Timestamp", "(", "'2014'", ",", "tz", "=", "'UTC'", ")", ".", "asm8", "offsets", "=", "self", ".", "state", ".", "randint", "(", "low", "=", "0", ",", "high", "=", "364"...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
quantiles
Compute rowwise array quantiles on an input.
zipline/lib/quantiles.py
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): """ Compute rowwise array quantiles on an input. """ return apply_along_axis( qcut, 1, data, q=nbins_or_partition_bounds, labels=False, )
[ "Compute", "rowwise", "array", "quantiles", "on", "an", "input", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/quantiles.py#L8-L17
[ "def", "quantiles", "(", "data", ",", "nbins_or_partition_bounds", ")", ":", "return", "apply_along_axis", "(", "qcut", ",", "1", ",", "data", ",", "q", "=", "nbins_or_partition_bounds", ",", "labels", "=", "False", ",", ")" ]
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
MetricsTracker.handle_minute_close
Handles the close of the given minute in minute emission. Parameters ---------- dt : Timestamp The minute that is ending Returns ------- A minute perf packet.
zipline/finance/metrics/tracker.py
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): """ 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...
[ "Handles", "the", "close", "of", "the", "given", "minute", "in", "minute", "emission", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/tracker.py#L204-L243
[ "def", "handle_minute_close", "(", "self", ",", "dt", ",", "data_portal", ")", ":", "self", ".", "sync_last_sale_prices", "(", "dt", ",", "data_portal", ")", "packet", "=", "{", "'period_start'", ":", "self", ".", "_first_session", ",", "'period_end'", ":", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
MetricsTracker.handle_market_open
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.
zipline/finance/metrics/tracker.py
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): """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", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/tracker.py#L245-L275
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
MetricsTracker.handle_market_close
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.
zipline/finance/metrics/tracker.py
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): """Handles the close of the given day. Parameters ---------- dt : Timestamp The most recently completed simulation datetime. data_portal : DataPortal The current data portal. Returns -------...
[ "Handles", "the", "close", "of", "the", "given", "day", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/tracker.py#L277-L328
[ "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", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
MetricsTracker.handle_simulation_end
When the simulation is complete, run the full period risk report and send it out on the results socket.
zipline/finance/metrics/tracker.py
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): """ 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: {}', ...
[ "When", "the", "simulation", "is", "complete", "run", "the", "full", "period", "risk", "report", "and", "send", "it", "out", "on", "the", "results", "socket", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/tracker.py#L330-L353
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
create_args
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...
zipline/extensions.py
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): """ 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...
[ "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", ...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L6-L28
[ "def", "create_args", "(", "args", ",", "root", ")", ":", "extension_args", "=", "{", "}", "for", "arg", "in", "args", ":", "parse_extension_arg", "(", "arg", ",", "extension_args", ")", "for", "name", "in", "sorted", "(", "extension_args", ",", "key", "...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
parse_extension_arg
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...
zipline/extensions.py
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): """ 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 ...
[ "Converts", "argument", "strings", "in", "key", "=", "value", "or", "key", ".", "namespace", "=", "value", "form", "to", "dictionary", "entries" ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L31-L53
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
update_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...
zipline/extensions.py
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): """ 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...
[ "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...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L56-L83
[ "def", "update_namespace", "(", "namespace", ",", "path", ",", "name", ")", ":", "if", "len", "(", "path", ")", "==", "1", ":", "setattr", "(", "namespace", ",", "path", "[", "0", "]", ",", "name", ")", "else", ":", "if", "hasattr", "(", "namespace...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
create_registry
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...
zipline/extensions.py
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): """ 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...
[ "Create", "a", "new", "registry", "for", "an", "extensible", "interface", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L244-L263
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
Registry.load
Construct an object from a registered factory. Parameters ---------- name : str Name with which the factory was registered.
zipline/extensions.py
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): """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( ...
[ "Construct", "an", "object", "from", "a", "registered", "factory", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L110-L124
[ "def", "load", "(", "self", ",", "name", ")", ":", "try", ":", "return", "self", ".", "_factories", "[", "name", "]", "(", ")", "except", "KeyError", ":", "raise", "ValueError", "(", "\"no %s factory registered under name %r, options are: %r\"", "%", "(", "sel...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
calculate_per_unit_commission
If there is a minimum commission: If the order hasn't had a commission paid yet, pay the minimum commission. If the order has paid a commission, start paying additional commission once the minimum commission has been reached. If there is no minimum commission: Pay commissio...
zipline/finance/commission.py
def calculate_per_unit_commission(order, transaction, cost_per_unit, initial_commission, min_trade_cost): """ If there is a minimum commission: If the order hasn't had ...
def calculate_per_unit_commission(order, transaction, cost_per_unit, initial_commission, min_trade_cost): """ If there is a minimum commission: If the order hasn't had ...
[ "If", "there", "is", "a", "minimum", "commission", ":", "If", "the", "order", "hasn", "t", "had", "a", "commission", "paid", "yet", "pay", "the", "minimum", "commission", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/commission.py#L102-L138
[ "def", "calculate_per_unit_commission", "(", "order", ",", "transaction", ",", "cost_per_unit", ",", "initial_commission", ",", "min_trade_cost", ")", ":", "additional_commission", "=", "abs", "(", "transaction", ".", "amount", "*", "cost_per_unit", ")", "if", "orde...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
PerDollar.calculate
Pay commission based on dollar value of shares.
zipline/finance/commission.py
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): """ Pay commission based on dollar value of shares. """ cost_per_share = transaction.price * self.cost_per_dollar return abs(transaction.amount) * cost_per_share
[ "Pay", "commission", "based", "on", "dollar", "value", "of", "shares", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/commission.py#L364-L369
[ "def", "calculate", "(", "self", ",", "order", ",", "transaction", ")", ":", "cost_per_share", "=", "transaction", ".", "price", "*", "self", ".", "cost_per_dollar", "return", "abs", "(", "transaction", ".", "amount", ")", "*", "cost_per_share" ]
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
_ClassicRiskMetrics.risk_metric_period
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...
zipline/finance/metrics/metric.py
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): """ Creates a dictionary representing the state of th...
[ "Creates", "a", "dictionary", "representing", "the", "state", "of", "the", "risk", "report", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/metric.py#L559-L666
[ "def", "risk_metric_period", "(", "cls", ",", "start_session", ",", "end_session", ",", "algorithm_returns", ",", "benchmark_returns", ",", "algorithm_leverages", ")", ":", "algorithm_returns", "=", "algorithm_returns", "[", "(", "algorithm_returns", ".", "index", ">=...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
RollFinder._get_active_contract_at_offset
For the given root symbol, find the contract that is considered active on a specific date at a specific offset.
zipline/assets/roll_finder.py
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): """ 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...
[ "For", "the", "given", "root", "symbol", "find", "the", "contract", "that", "is", "considered", "active", "on", "a", "specific", "date", "at", "a", "specific", "offset", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/roll_finder.py#L33-L45
[ "def", "_get_active_contract_at_offset", "(", "self", ",", "root_symbol", ",", "dt", ",", "offset", ")", ":", "oc", "=", "self", ".", "asset_finder", ".", "get_ordered_contracts", "(", "root_symbol", ")", "session", "=", "self", ".", "trading_calendar", ".", "...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
RollFinder.get_contract_center
Parameters ---------- root_symbol : str The root symbol for the contract chain. dt : Timestamp The datetime for which to retrieve the current contract. offset : int The offset from the primary contract. 0 is the primary, 1 is the secondary,...
zipline/assets/roll_finder.py
def get_contract_center(self, root_symbol, dt, offset): """ Parameters ---------- root_symbol : str The root symbol for the contract chain. dt : Timestamp The datetime for which to retrieve the current contract. offset : int The offset ...
def get_contract_center(self, root_symbol, dt, offset): """ Parameters ---------- root_symbol : str The root symbol for the contract chain. dt : Timestamp The datetime for which to retrieve the current contract. offset : int The offset ...
[ "Parameters", "----------", "root_symbol", ":", "str", "The", "root", "symbol", "for", "the", "contract", "chain", ".", "dt", ":", "Timestamp", "The", "datetime", "for", "which", "to", "retrieve", "the", "current", "contract", ".", "offset", ":", "int", "The...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/roll_finder.py#L47-L64
[ "def", "get_contract_center", "(", "self", ",", "root_symbol", ",", "dt", ",", "offset", ")", ":", "return", "self", ".", "_get_active_contract_at_offset", "(", "root_symbol", ",", "dt", ",", "offset", ")" ]
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
RollFinder.get_rolls
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...
zipline/assets/roll_finder.py
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): """ 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 ...
[ "Get", "the", "rolls", "i", ".", "e", ".", "the", "session", "at", "which", "to", "hop", "from", "contract", "to", "contract", "in", "the", "chain", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/roll_finder.py#L66-L137
[ "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", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
VolumeRollFinder._active_contract
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' | ...
zipline/assets/roll_finder.py
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): 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: | +++++ _____...
[ "r", "Return", "the", "active", "contract", "based", "on", "the", "previous", "trading", "day", "s", "volume", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/roll_finder.py#L170-L241
[ "def", "_active_contract", "(", "self", ",", "oc", ",", "front", ",", "back", ",", "dt", ")", ":", "front_contract", "=", "oc", ".", "sid_to_contract", "[", "front", "]", ".", "contract", "back_contract", "=", "oc", ".", "sid_to_contract", "[", "back", "...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
VolumeRollFinder.get_contract_center
Parameters ---------- root_symbol : str The root symbol for the contract chain. dt : Timestamp The datetime for which to retrieve the current contract. offset : int The offset from the primary contract. 0 is the primary, 1 is the secondary,...
zipline/assets/roll_finder.py
def get_contract_center(self, root_symbol, dt, offset): """ Parameters ---------- root_symbol : str The root symbol for the contract chain. dt : Timestamp The datetime for which to retrieve the current contract. offset : int The offset ...
def get_contract_center(self, root_symbol, dt, offset): """ Parameters ---------- root_symbol : str The root symbol for the contract chain. dt : Timestamp The datetime for which to retrieve the current contract. offset : int The offset ...
[ "Parameters", "----------", "root_symbol", ":", "str", "The", "root", "symbol", "for", "the", "contract", "chain", ".", "dt", ":", "Timestamp", "The", "datetime", "for", "which", "to", "retrieve", "the", "current", "contract", ".", "offset", ":", "int", "The...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/roll_finder.py#L243-L276
[ "def", "get_contract_center", "(", "self", ",", "root_symbol", ",", "dt", ",", "offset", ")", ":", "# When determining the center contract on a specific day using volume", "# rolls, simply picking the contract with the highest volume could", "# cause flip-flopping between active contract...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
_normalize_array
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...
zipline/lib/adjusted_array.py
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): """ 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...
[ "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...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L84-L136
[ "def", "_normalize_array", "(", "data", ",", "missing_value", ")", ":", "if", "isinstance", "(", "data", ",", "LabelArray", ")", ":", "return", "data", ",", "{", "}", "data_dtype", "=", "data", ".", "dtype", "if", "data_dtype", "in", "BOOL_DTYPES", ":", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
_merge_simple
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...
zipline/lib/adjusted_array.py
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): """ 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....
[ "Merge", "lists", "of", "new", "and", "existing", "adjustments", "for", "a", "given", "index", "by", "appending", "or", "prepending", "new", "adjustments", "to", "existing", "adjustments", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L139-L170
[ "def", "_merge_simple", "(", "adjustment_lists", ",", "front_idx", ",", "back_idx", ")", ":", "if", "len", "(", "adjustment_lists", ")", "==", "1", ":", "return", "list", "(", "adjustment_lists", "[", "0", "]", ")", "else", ":", "return", "adjustment_lists",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
ensure_ndarray
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 --...
zipline/lib/adjusted_array.py
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): """ 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...
[ "Return", "the", "input", "as", "a", "numpy", "ndarray", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L345-L368
[ "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", ")", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
_check_window_params
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 ...
zipline/lib/adjusted_array.py
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): """ 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 ------- ...
[ "Check", "that", "a", "window", "of", "length", "window_length", "is", "well", "-", "defined", "on", "data", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L371-L400
[ "def", "_check_window_params", "(", "data", ",", "window_length", ")", ":", "if", "window_length", "<", "1", ":", "raise", "WindowLengthNotPositive", "(", "window_length", "=", "window_length", ")", "if", "window_length", ">", "data", ".", "shape", "[", "0", "...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
AdjustedArray.update_adjustments
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...
zipline/lib/adjusted_array.py
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): """ 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...
[ "Merge", "adjustments", "with", "existing", "adjustments", "handling", "index", "collisions", "according", "to", "method", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L209-L236
[ "def", "update_adjustments", "(", "self", ",", "adjustments", ",", "method", ")", ":", "try", ":", "merge_func", "=", "_merge_methods", "[", "method", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "\"Invalid merge method %s\\n\"", "\"Valid methods are:...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
AdjustedArray._iterator_type
The iterator produced when `traverse` is called on this Array.
zipline/lib/adjusted_array.py
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): """ The iterator produced when `traverse` is called on this Array. """ if isinstance(self._data, LabelArray): return LabelWindow return CONCRETE_WINDOW_TYPES[self._data.dtype]
[ "The", "iterator", "produced", "when", "traverse", "is", "called", "on", "this", "Array", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L253-L259
[ "def", "_iterator_type", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_data", ",", "LabelArray", ")", ":", "return", "LabelWindow", "return", "CONCRETE_WINDOW_TYPES", "[", "self", ".", "_data", ".", "dtype", "]" ]
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
AdjustedArray.traverse
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...
zipline/lib/adjusted_array.py
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): """ Produce an iterator rolling windows rows over our data. Each emitted window will have `window_length` rows. Parameters ---------- window_length : int...
[ "Produce", "an", "iterator", "rolling", "windows", "rows", "over", "our", "data", ".", "Each", "emitted", "window", "will", "have", "window_length", "rows", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L261-L289
[ "def", "traverse", "(", "self", ",", "window_length", ",", "offset", "=", "0", ",", "perspective_offset", "=", "0", ")", ":", "data", "=", "self", ".", "_data", ".", "copy", "(", ")", "_check_window_params", "(", "data", ",", "window_length", ")", "retur...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
AdjustedArray.inspect
Return a string representation of the data stored in this array.
zipline/lib/adjusted_array.py
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 a string representation of the data stored in this array. """ return dedent( """\ Adjusted Array ({dtype}): Data: {data!r} Adjustments: {adjustments} """ ).format( ...
[ "Return", "a", "string", "representation", "of", "the", "data", "stored", "in", "this", "array", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L291-L309
[ "def", "inspect", "(", "self", ")", ":", "return", "dedent", "(", "\"\"\"\\\n Adjusted Array ({dtype}):\n\n Data:\n {data!r}\n\n Adjustments:\n {adjustments}\n \"\"\"", ")", ".", "format", "(", "dtype", "=", "self", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
AdjustedArray.update_labels
Map a function over baseline and adjustment values in place. Note that the baseline data values must be a LabelArray.
zipline/lib/adjusted_array.py
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): """ 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...
[ "Map", "a", "function", "over", "baseline", "and", "adjustment", "values", "in", "place", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/adjusted_array.py#L311-L328
[ "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.",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
TradingControl.handle_violation
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`.
zipline/finance/controls.py
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): """ 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", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L79-L99
[ "def", "handle_violation", "(", "self", ",", "asset", ",", "amount", ",", "datetime", ",", "metadata", "=", "None", ")", ":", "constraint", "=", "self", ".", "_constraint_msg", "(", "metadata", ")", "if", "self", ".", "on_error", "==", "'fail'", ":", "ra...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
MaxOrderCount.validate
Fail if we've already placed self.max_count orders today.
zipline/finance/controls.py
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): """ Fail if we've already placed self.max_count orders today. """ algo_date = algo_datetime.date() # Reset order c...
[ "Fail", "if", "we", "ve", "already", "placed", "self", ".", "max_count", "orders", "today", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L119-L137
[ "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...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
RestrictedListOrder.validate
Fail if the asset is in the restricted_list.
zipline/finance/controls.py
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): """ Fail if the asset is in the restricted_list. """ if self.restrictions.is_restricted(asset, algo_datetime): ...
[ "Fail", "if", "the", "asset", "is", "in", "the", "restricted_list", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L154-L164
[ "def", "validate", "(", "self", ",", "asset", ",", "amount", ",", "portfolio", ",", "algo_datetime", ",", "algo_current_data", ")", ":", "if", "self", ".", "restrictions", ".", "is_restricted", "(", "asset", ",", "algo_datetime", ")", ":", "self", ".", "ha...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
MaxOrderSize.validate
Fail if the magnitude of the given order exceeds either self.max_shares or self.max_notional.
zipline/finance/controls.py
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): """ Fail if the magnitude of the given order exceeds either self.max_shares or self.max_notional. """ if self.asse...
[ "Fail", "if", "the", "magnitude", "of", "the", "given", "order", "exceeds", "either", "self", ".", "max_shares", "or", "self", ".", "max_notional", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L199-L223
[ "def", "validate", "(", "self", ",", "asset", ",", "amount", ",", "portfolio", ",", "algo_datetime", ",", "algo_current_data", ")", ":", "if", "self", ".", "asset", "is", "not", "None", "and", "self", ".", "asset", "!=", "asset", ":", "return", "if", "...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
MaxPositionSize.validate
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.
zipline/finance/controls.py
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): """ 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...
[ "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", "...
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L257-L287
[ "def", "validate", "(", "self", ",", "asset", ",", "amount", ",", "portfolio", ",", "algo_datetime", ",", "algo_current_data", ")", ":", "if", "self", ".", "asset", "is", "not", "None", "and", "self", ".", "asset", "!=", "asset", ":", "return", "current_...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
LongOnly.validate
Fail if we would hold negative shares of asset after completing this order.
zipline/finance/controls.py
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): """ Fail if we would hold negative shares of asset after completing this order. """ if portfolio.positions[asset].a...
[ "Fail", "if", "we", "would", "hold", "negative", "shares", "of", "asset", "after", "completing", "this", "order", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L298-L309
[ "def", "validate", "(", "self", ",", "asset", ",", "amount", ",", "portfolio", ",", "algo_datetime", ",", "algo_current_data", ")", ":", "if", "portfolio", ".", "positions", "[", "asset", "]", ".", "amount", "+", "amount", "<", "0", ":", "self", ".", "...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
AssetDateBounds.validate
Fail if the algo has passed this Asset's end_date, or before the Asset's start date.
zipline/finance/controls.py
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): """ Fail if the algo has passed this Asset's end_date, or before the Asset's start date. """ # If the order is for ...
[ "Fail", "if", "the", "algo", "has", "passed", "this", "Asset", "s", "end_date", "or", "before", "the", "Asset", "s", "start", "date", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L321-L354
[ "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", "=",...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
MaxLeverage.validate
Fail if the leverage is greater than the allowed leverage.
zipline/finance/controls.py
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): """ Fail if the leverage is greater than the allowed leverage. """ if _account.leverage > self.max_leverage: self.fail()
[ "Fail", "if", "the", "leverage", "is", "greater", "than", "the", "allowed", "leverage", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L424-L433
[ "def", "validate", "(", "self", ",", "_portfolio", ",", "_account", ",", "_algo_datetime", ",", "_algo_current_data", ")", ":", "if", "_account", ".", "leverage", ">", "self", ".", "max_leverage", ":", "self", ".", "fail", "(", ")" ]
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe
train
MinLeverage.validate
Make validation checks if we are after the deadline. Fail if the leverage is less than the min leverage.
zipline/finance/controls.py
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): """ Make validation checks if we are after the deadline. Fail if the leverage is less than the min leverage. """ if (algo_datetime > sel...
[ "Make", "validation", "checks", "if", "we", "are", "after", "the", "deadline", ".", "Fail", "if", "the", "leverage", "is", "less", "than", "the", "min", "leverage", "." ]
quantopian/zipline
python
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/controls.py#L463-L474
[ "def", "validate", "(", "self", ",", "_portfolio", ",", "account", ",", "algo_datetime", ",", "_algo_current_data", ")", ":", "if", "(", "algo_datetime", ">", "self", ".", "deadline", "and", "account", ".", "leverage", "<", "self", ".", "min_leverage", ")", ...
77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe