code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def test_end_on_asset_start(self): """ Test loading with queries that end on the first day of each asset's lifetime. """ columns = ['close', 'volume'] for asset in self.assets: self._check_read_results( columns, self.assets, ...
Test loading with queries that end on the first day of each asset's lifetime.
test_end_on_asset_start
python
quantopian/zipline
tests/data/test_daily_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_daily_bars.py
Apache-2.0
def test_end_on_asset_end(self): """ Test loading with queries that end on the last day of each asset's lifetime. """ columns = [CLOSE, VOLUME] for asset in self.assets: self._check_read_results( columns, self.assets, ...
Test loading with queries that end on the last day of each asset's lifetime.
test_end_on_asset_end
python
quantopian/zipline
tests/data/test_daily_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_daily_bars.py
Apache-2.0
def test_read_known_and_unknown_sids(self): """ Test a query with some known sids mixed in with unknown sids. """ # Construct a list of alternating valid and invalid query sids, # bookended by invalid sids. # # E.g. # INVALID VALID INVALID VALID ... VAL...
Test a query with some known sids mixed in with unknown sids.
test_read_known_and_unknown_sids
python
quantopian/zipline
tests/data/test_daily_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_daily_bars.py
Apache-2.0
def test_unadjusted_get_value(self): """Test get_value() on both a price field (CLOSE) and VOLUME.""" reader = self.daily_bar_reader def make_failure_msg(asset, date, field): return "Unexpected value for sid={}; date={}; field={}.".format( asset, date...
Test get_value() on both a price field (CLOSE) and VOLUME.
test_unadjusted_get_value
python
quantopian/zipline
tests/data/test_daily_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_daily_bars.py
Apache-2.0
def test_unadjusted_get_value_no_data(self): """Test behavior of get_value() around missing data.""" reader = self.daily_bar_reader for asset in self.assets: before_start = self.trading_calendar.previous_session_label( self.asset_start(asset) ) ...
Test behavior of get_value() around missing data.
test_unadjusted_get_value_no_data
python
quantopian/zipline
tests/data/test_daily_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_daily_bars.py
Apache-2.0
def test_write_empty_country(self): """ Test that we can write an empty country to an HDF5 daily bar writer. This is useful functionality for some tests, but it requires a bunch of special cased logic in the writer. """ path = self.tmpdir.getpath('empty.h5') writ...
Test that we can write an empty country to an HDF5 daily bar writer. This is useful functionality for some tests, but it requires a bunch of special cased logic in the writer.
test_write_empty_country
python
quantopian/zipline
tests/data/test_hdf5_daily_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_hdf5_daily_bars.py
Apache-2.0
def test_precision_after_scaling(self): '''For numbers that don't have an exact float representation, assert that scaling the value does not cause a loss in precision. ''' minute = self.market_opens[self.test_calendar_start] sid = 1 data = DataFrame( data={ ...
For numbers that don't have an exact float representation, assert that scaling the value does not cause a loss in precision.
test_precision_after_scaling
python
quantopian/zipline
tests/data/test_minute_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_minute_bars.py
Apache-2.0
def test_append_to_same_day(self): """ Test writing data with the same date as existing data in our file. """ sid = 1 first_minute = self.market_opens[TEST_CALENDAR_START] data = DataFrame( data={ 'open': [10.0], 'high': [20.0]...
Test writing data with the same date as existing data in our file.
test_append_to_same_day
python
quantopian/zipline
tests/data/test_minute_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_minute_bars.py
Apache-2.0
def test_write_multiple_sids(self): """ Test writing multiple sids. Tests both that the data is written to the correct sid, as well as ensuring that the logic for creating the subdirectory path to each sid does not cause issues from attempts to recreate existing paths. (...
Test writing multiple sids. Tests both that the data is written to the correct sid, as well as ensuring that the logic for creating the subdirectory path to each sid does not cause issues from attempts to recreate existing paths. (Calling out this coverage, because an assertion...
test_write_multiple_sids
python
quantopian/zipline
tests/data/test_minute_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_minute_bars.py
Apache-2.0
def test_differing_nans(self): """ Also test nans of differing values/construction. """ sid = 1 last_date = self.writer.last_date_in_output_for_sid(sid) self.assertIs(last_date, NaT) self.writer.pad(sid, TEST_CALENDAR_START) last_date = self.writer.last_...
Also test nans of differing values/construction.
test_differing_nans
python
quantopian/zipline
tests/data/test_minute_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_minute_bars.py
Apache-2.0
def test_unadjusted_minutes_early_close(self): """ Test unadjusted minute window, ensuring that early closes are filtered out. """ day_before_thanksgiving = Timestamp('2015-11-25', tz='UTC') xmas_eve = Timestamp('2015-12-24', tz='UTC') market_day_after_xmas = Time...
Test unadjusted minute window, ensuring that early closes are filtered out.
test_unadjusted_minutes_early_close
python
quantopian/zipline
tests/data/test_minute_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_minute_bars.py
Apache-2.0
def test_set_sid_attrs(self): """Confirm that we can set the attributes of a sid's file correctly. """ sid = 1 start_day = Timestamp('2015-11-27', tz='UTC') end_day = Timestamp('2015-06-02', tz='UTC') attrs = { 'start_day': start_day.value / int(1e9), ...
Confirm that we can set the attributes of a sid's file correctly.
test_set_sid_attrs
python
quantopian/zipline
tests/data/test_minute_bars.py
https://github.com/quantopian/zipline/blob/master/tests/data/test_minute_bars.py
Apache-2.0
def _empty_ingest(self, _wrote_to=[]): """Run the nth empty ingest. Returns ------- wrote_to : str The timestr of the bundle written. """ if not self.bundles: @self.register('bundle', calendar_name='NYSE', ...
Run the nth empty ingest. Returns ------- wrote_to : str The timestr of the bundle written.
_empty_ingest
python
quantopian/zipline
tests/data/bundles/test_core.py
https://github.com/quantopian/zipline/blob/master/tests/data/bundles/test_core.py
Apache-2.0
def minutes_for_days(cal, ordered_days=False): """ 500 randomly selected days. This is used to make sure our test coverage is unbiased towards any rules. We use a random sample because testing on all the trading days took around 180 seconds on my laptop, which is far too much for normal unit tes...
500 randomly selected days. This is used to make sure our test coverage is unbiased towards any rules. We use a random sample because testing on all the trading days took around 180 seconds on my laptop, which is far too much for normal unit testing. We manually set the seed so that this will ...
minutes_for_days
python
quantopian/zipline
tests/events/test_events.py
https://github.com/quantopian/zipline/blob/master/tests/events/test_events.py
Apache-2.0
def test_completeness(self): """ Tests that all rules are being tested. """ if not self.class_: return # This is the base class testing, it is always complete. classes_to_ignore = [TradingDayOfWeekRule, TradingDayOfMonthRule] dem = { k for k, v ...
Tests that all rules are being tested.
test_completeness
python
quantopian/zipline
tests/events/test_events.py
https://github.com/quantopian/zipline/blob/master/tests/events/test_events.py
Apache-2.0
def test_NthTradingDayOfWeek_day_zero(self): """ Test that we don't blow up when trying to call week_start's should_trigger on the first day of a trading environment. """ rule = NthTradingDayOfWeek(0) rule.cal = self.cal first_open = self.cal.open_and_close_for_se...
Test that we don't blow up when trying to call week_start's should_trigger on the first day of a trading environment.
test_NthTradingDayOfWeek_day_zero
python
quantopian/zipline
tests/events/test_events.py
https://github.com/quantopian/zipline/blob/master/tests/events/test_events.py
Apache-2.0
def test_edge_cases_for_TradingDayOfWeek(self): """ Test that we account for midweek holidays. Monday 01/20 is a holiday. Ensure that the trigger date for that week is adjusted appropriately, or thrown out if not enough trading days. Also, test that if we start the simulation on ...
Test that we account for midweek holidays. Monday 01/20 is a holiday. Ensure that the trigger date for that week is adjusted appropriately, or thrown out if not enough trading days. Also, test that if we start the simulation on a day where we miss the trigger for that week, that...
test_edge_cases_for_TradingDayOfWeek
python
quantopian/zipline
tests/events/test_events_nyse.py
https://github.com/quantopian/zipline/blob/master/tests/events/test_events_nyse.py
Apache-2.0
def check_metrics(self, metrics, total_months, start_date): """ confirm that the right number of riskmetrics were calculated for each window length. """ for period, length in zip(PERIODS, [1, 3, 6, 12]): self.assert_range_length( metrics[period], ...
confirm that the right number of riskmetrics were calculated for each window length.
check_metrics
python
quantopian/zipline
tests/finance/test_risk.py
https://github.com/quantopian/zipline/blob/master/tests/finance/test_risk.py
Apache-2.0
def generate_minute_test_data(first_day, last_day, starting_open, starting_volume, multipliers_list, path): """ Utility method to generate fake minute-level CSV d...
Utility method to generate fake minute-level CSV data. :param first_day: first trading day :param last_day: last trading day :param starting_open: first open value, raw value. :param starting_volume: first volume value, raw value. :param multipliers_list: ordered list of pd.Timestamp -> float, ...
generate_minute_test_data
python
quantopian/zipline
tests/history/generate_csvs.py
https://github.com/quantopian/zipline/blob/master/tests/history/generate_csvs.py
Apache-2.0
def portfolio_snapshot(p): """Extract all of the fields from the portfolio as a new dictionary. """ fields = ( 'cash_flow', 'starting_cash', 'portfolio_value', 'pnl', 'returns', 'cash', 'positions', 'positions_value', 'positions_exposur...
Extract all of the fields from the portfolio as a new dictionary.
portfolio_snapshot
python
quantopian/zipline
tests/metrics/test_metrics.py
https://github.com/quantopian/zipline/blob/master/tests/metrics/test_metrics.py
Apache-2.0
def with_defaults(**default_funcs): """ Decorator for providing dynamic default values for a method. Usages: @with_defaults(foo=lambda self: self.x + self.y) def func(self, foo): ... If a value is passed for `foo`, it will be used. Otherwise the function supplied to `with_defaults...
Decorator for providing dynamic default values for a method. Usages: @with_defaults(foo=lambda self: self.x + self.y) def func(self, foo): ... If a value is passed for `foo`, it will be used. Otherwise the function supplied to `with_defaults` will be called with `self` as an argument...
with_defaults
python
quantopian/zipline
tests/pipeline/base.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/base.py
Apache-2.0
def run_graph(self, graph, initial_workspace, mask=None): """ Compute the given TermGraph, seeding the workspace of our engine with `initial_workspace`. Parameters ---------- graph : zipline.pipeline.graph.ExecutionPlan Graph to run. initial_workspace...
Compute the given TermGraph, seeding the workspace of our engine with `initial_workspace`. Parameters ---------- graph : zipline.pipeline.graph.ExecutionPlan Graph to run. initial_workspace : dict Initial workspace to forward to SimplePipelineEng...
run_graph
python
quantopian/zipline
tests/pipeline/base.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/base.py
Apache-2.0
def check_terms(self, terms, expected, initial_workspace, mask, check=check_arrays): """ Compile the given terms into a TermGraph, compute it with initial_workspace, and compare the results with `...
Compile the given terms into a TermGraph, compute it with initial_workspace, and compare the results with ``expected``.
check_terms
python
quantopian/zipline
tests/pipeline/base.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/base.py
Apache-2.0
def build_mask(self, array): """ Helper for constructing an AssetExists mask from a boolean-coercible array. """ ndates, nassets = array.shape return DataFrame( array, # Use the **last** N dates rather than the first N so that we have #...
Helper for constructing an AssetExists mask from a boolean-coercible array.
build_mask
python
quantopian/zipline
tests/pipeline/base.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/base.py
Apache-2.0
def rand_ints(self, seed, shape, low=0, high=10): """ Build a block of random numerical data. """ rand = np.random.RandomState(seed) return rand.randint(low, high, shape, dtype='i8')
Build a block of random numerical data.
rand_ints
python
quantopian/zipline
tests/pipeline/base.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/base.py
Apache-2.0
def rand_categoricals(self, categories, seed, shape, missing_value=None): """Build a block of random categorical data. Categories should not include ``missing_value``. """ categories = list(categories) + [missing_value] data = np.random.RandomState(seed).choice(categories, shape...
Build a block of random categorical data. Categories should not include ``missing_value``.
rand_categoricals
python
quantopian/zipline
tests/pipeline/base.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/base.py
Apache-2.0
def moving_window(array, nrows): """ Simple moving window generator over a 2D numpy array. """ count = num_windows_of_length_M_on_buffers_of_length_N(nrows, len(array)) for i in range(count): yield array[i:i + nrows]
Simple moving window generator over a 2D numpy array.
moving_window
python
quantopian/zipline
tests/pipeline/test_adjusted_array.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_adjusted_array.py
Apache-2.0
def as_labelarray(initial_dtype, missing_value, array): """ Curried wrapper around LabelArray, that round-trips the input data through `initial_dtype` first. """ return LabelArray( array.astype(initial_dtype), missing_value=initial_dtype.type(missing_value), )
Curried wrapper around LabelArray, that round-trips the input data through `initial_dtype` first.
as_labelarray
python
quantopian/zipline
tests/pipeline/test_adjusted_array.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_adjusted_array.py
Apache-2.0
def _gen_multiplicative_adjustment_cases(dtype): """ Generate expected moving windows on a buffer with adjustments. We proceed by constructing, at each row, the view of the array we expect in in all windows anchored on that row. In general, if we have an adjustment to be applied once we process th...
Generate expected moving windows on a buffer with adjustments. We proceed by constructing, at each row, the view of the array we expect in in all windows anchored on that row. In general, if we have an adjustment to be applied once we process the row at index N, should see that adjustment applied...
_gen_multiplicative_adjustment_cases
python
quantopian/zipline
tests/pipeline/test_adjusted_array.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_adjusted_array.py
Apache-2.0
def _gen_overwrite_adjustment_cases(dtype): """ Generate test cases for overwrite adjustments. The algorithm used here is the same as the one used above for multiplicative adjustments. The only difference is the semantics of how the adjustments are expected to modify the arrays. This is param...
Generate test cases for overwrite adjustments. The algorithm used here is the same as the one used above for multiplicative adjustments. The only difference is the semantics of how the adjustments are expected to modify the arrays. This is parameterized on `make_input` and `make_expected_output`...
_gen_overwrite_adjustment_cases
python
quantopian/zipline
tests/pipeline/test_adjusted_array.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_adjusted_array.py
Apache-2.0
def _gen_overwrite_1d_array_adjustment_case(dtype): """ Generate test cases for overwrite adjustments. The algorithm used here is the same as the one used above for multiplicative adjustments. The only difference is the semantics of how the adjustments are expected to modify the arrays. This ...
Generate test cases for overwrite adjustments. The algorithm used here is the same as the one used above for multiplicative adjustments. The only difference is the semantics of how the adjustments are expected to modify the arrays. This is parameterized on `make_input` and `make_expected_output`...
_gen_overwrite_1d_array_adjustment_case
python
quantopian/zipline
tests/pipeline/test_adjusted_array.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_adjusted_array.py
Apache-2.0
def test_cols_with_all_missing_vals(self): """ Tests that when there is no known data, we get output where the columns have the right dtypes and the right missing values filled in. input (self.df): Empty DataFrame Columns: [sid, float_value, str_value, int_value, bool_va...
Tests that when there is no known data, we get output where the columns have the right dtypes and the right missing values filled in. input (self.df): Empty DataFrame Columns: [sid, float_value, str_value, int_value, bool_value, dt_value, asof_date, timestamp] ...
test_cols_with_all_missing_vals
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_cols_with_some_missing_vals(self): """ Tests the following: 1) Forward filling replaces missing values correctly for the data types supported in pipeline. 2) We don't forward fill when the missing value is the actual value we got for a date in th...
Tests the following: 1) Forward filling replaces missing values correctly for the data types supported in pipeline. 2) We don't forward fill when the missing value is the actual value we got for a date in the case of int/bool columns. 3) We get the c...
test_cols_with_some_missing_vals
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_custom_query_time_tz(self): """ input (df): asof_date int_value sid timestamp value 0 2013-12-31 0 65 2014-01-01 13:44:00 0.0 1 2013-12-31 1 66 2014-01-01 13:44:00 1.0 2 2013-12-31 2 67 2014-01-01 13:44:00 ...
input (df): asof_date int_value sid timestamp value 0 2013-12-31 0 65 2014-01-01 13:44:00 0.0 1 2013-12-31 1 66 2014-01-01 13:44:00 1.0 2 2013-12-31 2 67 2014-01-01 13:44:00 2.0 3 2013-12-31 1 65 2014-0...
test_custom_query_time_tz
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_id(self): """ input (self.df): asof_date sid timestamp int_value value 0 2014-01-01 65 2014-01-01 0 0 1 2014-01-01 66 2014-01-01 1 1 2 2014-01-01 67 2014-01-01 2 2 3 2014-01-02 65 2014-01-02 1 1...
input (self.df): asof_date sid timestamp int_value value 0 2014-01-01 65 2014-01-01 0 0 1 2014-01-01 66 2014-01-01 1 1 2 2014-01-01 67 2014-01-01 2 2 3 2014-01-02 65 2014-01-02 1 1 4 2014-01-02 66 201...
test_id
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_id_with_asof_date(self): """ input (self.df): asof_date sid timestamp int_value value 0 2014-01-01 65 2014-01-01 0 0 1 2014-01-01 66 2014-01-01 1 1 2 2014-01-01 67 2014-01-01 2 2 3 2014-01-02 65 2014-01-02 ...
input (self.df): asof_date sid timestamp int_value value 0 2014-01-01 65 2014-01-01 0 0 1 2014-01-01 66 2014-01-01 1 1 2 2014-01-01 67 2014-01-01 2 2 3 2014-01-02 65 2014-01-02 1 1 4 2014-01-02 66 201...
test_id_with_asof_date
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_id_ffill_out_of_window(self): """ input (df): asof_date timestamp sid other value 0 2013-12-22 2013-12-22 65 0 0 1 2013-12-22 2013-12-22 66 NaN 1 2 2013-12-22 2013-12-22 67 2 NaN 3 2013-12-23 2013-12-23 65 NaN ...
input (df): asof_date timestamp sid other value 0 2013-12-22 2013-12-22 65 0 0 1 2013-12-22 2013-12-22 66 NaN 1 2 2013-12-22 2013-12-22 67 2 NaN 3 2013-12-23 2013-12-23 65 NaN 1 4 2013-12-23 2013-12-23 66 2...
test_id_ffill_out_of_window
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_id_multiple_columns(self): """ input (df): asof_date sid timestamp value other 0 2014-01-01 65 2014-01-01 0 1 1 2014-01-01 66 2014-01-01 1 2 2 2014-01-01 67 2014-01-01 2 3 3 2014-01-02 65 2014-01-02 1 ...
input (df): asof_date sid timestamp value other 0 2014-01-01 65 2014-01-01 0 1 1 2014-01-01 66 2014-01-01 1 2 2 2014-01-01 67 2014-01-01 2 3 3 2014-01-02 65 2014-01-02 1 2 4 2014-01-02 66 2014-01-02 2 ...
test_id_multiple_columns
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_id_macro_dataset(self): """ input (self.macro_df) asof_date timestamp value 0 2014-01-01 2014-01-01 0 3 2014-01-02 2014-01-02 1 6 2014-01-03 2014-01-03 2 output (expected): value 2014-01-01 0 2...
input (self.macro_df) asof_date timestamp value 0 2014-01-01 2014-01-01 0 3 2014-01-02 2014-01-02 1 6 2014-01-03 2014-01-03 2 output (expected): value 2014-01-01 0 2014-01-02 1 2014-01-03 2 ...
test_id_macro_dataset
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_id_ffill_out_of_window_macro_dataset(self): """ input (df): asof_date timestamp other value 0 2013-12-22 2013-12-22 NaN 0 1 2013-12-23 2013-12-23 1 NaN 2 2013-12-24 2013-12-24 NaN NaN output (expected): oth...
input (df): asof_date timestamp other value 0 2013-12-22 2013-12-22 NaN 0 1 2013-12-23 2013-12-23 1 NaN 2 2013-12-24 2013-12-24 NaN NaN output (expected): other value 2014-01-01 1 0 2014-01-02 ...
test_id_ffill_out_of_window_macro_dataset
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_id_macro_dataset_multiple_columns(self): """ input (df): asof_date timestamp other value 0 2014-01-01 2014-01-01 1 0 3 2014-01-02 2014-01-02 2 1 6 2014-01-03 2014-01-03 3 2 output (expected): other ...
input (df): asof_date timestamp other value 0 2014-01-01 2014-01-01 1 0 3 2014-01-02 2014-01-02 2 1 6 2014-01-03 2014-01-03 3 2 output (expected): other value 2014-01-01 1 0 2014-01-02 ...
test_id_macro_dataset_multiple_columns
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def _test_checkpoints_macro(self, checkpoints, ffilled_value=-1.0): """Simple checkpoints test that accepts a checkpoints dataframe and the expected value for 2014-01-03 for macro datasets. The underlying data has value -1.0 on 2014-01-01 and 1.0 on 2014-01-04. Parameters -----...
Simple checkpoints test that accepts a checkpoints dataframe and the expected value for 2014-01-03 for macro datasets. The underlying data has value -1.0 on 2014-01-01 and 1.0 on 2014-01-04. Parameters ---------- checkpoints : pd.DataFrame The checkpoints data. ...
_test_checkpoints_macro
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def _test_checkpoints(self, checkpoints, ffilled_values=None): """Simple checkpoints test that accepts a checkpoints dataframe and the expected value for 2014-01-03. The underlying data has value -(sid + 1) on 2014-01-01 and sid + 1 on 2014-01-04. Parameters ---------- ...
Simple checkpoints test that accepts a checkpoints dataframe and the expected value for 2014-01-03. The underlying data has value -(sid + 1) on 2014-01-01 and sid + 1 on 2014-01-04. Parameters ---------- checkpoints : pd.DataFrame The checkpoints data. ...
_test_checkpoints
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_id_take_last_in_group_sorted(self): """ input asof_date timestamp other value 2014-01-03 2014-01-04 00 3 3 2014-01-02 2014-01-04 00 2 2 output (expected): other value 2014-01-02 NaN NaN ...
input asof_date timestamp other value 2014-01-03 2014-01-04 00 3 3 2014-01-02 2014-01-04 00 2 2 output (expected): other value 2014-01-02 NaN NaN 2014-01-03 NaN NaN 2014-01-06 3 ...
test_id_take_last_in_group_sorted
python
quantopian/zipline
tests/pipeline/test_blaze.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_blaze.py
Apache-2.0
def test_element_of_integral(self): """ Element of is well-defined for integral classifiers. """ class C(Classifier): dtype = int64_dtype missing_value = -1 inputs = () window_length = 0 c = C() # There's no significance t...
Element of is well-defined for integral classifiers.
test_element_of_integral
python
quantopian/zipline
tests/pipeline/test_classifier.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_classifier.py
Apache-2.0
def test_element_of_rejects_missing_value(self): """ Test that element_of raises a useful error if we attempt to pass it an array of choices that include the classifier's missing_value. """ missing = "not in the array" class C(Classifier): dtype = categorical...
Test that element_of raises a useful error if we attempt to pass it an array of choices that include the classifier's missing_value.
test_element_of_rejects_missing_value
python
quantopian/zipline
tests/pipeline/test_classifier.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_classifier.py
Apache-2.0
def test_mixed_generics(self): """ Test that we can run pipelines with mixed generic/non-generic terms. This test is a regression test for failures encountered during development where having a mix of generic and non-generic columns in the term graph caused bugs in our extra row...
Test that we can run pipelines with mixed generic/non-generic terms. This test is a regression test for failures encountered during development where having a mix of generic and non-generic columns in the term graph caused bugs in our extra row accounting.
test_mixed_generics
python
quantopian/zipline
tests/pipeline/test_domain.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_domain.py
Apache-2.0
def check_extra_row_calculations(self, terms, all_sessions, start_session, end_session, min_extra_rows, ...
Check that each term in ``terms`` computes an expected number of extra rows for the given parameters.
check_extra_row_calculations
python
quantopian/zipline
tests/pipeline/test_downsampling.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_downsampling.py
Apache-2.0
def assert_multi_index_is_product(testcase, index, *levels): """Assert that a MultiIndex contains the product of `*levels`.""" testcase.assertIsInstance( index, MultiIndex, "%s is not a MultiIndex" % index ) testcase.assertEqual(set(index), set(product(*levels)))
Assert that a MultiIndex contains the product of `*levels`.
assert_multi_index_is_product
python
quantopian/zipline
tests/pipeline/test_engine.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_engine.py
Apache-2.0
def test_masked_factor(self): """ Test that a Custom Factor computes the correct values when passed a mask. The mask/filter should be applied prior to computing any values, as opposed to computing the factor across the entire universe of assets. Any assets that are filtered out s...
Test that a Custom Factor computes the correct values when passed a mask. The mask/filter should be applied prior to computing any values, as opposed to computing the factor across the entire universe of assets. Any assets that are filtered out should be filled with missing valu...
test_masked_factor
python
quantopian/zipline
tests/pipeline/test_engine.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_engine.py
Apache-2.0
def test_factor_with_single_output(self): """ Test passing an `outputs` parameter of length 1 to a CustomFactor. """ dates = self.dates[5:10] assets = self.assets num_dates = len(dates) open = EquityPricing.open open_values = [self.constants[open]] * num_d...
Test passing an `outputs` parameter of length 1 to a CustomFactor.
test_factor_with_single_output
python
quantopian/zipline
tests/pipeline/test_engine.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_engine.py
Apache-2.0
def test_instance_of_factor_with_multiple_outputs(self): """ Test adding a CustomFactor instance, which has multiple outputs, as a pipeline column directly. Its computed values should be tuples containing the computed values of each of its outputs. """ dates = self.dates[...
Test adding a CustomFactor instance, which has multiple outputs, as a pipeline column directly. Its computed values should be tuples containing the computed values of each of its outputs.
test_instance_of_factor_with_multiple_outputs
python
quantopian/zipline
tests/pipeline/test_engine.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_engine.py
Apache-2.0
def write_nans(self, df): """ Write nans to the locations in data corresponding to the (date, asset) pairs for which we wouldn't have data for `asset` on `date` in a backtest. Parameters ---------- df : pd.DataFrame A DataFrame with a DatetimeIndex as...
Write nans to the locations in data corresponding to the (date, asset) pairs for which we wouldn't have data for `asset` on `date` in a backtest. Parameters ---------- df : pd.DataFrame A DataFrame with a DatetimeIndex as index and an object index of ...
write_nans
python
quantopian/zipline
tests/pipeline/test_engine.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_engine.py
Apache-2.0
def test_string_classifiers_produce_categoricals(self): """ Test that string-based classifiers produce pandas categoricals as their outputs. """ col = TestingDataSet.categorical_col pipe = Pipeline(columns={'c': col.latest}) run_dates = self.trading_days[-10:] ...
Test that string-based classifiers produce pandas categoricals as their outputs.
test_string_classifiers_produce_categoricals
python
quantopian/zipline
tests/pipeline/test_engine.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_engine.py
Apache-2.0
def test_run_chunked_pipeline(self): """ Test that running a pipeline in chunks produces the same result as if it were run all at once """ pipe = Pipeline( columns={ 'float': TestingDataSet.float_col.latest, 'custom_factor': SimpleMovi...
Test that running a pipeline in chunks produces the same result as if it were run all at once
test_run_chunked_pipeline
python
quantopian/zipline
tests/pipeline/test_engine.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_engine.py
Apache-2.0
def make_null_event_date_events(all_sids, timestamp): """ Make an event with a null event_date for all sids. Used to test that EventsLoaders filter out null events. """ return pd.DataFrame({ 'sid': all_sids, 'timestamp': timestamp, 'event_date': pd.Timestamp('NaT'), ...
Make an event with a null event_date for all sids. Used to test that EventsLoaders filter out null events.
make_null_event_date_events
python
quantopian/zipline
tests/pipeline/test_events.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_events.py
Apache-2.0
def make_events(add_nulls): """ Every event has at least three pieces of data associated with it: 1. sid : The ID of the asset associated with the event. 2. event_date : The date on which an event occurred. 3. timestamp : The date on which we learned about the event. This can be ...
Every event has at least three pieces of data associated with it: 1. sid : The ID of the asset associated with the event. 2. event_date : The date on which an event occurred. 3. timestamp : The date on which we learned about the event. This can be before the occurence_date in the ca...
make_events
python
quantopian/zipline
tests/pipeline/test_events.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_events.py
Apache-2.0
def test_load_empty(self): """ For the case where raw data is empty, make sure we have a result for all sids, that the dimensions are correct, and that we have the correct missing value. """ raw_events = pd.DataFrame( columns=["sid", "time...
For the case where raw data is empty, make sure we have a result for all sids, that the dimensions are correct, and that we have the correct missing value.
test_load_empty
python
quantopian/zipline
tests/pipeline/test_events.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_events.py
Apache-2.0
def check_previous_value_results(self, column, results, dates): """ Check previous value results for a single column. """ # Verify that we got a result for every sid. self.assert_result_contains_all_sids(results) events = self.raw_events_no_nulls # Remove timezon...
Check previous value results for a single column.
check_previous_value_results
python
quantopian/zipline
tests/pipeline/test_events.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_events.py
Apache-2.0
def scipy_winsorize_with_nan_handling(array, limits): """ Wrapper around scipy.stats.mstats.winsorize that handles NaNs correctly. scipy's winsorize sorts NaNs to the end of the array when calculating percentiles. """ # The basic idea of this function is to do the following: # 1. Sort the i...
Wrapper around scipy.stats.mstats.winsorize that handles NaNs correctly. scipy's winsorize sorts NaNs to the end of the array when calculating percentiles.
scipy_winsorize_with_nan_handling
python
quantopian/zipline
tests/pipeline/test_factor.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_factor.py
Apache-2.0
def test_normalizations_hand_computed(self): """ Test the hand-computed example in factor.demean. """ f = self.f m = Mask() c = C() str_c = C(dtype=categorical_dtype, missing_value=None) factor_data = array( [[1.0, 2.0, 3.0, 4.0], ...
Test the hand-computed example in factor.demean.
test_normalizations_hand_computed
python
quantopian/zipline
tests/pipeline/test_factor.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_factor.py
Apache-2.0
def test_winsorize_hand_computed(self): """ Test the hand-computed example in factor.winsorize. """ f = self.f m = Mask() c = C() str_c = C(dtype=categorical_dtype, missing_value=None) factor_data = array([ [1., 2., 3., 4., 5., 6., ...
Test the hand-computed example in factor.winsorize.
test_winsorize_hand_computed
python
quantopian/zipline
tests/pipeline/test_factor.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_factor.py
Apache-2.0
def test_winsorize_bad_bounds(self): """ Test out of bounds input for factor.winsorize. """ f = self.f bad_percentiles = [ (-.1, 1), (0, 95), (5, 95), (5, 5), (.6, .4) ] for min_, max_ in bad_percentiles...
Test out of bounds input for factor.winsorize.
test_winsorize_bad_bounds
python
quantopian/zipline
tests/pipeline/test_factor.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_factor.py
Apache-2.0
def test_summary_methods(self, seed, mask): """Test that summary funcs work the same as numpy NaN-aware funcs. """ rand = np.random.RandomState(seed) shape = (10, 5) data = rand.randn(*shape) data[~mask] = np.nan workspace = {F(): data} terms = { ...
Test that summary funcs work the same as numpy NaN-aware funcs.
test_summary_methods
python
quantopian/zipline
tests/pipeline/test_factor.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_factor.py
Apache-2.0
def test_built_in_vs_summary(self, seed, mask): """Test that summary funcs match normalization functions. """ rand = np.random.RandomState(seed) shape = (10, 5) data = rand.randn(*shape) data[~mask] = np.nan workspace = {F(): data} terms = { '...
Test that summary funcs match normalization functions.
test_built_in_vs_summary
python
quantopian/zipline
tests/pipeline/test_factor.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_factor.py
Apache-2.0
def rowwise_rank(array, mask=None): """ Take a 2D array and return the 0-indexed sorted position of each element in the array for each row. Examples -------- In [5]: data Out[5]: array([[-0.141, -1.103, -1.0171, 0.7812, 0.07 ], [ 0.926, 0.235, -0.7698, 1.4552, 0.2061], ...
Take a 2D array and return the 0-indexed sorted position of each element in the array for each row. Examples -------- In [5]: data Out[5]: array([[-0.141, -1.103, -1.0171, 0.7812, 0.07 ], [ 0.926, 0.235, -0.7698, 1.4552, 0.2061], [ 1.579, 0.929, -0.557 , 0.789...
rowwise_rank
python
quantopian/zipline
tests/pipeline/test_filter.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_filter.py
Apache-2.0
def test_all_present_float_factor_input(self): """Test float factor input to `AllPresent` """ class SomeWindowSafeFactor(Factor): dtype = float64_dtype inputs = () window_length = 0 window_safe = True input_factor = SomeWindowSafeFactor() ...
Test float factor input to `AllPresent`
test_all_present_float_factor_input
python
quantopian/zipline
tests/pipeline/test_filter.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_filter.py
Apache-2.0
def test_all_present_int_factor_input(self): """Test int factor input to `AllPresent` """ class SomeWindowSafeIntFactor(Factor): dtype = int64_dtype inputs = () window_length = 0 window_safe = True missing_value = 0 input_facto...
Test int factor input to `AllPresent`
test_all_present_int_factor_input
python
quantopian/zipline
tests/pipeline/test_filter.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_filter.py
Apache-2.0
def test_all_present_classifier_input(self): """Test classifier factor input to `AllPresent` """ class SomeWindowSafeStringClassifier(Classifier): dtype = object_dtype inputs = () window_length = 0 missing_value = '' window_safe = True ...
Test classifier factor input to `AllPresent`
test_all_present_classifier_input
python
quantopian/zipline
tests/pipeline/test_filter.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_filter.py
Apache-2.0
def test_all_present_filter_input(self): """Test error is raised when filter factor is input to `AllPresent` """ with self.assertRaises(TypeError) as err: AllPresent([Mask()], window_length=4) self.assertEqual( "Input to filter `AllPresent` cannot be a Filter.", ...
Test error is raised when filter factor is input to `AllPresent`
test_all_present_filter_input
python
quantopian/zipline
tests/pipeline/test_filter.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_filter.py
Apache-2.0
def split_by_chunk(self, trace): """ Split a trace of a chunked pipeline execution into a list of traces for each chunk. """ def is_end_of_chunk(call): return ( call.method_name == 'computing_chunk' and call.state == 'exit' ) to_yi...
Split a trace of a chunked pipeline execution into a list of traces for each chunk.
split_by_chunk
python
quantopian/zipline
tests/pipeline/test_hooks.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_hooks.py
Apache-2.0
def expected_chunk_progress(self, pipeline_start, pipeline_end, chunk_end): """Get expected progress after finishing a chunk ending at ``chunk_end``. """ # +1 to be inclusive of end dates total_days = (pipeline_end - pipeline_start).days + 1 days_complete = (chunk_end - pipeline_...
Get expected progress after finishing a chunk ending at ``chunk_end``.
expected_chunk_progress
python
quantopian/zipline
tests/pipeline/test_hooks.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_hooks.py
Apache-2.0
def check_expected_latest_value(self, calendar, col, date, asset, value): """Check the expected result of column.latest from a pipeline. """ if np.isnan(value): # If we got a NaN, we should be outside the asset's # lifetime. self.assertTrue(date <= asset.start...
Check the expected result of column.latest from a pipeline.
check_expected_latest_value
python
quantopian/zipline
tests/pipeline/test_international_markets.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_international_markets.py
Apache-2.0
def assert_identical_results(self, left, right, start_date, end_date): """Assert that two pipelines produce the same results. """ left_result = self.run_pipeline(left, start_date, end_date) right_result = self.run_pipeline(right, start_date, end_date) assert_equal(left_result, ri...
Assert that two pipelines produce the same results.
assert_identical_results
python
quantopian/zipline
tests/pipeline/test_international_markets.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_international_markets.py
Apache-2.0
def alive_in_range(asset, start, end, include_asset_start_date=False): """ Check if an asset was alive in the range from start to end. Parameters ---------- asset : Asset The asset to check start : pd.Timestamp Start of the interval. end : pd.Timestamp End of the int...
Check if an asset was alive in the range from start to end. Parameters ---------- asset : Asset The asset to check start : pd.Timestamp Start of the interval. end : pd.Timestamp End of the interval. include_asset_start_date : bool Whether to include the star...
alive_in_range
python
quantopian/zipline
tests/pipeline/test_international_markets.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_international_markets.py
Apache-2.0
def intervals_overlap(a, b): """ Check whether a pair of datetime intervals overlap. Parameters ---------- a : (pd.Timestamp, pd.Timestamp) b : (pd.Timestamp, pd.Timestamp) Returns ------- have_overlap : bool Bool indicating whether there there is a non-empty intersection b...
Check whether a pair of datetime intervals overlap. Parameters ---------- a : (pd.Timestamp, pd.Timestamp) b : (pd.Timestamp, pd.Timestamp) Returns ------- have_overlap : bool Bool indicating whether there there is a non-empty intersection between the intervals.
intervals_overlap
python
quantopian/zipline
tests/pipeline/test_international_markets.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_international_markets.py
Apache-2.0
def gen_boolops(x, y, z): """ Generate all possible interleavings of & and | between all possible orderings of x, y, and z. """ for a, b, c in permutations([x, y, z]): yield (a & b) & c yield (a & b) | c yield (a...
Generate all possible interleavings of & and | between all possible orderings of x, y, and z.
gen_boolops
python
quantopian/zipline
tests/pipeline/test_numerical_expression.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_numerical_expression.py
Apache-2.0
def rolling_vwap(df, length): "Simple rolling vwap implementation for testing" closes = df['close'].values volumes = df['volume'].values product = closes * volumes out = full_like(closes, nan) for upper_bound in range(length, len(closes) + 1): bounds = slice(upper_bound - length, upper_b...
Simple rolling vwap implementation for testing
rolling_vwap
python
quantopian/zipline
tests/pipeline/test_pipeline_algo.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_pipeline_algo.py
Apache-2.0
def test_attach_pipeline_after_initialize(self): """ Assert that calling attach_pipeline after initialize raises correctly. """ def initialize(context): pass def late_attach(context, data): attach_pipeline(Pipeline(), 'test') raise AssertionEr...
Assert that calling attach_pipeline after initialize raises correctly.
test_attach_pipeline_after_initialize
python
quantopian/zipline
tests/pipeline/test_pipeline_algo.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_pipeline_algo.py
Apache-2.0
def test_pipeline_output_after_initialize(self): """ Assert that calling pipeline_output after initialize raises correctly. """ def initialize(context): attach_pipeline(Pipeline(), 'test') pipeline_output('test') raise AssertionError("Shouldn't make it...
Assert that calling pipeline_output after initialize raises correctly.
test_pipeline_output_after_initialize
python
quantopian/zipline
tests/pipeline/test_pipeline_algo.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_pipeline_algo.py
Apache-2.0
def test_get_output_nonexistent_pipeline(self): """ Assert that calling add_pipeline after initialize raises appropriately. """ def initialize(context): attach_pipeline(Pipeline(), 'test') def handle_data(context, data): raise AssertionError("Shouldn't ma...
Assert that calling add_pipeline after initialize raises appropriately.
test_get_output_nonexistent_pipeline
python
quantopian/zipline
tests/pipeline/test_pipeline_algo.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_pipeline_algo.py
Apache-2.0
def test_assets_appear_on_correct_days(self, test_name, chunks): """ Assert that assets appear at correct times during a backtest, with correctly-adjusted close price values. """ if chunks == 'all_but_one_day': chunks = ( self.dates.get_loc(self.last_...
Assert that assets appear at correct times during a backtest, with correctly-adjusted close price values.
test_assets_appear_on_correct_days
python
quantopian/zipline
tests/pipeline/test_pipeline_algo.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_pipeline_algo.py
Apache-2.0
def test_multiple_pipelines(self): """ Test that we can attach multiple pipelines and access the correct output based on the pipeline name. """ def initialize(context): pipeline_close = attach_pipeline(Pipeline(), 'test_close') pipeline_volume = attach_pip...
Test that we can attach multiple pipelines and access the correct output based on the pipeline name.
test_multiple_pipelines
python
quantopian/zipline
tests/pipeline/test_pipeline_algo.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_pipeline_algo.py
Apache-2.0
def test_duplicate_pipeline_names(self): """ Test that we raise an error when we try to attach a pipeline with a name that already exists for another attached pipeline. """ def initialize(context): attach_pipeline(Pipeline(), 'test') attach_pipeline(Pipeli...
Test that we raise an error when we try to attach a pipeline with a name that already exists for another attached pipeline.
test_duplicate_pipeline_names
python
quantopian/zipline
tests/pipeline/test_pipeline_algo.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_pipeline_algo.py
Apache-2.0
def test_pipeline_beyond_daily_bars(self): """ Ensure that we can run an algo with pipeline beyond the max date of the daily bars. """ # For ensuring we call before_trading_start. count = [0] current_day = self.trading_calendar.next_session_label( se...
Ensure that we can run an algo with pipeline beyond the max date of the daily bars.
test_pipeline_beyond_daily_bars
python
quantopian/zipline
tests/pipeline/test_pipeline_algo.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_pipeline_algo.py
Apache-2.0
def create_expected_df_for_factor_compute(start_date, sids, tuples, end_date): """ Given a list of tuples of new data we get for each sid on each critical date (when information chan...
Given a list of tuples of new data we get for each sid on each critical date (when information changes), create a DataFrame that fills that data through a date range ending at `end_date`.
create_expected_df_for_factor_compute
python
quantopian/zipline
tests/pipeline/test_quarters_estimates.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_quarters_estimates.py
Apache-2.0
def make_events(cls): """ In order to determine which estimate we care about for a particular sid, we need to look at all estimates that we have for that sid and their associated event dates. We define q1 < q2, and thus event1 < event2 since event1 occurs during q1 and e...
In order to determine which estimate we care about for a particular sid, we need to look at all estimates that we have for that sid and their associated event dates. We define q1 < q2, and thus event1 < event2 since event1 occurs during q1 and event2 occurs during q2 and we ass...
make_events
python
quantopian/zipline
tests/pipeline/test_quarters_estimates.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_quarters_estimates.py
Apache-2.0
def test_slice(self, my_asset_column, window_length_): """ Test that slices can be created by indexing into a term, and that they have the correct shape when used as inputs. """ sids = self.sids my_asset = self.asset_finder.retrieve_asset(self.sids[my_asset_column]) ...
Test that slices can be created by indexing into a term, and that they have the correct shape when used as inputs.
test_slice
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_slice_with_masking(self, unmasked_column, slice_column): """ Test that masking a factor that uses slices as inputs does not mask the slice data. """ sids = self.sids asset_finder = self.asset_finder start_date = self.pipeline_start_date end_date =...
Test that masking a factor that uses slices as inputs does not mask the slice data.
test_slice_with_masking
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_adding_slice_column(self): """ Test that slices cannot be added as a pipeline column. """ my_asset = self.asset_finder.retrieve_asset(self.sids[0]) open_slice = OpenPrice()[my_asset] with self.assertRaises(UnsupportedPipelineOutput): Pipeline(columns...
Test that slices cannot be added as a pipeline column.
test_adding_slice_column
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_loadable_term_slices(self): """ Test that slicing loadable terms raises the proper error. """ my_asset = self.asset_finder.retrieve_asset(self.sids[0]) with self.assertRaises(NonSliceableTerm): USEquityPricing.close[my_asset]
Test that slicing loadable terms raises the proper error.
test_loadable_term_slices
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_non_existent_asset(self): """ Test that indexing into a term with a non-existent asset raises the proper exception. """ my_asset = Asset( 0, exchange_info=ExchangeInfo('TEST FULL', 'TEST', 'US'), ) returns = Returns(window_length=2...
Test that indexing into a term with a non-existent asset raises the proper exception.
test_non_existent_asset
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_window_safety_of_slices(self): """ Test that slices correctly inherit the `window_safe` property of the term from which they are derived. """ col = self.col my_asset = self.asset_finder.retrieve_asset(self.sids[0]) # SimpleMovingAverage is not window saf...
Test that slices correctly inherit the `window_safe` property of the term from which they are derived.
test_window_safety_of_slices
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_single_column_output(self): """ Tests for custom factors that compute a 1D out. """ start_date = self.pipeline_start_date end_date = self.pipeline_end_date alternating_mask = (AssetIDPlusDay() % 2).eq(0) cascading_mask = AssetIDPlusDay() < (self.sids[-1]...
Tests for custom factors that compute a 1D out.
test_single_column_output
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_masked_single_column_output(self): """ Tests for masking custom factors that compute a 1D out. """ start_date = self.pipeline_start_date end_date = self.pipeline_end_date alternating_mask = (AssetIDPlusDay() % 2).eq(0) cascading_mask = AssetIDPlusDay() <...
Tests for masking custom factors that compute a 1D out.
test_masked_single_column_output
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_factor_correlation_methods(self, returns_length, correlation_length): """ Ensure that `Factor.pearsonr` and `Factor.spearmanr` are consistent with the built-in factors `RollingPearsonOfReturns` and `...
Ensure that `Factor.pearsonr` and `Factor.spearmanr` are consistent with the built-in factors `RollingPearsonOfReturns` and `RollingSpearmanOfReturns`.
test_factor_correlation_methods
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_factor_regression_method(self, returns_length, regression_length): """ Ensure that `Factor.linear_regression` is consistent with the built-in factor `RollingLinearRegressionOfReturns`. """ my_asset = self.asset_finder.retrieve_asset(self.sids[0]) returns = Retur...
Ensure that `Factor.linear_regression` is consistent with the built-in factor `RollingLinearRegressionOfReturns`.
test_factor_regression_method
python
quantopian/zipline
tests/pipeline/test_slice.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_slice.py
Apache-2.0
def test_correlation_factors(self, returns_length, correlation_length): """ Tests for the built-in factors `RollingPearsonOfReturns` and `RollingSpearmanOfReturns`. """ assets = self.assets my_asset = self.my_asset my_asset_column = self.my_asset_column da...
Tests for the built-in factors `RollingPearsonOfReturns` and `RollingSpearmanOfReturns`.
test_correlation_factors
python
quantopian/zipline
tests/pipeline/test_statistical.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_statistical.py
Apache-2.0
def test_regression_of_returns_factor(self, returns_length, regression_length): """ Tests for the built-in factor `RollingLinearRegressionOfReturns`. """ assets = self.assets my_asset = self.my_as...
Tests for the built-in factor `RollingLinearRegressionOfReturns`.
test_regression_of_returns_factor
python
quantopian/zipline
tests/pipeline/test_statistical.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_statistical.py
Apache-2.0
def test_correlation_and_regression_with_bad_asset(self): """ Test that `RollingPearsonOfReturns`, `RollingSpearmanOfReturns` and `RollingLinearRegressionOfReturns` raise the proper exception when given a nonexistent target asset. """ my_asset = Equity( 0, ...
Test that `RollingPearsonOfReturns`, `RollingSpearmanOfReturns` and `RollingLinearRegressionOfReturns` raise the proper exception when given a nonexistent target asset.
test_correlation_and_regression_with_bad_asset
python
quantopian/zipline
tests/pipeline/test_statistical.py
https://github.com/quantopian/zipline/blob/master/tests/pipeline/test_statistical.py
Apache-2.0