From 99efa7a9f39d1f5e068d8f9708038d638b3734d0 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 19 Jun 2017 05:09:25 -0700 Subject: [PATCH] Fixed catalyst tests except example tests --- .travis.yml | 6 +- catalyst/algorithm.py | 6 +- catalyst/data/benchmarks.py | 3 + catalyst/data/bundles/quandl.py | 1 + catalyst/data/us_equity_pricing.py | 5 +- catalyst/examples/momentum_pipeline.py | 13 +- catalyst/pipeline/api_utils.py | 5 +- catalyst/pipeline/classifiers/classifier.py | 3 +- catalyst/pipeline/data/crypto_pricing.py | 8 +- catalyst/pipeline/data/dataset.py | 5 +- catalyst/pipeline/data/equity_pricing.py | 8 +- catalyst/pipeline/factors/equity/__init__.py | 3 + catalyst/pipeline/factors/factor.py | 11 +- catalyst/pipeline/filters/filter.py | 2 +- catalyst/pipeline/loaders/blaze/estimates.py | 4 + catalyst/pipeline/loaders/blaze/events.py | 6 + .../pipeline/loaders/crypto_pricing_loader.py | 5 +- .../pipeline/loaders/earnings_estimates.py | 5 + .../pipeline/loaders/equity_pricing_loader.py | 2 +- catalyst/pipeline/loaders/events.py | 6 + catalyst/pipeline/loaders/frame.py | 7 + catalyst/pipeline/loaders/synthetic.py | 16 ++ catalyst/pipeline/term.py | 3 +- catalyst/testing/fixtures.py | 5 +- catalyst/utils/calendars/calendar_utils.py | 20 ++- .../utils/calendars/exchange_calendar_open.py | 1 - catalyst/utils/events.py | 4 +- catalyst/utils/pool.py | 4 +- catalyst/utils/run_algo.py | 14 +- tests/calendars/test_calendar_dispatcher.py | 8 +- tests/calendars/test_cfe_calendar.py | 2 +- tests/calendars/test_cme_calendar.py | 2 +- tests/calendars/test_ice_calendar.py | 2 +- tests/calendars/test_nyse_calendar.py | 4 +- tests/calendars/test_trading_calendar.py | 10 +- tests/data/bundles/test_core.py | 28 ++-- tests/data/bundles/test_quandl.py | 20 +-- tests/data/bundles/test_yahoo.py | 18 +-- tests/data/test_dispatch_bar_reader.py | 8 +- tests/data/test_minute_bars.py | 6 +- tests/data/test_resample.py | 6 +- tests/data/test_us_equity_pricing.py | 10 +- tests/events/test_events.py | 8 +- tests/events/test_events_cme.py | 2 +- tests/events/test_events_nyse.py | 6 +- tests/finance/test_blotter.py | 20 +-- tests/finance/test_cancel_policy.py | 4 +- tests/finance/test_commissions.py | 20 +-- tests/finance/test_slippage.py | 18 +-- tests/finance/test_transaction.py | 4 +- tests/history/generate_csvs.py | 4 +- tests/pipeline/base.py | 16 +- tests/pipeline/test_adjusted_array.py | 14 +- tests/pipeline/test_adjustment.py | 6 +- tests/pipeline/test_alias.py | 6 +- tests/pipeline/test_blaze.py | 22 +-- tests/pipeline/test_classifier.py | 12 +- tests/pipeline/test_column.py | 10 +- tests/pipeline/test_downsampling.py | 16 +- tests/pipeline/test_engine.py | 39 ++--- tests/pipeline/test_events.py | 20 +-- tests/pipeline/test_factor.py | 24 +-- tests/pipeline/test_filter.py | 18 +-- tests/pipeline/test_frameload.py | 12 +- tests/pipeline/test_numerical_expression.py | 8 +- tests/pipeline/test_pipeline.py | 12 +- tests/pipeline/test_pipeline_algo.py | 31 ++-- tests/pipeline/test_quarters_estimates.py | 22 +-- tests/pipeline/test_slice.py | 18 +-- tests/pipeline/test_statistical.py | 24 +-- tests/pipeline/test_technical.py | 12 +- tests/pipeline/test_term.py | 26 +-- .../pipeline/test_us_equity_pricing_loader.py | 16 +- .../quandl_samples/rebuild_samples.py | 4 +- tests/resources/rebuild_example_data | 8 +- tests/resources/yahoo_samples/rebuild_samples | 4 +- tests/risk/test_risk_cumulative.py | 8 +- tests/risk/test_risk_period.py | 10 +- tests/test_algorithm.py | 150 +++++++++--------- tests/test_api_shim.py | 27 ++-- tests/test_assets.py | 22 +-- tests/test_bar_data.py | 12 +- tests/test_benchmark.py | 10 +- tests/test_clock.py | 6 +- tests/test_continuous_futures.py | 14 +- tests/test_data_portal.py | 14 +- tests/test_examples.py | 16 +- tests/test_exception_handling.py | 4 +- tests/test_execution_styles.py | 8 +- tests/test_fetcher.py | 42 ++--- tests/test_finance.py | 36 ++--- tests/test_history.py | 18 +-- tests/test_labelarray.py | 8 +- tests/test_memoize.py | 4 +- tests/test_panel_bar_reader.py | 8 +- tests/test_perf_tracking.py | 30 ++-- tests/test_restrictions.py | 8 +- tests/test_security_list.py | 12 +- tests/test_testing.py | 14 +- tests/test_tradesimulation.py | 24 +-- tests/utils/daily_bar_writer.py | 2 +- tests/utils/test_argcheck.py | 2 +- tests/utils/test_cache.py | 2 +- tests/utils/test_date_utils.py | 6 +- tests/utils/test_final.py | 4 +- tests/utils/test_math_utils.py | 2 +- tests/utils/test_metautils.py | 6 +- tests/utils/test_numpy_utils.py | 6 +- tests/utils/test_pandas_utils.py | 8 +- tests/utils/test_preprocess.py | 6 +- tests/utils/test_sentinel.py | 2 +- tests/utils/test_sharedoc.py | 4 +- 112 files changed, 705 insertions(+), 641 deletions(-) diff --git a/.travis.yml b/.travis.yml index 130d54d21..3c4ac2810 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ install: - if [[ "$TRAVIS_SECURE_ENV_VARS" = "true" && "$TRAVIS_BRANCH" = "master" && "$TRAVIS_PULL_REQUEST" = "false" ]]; then DO_UPLOAD="true"; else DO_UPLOAD="false"; fi - | for recipe in $(ls -d conda/*/ | xargs -I {} basename {}); do - if [[ "$recipe" = "zipline" ]]; then continue; fi + if [[ "$recipe" = "catalyst" ]]; then continue; fi conda build conda/$recipe --python=$CONDA_PY --numpy=$CONDA_NPY --skip-existing -c quantopian -c quantopian/label/ci RECIPE_OUTPUT=$(conda build conda/$recipe --python=$CONDA_PY --numpy=$CONDA_NPY --output) @@ -61,14 +61,14 @@ install: before_script: - pip freeze | sort script: - - flake8 zipline tests + - flake8 catalyst tests - nosetests --with-coverage # deactive env to get access to anaconda command - source deactivate # unshallow the clone so the conda build can clone it. - git fetch --unshallow - - exec 3>&1; ZP_OUT=$(conda build conda/zipline --python=$CONDA_PY --numpy=$CONDA_NPY -c quantopian -c quantopian/label/ci | tee >(cat - >&3)) + - exec 3>&1; ZP_OUT=$(conda build conda/catalyst --python=$CONDA_PY --numpy=$CONDA_NPY -c quantopian -c quantopian/label/ci | tee >(cat - >&3)) - ZP_OUTPUT=$(echo "$ZP_OUT" | grep "anaconda upload" | awk '{print $NF}') - if [[ "$DO_UPLOAD" = "true" ]]; then anaconda -t $ANACONDA_TOKEN upload $ZP_OUTPUT -u quantopian --label ci; fi # reactivate env (necessary for coveralls) diff --git a/catalyst/algorithm.py b/catalyst/algorithm.py index 8573768eb..83855f83b 100644 --- a/catalyst/algorithm.py +++ b/catalyst/algorithm.py @@ -1115,7 +1115,7 @@ def schedule_function(self, if calendar is None: cal = self.trading_calendar elif calendar is calendars.CRYPTO_ASSETS: - cal = get_environment('OPEN') + cal = get_calendar('OPEN') elif calendar is calendars.US_EQUITIES: cal = get_calendar('NYSE') elif calendar is calendars.US_FUTURES: @@ -1124,7 +1124,9 @@ def schedule_function(self, raise ScheduleFunctionInvalidCalendar( given_calendar=calendar, allowed_calendars=( - '[calendars.CRYPTO_ASSETS, calendars.US_EQUITIES, calendars.US_FUTURES]' + '[calendars.CRYPTO_ASSETS, ' + 'calendars.US_EQUITIES, ' + 'calendars.US_FUTURES]' ), ) diff --git a/catalyst/data/benchmarks.py b/catalyst/data/benchmarks.py index 88b005dfe..2e4aad50c 100644 --- a/catalyst/data/benchmarks.py +++ b/catalyst/data/benchmarks.py @@ -43,6 +43,9 @@ def get_benchmark_returns(symbol, first_date, last_date): first_date is **not** included because we need the close from day N - 1 to compute the returns for day N. """ + if symbol == '^GSPC': + symbol = 'spy' + data = pd_reader.DataReader( symbol, 'google', diff --git a/catalyst/data/bundles/quandl.py b/catalyst/data/bundles/quandl.py index da48c2594..3a423d6cd 100644 --- a/catalyst/data/bundles/quandl.py +++ b/catalyst/data/bundles/quandl.py @@ -412,6 +412,7 @@ def quantopian_quandl_bundle(environ, 'https://s3.amazonaws.com/quantopian-public-zipline-data/quandl' ) + @bundles.register( 'catalyst', calendar_name='NYSE', diff --git a/catalyst/data/us_equity_pricing.py b/catalyst/data/us_equity_pricing.py index 76606bb04..732817196 100644 --- a/catalyst/data/us_equity_pricing.py +++ b/catalyst/data/us_equity_pricing.py @@ -67,7 +67,10 @@ preprocess, verify_indices_all_unique, ) -from catalyst.utils.sqlite_utils import group_into_chunks, coerce_string_to_conn +from catalyst.utils.sqlite_utils import ( + group_into_chunks, + coerce_string_to_conn, +) from catalyst.utils.memoize import lazyval from catalyst.utils.cli import maybe_show_progress from ._equities import _compute_row_slices, _read_bcolz_data diff --git a/catalyst/examples/momentum_pipeline.py b/catalyst/examples/momentum_pipeline.py index 5a1aac2f8..40cac0500 100644 --- a/catalyst/examples/momentum_pipeline.py +++ b/catalyst/examples/momentum_pipeline.py @@ -10,26 +10,23 @@ pipeline_output, record, schedule_function, + symbol, ) from catalyst.pipeline import Pipeline -from catalyst.pipeline.factors.crypto import RSI as cRSI -from catalyst.pipeline.factors.equity import RSI as eRSI +from catalyst.pipeline.factors.equity import RSI def make_pipeline(): - crsi = cRSI() - ersi = eRSI() + rsi = RSI() return Pipeline( columns={ - 'longs': crsi.top(3), - 'shorts': crsi.bottom(3), - 'equity': ersi.top(3), + 'longs': rsi.top(3), + 'shorts': rsi.bottom(3), }, ) def rebalance(context, data): - # Pipeline data will be a dataframe with boolean columns named 'longs' and # 'shorts'. pipeline_data = context.pipeline_data diff --git a/catalyst/pipeline/api_utils.py b/catalyst/pipeline/api_utils.py index fd492232c..7649daff1 100644 --- a/catalyst/pipeline/api_utils.py +++ b/catalyst/pipeline/api_utils.py @@ -10,8 +10,9 @@ def restrict_to_dtype(dtype, message_template): Terms with a specific dtype. This is conceptually similar to - catalyst.utils.input_validation.expect_dtypes, but provides more flexibility - for providing error messages that are specifically targeting Term methods. + catalyst.utils.input_validation.expect_dtypes, but provides more + flexibility for providing error messages that are specifically targeting + Term methods. Parameters ---------- diff --git a/catalyst/pipeline/classifiers/classifier.py b/catalyst/pipeline/classifiers/classifier.py index 933f9652d..0039be98f 100644 --- a/catalyst/pipeline/classifiers/classifier.py +++ b/catalyst/pipeline/classifiers/classifier.py @@ -330,7 +330,8 @@ def to_workspace_value(self, result, assets): Called with the result of a pipeline. This needs to return an object which can be put into the workspace to continue doing computations. - This is the inverse of :func:`~catalyst.pipeline.term.Term.postprocess`. + This is the inverse of + :func:`~catalyst.pipeline.term.Term.postprocess`. """ if self.dtype == int64_dtype: return super(Classifier, self).to_workspace_value(result, assets) diff --git a/catalyst/pipeline/data/crypto_pricing.py b/catalyst/pipeline/data/crypto_pricing.py index 49e50b146..a00f1c54a 100644 --- a/catalyst/pipeline/data/crypto_pricing.py +++ b/catalyst/pipeline/data/crypto_pricing.py @@ -8,8 +8,8 @@ class CryptoPricing(DataSet): """ Dataset representing daily trading prices and volumes of crypto-assets. """ - open = Column(float64_dtype) - high = Column(float64_dtype) - low = Column(float64_dtype) - close = Column(float64_dtype) + open = Column(float64_dtype) + high = Column(float64_dtype) + low = Column(float64_dtype) + close = Column(float64_dtype) volume = Column(float64_dtype) diff --git a/catalyst/pipeline/data/dataset.py b/catalyst/pipeline/data/dataset.py index 46c213aa7..b9f4a6f32 100644 --- a/catalyst/pipeline/data/dataset.py +++ b/catalyst/pipeline/data/dataset.py @@ -7,7 +7,10 @@ with_metaclass, ) -from catalyst.pipeline.classifiers import Classifier, Latest as LatestClassifier +from catalyst.pipeline.classifiers import ( + Classifier, + Latest as LatestClassifier, +) from catalyst.pipeline.factors import Factor, Latest as LatestFactor from catalyst.pipeline.filters import Filter, Latest as LatestFilter from catalyst.pipeline.sentinels import NotSpecified diff --git a/catalyst/pipeline/data/equity_pricing.py b/catalyst/pipeline/data/equity_pricing.py index e84a716c5..d63c0a8d1 100644 --- a/catalyst/pipeline/data/equity_pricing.py +++ b/catalyst/pipeline/data/equity_pricing.py @@ -8,8 +8,8 @@ class USEquityPricing(DataSet): """ Dataset representing daily trading prices and volumes. """ - open = Column(float64_dtype) - high = Column(float64_dtype) - low = Column(float64_dtype) - close = Column(float64_dtype) + open = Column(float64_dtype) + high = Column(float64_dtype) + low = Column(float64_dtype) + close = Column(float64_dtype) volume = Column(float64_dtype) diff --git a/catalyst/pipeline/factors/equity/__init__.py b/catalyst/pipeline/factors/equity/__init__.py index e8d29cf05..663d025f6 100644 --- a/catalyst/pipeline/factors/equity/__init__.py +++ b/catalyst/pipeline/factors/equity/__init__.py @@ -1,6 +1,9 @@ from .statistical import ( + RollingPearson, + RollingLinearRegression, RollingLinearRegressionOfReturns, RollingPearsonOfReturns, + RollingSpearman, RollingSpearmanOfReturns, ) from .technical import ( diff --git a/catalyst/pipeline/factors/factor.py b/catalyst/pipeline/factors/factor.py index afe9c219e..2349c23fe 100644 --- a/catalyst/pipeline/factors/factor.py +++ b/catalyst/pipeline/factors/factor.py @@ -338,8 +338,9 @@ class Factor(RestrictedDTypeMixin, ComputableTerm): >>> f2 = SomeOtherFactor(...) # doctest: +SKIP >>> average = (f1 + f2) / 2.0 # doctest: +SKIP - Factors can also be converted into :class:`catalyst.pipeline.Filter` objects - via comparison operators: (``<``, ``<=``, ``!=``, ``eq``, ``>``, ``>=``). + Factors can also be converted into :class:`catalyst.pipeline.Filter` + objects via comparison operators: + (``<``, ``<=``, ``!=``, ``eq``, ``>``, ``>=``). There are many natural operators defined on Factors besides the basic numerical operators. These include methods identifying missing or @@ -699,7 +700,7 @@ def pearsonr(self, target, correlation_length, mask=NotSpecified): :class:`catalyst.pipeline.factors.RollingPearsonOfReturns` :meth:`Factor.spearmanr` """ - from .statistical import RollingPearson + from .equity import RollingPearson return RollingPearson( base_factor=self, target=target, @@ -764,7 +765,7 @@ def spearmanr(self, target, correlation_length, mask=NotSpecified): :class:`catalyst.pipeline.factors.RollingSpearmanOfReturns` :meth:`Factor.pearsonr` """ - from .statistical import RollingSpearman + from .equity import RollingSpearman return RollingSpearman( base_factor=self, target=target, @@ -826,7 +827,7 @@ def linear_regression(self, target, regression_length, mask=NotSpecified): :func:`scipy.stats.linregress` :class:`catalyst.pipeline.factors.RollingLinearRegressionOfReturns` """ - from .statistical import RollingLinearRegression + from .equity import RollingLinearRegression return RollingLinearRegression( dependent=self, independent=target, diff --git a/catalyst/pipeline/filters/filter.py b/catalyst/pipeline/filters/filter.py index aaa9170bd..0f67f7ffd 100644 --- a/catalyst/pipeline/filters/filter.py +++ b/catalyst/pipeline/filters/filter.py @@ -141,7 +141,7 @@ class Filter(RestrictedDTypeMixin, ComputableTerm): construct a Factor computing 10-day VWAP and compare it to the scalar value 20.0:: - >>> from catalyst.pipeline.factors import VWAP + >>> from catalyst.pipeline.factors.equity import VWAP >>> vwap_10 = VWAP(window_length=10) >>> vwaps_under_20 = (vwap_10 <= 20) diff --git a/catalyst/pipeline/loaders/blaze/estimates.py b/catalyst/pipeline/loaders/blaze/estimates.py index 506954e6b..04093cba3 100644 --- a/catalyst/pipeline/loaders/blaze/estimates.py +++ b/catalyst/pipeline/loaders/blaze/estimates.py @@ -130,6 +130,10 @@ def load_adjusted_array(self, columns, dates, assets, mask): mask, ) + @property + def columns(self): + return self._columns + class BlazeNextEstimatesLoader(BlazeEstimatesLoader): loader = NextEarningsEstimatesLoader diff --git a/catalyst/pipeline/loaders/blaze/events.py b/catalyst/pipeline/loaders/blaze/events.py index b37136b3d..176da77fe 100644 --- a/catalyst/pipeline/loaders/blaze/events.py +++ b/catalyst/pipeline/loaders/blaze/events.py @@ -91,6 +91,8 @@ def __init__(self, self._data_query_time = data_query_time self._data_query_tz = data_query_tz + self._columns = next_value_columns + def load_adjusted_array(self, columns, dates, assets, mask): raw = load_raw_data(assets, dates, @@ -109,3 +111,7 @@ def load_adjusted_array(self, columns, dates, assets, mask): assets, mask, ) + + @property + def columns(self): + return self._columns diff --git a/catalyst/pipeline/loaders/crypto_pricing_loader.py b/catalyst/pipeline/loaders/crypto_pricing_loader.py index eb21e0579..32fa3c148 100644 --- a/catalyst/pipeline/loaders/crypto_pricing_loader.py +++ b/catalyst/pipeline/loaders/crypto_pricing_loader.py @@ -16,10 +16,7 @@ uint32, ) -from catalyst.data.us_equity_pricing import ( - BcolzDailyBarReader, - SQLiteAdjustmentReader, -) +from catalyst.data.us_equity_pricing import BcolzDailyBarReader from catalyst.lib.adjusted_array import AdjustedArray from catalyst.errors import NoFurtherDataError from catalyst.utils.calendars import get_calendar diff --git a/catalyst/pipeline/loaders/earnings_estimates.py b/catalyst/pipeline/loaders/earnings_estimates.py index afe8d874d..396690cac 100644 --- a/catalyst/pipeline/loaders/earnings_estimates.py +++ b/catalyst/pipeline/loaders/earnings_estimates.py @@ -162,6 +162,7 @@ def __init__(self, } self.name_map = name_map + self._columns = set(name_map.keys()) @abstractmethod def get_zeroth_quarter_idx(self, stacked_last_per_qtr): @@ -664,6 +665,10 @@ def load_adjusted_array(self, columns, dates, assets, mask): ) return out + @property + def columns(self): + return self._columns + def get_last_data_per_qtr(self, assets_with_data, columns, dates): """ Determine the last piece of information we know for each column on each diff --git a/catalyst/pipeline/loaders/equity_pricing_loader.py b/catalyst/pipeline/loaders/equity_pricing_loader.py index d3457364c..99c8ae007 100644 --- a/catalyst/pipeline/loaders/equity_pricing_loader.py +++ b/catalyst/pipeline/loaders/equity_pricing_loader.py @@ -95,7 +95,7 @@ def load_adjusted_array(self, columns, dates, assets, mask): c.missing_value, ) return out - + @property def columns(self): return self._columns diff --git a/catalyst/pipeline/loaders/events.py b/catalyst/pipeline/loaders/events.py index e5f3f241c..ece7b25e9 100644 --- a/catalyst/pipeline/loaders/events.py +++ b/catalyst/pipeline/loaders/events.py @@ -115,6 +115,8 @@ def __init__(self, # Columns to load with self.load_previous_events. self.previous_value_columns = previous_value_columns + self._columns = events.columns + def split_next_and_previous_event_columns(self, requested_columns): """ Split requested columns into columns that should load the next known @@ -229,3 +231,7 @@ def load_adjusted_array(self, columns, dates, sids, mask): self.load_next_events(n, dates, sids, mask), self.load_previous_events(p, dates, sids, mask), ) + + @property + def columns(self): + return self._columns diff --git a/catalyst/pipeline/loaders/frame.py b/catalyst/pipeline/loaders/frame.py index 9f4bfec5c..827c12be6 100644 --- a/catalyst/pipeline/loaders/frame.py +++ b/catalyst/pipeline/loaders/frame.py @@ -64,6 +64,8 @@ def __init__(self, column, baseline, adjustments=None): self.dates = baseline.index self.assets = baseline.columns + self._columns = self.assets + if adjustments is None: adjustments = DataFrame( index=DatetimeIndex([]), @@ -174,3 +176,8 @@ def load_adjusted_array(self, columns, dates, assets, mask): missing_value=column.missing_value, ), } + + @property + def columns(self): + return self._columns + diff --git a/catalyst/pipeline/loaders/synthetic.py b/catalyst/pipeline/loaders/synthetic.py index 8559f8044..1f88396ab 100644 --- a/catalyst/pipeline/loaders/synthetic.py +++ b/catalyst/pipeline/loaders/synthetic.py @@ -61,7 +61,9 @@ class PrecomputedLoader(PipelineLoader): """ def __init__(self, constants, dates, sids): loaders = {} + columns = [] for column, const in iteritems(constants): + columns.append(column) frame = DataFrame( const, index=dates, @@ -75,6 +77,7 @@ def __init__(self, constants, dates, sids): ) self._loaders = loaders + self._columns = set(columns) def load_adjusted_array(self, columns, dates, assets, mask): """ @@ -91,6 +94,9 @@ def load_adjusted_array(self, columns, dates, assets, mask): ) return out + def columns(self): + return self._columns + class EyeLoader(PrecomputedLoader): """ @@ -108,12 +114,17 @@ class EyeLoader(PrecomputedLoader): """ def __init__(self, columns, dates, sids): shape = (len(dates), len(sids)) + self._columns = columns super(EyeLoader, self).__init__( {column: eye(shape, dtype=column.dtype) for column in columns}, dates, sids, ) + @property + def columns(self): + return self._columns + class SeededRandomLoader(PrecomputedLoader): """ @@ -133,6 +144,7 @@ class SeededRandomLoader(PrecomputedLoader): def __init__(self, seed, columns, dates, sids): self._seed = seed + self._columns = columns super(SeededRandomLoader, self).__init__( {c: self.values(c.dtype, dates, sids) for c in columns}, dates, @@ -151,6 +163,10 @@ def values(self, dtype, dates, sids): bool_dtype: self._bool_values, object_dtype: self._object_values, }[dtype](shape) + + @property + def columns(self): + return self._columns @property def state(self): diff --git a/catalyst/pipeline/term.py b/catalyst/pipeline/term.py index 0f2c9100e..45e757051 100644 --- a/catalyst/pipeline/term.py +++ b/catalyst/pipeline/term.py @@ -428,7 +428,8 @@ class ComputableTerm(Term): A Term that should be computed from a tuple of inputs. This is the base class for :class:`catalyst.pipeline.Factor`, - :class:`catalyst.pipeline.Filter`, and :class:`catalyst.pipeline.Classifier`. + :class:`catalyst.pipeline.Filter`, and + :class:`catalyst.pipeline.Classifier`. """ inputs = NotSpecified outputs = NotSpecified diff --git a/catalyst/testing/fixtures.py b/catalyst/testing/fixtures.py index 96a2bc9d1..cd3c9b6c6 100644 --- a/catalyst/testing/fixtures.py +++ b/catalyst/testing/fixtures.py @@ -512,8 +512,8 @@ def load(*args, **kwargs): pd.DataFrame.from_csv(source_path).tz_localize('UTC') # The TradingEnvironment ordinarily uses cached benchmark returns - # and treasury curves data, but when running the catalyst tests this - # cache is not always updated to include the appropriate dates + # and treasury curves data, but when running the catalyst tests + # this cache is not always updated to include the appropriate dates # required by both the futures and equity calendars. In order to # create more reliable and consistent data throughout the entirety # of the tests, we read static benchmark returns and treasury curve @@ -1331,6 +1331,7 @@ def init_class_fixtures(cls): loader = USEquityPricingLoader( cls.bcolz_equity_daily_bar_reader, SQLiteAdjustmentReader(cls.adjustments_db_path), + USEquityPricing, ) def get_loader(column): diff --git a/catalyst/utils/calendars/calendar_utils.py b/catalyst/utils/calendars/calendar_utils.py index 38e0d429f..0e4824a79 100644 --- a/catalyst/utils/calendars/calendar_utils.py +++ b/catalyst/utils/calendars/calendar_utils.py @@ -3,17 +3,15 @@ CyclicCalendarAlias, InvalidCalendarName, ) -from catalyst.utils.calendars.exchange_calendar_open import OpenExchangeCalendar -from catalyst.utils.calendars.exchange_calendar_cfe import CFEExchangeCalendar -from catalyst.utils.calendars.exchange_calendar_ice import ICEExchangeCalendar -from catalyst.utils.calendars.exchange_calendar_nyse import NYSEExchangeCalendar -from catalyst.utils.calendars.exchange_calendar_cme import CMEExchangeCalendar -from catalyst.utils.calendars.exchange_calendar_bmf import BMFExchangeCalendar -from catalyst.utils.calendars.exchange_calendar_lse import LSEExchangeCalendar -from catalyst.utils.calendars.exchange_calendar_tsx import TSXExchangeCalendar -from catalyst.utils.calendars.us_futures_calendar import ( - QuantopianUSFuturesCalendar, -) +from .exchange_calendar_open import OpenExchangeCalendar +from .exchange_calendar_cfe import CFEExchangeCalendar +from .exchange_calendar_ice import ICEExchangeCalendar +from .exchange_calendar_nyse import NYSEExchangeCalendar +from .exchange_calendar_cme import CMEExchangeCalendar +from .exchange_calendar_bmf import BMFExchangeCalendar +from .exchange_calendar_lse import LSEExchangeCalendar +from .exchange_calendar_tsx import TSXExchangeCalendar +from .us_futures_calendar import QuantopianUSFuturesCalendar _default_calendar_factories = { 'OPEN': OpenExchangeCalendar, diff --git a/catalyst/utils/calendars/exchange_calendar_open.py b/catalyst/utils/calendars/exchange_calendar_open.py index 728fda606..bf5f8ce5f 100644 --- a/catalyst/utils/calendars/exchange_calendar_open.py +++ b/catalyst/utils/calendars/exchange_calendar_open.py @@ -15,7 +15,6 @@ def name(self): def tz(self): return timezone('US/Eastern') - @property def open_time(self): return time(0) diff --git a/catalyst/utils/events.py b/catalyst/utils/events.py index 7bb810b34..10bb2f552 100644 --- a/catalyst/utils/events.py +++ b/catalyst/utils/events.py @@ -607,8 +607,8 @@ class time_rules(object): class calendars(object): CRYPTO_ASSETS = sentinel('CRYPTO_ASSETS') - US_EQUITIES = sentinel('US_EQUITIES') - US_FUTURES = sentinel('US_FUTURES') + US_EQUITIES = sentinel('US_EQUITIES') + US_FUTURES = sentinel('US_FUTURES') def make_eventrule(date_rule, time_rule, cal, half_days=True): diff --git a/catalyst/utils/pool.py b/catalyst/utils/pool.py index b39bee2cc..6e2bc00b7 100644 --- a/catalyst/utils/pool.py +++ b/catalyst/utils/pool.py @@ -37,8 +37,8 @@ def ready(self): Notes ----- - In the :class:`~catalyst.utils.pool.SequentialPool` case, this is always - ``True``. + In the :class:`~catalyst.utils.pool.SequentialPool` case, this is + always ``True``. """ return True diff --git a/catalyst/utils/run_algo.py b/catalyst/utils/run_algo.py index eb8cb4bb7..696b8245c 100644 --- a/catalyst/utils/run_algo.py +++ b/catalyst/utils/run_algo.py @@ -19,7 +19,10 @@ from catalyst.data.data_portal import DataPortal from catalyst.finance.trading import TradingEnvironment from catalyst.pipeline.data import USEquityPricing, CryptoPricing -from catalyst.pipeline.loaders import USEquityPricingLoader, CryptoPricingLoader +from catalyst.pipeline.loaders import ( + USEquityPricingLoader, + CryptoPricingLoader, +) from catalyst.utils.calendars import get_calendar from catalyst.utils.factory import create_simulation_parameters import catalyst.utils.paths as pth @@ -123,13 +126,13 @@ def get_trading_env_and_data(bundles): return env, data elif len(bundles) == 1: b = bundles[0] - + bundle_data = load( b, environ, bundle_timestamp, ) - + prefix, connstr = re.split( r'sqlite:///', str(bundle_data.asset_finder.engine.url), @@ -173,13 +176,12 @@ def get_loader_for_bundle(b): USEquityPricing, ) raise ValueError( - "No PipelineLoader registered for column %s." % column + "No PipelineLoader registered for bundle %s." % b ) - loaders = [get_loader_for_bundle(b) for b in bundles] env, data = get_trading_env_and_data(bundles) - + def choose_loader(column): for loader in loaders: if column in loader.columns: diff --git a/tests/calendars/test_calendar_dispatcher.py b/tests/calendars/test_calendar_dispatcher.py index 0fcca97d1..abdf45a86 100644 --- a/tests/calendars/test_calendar_dispatcher.py +++ b/tests/calendars/test_calendar_dispatcher.py @@ -1,14 +1,14 @@ """ Tests for TradingCalendarDispatcher. """ -from zipline.errors import ( +from catalyst.errors import ( CalendarNameCollision, CyclicCalendarAlias, InvalidCalendarName, ) -from zipline.testing import ZiplineTestCase -from zipline.utils.calendars.calendar_utils import TradingCalendarDispatcher -from zipline.utils.calendars.exchange_calendar_ice import ICEExchangeCalendar +from catalyst.testing import ZiplineTestCase +from catalyst.utils.calendars.calendar_utils import TradingCalendarDispatcher +from catalyst.utils.calendars.exchange_calendar_ice import ICEExchangeCalendar class CalendarAliasTestCase(ZiplineTestCase): diff --git a/tests/calendars/test_cfe_calendar.py b/tests/calendars/test_cfe_calendar.py index 9c2155628..596a8675f 100644 --- a/tests/calendars/test_cfe_calendar.py +++ b/tests/calendars/test_cfe_calendar.py @@ -2,7 +2,7 @@ import pandas as pd from .test_trading_calendar import ExchangeCalendarTestBase -from zipline.utils.calendars.exchange_calendar_cfe import CFEExchangeCalendar +from catalyst.utils.calendars.exchange_calendar_cfe import CFEExchangeCalendar class CFECalendarTestCase(ExchangeCalendarTestBase, TestCase): diff --git a/tests/calendars/test_cme_calendar.py b/tests/calendars/test_cme_calendar.py index 001932498..4018959a8 100644 --- a/tests/calendars/test_cme_calendar.py +++ b/tests/calendars/test_cme_calendar.py @@ -2,7 +2,7 @@ import pandas as pd from .test_trading_calendar import ExchangeCalendarTestBase -from zipline.utils.calendars.exchange_calendar_cme import CMEExchangeCalendar +from catalyst.utils.calendars.exchange_calendar_cme import CMEExchangeCalendar class CMECalendarTestCase(ExchangeCalendarTestBase, TestCase): diff --git a/tests/calendars/test_ice_calendar.py b/tests/calendars/test_ice_calendar.py index fbc8fe2a9..45c89e861 100644 --- a/tests/calendars/test_ice_calendar.py +++ b/tests/calendars/test_ice_calendar.py @@ -2,7 +2,7 @@ import pandas as pd from .test_trading_calendar import ExchangeCalendarTestBase -from zipline.utils.calendars.exchange_calendar_ice import ICEExchangeCalendar +from catalyst.utils.calendars.exchange_calendar_ice import ICEExchangeCalendar class ICECalendarTestCase(ExchangeCalendarTestBase, TestCase): diff --git a/tests/calendars/test_nyse_calendar.py b/tests/calendars/test_nyse_calendar.py index 26bd879c5..e9d9f5b7d 100644 --- a/tests/calendars/test_nyse_calendar.py +++ b/tests/calendars/test_nyse_calendar.py @@ -2,7 +2,9 @@ import pandas as pd from .test_trading_calendar import ExchangeCalendarTestBase -from zipline.utils.calendars.exchange_calendar_nyse import NYSEExchangeCalendar +from catalyst.utils.calendars.exchange_calendar_nyse import ( + NYSEExchangeCalendar, +) class NYSECalendarTestCase(ExchangeCalendarTestBase, TestCase): diff --git a/tests/calendars/test_trading_calendar.py b/tests/calendars/test_trading_calendar.py index f463ff2db..0c34885bc 100644 --- a/tests/calendars/test_trading_calendar.py +++ b/tests/calendars/test_trading_calendar.py @@ -29,24 +29,24 @@ from pytz import timezone from toolz import concat -from zipline.errors import ( +from catalyst.errors import ( CalendarNameCollision, InvalidCalendarName, ) -from zipline.testing.predicates import assert_equal -from zipline.utils.calendars import ( +from catalyst.testing.predicates import assert_equal +from catalyst.utils.calendars import ( deregister_calendar, get_calendar, register_calendar, ) -from zipline.utils.calendars.calendar_utils import ( +from catalyst.utils.calendars.calendar_utils import ( _default_calendar_aliases, _default_calendar_factories, register_calendar_type, ) -from zipline.utils.calendars.trading_calendar import days_at_time, \ +from catalyst.utils.calendars.trading_calendar import days_at_time, \ TradingCalendar diff --git a/tests/data/bundles/test_core.py b/tests/data/bundles/test_core.py index aea7fab0e..4713795f3 100644 --- a/tests/data/bundles/test_core.py +++ b/tests/data/bundles/test_core.py @@ -5,26 +5,26 @@ import sqlalchemy as sa from toolz import valmap import toolz.curried.operator as op -from zipline.assets import ASSET_DB_VERSION +from catalyst.assets import ASSET_DB_VERSION -from zipline.assets.asset_writer import check_version_info -from zipline.assets.synthetic import make_simple_equity_info -from zipline.data.bundles import UnknownBundle, from_bundle_ingest_dirname, \ +from catalyst.assets.asset_writer import check_version_info +from catalyst.assets.synthetic import make_simple_equity_info +from catalyst.data.bundles import UnknownBundle, from_bundle_ingest_dirname, \ ingestions_for_bundle -from zipline.data.bundles.core import _make_bundle_core, BadClean, \ +from catalyst.data.bundles.core import _make_bundle_core, BadClean, \ to_bundle_ingest_dirname, asset_db_path -from zipline.lib.adjustment import Float64Multiply -from zipline.pipeline.loaders.synthetic import ( +from catalyst.lib.adjustment import Float64Multiply +from catalyst.pipeline.loaders.synthetic import ( make_bar_data, expected_bar_values_2d, ) -from zipline.testing import ( +from catalyst.testing import ( subtest, str_to_seconds, ) -from zipline.testing.fixtures import WithInstanceTmpDir, ZiplineTestCase, \ +from catalyst.testing.fixtures import WithInstanceTmpDir, ZiplineTestCase, \ WithDefaultDateBounds -from zipline.testing.predicates import ( +from catalyst.testing.predicates import ( assert_equal, assert_false, assert_in, @@ -34,10 +34,10 @@ assert_raises, assert_true, ) -from zipline.utils.cache import dataframe_cache -from zipline.utils.functional import apply -from zipline.utils.calendars import TradingCalendar, get_calendar -import zipline.utils.paths as pth +from catalyst.utils.cache import dataframe_cache +from catalyst.utils.functional import apply +from catalyst.utils.calendars import TradingCalendar, get_calendar +import catalyst.utils.paths as pth _1_ns = pd.Timedelta(1, unit='ns') diff --git a/tests/data/bundles/test_quandl.py b/tests/data/bundles/test_quandl.py index c0fa4f8b8..8425a9e05 100644 --- a/tests/data/bundles/test_quandl.py +++ b/tests/data/bundles/test_quandl.py @@ -5,23 +5,23 @@ from toolz import merge import toolz.curried.operator as op -from zipline import get_calendar -from zipline.data.bundles import ingest, load, bundles -from zipline.data.bundles.quandl import ( +from catalyst import get_calendar +from catalyst.data.bundles import ingest, load, bundles +from catalyst.data.bundles.quandl import ( format_wiki_url, format_metadata_url, ) -from zipline.lib.adjustment import Float64Multiply -from zipline.testing import ( +from catalyst.lib.adjustment import Float64Multiply +from catalyst.testing import ( test_resource_path, tmp_dir, patch_read_csv, ) -from zipline.testing.fixtures import ZiplineTestCase -from zipline.testing.predicates import ( +from catalyst.testing.fixtures import ZiplineTestCase +from catalyst.testing.predicates import ( assert_equal, ) -from zipline.utils.functional import apply +from catalyst.utils.functional import apply class QuandlBundleTestCase(ZiplineTestCase): @@ -202,9 +202,9 @@ def test_bundle(self): for n in (1, 2) }, ) - zipline_root = self.enter_instance_context(tmp_dir()).path + catalyst_root = self.enter_instance_context(tmp_dir()).path environ = { - 'ZIPLINE_ROOT': zipline_root, + 'ZIPLINE_ROOT': catalyst_root, 'QUANDL_API_KEY': self.api_key, } diff --git a/tests/data/bundles/test_yahoo.py b/tests/data/bundles/test_yahoo.py index e3d258020..7bc0ada4f 100644 --- a/tests/data/bundles/test_yahoo.py +++ b/tests/data/bundles/test_yahoo.py @@ -6,13 +6,13 @@ from toolz import flip, identity from toolz.curried import merge_with, operator as op -from zipline.data.bundles.core import _make_bundle_core -from zipline.data.bundles import yahoo_equities -from zipline.lib.adjustment import Float64Multiply -from zipline.testing import test_resource_path, tmp_dir, read_compressed -from zipline.testing.fixtures import WithResponses, ZiplineTestCase -from zipline.testing.predicates import assert_equal -from zipline.utils.calendars import get_calendar +from catalyst.data.bundles.core import _make_bundle_core +from catalyst.data.bundles import yahoo_equities +from catalyst.lib.adjustment import Float64Multiply +from catalyst.testing import test_resource_path, tmp_dir, read_compressed +from catalyst.testing.fixtures import WithResponses, ZiplineTestCase +from catalyst.testing.predicates import assert_equal +from catalyst.utils.calendars import get_calendar class YahooBundleTestCase(WithResponses, ZiplineTestCase): @@ -162,9 +162,9 @@ def adjustments_callback(request): end_session=self.asset_end, ) - zipline_root = self.enter_instance_context(tmp_dir()).path + catalyst_root = self.enter_instance_context(tmp_dir()).path environ = { - 'ZIPLINE_ROOT': zipline_root, + 'ZIPLINE_ROOT': catalyst_root, } self.ingest('bundle', environ=environ, show_progress=False) diff --git a/tests/data/test_dispatch_bar_reader.py b/tests/data/test_dispatch_bar_reader.py index cc05bcd03..5887480c1 100644 --- a/tests/data/test_dispatch_bar_reader.py +++ b/tests/data/test_dispatch_bar_reader.py @@ -15,18 +15,18 @@ from numpy.testing import assert_almost_equal from pandas import DataFrame, Timestamp -from zipline.assets import Equity, Future +from catalyst.assets import Equity, Future -from zipline.data.dispatch_bar_reader import ( +from catalyst.data.dispatch_bar_reader import ( AssetDispatchMinuteBarReader, AssetDispatchSessionBarReader, ) -from zipline.data.resample import ( +from catalyst.data.resample import ( MinuteResampleSessionBarReader, ReindexMinuteBarReader, ReindexSessionBarReader, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithBcolzEquityMinuteBarReader, WithBcolzEquityDailyBarReader, WithBcolzFutureMinuteBarReader, diff --git a/tests/data/test_minute_bars.py b/tests/data/test_minute_bars.py index a801296aa..135bf84b5 100644 --- a/tests/data/test_minute_bars.py +++ b/tests/data/test_minute_bars.py @@ -35,8 +35,8 @@ date_range, ) -from zipline.data.bar_reader import NoDataOnDate -from zipline.data.minute_bars import ( +from catalyst.data.bar_reader import NoDataOnDate +from catalyst.data.minute_bars import ( BcolzMinuteBarMetadata, BcolzMinuteBarWriter, BcolzMinuteBarReader, @@ -47,7 +47,7 @@ H5MinuteBarUpdateReader, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithAssetFinder, WithInstanceTmpDir, WithTradingCalendars, diff --git a/tests/data/test_resample.py b/tests/data/test_resample.py index 4829189e9..fd8d3948e 100644 --- a/tests/data/test_resample.py +++ b/tests/data/test_resample.py @@ -21,7 +21,7 @@ from pandas import DataFrame from six import iteritems -from zipline.data.resample import ( +from catalyst.data.resample import ( minute_frame_to_session_frame, DailyHistoryAggregator, MinuteResampleSessionBarReader, @@ -29,8 +29,8 @@ ReindexSessionBarReader, ) -from zipline.testing import parameter_space -from zipline.testing.fixtures import ( +from catalyst.testing import parameter_space +from catalyst.testing.fixtures import ( WithEquityMinuteBarData, WithBcolzEquityMinuteBarReader, WithBcolzEquityDailyBarReader, diff --git a/tests/data/test_us_equity_pricing.py b/tests/data/test_us_equity_pricing.py index c56d8df70..77e5bba9d 100644 --- a/tests/data/test_us_equity_pricing.py +++ b/tests/data/test_us_equity_pricing.py @@ -30,13 +30,13 @@ ) from pandas.util.testing import assert_index_equal -from zipline.data.us_equity_pricing import ( +from catalyst.data.us_equity_pricing import ( BcolzDailyBarReader, BcolzDailyBarWriter, NoDataBeforeDate, NoDataAfterDate, ) -from zipline.pipeline.loaders.synthetic import ( +from catalyst.pipeline.loaders.synthetic import ( OHLCV, asset_start, asset_end, @@ -44,15 +44,15 @@ expected_bar_values_2d, make_bar_data, ) -from zipline.testing import seconds_to_timestamp -from zipline.testing.fixtures import ( +from catalyst.testing import seconds_to_timestamp +from catalyst.testing.fixtures import ( WithAssetFinder, WithBcolzEquityDailyBarReader, WithTmpDir, WithTradingCalendars, ZiplineTestCase, ) -from zipline.utils.calendars import get_calendar +from catalyst.utils.calendars import get_calendar TEST_CALENDAR_START = Timestamp('2015-06-01', tz='UTC') TEST_CALENDAR_STOP = Timestamp('2015-06-30', tz='UTC') diff --git a/tests/events/test_events.py b/tests/events/test_events.py index d5573c60d..8445440de 100644 --- a/tests/events/test_events.py +++ b/tests/events/test_events.py @@ -23,9 +23,9 @@ from six import iteritems from six.moves import range, map -import zipline.utils.events -from zipline.utils.calendars import get_calendar -from zipline.utils.events import ( +import catalyst.utils.events +from catalyst.utils.calendars import get_calendar +from catalyst.utils.events import ( EventRule, StatelessRule, Always, @@ -248,7 +248,7 @@ def test_completeness(self): classes_to_ignore = [TradingDayOfWeekRule, TradingDayOfMonthRule] dem = { - k for k, v in iteritems(vars(zipline.utils.events)) + k for k, v in iteritems(vars(catalyst.utils.events)) if isinstance(v, type) and issubclass(v, self.class_) and v is not self.class_ and diff --git a/tests/events/test_events_cme.py b/tests/events/test_events_cme.py index b6e12efcd..5db5ad8ef 100644 --- a/tests/events/test_events_cme.py +++ b/tests/events/test_events_cme.py @@ -17,7 +17,7 @@ from test_events import StatefulRulesTests, StatelessRulesTests, \ minutes_for_days -from zipline.utils.events import AfterOpen +from catalyst.utils.events import AfterOpen class TestStatelessRulesCME(StatelessRulesTests, TestCase): diff --git a/tests/events/test_events_nyse.py b/tests/events/test_events_nyse.py index ac2e90873..2cd1f89a9 100644 --- a/tests/events/test_events_nyse.py +++ b/tests/events/test_events_nyse.py @@ -17,10 +17,10 @@ import pandas as pd from nose_parameterized import parameterized -from zipline.testing import parameter_space -from zipline.utils.events import NDaysBeforeLastTradingDayOfWeek, AfterOpen, \ +from catalyst.testing import parameter_space +from catalyst.utils.events import NDaysBeforeLastTradingDayOfWeek, AfterOpen, \ BeforeClose -from zipline.utils.events import NthTradingDayOfWeek +from catalyst.utils.events import NthTradingDayOfWeek from test_events import StatelessRulesTests, StatefulRulesTests, \ minutes_for_days diff --git a/tests/finance/test_blotter.py b/tests/finance/test_blotter.py index 9c39115a0..499ac6fc3 100644 --- a/tests/finance/test_blotter.py +++ b/tests/finance/test_blotter.py @@ -16,30 +16,30 @@ import pandas as pd -from zipline.assets import Equity -from zipline.finance.blotter import Blotter -from zipline.finance.cancel_policy import EODCancel, NeverCancel -from zipline.finance.commission import PerTrade -from zipline.finance.execution import ( +from catalyst.assets import Equity +from catalyst.finance.blotter import Blotter +from catalyst.finance.cancel_policy import EODCancel, NeverCancel +from catalyst.finance.commission import PerTrade +from catalyst.finance.execution import ( LimitOrder, MarketOrder, StopLimitOrder, StopOrder, ) -from zipline.finance.order import ORDER_STATUS, Order -from zipline.finance.slippage import ( +from catalyst.finance.order import ORDER_STATUS, Order +from catalyst.finance.slippage import ( DEFAULT_EQUITY_VOLUME_SLIPPAGE_BAR_LIMIT, FixedSlippage, ) -from zipline.gens.sim_engine import BAR, SESSION_END -from zipline.testing.fixtures import ( +from catalyst.gens.sim_engine import BAR, SESSION_END +from catalyst.testing.fixtures import ( WithCreateBarData, WithDataPortal, WithLogger, WithSimParams, ZiplineTestCase, ) -from zipline.utils.classproperty import classproperty +from catalyst.utils.classproperty import classproperty class BlotterTestCase(WithCreateBarData, diff --git a/tests/finance/test_cancel_policy.py b/tests/finance/test_cancel_policy.py index 5a199bf7a..b25363067 100644 --- a/tests/finance/test_cancel_policy.py +++ b/tests/finance/test_cancel_policy.py @@ -14,8 +14,8 @@ # limitations under the License. from unittest import TestCase -from zipline.finance.cancel_policy import NeverCancel, EODCancel -from zipline.gens.sim_engine import ( +from catalyst.finance.cancel_policy import NeverCancel, EODCancel +from catalyst.gens.sim_engine import ( BAR, SESSION_END ) diff --git a/tests/finance/test_commissions.py b/tests/finance/test_commissions.py index 033098550..d2f82e9d2 100644 --- a/tests/finance/test_commissions.py +++ b/tests/finance/test_commissions.py @@ -4,10 +4,10 @@ from nose_parameterized import parameterized from pandas import DataFrame -from zipline import TradingAlgorithm -from zipline.assets import Equity, Future -from zipline.errors import IncompatibleCommissionModel -from zipline.finance.commission import ( +from catalyst import TradingAlgorithm +from catalyst.assets import Equity, Future +from catalyst.errors import IncompatibleCommissionModel +from catalyst.finance.commission import ( CommissionModel, EquityCommissionModel, FutureCommissionModel, @@ -17,15 +17,15 @@ PerShare, PerTrade, ) -from zipline.finance.order import Order -from zipline.finance.transaction import Transaction -from zipline.testing import ZiplineTestCase, trades_by_sid_to_dfs -from zipline.testing.fixtures import ( +from catalyst.finance.order import Order +from catalyst.finance.transaction import Transaction +from catalyst.testing import ZiplineTestCase, trades_by_sid_to_dfs +from catalyst.testing.fixtures import ( WithAssetFinder, WithSimParams, WithDataPortal ) -from zipline.utils import factory +from catalyst.utils import factory class CommissionUnitTests(WithAssetFinder, ZiplineTestCase): @@ -279,7 +279,7 @@ class CommissionAlgorithmTests(WithDataPortal, WithSimParams, ZiplineTestCase): code = dedent( """ - from zipline.api import ( + from catalyst.api import ( sid, order, set_slippage, slippage, FixedSlippage, set_commission, commission ) diff --git a/tests/finance/test_slippage.py b/tests/finance/test_slippage.py index 59ed13b85..1101928a3 100644 --- a/tests/finance/test_slippage.py +++ b/tests/finance/test_slippage.py @@ -26,11 +26,11 @@ import pandas as pd import pytz -from zipline.assets import Equity, Future -from zipline.data.data_portal import DataPortal -from zipline.finance.asset_restrictions import NoRestrictions -from zipline.finance.order import Order -from zipline.finance.slippage import ( +from catalyst.assets import Equity, Future +from catalyst.data.data_portal import DataPortal +from catalyst.finance.asset_restrictions import NoRestrictions +from catalyst.finance.order import Order +from catalyst.finance.slippage import ( EquitySlippageModel, fill_price_worse_than_limit_price, FutureSlippageModel, @@ -38,19 +38,19 @@ VolatilityVolumeShare, VolumeShareSlippage, ) -from zipline.protocol import DATASOURCE_TYPE, BarData -from zipline.testing import ( +from catalyst.protocol import DATASOURCE_TYPE, BarData +from catalyst.testing import ( create_minute_bar_data, tmp_bcolz_equity_minute_bar_reader, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithCreateBarData, WithDataPortal, WithSimParams, WithTradingEnvironment, ZiplineTestCase, ) -from zipline.utils.classproperty import classproperty +from catalyst.utils.classproperty import classproperty TestOrder = namedtuple('TestOrder', 'limit direction') diff --git a/tests/finance/test_transaction.py b/tests/finance/test_transaction.py index 161fa80bd..000b7797e 100644 --- a/tests/finance/test_transaction.py +++ b/tests/finance/test_transaction.py @@ -15,8 +15,8 @@ import pandas as pd from unittest import TestCase -from zipline.assets import Equity -from zipline.finance.transaction import Transaction +from catalyst.assets import Equity +from catalyst.finance.transaction import Transaction class TransactionTestCase(TestCase): diff --git a/tests/history/generate_csvs.py b/tests/history/generate_csvs.py index 6ce8de94f..cdf4fdfde 100644 --- a/tests/history/generate_csvs.py +++ b/tests/history/generate_csvs.py @@ -17,8 +17,8 @@ import numpy as np import pandas as pd -from zipline.finance.trading import TradingEnvironment -from zipline.data.us_equity_minutes import BcolzMinuteBarWriter +from catalyst.finance.trading import TradingEnvironment +from catalyst.data.us_equity_minutes import BcolzMinuteBarWriter def generate_daily_test_data(first_day, diff --git a/tests/pipeline/base.py b/tests/pipeline/base.py index 98de5aee0..b3c862e79 100644 --- a/tests/pipeline/base.py +++ b/tests/pipeline/base.py @@ -8,21 +8,21 @@ from pandas import DataFrame, Timestamp from six import iteritems -from zipline.pipeline.engine import SimplePipelineEngine -from zipline.pipeline import ExecutionPlan -from zipline.pipeline.term import AssetExists, InputDates -from zipline.testing import ( +from catalyst.pipeline.engine import SimplePipelineEngine +from catalyst.pipeline import ExecutionPlan +from catalyst.pipeline.term import AssetExists, InputDates +from catalyst.testing import ( check_arrays, ExplodingObject, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithAssetFinder, WithTradingSessions, ZiplineTestCase, ) -from zipline.utils.functional import dzip_exact -from zipline.utils.pandas_utils import explode +from catalyst.utils.functional import dzip_exact +from catalyst.utils.pandas_utils import explode def with_defaults(**default_funcs): @@ -80,7 +80,7 @@ def run_graph(self, graph, initial_workspace, mask=None): Parameters ---------- - graph : zipline.pipeline.graph.TermGraph + graph : catalyst.pipeline.graph.TermGraph Graph to run. initial_workspace : dict Initial workspace to forward to SimplePipelineEngine.compute_chunk. diff --git a/tests/pipeline/test_adjusted_array.py b/tests/pipeline/test_adjusted_array.py index f7c94a70e..0da3dc43a 100644 --- a/tests/pipeline/test_adjusted_array.py +++ b/tests/pipeline/test_adjusted_array.py @@ -18,8 +18,8 @@ from six.moves import zip_longest from toolz import curry -from zipline.errors import WindowLengthNotPositive, WindowLengthTooLong -from zipline.lib.adjustment import ( +from catalyst.errors import WindowLengthNotPositive, WindowLengthTooLong +from catalyst.lib.adjustment import ( Datetime64Overwrite, Datetime641DArrayOverwrite, Float64Multiply, @@ -28,11 +28,11 @@ Int64Overwrite, ObjectOverwrite, ) -from zipline.lib.adjusted_array import AdjustedArray, NOMASK -from zipline.lib.labelarray import LabelArray -from zipline.testing import check_arrays, parameter_space -from zipline.utils.compat import unicode -from zipline.utils.numpy_utils import ( +from catalyst.lib.adjusted_array import AdjustedArray, NOMASK +from catalyst.lib.labelarray import LabelArray +from catalyst.testing import check_arrays, parameter_space +from catalyst.utils.compat import unicode +from catalyst.utils.numpy_utils import ( coerce_to_dtype, datetime64ns_dtype, default_missing_value_for_dtype, diff --git a/tests/pipeline/test_adjustment.py b/tests/pipeline/test_adjustment.py index 9e31041e6..231ed4668 100644 --- a/tests/pipeline/test_adjustment.py +++ b/tests/pipeline/test_adjustment.py @@ -1,11 +1,11 @@ """ -Tests for zipline.lib.adjustment +Tests for catalyst.lib.adjustment """ from unittest import TestCase from nose_parameterized import parameterized -from zipline.lib import adjustment as adj -from zipline.utils.numpy_utils import make_datetime64ns +from catalyst.lib import adjustment as adj +from catalyst.utils.numpy_utils import make_datetime64ns class AdjustmentTestCase(TestCase): diff --git a/tests/pipeline/test_alias.py b/tests/pipeline/test_alias.py index bdc68675a..70f860f4e 100644 --- a/tests/pipeline/test_alias.py +++ b/tests/pipeline/test_alias.py @@ -1,9 +1,9 @@ from nose.tools import nottest import numpy as np -from zipline.testing.predicates import assert_equal -from zipline.pipeline import Classifier, Factor, Filter -from zipline.utils.numpy_utils import float64_dtype, int64_dtype +from catalyst.testing.predicates import assert_equal +from catalyst.pipeline import Classifier, Factor, Filter +from catalyst.utils.numpy_utils import float64_dtype, int64_dtype from .base import BasePipelineTestCase diff --git a/tests/pipeline/test_blaze.py b/tests/pipeline/test_blaze.py index 3f5f7e081..07f0b2d68 100644 --- a/tests/pipeline/test_blaze.py +++ b/tests/pipeline/test_blaze.py @@ -19,28 +19,28 @@ from toolz import keymap, valmap, concatv from toolz.curried import operator as op -from zipline.assets.synthetic import make_simple_equity_info -from zipline.errors import UnsupportedPipelineOutput -from zipline.pipeline import Pipeline, CustomFactor -from zipline.pipeline.data import DataSet, BoundColumn, Column -from zipline.pipeline.engine import SimplePipelineEngine -from zipline.pipeline.loaders.blaze import ( +from catalyst.assets.synthetic import make_simple_equity_info +from catalyst.errors import UnsupportedPipelineOutput +from catalyst.pipeline import Pipeline, CustomFactor +from catalyst.pipeline.data import DataSet, BoundColumn, Column +from catalyst.pipeline.engine import SimplePipelineEngine +from catalyst.pipeline.loaders.blaze import ( from_blaze, BlazeLoader, NoMetaDataWarning, ) -from zipline.pipeline.loaders.blaze.core import ( +from catalyst.pipeline.loaders.blaze.core import ( ExprData, NonPipelineField, ) -from zipline.testing import ( +from catalyst.testing import ( ZiplineTestCase, parameter_space, tmp_asset_finder, ) -from zipline.testing.fixtures import WithAssetFinder -from zipline.testing.predicates import assert_equal, assert_isidentical -from zipline.utils.numpy_utils import float64_dtype, int64_dtype +from catalyst.testing.fixtures import WithAssetFinder +from catalyst.testing.predicates import assert_equal, assert_isidentical +from catalyst.utils.numpy_utils import float64_dtype, int64_dtype nameof = op.attrgetter('name') diff --git a/tests/pipeline/test_classifier.py b/tests/pipeline/test_classifier.py index fa47df878..43615b37b 100644 --- a/tests/pipeline/test_classifier.py +++ b/tests/pipeline/test_classifier.py @@ -4,12 +4,12 @@ import numpy as np import pandas as pd -from zipline.lib.labelarray import LabelArray -from zipline.pipeline import Classifier -from zipline.testing import parameter_space -from zipline.testing.fixtures import ZiplineTestCase -from zipline.testing.predicates import assert_equal -from zipline.utils.numpy_utils import ( +from catalyst.lib.labelarray import LabelArray +from catalyst.pipeline import Classifier +from catalyst.testing import parameter_space +from catalyst.testing.fixtures import ZiplineTestCase +from catalyst.testing.predicates import assert_equal +from catalyst.utils.numpy_utils import ( categorical_dtype, int64_dtype, ) diff --git a/tests/pipeline/test_column.py b/tests/pipeline/test_column.py index 99b8b5d78..67db39e7c 100644 --- a/tests/pipeline/test_column.py +++ b/tests/pipeline/test_column.py @@ -7,11 +7,11 @@ from pandas import date_range, DataFrame from pandas.util.testing import assert_frame_equal -from zipline.lib.labelarray import LabelArray -from zipline.pipeline import Pipeline -from zipline.pipeline.data.testing import TestingDataSet as TDS -from zipline.testing import chrange, temp_pipeline_engine -from zipline.utils.pandas_utils import ignore_pandas_nan_categorical_warning +from catalyst.lib.labelarray import LabelArray +from catalyst.pipeline import Pipeline +from catalyst.pipeline.data.testing import TestingDataSet as TDS +from catalyst.testing import chrange, temp_pipeline_engine +from catalyst.utils.pandas_utils import ignore_pandas_nan_categorical_warning class LatestTestCase(TestCase): diff --git a/tests/pipeline/test_downsampling.py b/tests/pipeline/test_downsampling.py index 56344051e..1068527dc 100644 --- a/tests/pipeline/test_downsampling.py +++ b/tests/pipeline/test_downsampling.py @@ -4,22 +4,22 @@ import pandas as pd from pandas.util.testing import assert_frame_equal -from zipline.pipeline import ( +from catalyst.pipeline import ( Pipeline, CustomFactor, CustomFilter, CustomClassifier, ) -from zipline.pipeline.data.testing import TestingDataSet -from zipline.pipeline.factors import SimpleMovingAverage -from zipline.pipeline.filters.smoothing import All -from zipline.testing import ZiplineTestCase, parameter_space -from zipline.testing.fixtures import ( +from catalyst.pipeline.data.testing import TestingDataSet +from catalyst.pipeline.factors.equity import SimpleMovingAverage +from catalyst.pipeline.filters.smoothing import All +from catalyst.testing import ZiplineTestCase, parameter_space +from catalyst.testing.fixtures import ( WithTradingSessions, WithSeededRandomPipelineEngine, ) -from zipline.utils.input_validation import _qualified_name -from zipline.utils.numpy_utils import int64_dtype +from catalyst.utils.input_validation import _qualified_name +from catalyst.utils.numpy_utils import int64_dtype class NDaysAgoFactor(CustomFactor): diff --git a/tests/pipeline/test_engine.py b/tests/pipeline/test_engine.py index b1e389200..dae79f2ba 100644 --- a/tests/pipeline/test_engine.py +++ b/tests/pipeline/test_engine.py @@ -36,15 +36,15 @@ from six import iteritems, itervalues from toolz import merge -from zipline.assets.synthetic import make_rotating_equity_info -from zipline.errors import NoFurtherDataError -from zipline.lib.adjustment import MULTIPLY -from zipline.lib.labelarray import LabelArray -from zipline.pipeline import CustomFactor, Pipeline -from zipline.pipeline.data import Column, DataSet, USEquityPricing -from zipline.pipeline.data.testing import TestingDataSet -from zipline.pipeline.engine import SimplePipelineEngine -from zipline.pipeline.factors import ( +from catalyst.assets.synthetic import make_rotating_equity_info +from catalyst.errors import NoFurtherDataError +from catalyst.lib.adjustment import MULTIPLY +from catalyst.lib.labelarray import LabelArray +from catalyst.pipeline import CustomFactor, Pipeline +from catalyst.pipeline.data import Column, DataSet, USEquityPricing +from catalyst.pipeline.data.testing import TestingDataSet +from catalyst.pipeline.engine import SimplePipelineEngine +from catalyst.pipeline.factors.equity import ( AverageDollarVolume, EWMA, EWMSTD, @@ -54,18 +54,18 @@ Returns, SimpleMovingAverage, ) -from zipline.pipeline.loaders.equity_pricing_loader import ( +from catalyst.pipeline.loaders.equity_pricing_loader import ( USEquityPricingLoader, ) -from zipline.pipeline.loaders.frame import DataFrameLoader -from zipline.pipeline.loaders.synthetic import ( +from catalyst.pipeline.loaders.frame import DataFrameLoader +from catalyst.pipeline.loaders.synthetic import ( PrecomputedLoader, make_bar_data, expected_bar_values_2d, ) -from zipline.pipeline.sentinels import NotSpecified -from zipline.pipeline.term import InputDates -from zipline.testing import ( +from catalyst.pipeline.sentinels import NotSpecified +from catalyst.pipeline.term import InputDates +from catalyst.testing import ( AssetID, AssetIDPlusDay, ExplodingObject, @@ -76,16 +76,16 @@ parameter_space, product_upper_triangle, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithAdjustmentReader, WithEquityPricingPipelineEngine, WithSeededRandomPipelineEngine, WithTradingEnvironment, ZiplineTestCase, ) -from zipline.testing.predicates import assert_equal -from zipline.utils.memoize import lazyval -from zipline.utils.numpy_utils import bool_dtype, datetime64ns_dtype +from catalyst.testing.predicates import assert_equal +from catalyst.utils.memoize import lazyval +from catalyst.utils.numpy_utils import bool_dtype, datetime64ns_dtype class RollingSumDifference(CustomFactor): @@ -952,6 +952,7 @@ def init_class_fixtures(cls): cls.pipeline_loader = USEquityPricingLoader( cls.bcolz_equity_daily_bar_reader, cls.adjustment_reader, + USEquityPricing, ) def write_nans(self, df): diff --git a/tests/pipeline/test_events.py b/tests/pipeline/test_events.py index 85c85d518..b80bd47a2 100644 --- a/tests/pipeline/test_events.py +++ b/tests/pipeline/test_events.py @@ -10,27 +10,27 @@ import numpy as np import pandas as pd -from zipline.pipeline import Pipeline, SimplePipelineEngine -from zipline.pipeline.common import ( +from catalyst.pipeline import Pipeline, SimplePipelineEngine +from catalyst.pipeline.common import ( EVENT_DATE_FIELD_NAME, TS_FIELD_NAME, SID_FIELD_NAME, ) -from zipline.pipeline.data import DataSet, Column -from zipline.pipeline.loaders.events import EventsLoader -from zipline.pipeline.loaders.blaze.events import BlazeEventsLoader -from zipline.pipeline.loaders.utils import ( +from catalyst.pipeline.data import DataSet, Column +from catalyst.pipeline.loaders.events import EventsLoader +from catalyst.pipeline.loaders.blaze.events import BlazeEventsLoader +from catalyst.pipeline.loaders.utils import ( next_event_indexer, normalize_timestamp_to_query_time, previous_event_indexer, ) -from zipline.testing import check_arrays, ZiplineTestCase -from zipline.testing.fixtures import ( +from catalyst.testing import check_arrays, ZiplineTestCase +from catalyst.testing.fixtures import ( WithAssetFinder, WithTradingSessions, ) -from zipline.testing.predicates import assert_equal -from zipline.utils.numpy_utils import ( +from catalyst.testing.predicates import assert_equal +from catalyst.utils.numpy_utils import ( categorical_dtype, datetime64ns_dtype, float64_dtype, diff --git a/tests/pipeline/test_factor.py b/tests/pipeline/test_factor.py index f6d4ba922..df500b77d 100644 --- a/tests/pipeline/test_factor.py +++ b/tests/pipeline/test_factor.py @@ -24,32 +24,32 @@ import pandas as pd from scipy.stats.mstats import winsorize as scipy_winsorize -from zipline.errors import BadPercentileBounds, UnknownRankMethod -from zipline.lib.labelarray import LabelArray -from zipline.lib.rank import masked_rankdata_2d -from zipline.lib.normalize import naive_grouped_rowwise_apply as grouped_apply -from zipline.pipeline import Classifier, Factor, Filter -from zipline.pipeline.factors import ( - CustomFactor, +from catalyst.errors import BadPercentileBounds, UnknownRankMethod +from catalyst.lib.labelarray import LabelArray +from catalyst.lib.rank import masked_rankdata_2d +from catalyst.lib.normalize import naive_grouped_rowwise_apply as grouped_apply +from catalyst.pipeline import Classifier, Factor, Filter +from catalyst.pipeline.factors import CustomFactor +from catalyst.pipeline.factors.equity import ( Returns, RSI, ) -from zipline.testing import ( +from catalyst.testing import ( check_allclose, check_arrays, parameter_space, permute_rows, ) -from zipline.testing.fixtures import ZiplineTestCase -from zipline.testing.predicates import assert_equal -from zipline.utils.numpy_utils import ( +from catalyst.testing.fixtures import ZiplineTestCase +from catalyst.testing.predicates import assert_equal +from catalyst.utils.numpy_utils import ( categorical_dtype, datetime64ns_dtype, float64_dtype, int64_dtype, NaTns, ) -from zipline.utils.math_utils import nanmean, nanstd +from catalyst.utils.math_utils import nanmean, nanstd from .base import BasePipelineTestCase diff --git a/tests/pipeline/test_filter.py b/tests/pipeline/test_filter.py index 2ec4e183c..d67423487 100644 --- a/tests/pipeline/test_filter.py +++ b/tests/pipeline/test_filter.py @@ -26,21 +26,21 @@ from numpy.random import randn, seed as random_seed import pandas as pd -from zipline.errors import BadPercentileBounds -from zipline.pipeline import Filter, Factor, Pipeline -from zipline.pipeline.classifiers import Classifier -from zipline.pipeline.factors import CustomFactor -from zipline.pipeline.filters import ( +from catalyst.errors import BadPercentileBounds +from catalyst.pipeline import Filter, Factor, Pipeline +from catalyst.pipeline.classifiers import Classifier +from catalyst.pipeline.factors import CustomFactor +from catalyst.pipeline.filters import ( All, Any, AtLeastN, StaticAssets, StaticSids, ) -from zipline.testing import parameter_space, permute_rows, ZiplineTestCase -from zipline.testing.fixtures import WithSeededRandomPipelineEngine -from zipline.testing.predicates import assert_equal -from zipline.utils.numpy_utils import float64_dtype, int64_dtype +from catalyst.testing import parameter_space, permute_rows, ZiplineTestCase +from catalyst.testing.fixtures import WithSeededRandomPipelineEngine +from catalyst.testing.predicates import assert_equal +from catalyst.utils.numpy_utils import float64_dtype, int64_dtype from .base import BasePipelineTestCase, with_default_shape diff --git a/tests/pipeline/test_frameload.py b/tests/pipeline/test_frameload.py index 57ec20914..4985041df 100644 --- a/tests/pipeline/test_frameload.py +++ b/tests/pipeline/test_frameload.py @@ -1,5 +1,5 @@ """ -Tests for zipline.pipeline.loaders.frame.DataFrameLoader. +Tests for catalyst.pipeline.loaders.frame.DataFrameLoader. """ from unittest import TestCase @@ -12,7 +12,7 @@ Int64Index, ) -from zipline.lib.adjustment import ( +from catalyst.lib.adjustment import ( ADD, Float64Add, Float64Multiply, @@ -20,11 +20,11 @@ MULTIPLY, OVERWRITE, ) -from zipline.pipeline.data import USEquityPricing -from zipline.pipeline.loaders.frame import ( +from catalyst.pipeline.data import USEquityPricing +from catalyst.pipeline.loaders.frame import ( DataFrameLoader, ) -from zipline.utils.calendars import get_calendar +from catalyst.utils.calendars import get_calendar class DataFrameLoaderTestCase(TestCase): @@ -228,7 +228,7 @@ def test_adjustments(self): self.assertEqual(formatted_adjustments, expected_formatted_adjustments) mask = self.mask[dates_slice, sids_slice] - with patch('zipline.pipeline.loaders.frame.AdjustedArray') as m: + with patch('catalyst.pipeline.loaders.frame.AdjustedArray') as m: loader.load_adjusted_array( columns=[USEquityPricing.close], dates=self.dates[dates_slice], diff --git a/tests/pipeline/test_numerical_expression.py b/tests/pipeline/test_numerical_expression.py index 9922004db..912862b5f 100644 --- a/tests/pipeline/test_numerical_expression.py +++ b/tests/pipeline/test_numerical_expression.py @@ -29,13 +29,13 @@ Int64Index, ) -from zipline.pipeline import Factor, Filter -from zipline.pipeline.expression import ( +from catalyst.pipeline import Factor, Filter +from catalyst.pipeline.expression import ( NumericalExpression, NUMEXPR_MATH_FUNCS, ) -from zipline.testing import check_allclose -from zipline.utils.numpy_utils import datetime64ns_dtype, float64_dtype +from catalyst.testing import check_allclose +from catalyst.utils.numpy_utils import datetime64ns_dtype, float64_dtype class F(Factor): diff --git a/tests/pipeline/test_pipeline.py b/tests/pipeline/test_pipeline.py index 30d9014c2..b00a01949 100644 --- a/tests/pipeline/test_pipeline.py +++ b/tests/pipeline/test_pipeline.py @@ -1,15 +1,15 @@ """ -Tests for zipline.pipeline.Pipeline +Tests for catalyst.pipeline.Pipeline """ import inspect from unittest import TestCase from mock import patch -from zipline.pipeline import Factor, Filter, Pipeline -from zipline.pipeline.data import USEquityPricing -from zipline.pipeline.graph import display_graph -from zipline.utils.numpy_utils import float64_dtype +from catalyst.pipeline import Factor, Filter, Pipeline +from catalyst.pipeline.data import USEquityPricing +from catalyst.pipeline.graph import display_graph +from catalyst.utils.numpy_utils import float64_dtype class SomeFactor(Factor): @@ -159,7 +159,7 @@ def mock_display_graph(g, format='svg', include_asset_exists=False): ) patch_display_graph = patch( - 'zipline.pipeline.graph.display_graph', + 'catalyst.pipeline.graph.display_graph', mock_display_graph, ) diff --git a/tests/pipeline/test_pipeline_algo.py b/tests/pipeline/test_pipeline_algo.py index 4721236ee..eca132ba4 100644 --- a/tests/pipeline/test_pipeline_algo.py +++ b/tests/pipeline/test_pipeline_algo.py @@ -30,42 +30,42 @@ from pandas.tseries.tools import normalize_date from six import iteritems, itervalues -from zipline.algorithm import TradingAlgorithm -from zipline.api import ( +from catalyst.algorithm import TradingAlgorithm +from catalyst.api import ( attach_pipeline, pipeline_output, get_datetime, ) -from zipline.errors import ( +from catalyst.errors import ( AttachPipelineAfterInitialize, PipelineOutputDuringInitialize, NoSuchPipeline, ) -from zipline.lib.adjustment import MULTIPLY -from zipline.pipeline import Pipeline -from zipline.pipeline.factors import VWAP -from zipline.pipeline.data import USEquityPricing -from zipline.pipeline.loaders.frame import DataFrameLoader -from zipline.pipeline.loaders.equity_pricing_loader import ( +from catalyst.lib.adjustment import MULTIPLY +from catalyst.pipeline import Pipeline +from catalyst.pipeline.factors.equity import VWAP +from catalyst.pipeline.data import USEquityPricing +from catalyst.pipeline.loaders.frame import DataFrameLoader +from catalyst.pipeline.loaders.equity_pricing_loader import ( USEquityPricingLoader, ) -from zipline.testing import ( +from catalyst.testing import ( str_to_seconds ) -from zipline.testing import ( +from catalyst.testing import ( create_empty_splits_mergers_frame, FakeDataPortal, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithAdjustmentReader, WithBcolzEquityDailyBarReaderFromCSVs, WithDataPortal, ZiplineTestCase, ) -from zipline.utils.calendars import get_calendar +from catalyst.utils.calendars import get_calendar TEST_RESOURCE_PATH = join( - dirname(dirname(realpath(__file__))), # zipline_repo/tests + dirname(dirname(realpath(__file__))), # catalyst_repo/tests 'resources', 'pipeline_inputs', ) @@ -375,7 +375,7 @@ def make_equity_daily_bar_data(cls): asset: read_csv(path, parse_dates=['day']).set_index('day') for asset, path in resources.items() } - # Add 'price' column as an alias because all kinds of stuff in zipline + # Add 'price' column as an alias because all kinds of stuff in catalyst # depends on it being present. :/ for frame in raw_data.values(): frame['price'] = frame['close'] @@ -413,6 +413,7 @@ def init_class_fixtures(cls): cls.pipeline_loader = USEquityPricingLoader( cls.bcolz_equity_daily_bar_reader, cls.adjustment_reader, + USEquityPricing, ) cls.dates = cls.raw_data[cls.AAPL].index.tz_localize('UTC') cls.AAPL_split_date = Timestamp("2014-06-09", tz='UTC') diff --git a/tests/pipeline/test_quarters_estimates.py b/tests/pipeline/test_quarters_estimates.py index a26c4e7d7..56be084c6 100644 --- a/tests/pipeline/test_quarters_estimates.py +++ b/tests/pipeline/test_quarters_estimates.py @@ -12,23 +12,23 @@ import pandas as pd from toolz import merge -from zipline.pipeline import SimplePipelineEngine, Pipeline, CustomFactor -from zipline.pipeline.common import ( +from catalyst.pipeline import SimplePipelineEngine, Pipeline, CustomFactor +from catalyst.pipeline.common import ( EVENT_DATE_FIELD_NAME, FISCAL_QUARTER_FIELD_NAME, FISCAL_YEAR_FIELD_NAME, SID_FIELD_NAME, TS_FIELD_NAME, ) -from zipline.pipeline.data import DataSet -from zipline.pipeline.data import Column -from zipline.pipeline.loaders.blaze.estimates import ( +from catalyst.pipeline.data import DataSet +from catalyst.pipeline.data import Column +from catalyst.pipeline.loaders.blaze.estimates import ( BlazeNextEstimatesLoader, BlazeNextSplitAdjustedEstimatesLoader, BlazePreviousEstimatesLoader, BlazePreviousSplitAdjustedEstimatesLoader, ) -from zipline.pipeline.loaders.earnings_estimates import ( +from catalyst.pipeline.loaders.earnings_estimates import ( INVALID_NUM_QTRS_MESSAGE, NextEarningsEstimatesLoader, NextSplitAdjustedEarningsEstimatesLoader, @@ -37,15 +37,15 @@ PreviousSplitAdjustedEarningsEstimatesLoader, split_normalized_quarters, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithAdjustmentReader, WithTradingSessions, ZiplineTestCase, ) -from zipline.testing.predicates import assert_equal, assert_raises_regex -from zipline.testing.predicates import assert_frame_equal -from zipline.utils.numpy_utils import datetime64ns_dtype -from zipline.utils.numpy_utils import float64_dtype +from catalyst.testing.predicates import assert_equal, assert_raises_regex +from catalyst.testing.predicates import assert_frame_equal +from catalyst.utils.numpy_utils import datetime64ns_dtype +from catalyst.utils.numpy_utils import float64_dtype class Estimates(DataSet): diff --git a/tests/pipeline/test_slice.py b/tests/pipeline/test_slice.py index f6728bb7b..027a6fe79 100644 --- a/tests/pipeline/test_slice.py +++ b/tests/pipeline/test_slice.py @@ -5,35 +5,35 @@ from pandas import Int64Index, Timestamp from pandas.util.testing import assert_frame_equal -from zipline.assets import Asset -from zipline.errors import ( +from catalyst.assets import Asset +from catalyst.errors import ( NonExistentAssetInTimeFrame, NonSliceableTerm, NonWindowSafeInput, UnsupportedPipelineOutput, ) -from zipline.pipeline import CustomFactor, Pipeline -from zipline.pipeline.data import USEquityPricing -from zipline.pipeline.data.testing import TestingDataSet -from zipline.pipeline.factors import ( +from catalyst.pipeline import CustomFactor, Pipeline +from catalyst.pipeline.data import USEquityPricing +from catalyst.pipeline.data.testing import TestingDataSet +from catalyst.pipeline.factors.equity import ( Returns, RollingLinearRegressionOfReturns, RollingPearsonOfReturns, RollingSpearmanOfReturns, SimpleMovingAverage, ) -from zipline.testing import ( +from catalyst.testing import ( AssetID, AssetIDPlusDay, check_arrays, OpenPrice, parameter_space, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithSeededRandomPipelineEngine, ZiplineTestCase, ) -from zipline.utils.numpy_utils import datetime64ns_dtype +from catalyst.utils.numpy_utils import datetime64ns_dtype class SliceTestCase(WithSeededRandomPipelineEngine, ZiplineTestCase): diff --git a/tests/pipeline/test_statistical.py b/tests/pipeline/test_statistical.py index d2fdcde02..ca94e5a63 100644 --- a/tests/pipeline/test_statistical.py +++ b/tests/pipeline/test_statistical.py @@ -17,21 +17,21 @@ from pandas.util.testing import assert_frame_equal from scipy.stats import linregress, pearsonr, spearmanr -from zipline.assets import Equity -from zipline.errors import IncompatibleTerms, NonExistentAssetInTimeFrame -from zipline.pipeline import CustomFactor, Pipeline -from zipline.pipeline.data import USEquityPricing -from zipline.pipeline.data.testing import TestingDataSet -from zipline.pipeline.engine import SimplePipelineEngine -from zipline.pipeline.factors import ( +from catalyst.assets import Equity +from catalyst.errors import IncompatibleTerms, NonExistentAssetInTimeFrame +from catalyst.pipeline import CustomFactor, Pipeline +from catalyst.pipeline.data import USEquityPricing +from catalyst.pipeline.data.testing import TestingDataSet +from catalyst.pipeline.engine import SimplePipelineEngine +from catalyst.pipeline.factors.equity import ( Returns, RollingLinearRegressionOfReturns, RollingPearsonOfReturns, RollingSpearmanOfReturns, ) -from zipline.pipeline.loaders.frame import DataFrameLoader -from zipline.pipeline.sentinels import NotSpecified -from zipline.testing import ( +from catalyst.pipeline.loaders.frame import DataFrameLoader +from catalyst.pipeline.sentinels import NotSpecified +from catalyst.testing import ( AssetID, AssetIDPlusDay, check_arrays, @@ -39,12 +39,12 @@ make_cascading_boolean_array, parameter_space, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithSeededRandomPipelineEngine, WithTradingEnvironment, ZiplineTestCase, ) -from zipline.utils.numpy_utils import ( +from catalyst.utils.numpy_utils import ( bool_dtype, datetime64ns_dtype, float64_dtype, diff --git a/tests/pipeline/test_technical.py b/tests/pipeline/test_technical.py index 789768935..8fd019bec 100644 --- a/tests/pipeline/test_technical.py +++ b/tests/pipeline/test_technical.py @@ -7,9 +7,9 @@ import talib from numpy.random import RandomState -from zipline.lib.adjusted_array import AdjustedArray -from zipline.pipeline.data import USEquityPricing -from zipline.pipeline.factors import ( +from catalyst.lib.adjusted_array import AdjustedArray +from catalyst.pipeline.data import USEquityPricing +from catalyst.pipeline.factors.equity import ( BollingerBands, Aroon, FastStochasticOscillator, @@ -20,9 +20,9 @@ MovingAverageConvergenceDivergenceSignal, AnnualizedVolatility, ) -from zipline.testing import parameter_space -from zipline.testing.fixtures import ZiplineTestCase -from zipline.testing.predicates import assert_equal +from catalyst.testing import parameter_space +from catalyst.testing.fixtures import ZiplineTestCase +from catalyst.testing.predicates import assert_equal from .base import BasePipelineTestCase diff --git a/tests/pipeline/test_term.py b/tests/pipeline/test_term.py index 1bb93c8f2..e6c0dbff0 100644 --- a/tests/pipeline/test_term.py +++ b/tests/pipeline/test_term.py @@ -8,8 +8,8 @@ from toolz import assoc import pandas as pd -from zipline.assets import Asset -from zipline.errors import ( +from catalyst.assets import Asset +from catalyst.errors import ( DTypeNotSpecified, InvalidOutputName, NonWindowSafeInput, @@ -19,7 +19,7 @@ UnsupportedDType, WindowLengthNotSpecified, ) -from zipline.pipeline import ( +from catalyst.pipeline import ( Classifier, CustomClassifier, CustomFactor, @@ -27,21 +27,21 @@ Filter, ExecutionPlan, ) -from zipline.pipeline.data import Column, DataSet -from zipline.pipeline.data.testing import TestingDataSet -from zipline.pipeline.expression import NUMEXPR_MATH_FUNCS -from zipline.pipeline.factors import RecarrayField -from zipline.pipeline.sentinels import NotSpecified -from zipline.pipeline.term import AssetExists, Slice -from zipline.testing import parameter_space -from zipline.testing.fixtures import WithTradingSessions, ZiplineTestCase -from zipline.testing.predicates import ( +from catalyst.pipeline.data import Column, DataSet +from catalyst.pipeline.data.testing import TestingDataSet +from catalyst.pipeline.expression import NUMEXPR_MATH_FUNCS +from catalyst.pipeline.factors import RecarrayField +from catalyst.pipeline.sentinels import NotSpecified +from catalyst.pipeline.term import AssetExists, Slice +from catalyst.testing import parameter_space +from catalyst.testing.fixtures import WithTradingSessions, ZiplineTestCase +from catalyst.testing.predicates import ( assert_equal, assert_raises, assert_raises_regex, assert_regex, ) -from zipline.utils.numpy_utils import ( +from catalyst.utils.numpy_utils import ( bool_dtype, categorical_dtype, complex128_dtype, diff --git a/tests/pipeline/test_us_equity_pricing_loader.py b/tests/pipeline/test_us_equity_pricing_loader.py index 39a887c2c..f271a576e 100644 --- a/tests/pipeline/test_us_equity_pricing_loader.py +++ b/tests/pipeline/test_us_equity_pricing_loader.py @@ -36,24 +36,24 @@ from pandas.util.testing import assert_frame_equal from toolz.curried.operator import getitem -from zipline.lib.adjustment import Float64Multiply -from zipline.pipeline.loaders.synthetic import ( +from catalyst.lib.adjustment import Float64Multiply +from catalyst.pipeline.loaders.synthetic import ( NullAdjustmentReader, make_bar_data, expected_bar_values_2d, ) -from zipline.pipeline.loaders.equity_pricing_loader import ( +from catalyst.pipeline.loaders.equity_pricing_loader import ( USEquityPricingLoader, ) -from zipline.errors import WindowLengthTooLong -from zipline.pipeline.data import USEquityPricing -from zipline.testing import ( +from catalyst.errors import WindowLengthTooLong +from catalyst.pipeline.data import USEquityPricing +from catalyst.testing import ( seconds_to_timestamp, str_to_seconds, MockDailyBarReader, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithAdjustmentReader, ZiplineTestCase, ) @@ -473,6 +473,7 @@ def test_read_no_adjustments(self): pricing_loader = USEquityPricingLoader( self.bcolz_equity_daily_bar_reader, adjustment_reader, + USEquityPricing, ) results = pricing_loader.load_adjusted_array( @@ -550,6 +551,7 @@ def test_read_with_adjustments(self): pricing_loader = USEquityPricingLoader( self.bcolz_equity_daily_bar_reader, self.adjustment_reader, + USEquityPricing, ) results = pricing_loader.load_adjusted_array( diff --git a/tests/resources/quandl_samples/rebuild_samples.py b/tests/resources/quandl_samples/rebuild_samples.py index 377d90ff9..2a53eec4f 100644 --- a/tests/resources/quandl_samples/rebuild_samples.py +++ b/tests/resources/quandl_samples/rebuild_samples.py @@ -8,8 +8,8 @@ import requests -from zipline.data.quandl import format_wiki_url -from zipline.testing import test_resource_path, write_compressed +from catalyst.data.quandl import format_wiki_url +from catalyst.testing import test_resource_path, write_compressed def zipfile_path(symbol): diff --git a/tests/resources/rebuild_example_data b/tests/resources/rebuild_example_data index 1c306b624..68cbf33f8 100755 --- a/tests/resources/rebuild_example_data +++ b/tests/resources/rebuild_example_data @@ -9,10 +9,10 @@ import matplotlib import numpy as np import pandas as pd -from zipline import examples -from zipline.data.bundles import clean, ingest, register, yahoo_equities -from zipline.testing import test_resource_path, tmp_dir -from zipline.utils.cache import dataframe_cache +from catalyst import examples +from catalyst.data.bundles import clean, ingest, register, yahoo_equities +from catalyst.testing import test_resource_path, tmp_dir +from catalyst.utils.cache import dataframe_cache matplotlib.use('Agg') diff --git a/tests/resources/yahoo_samples/rebuild_samples b/tests/resources/yahoo_samples/rebuild_samples index c493cac14..a49d85322 100644 --- a/tests/resources/yahoo_samples/rebuild_samples +++ b/tests/resources/yahoo_samples/rebuild_samples @@ -7,8 +7,8 @@ from textwrap import dedent import numpy as np import pandas as pd -from zipline.testing import test_resource_path, write_compressed -from zipline.utils.calendars import get_calendar +from catalyst.testing import test_resource_path, write_compressed +from catalyst.utils.calendars import get_calendar def zipfile_path(symbol, ext): diff --git a/tests/risk/test_risk_cumulative.py b/tests/risk/test_risk_cumulative.py index 7d14ac7fc..8bcbb6721 100644 --- a/tests/risk/test_risk_cumulative.py +++ b/tests/risk/test_risk_cumulative.py @@ -15,12 +15,12 @@ import numpy as np import pandas as pd -import zipline.finance.risk as risk -from zipline.utils import factory +import catalyst.finance.risk as risk +from catalyst.utils import factory -from zipline.testing.fixtures import WithTradingEnvironment, ZiplineTestCase +from catalyst.testing.fixtures import WithTradingEnvironment, ZiplineTestCase -from zipline.finance.trading import SimulationParameters +from catalyst.finance.trading import SimulationParameters RETURNS_BASE = 0.01 RETURNS = [RETURNS_BASE] * 251 diff --git a/tests/risk/test_risk_period.py b/tests/risk/test_risk_period.py index a5cb51086..2dbcf77ba 100644 --- a/tests/risk/test_risk_period.py +++ b/tests/risk/test_risk_period.py @@ -18,13 +18,13 @@ import pandas as pd import numpy as np -import zipline.finance.risk as risk -from zipline.utils import factory +import catalyst.finance.risk as risk +from catalyst.utils import factory -from zipline.finance.trading import SimulationParameters -from zipline.testing.fixtures import WithTradingEnvironment, ZiplineTestCase +from catalyst.finance.trading import SimulationParameters +from catalyst.testing.fixtures import WithTradingEnvironment, ZiplineTestCase -from zipline.finance.risk.period import RiskMetricsPeriod +from catalyst.finance.risk.period import RiskMetricsPeriod RETURNS_BASE = 0.01 RETURNS = [RETURNS_BASE] * 251 diff --git a/tests/test_algorithm.py b/tests/test_algorithm.py index e8781d66e..7e38deb96 100644 --- a/tests/test_algorithm.py +++ b/tests/test_algorithm.py @@ -34,26 +34,26 @@ import pytz from pandas.core.common import PerformanceWarning -from zipline import run_algorithm -from zipline import TradingAlgorithm -from zipline.api import FixedSlippage -from zipline.assets import Equity, Future, Asset -from zipline.assets.continuous_futures import ContinuousFuture -from zipline.assets.synthetic import ( +from catalyst import run_algorithm +from catalyst import TradingAlgorithm +from catalyst.api import FixedSlippage +from catalyst.assets import Equity, Future, Asset +from catalyst.assets.continuous_futures import ContinuousFuture +from catalyst.assets.synthetic import ( make_jagged_equity_info, make_simple_equity_info, ) -from zipline.data.data_portal import DataPortal -from zipline.data.minute_bars import ( +from catalyst.data.data_portal import DataPortal +from catalyst.data.minute_bars import ( BcolzMinuteBarReader, BcolzMinuteBarWriter, US_EQUITIES_MINUTES_PER_DAY, ) -from zipline.data.us_equity_pricing import ( +from catalyst.data.us_equity_pricing import ( BcolzDailyBarReader, BcolzDailyBarWriter, ) -from zipline.errors import ( +from catalyst.errors import ( AccountControlViolation, CannotOrderDelistedAsset, IncompatibleSlippageModel, @@ -67,7 +67,7 @@ UnsupportedCancelPolicy, UnsupportedDatetimeFormat, ) -from zipline.api import ( +from catalyst.api import ( order, order_value, order_percent, @@ -76,17 +76,17 @@ order_target_percent ) -from zipline.finance.commission import PerShare -from zipline.finance.execution import LimitOrder -from zipline.finance.order import ORDER_STATUS -from zipline.finance.trading import SimulationParameters -from zipline.finance.asset_restrictions import ( +from catalyst.finance.commission import PerShare +from catalyst.finance.execution import LimitOrder +from catalyst.finance.order import ORDER_STATUS +from catalyst.finance.trading import SimulationParameters +from catalyst.finance.asset_restrictions import ( Restriction, HistoricalRestrictions, StaticRestrictions, RESTRICTION_STATES, ) -from zipline.testing import ( +from catalyst.testing import ( FakeDataPortal, copy_market_data, create_daily_df_for_asset, @@ -102,8 +102,8 @@ trades_by_sid_to_dfs, tmp_dir, ) -from zipline.testing import RecordBatchBlotter -from zipline.testing.fixtures import ( +from catalyst.testing import RecordBatchBlotter +from catalyst.testing.fixtures import ( WithDataPortal, WithLogger, WithSimParams, @@ -111,7 +111,7 @@ WithTmpDir, ZiplineTestCase, ) -from zipline.test_algorithms import ( +from catalyst.test_algorithms import ( access_account_in_init, access_portfolio_in_init, AmbitiousStopLimitAlgorithm, @@ -175,14 +175,14 @@ set_benchmark_algo, no_handle_data, ) -from zipline.testing.predicates import assert_equal -from zipline.utils.api_support import ZiplineAPI, set_algo_instance -from zipline.utils.calendars import get_calendar, register_calendar -from zipline.utils.context_tricks import CallbackManager -from zipline.utils.control_flow import nullctx -import zipline.utils.events -from zipline.utils.events import date_rules, time_rules, Always -import zipline.utils.factory as factory +from catalyst.testing.predicates import assert_equal +from catalyst.utils.api_support import ZiplineAPI, set_algo_instance +from catalyst.utils.calendars import get_calendar, register_calendar +from catalyst.utils.context_tricks import CallbackManager +from catalyst.utils.control_flow import nullctx +import catalyst.utils.events +from catalyst.utils.events import date_rules, time_rules, Always +import catalyst.utils.factory as factory # Because test cases appear to reuse some resources. @@ -276,7 +276,7 @@ def make_futures_info(cls): def test_cancel_policy_outside_init(self): code = """ -from zipline.api import cancel_policy, set_cancel_policy +from catalyst.api import cancel_policy, set_cancel_policy def initialize(algo): pass @@ -294,7 +294,7 @@ def handle_data(algo, data): def test_cancel_policy_invalid_param(self): code = """ -from zipline.api import set_cancel_policy +from catalyst.api import set_cancel_policy def initialize(algo): set_cancel_policy("foo") @@ -309,7 +309,7 @@ def handle_data(algo, data): with self.assertRaises(UnsupportedCancelPolicy): algo.run(self.data_portal) - def test_zipline_api_resolves_dynamically(self): + def test_catalyst_api_resolves_dynamically(self): # Make a dummy algo. algo = TradingAlgorithm( initialize=lambda context: None, @@ -328,11 +328,11 @@ def fake_method(*args, **kwargs): return sentinel setattr(algo, name, fake_method) with ZiplineAPI(algo): - self.assertIs(sentinel, getattr(zipline.api, name)()) + self.assertIs(sentinel, getattr(catalyst.api, name)()) def test_sid_datetime(self): algo_text = """ -from zipline.api import sid, get_datetime +from catalyst.api import sid, get_datetime def initialize(context): pass @@ -349,7 +349,7 @@ def handle_data(context, data): def test_datetime_bad_params(self): algo_text = """ -from zipline.api import get_datetime +from catalyst.api import get_datetime from pytz import timezone def initialize(context): @@ -371,11 +371,11 @@ def test_get_environment(self): 'start': pd.Timestamp('2006-01-03 14:31:00+0000', tz='utc'), 'end': pd.Timestamp('2006-01-04 21:00:00+0000', tz='utc'), 'capital_base': 100000.0, - 'platform': 'zipline' + 'platform': 'catalyst' } def initialize(algo): - self.assertEqual('zipline', algo.get_environment()) + self.assertEqual('catalyst', algo.get_environment()) self.assertEqual(expected_env, algo.get_environment('*')) def handle_data(algo, data): @@ -441,7 +441,7 @@ def test_schedule_function_custom_cal(self): # run a simulation on the CME cal, and schedule a function # using the NYSE cal algotext = """ -from zipline.api import ( +from catalyst.api import ( schedule_function, get_datetime, time_rules, date_rules, calendars, ) @@ -496,8 +496,8 @@ def log_nyse_close(context, data): # Test that passing an invalid calendar parameter raises an error. erroring_algotext = dedent( """ - from zipline.api import schedule_function - from zipline.utils.calendars import get_calendar + from catalyst.api import schedule_function + from catalyst.utils.calendars import get_calendar def initialize(context): schedule_function(func=my_func, calendar=get_calendar('NYSE')) @@ -634,27 +634,27 @@ def nop(*args, **kwargs): ) # Schedule something for NOT Always. - algo.schedule_function(nop, time_rule=zipline.utils.events.Never()) + algo.schedule_function(nop, time_rule=catalyst.utils.events.Never()) event_rule = algo.event_manager._events[1].rule - self.assertIsInstance(event_rule, zipline.utils.events.OncePerDay) + self.assertIsInstance(event_rule, catalyst.utils.events.OncePerDay) inner_rule = event_rule.rule - self.assertIsInstance(inner_rule, zipline.utils.events.ComposedRule) + self.assertIsInstance(inner_rule, catalyst.utils.events.ComposedRule) first = inner_rule.first second = inner_rule.second composer = inner_rule.composer - self.assertIsInstance(first, zipline.utils.events.Always) + self.assertIsInstance(first, catalyst.utils.events.Always) if mode == 'daily': - self.assertIsInstance(second, zipline.utils.events.Always) + self.assertIsInstance(second, catalyst.utils.events.Always) else: - self.assertIsInstance(second, zipline.utils.events.Never) + self.assertIsInstance(second, catalyst.utils.events.Never) - self.assertIs(composer, zipline.utils.events.ComposedRule.lazy_and) + self.assertIs(composer, catalyst.utils.events.ComposedRule.lazy_and) def test_asset_lookup(self): algo = TradingAlgorithm(env=self.env) @@ -877,8 +877,8 @@ def test_invalid_order_parameters(self): ]) def test_cannot_order_in_before_trading_start(self, order_method, amount): algotext = """ -from zipline.api import sid -from zipline.api import {order_func} +from catalyst.api import sid +from catalyst.api import {order_func} def initialize(context): context.asset = sid(133) @@ -1016,7 +1016,7 @@ def test_order_method_style_forwarding(self, order_style): def test_order_on_each_day_of_asset_lifetime(self): algo_code = dedent(""" - from zipline.api import sid, schedule_function, date_rules, order + from catalyst.api import sid, schedule_function, date_rules, order def initialize(context): schedule_function(order_it, date_rule=date_rules.every_day()) @@ -1300,7 +1300,7 @@ def make_equity_daily_bar_data(cls): def test_data_in_bts_minute(self): algo_code = dedent(""" - from zipline.api import record, sid + from catalyst.api import record, sid def initialize(context): context.history_values = [] @@ -1372,7 +1372,7 @@ def handle_data(context, data): def test_data_in_bts_daily(self): algo_code = dedent(""" - from zipline.api import record, sid + from catalyst.api import record, sid def initialize(context): context.history_values = [] @@ -1417,7 +1417,7 @@ def handle_data(context, data): def test_portfolio_bts(self): algo_code = dedent(""" - from zipline.api import order, sid, record + from catalyst.api import order, sid, record def initialize(context): context.ordered = False @@ -1456,7 +1456,7 @@ def handle_data(context, data): def test_account_bts(self): algo_code = dedent(""" - from zipline.api import order, sid, record + from catalyst.api import order, sid, record def initialize(context): context.ordered = False @@ -1496,7 +1496,7 @@ def handle_data(context, data): def test_portfolio_bts_with_overnight_split(self): algo_code = dedent(""" - from zipline.api import order, sid, record + from catalyst.api import order, sid, record def initialize(context): context.ordered = False context.hd_portfolio = context.portfolio @@ -1543,7 +1543,7 @@ def handle_data(context, data): def test_account_bts_with_overnight_split(self): algo_code = dedent(""" - from zipline.api import order, sid, record + from catalyst.api import order, sid, record def initialize(context): context.ordered = False context.hd_account = context.account @@ -1696,7 +1696,7 @@ def test_api_calls_string(self): algo.run(self.data_portal) def test_api_get_environment(self): - platform = 'zipline' + platform = 'catalyst' algo = TradingAlgorithm(script=api_get_environment_algo, platform=platform, env=self.env) @@ -1714,7 +1714,7 @@ def test_fixed_slippage(self): # -------------- test_algo = TradingAlgorithm( script=""" -from zipline.api import (slippage, +from catalyst.api import (slippage, commission, set_slippage, set_commission, @@ -1780,7 +1780,7 @@ def test_volshare_slippage(self, name, minimum_commission): # -------------- test_algo = TradingAlgorithm( script=""" -from zipline.api import * +from catalyst.api import * def initialize(context): model = slippage.VolumeShareSlippage( @@ -1846,7 +1846,7 @@ def handle_data(context, data): def test_incorrectly_set_futures_slippage_model(self): code = dedent( """ - from zipline.api import set_slippage, slippage + from catalyst.api import set_slippage, slippage class MySlippage(slippage.FutureSlippageModel): def process_order(self, data, order): @@ -1905,7 +1905,7 @@ def test_algo_record_nan(self): def test_order_methods(self): """ Only test that order methods can be called without error. - Correct filling of orders is tested in zipline. + Correct filling of orders is tested in catalyst. """ test_algo = TradingAlgorithm( script=call_all_order_methods, @@ -1923,7 +1923,7 @@ def test_batch_market_order_matches_multiple_manual_orders(self): from collections import OrderedDict from six import iteritems - from zipline.api import sid, order + from catalyst.api import sid, order def initialize(context): @@ -1951,7 +1951,7 @@ def handle_data(context, data): script=dedent("""\ import pandas as pd - from zipline.api import sid, batch_market_order + from catalyst.api import sid, batch_market_order def initialize(context): @@ -1994,7 +1994,7 @@ def test_batch_market_order_filters_null_orders(self): script=dedent("""\ import pandas as pd - from zipline.api import sid, batch_market_order + from catalyst.api import sid, batch_market_order def initialize(context): context.assets = [sid(0), sid(3)] @@ -2030,7 +2030,7 @@ def test_order_dead_asset(self): # order method shouldn't blow up test_algo = TradingAlgorithm( script=""" -from zipline.api import order, sid +from catalyst.api import order, sid def initialize(context): pass @@ -2048,7 +2048,7 @@ def handle_data(context, data): for order_str in ["order_value", "order_percent"]: test_algo = TradingAlgorithm( script=""" -from zipline.api import order_percent, order_value, sid +from catalyst.api import order_percent, order_value, sid def initialize(context): pass @@ -2273,7 +2273,7 @@ def test_schedule_function_time_rule_positionally_misplaced(self): ) algocode = dedent(""" - from zipline.api import time_rules, schedule_function + from catalyst.api import time_rules, schedule_function def do_at_open(context, data): context.done_at_open.append(context.get_datetime()) @@ -2397,7 +2397,7 @@ def test_capital_changes_daily_mode(self, change_type, value): } algocode = """ -from zipline.api import set_slippage, set_commission, slippage, commission, \ +from catalyst.api import set_slippage, set_commission, slippage, commission, \ schedule_function, time_rules, order, sid def initialize(context): @@ -2557,7 +2557,7 @@ def test_capital_changes_minute_mode_daily_emission(self, change, values): 'type': change_type, 'value': val[1]} for val in values} algocode = """ -from zipline.api import set_slippage, set_commission, slippage, commission, \ +from catalyst.api import set_slippage, set_commission, slippage, commission, \ schedule_function, time_rules, order, sid def initialize(context): @@ -2724,7 +2724,7 @@ def test_capital_changes_minute_mode_minute_emission(self, change, values): 'type': change_type, 'value': val[1]} for val in values} algocode = """ -from zipline.api import set_slippage, set_commission, slippage, commission, \ +from catalyst.api import set_slippage, set_commission, slippage, commission, \ schedule_function, time_rules, order, sid def initialize(context): @@ -2964,7 +2964,7 @@ def test_get_datetime(self, name, tz): algo = dedent( """ import pandas as pd - from zipline.api import get_datetime + from catalyst.api import get_datetime def initialize(context): context.tz = {tz} or 'UTC' @@ -3637,7 +3637,7 @@ def make_equity_daily_bar_data(cls): index=cls.sim_params.sessions, ) - @skip('broken in zipline 1.0.0') + @skip('broken in catalyst 1.0.0') def test_flip_algo(self): metadata = {1: {'symbol': 'TEST', 'start_date': self.sim_params.trading_days[0], @@ -3708,7 +3708,7 @@ def test_futures_history(self): algo_code = dedent( """ from datetime import time - from zipline.api import ( + from catalyst.api import ( date_rules, get_datetime, schedule_function, @@ -3789,7 +3789,7 @@ def check_market_close_time(context, data): def algo_with_slippage(slippage_model): return dedent( """ - from zipline.api import ( + from catalyst.api import ( commission, order, set_commission, @@ -3917,7 +3917,7 @@ class TestOrderCancelation(WithDataPortal, code = dedent( """ - from zipline.api import ( + from catalyst.api import ( sid, order, set_slippage, slippage, VolumeShareSlippage, set_cancel_policy, cancel_policy, EODCancel ) @@ -4704,7 +4704,7 @@ def test_order_in_quiet_period(self, name, sid): asset = self.asset_finder.retrieve_asset(sid) algo_code = dedent(""" - from zipline.api import ( + from catalyst.api import ( sid, order, order_value, diff --git a/tests/test_api_shim.py b/tests/test_api_shim.py index 614df1e05..b82011ee0 100644 --- a/tests/test_api_shim.py +++ b/tests/test_api_shim.py @@ -5,24 +5,24 @@ import pandas as pd from pandas.core.common import PerformanceWarning -from zipline import TradingAlgorithm -from zipline.finance.trading import SimulationParameters -from zipline.testing import ( +from catalyst import TradingAlgorithm +from catalyst.finance.trading import SimulationParameters +from catalyst.testing import ( MockDailyBarReader, create_daily_df_for_asset, create_minute_df_for_asset, str_to_seconds, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithCreateBarData, WithDataPortal, WithSimParams, ZiplineTestCase, ) -from zipline.zipline_warnings import ZiplineDeprecationWarning +from catalyst.catalyst_warnings import ZiplineDeprecationWarning simple_algo = """ -from zipline.api import sid, order +from catalyst.api import sid, order def initialize(context): pass @@ -35,7 +35,7 @@ def handle_data(context, data): """ history_algo = """ -from zipline.api import sid, history +from catalyst.api import sid, history def initialize(context): context.sid1 = sid(1) @@ -45,7 +45,7 @@ def handle_data(context, data): """ history_bts_algo = """ -from zipline.api import sid, history, record +from catalyst.api import sid, history, record def initialize(context): context.sid3 = sid(3) @@ -63,7 +63,7 @@ def handle_data(context, data): """ simple_transforms_algo = """ -from zipline.api import sid +from catalyst.api import sid def initialize(context): context.count = 0 @@ -90,7 +90,7 @@ def handle_data(context, data): """ sid_accessor_algo = """ -from zipline.api import sid +from catalyst.api import sid def initialize(context): context.asset1 = sid(1) @@ -101,7 +101,7 @@ def handle_data(context,data): """ data_items_algo = """ -from zipline.api import sid +from catalyst.api import sid def initialize(context): context.asset1 = sid(1) @@ -217,7 +217,7 @@ def test_old_new_data_api_paths(self): "volume", "price", ] - spot_value_meth = 'zipline.data.data_portal.DataPortal.get_spot_value' + spot_value_meth = 'catalyst.data.data_portal.DataPortal.get_spot_value' def assert_get_spot_value_called(fun, field): """ @@ -245,7 +245,8 @@ def assert_get_spot_value_called(fun, field): field, ) - history_meth = 'zipline.data.data_portal.DataPortal.get_history_window' + history_meth =\ + 'catalyst.data.data_portal.DataPortal.get_history_window' def assert_get_history_window_called(fun, is_legacy): """ diff --git a/tests/test_assets.py b/tests/test_assets.py index 3a1949564..2db6e8ef1 100644 --- a/tests/test_assets.py +++ b/tests/test_assets.py @@ -14,7 +14,7 @@ # limitations under the License. """ -Tests for the zipline.assets package +Tests for the catalyst.assets package """ from contextlib import contextmanager from datetime import timedelta @@ -33,14 +33,14 @@ from six import PY2, viewkeys import sqlalchemy as sa -from zipline.assets import ( +from catalyst.assets import ( Asset, Equity, Future, AssetDBWriter, AssetFinder, ) -from zipline.assets.synthetic import ( +from catalyst.assets.synthetic import ( make_commodity_future_info, make_rotating_equity_info, make_simple_equity_info, @@ -48,17 +48,17 @@ from six import itervalues, integer_types from toolz import valmap -from zipline.assets.asset_writer import ( +from catalyst.assets.asset_writer import ( check_version_info, write_version_info, _futures_defaults, SQLITE_MAX_VARIABLE_NUMBER, ) -from zipline.assets.asset_db_schema import ASSET_DB_VERSION -from zipline.assets.asset_db_migrations import ( +from catalyst.assets.asset_db_schema import ASSET_DB_VERSION +from catalyst.assets.asset_db_migrations import ( downgrade ) -from zipline.errors import ( +from catalyst.errors import ( EquitiesNotFound, FutureContractsNotFound, MultipleSymbolsFound, @@ -71,19 +71,19 @@ AssetDBImpossibleDowngrade, ValueNotFoundForField, ) -from zipline.testing import ( +from catalyst.testing import ( all_subindices, empty_assets_db, parameter_space, tmp_assets_db, ) -from zipline.testing.predicates import assert_equal -from zipline.testing.fixtures import ( +from catalyst.testing.predicates import assert_equal +from catalyst.testing.fixtures import ( WithAssetFinder, ZiplineTestCase, WithTradingCalendars, ) -from zipline.utils.range import range +from catalyst.utils.range import range @contextmanager diff --git a/tests/test_bar_data.py b/tests/test_bar_data.py index 539103617..2c13dac17 100644 --- a/tests/test_bar_data.py +++ b/tests/test_bar_data.py @@ -22,26 +22,26 @@ import pandas as pd from toolz import concat -from zipline._protocol import handle_non_market_minutes +from catalyst._protocol import handle_non_market_minutes -from zipline.finance.asset_restrictions import ( +from catalyst.finance.asset_restrictions import ( Restriction, HistoricalRestrictions, RESTRICTION_STATES, ) -from zipline.testing import ( +from catalyst.testing import ( MockDailyBarReader, create_daily_df_for_asset, create_minute_df_for_asset, str_to_seconds, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithCreateBarData, WithDataPortal, ZiplineTestCase, ) -from zipline.utils.calendars import get_calendar -from zipline.utils.calendars.trading_calendar import days_at_time +from catalyst.utils.calendars import get_calendar +from catalyst.utils.calendars.trading_calendar import days_at_time OHLC = ["open", "high", "low", "close"] OHLCP = OHLC + ["price"] diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py index f45632e2d..4ef3f0670 100644 --- a/tests/test_benchmark.py +++ b/tests/test_benchmark.py @@ -16,19 +16,19 @@ import pandas as pd from pandas.util.testing import assert_series_equal -from zipline.data.data_portal import DataPortal -from zipline.errors import ( +from catalyst.data.data_portal import DataPortal +from catalyst.errors import ( BenchmarkAssetNotAvailableTooEarly, BenchmarkAssetNotAvailableTooLate, InvalidBenchmarkAsset) -from zipline.sources.benchmark_source import BenchmarkSource -from zipline.testing import ( +from catalyst.sources.benchmark_source import BenchmarkSource +from catalyst.testing import ( MockDailyBarReader, create_minute_bar_data, tmp_bcolz_equity_minute_bar_reader, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithDataPortal, WithSimParams, WithTradingCalendars, diff --git a/tests/test_clock.py b/tests/test_clock.py index fa81b63cb..6271615d5 100644 --- a/tests/test_clock.py +++ b/tests/test_clock.py @@ -1,7 +1,7 @@ from datetime import time from unittest import TestCase import pandas as pd -from zipline.gens.sim_engine import ( +from catalyst.gens.sim_engine import ( MinuteSimulationClock, SESSION_START, BEFORE_TRADING_START_BAR, @@ -9,8 +9,8 @@ SESSION_END ) -from zipline.utils.calendars import get_calendar -from zipline.utils.calendars.trading_calendar import days_at_time +from catalyst.utils.calendars import get_calendar +from catalyst.utils.calendars.trading_calendar import days_at_time class TestClock(TestCase): diff --git a/tests/test_continuous_futures.py b/tests/test_continuous_futures.py index b05287c3c..27ce5d8b0 100644 --- a/tests/test_continuous_futures.py +++ b/tests/test_continuous_futures.py @@ -28,14 +28,14 @@ import pandas as pd from pandas import Timestamp, DataFrame -from zipline import TradingAlgorithm -from zipline.assets.continuous_futures import ( +from catalyst import TradingAlgorithm +from catalyst.assets.continuous_futures import ( OrderedContracts, delivery_predicate ) -from zipline.data.minute_bars import FUTURES_MINUTES_PER_DAY -from zipline.errors import SymbolNotFound -from zipline.testing.fixtures import ( +from catalyst.data.minute_bars import FUTURES_MINUTES_PER_DAY +from catalyst.errors import SymbolNotFound +from catalyst.testing.fixtures import ( WithAssetFinder, WithCreateBarData, WithDataPortal, @@ -512,7 +512,7 @@ def test_current_contract_volume_roll(self): def test_current_contract_in_algo(self): code = dedent(""" -from zipline.api import ( +from catalyst.api import ( record, continuous_future, schedule_function, @@ -565,7 +565,7 @@ def record_current_contract(algo, data): def test_current_chain_in_algo(self): code = dedent(""" -from zipline.api import ( +from catalyst.api import ( record, continuous_future, schedule_function, diff --git a/tests/test_data_portal.py b/tests/test_data_portal.py index 186e3e6dd..a4c38a6ea 100644 --- a/tests/test_data_portal.py +++ b/tests/test_data_portal.py @@ -19,21 +19,21 @@ import pandas as pd from pandas.tslib import Timedelta -from zipline.assets import Equity, Future -from zipline.data.data_portal import HISTORY_FREQUENCIES, OHLCV_FIELDS -from zipline.data.minute_bars import ( +from catalyst.assets import Equity, Future +from catalyst.data.data_portal import HISTORY_FREQUENCIES, OHLCV_FIELDS +from catalyst.data.minute_bars import ( FUTURES_MINUTES_PER_DAY, US_EQUITIES_MINUTES_PER_DAY, ) -from zipline.testing import parameter_space -from zipline.testing.fixtures import ( +from catalyst.testing import parameter_space +from catalyst.testing.fixtures import ( ZiplineTestCase, WithTradingSessions, WithDataPortal, alias, ) -from zipline.testing.predicates import assert_equal -from zipline.utils.numpy_utils import float64_dtype +from catalyst.testing.predicates import assert_equal +from catalyst.utils.numpy_utils import float64_dtype class DataPortalTestBase(WithDataPortal, diff --git a/tests/test_examples.py b/tests/test_examples.py index a08e239e1..135d0cc3e 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -19,13 +19,13 @@ from nose_parameterized import parameterized import pandas as pd -from zipline import examples -from zipline.data.bundles import register, unregister -from zipline.testing import test_resource_path -from zipline.testing.fixtures import WithTmpDir, ZiplineTestCase -from zipline.testing.predicates import assert_equal -from zipline.utils.cache import dataframe_cache -from zipline.utils.paths import update_modified_time +from catalyst import examples +from catalyst.data.bundles import register, unregister +from catalyst.testing import test_resource_path +from catalyst.testing.fixtures import WithTmpDir, ZiplineTestCase +from catalyst.testing.predicates import assert_equal +from catalyst.utils.cache import dataframe_cache +from catalyst.utils.paths import update_modified_time # Otherwise the next line sometimes complains about being run too late. @@ -68,7 +68,7 @@ def test_example(self, example_name): actual_perf = examples.run_example( example_name, # This should match the invocation in - # zipline/tests/resources/rebuild_example_data + # catalyst/tests/resources/rebuild_example_data environ={ 'ZIPLINE_ROOT': self.tmpdir.getpath('example_data/root'), }, diff --git a/tests/test_exception_handling.py b/tests/test_exception_handling.py index f12a0dc44..be8155254 100644 --- a/tests/test_exception_handling.py +++ b/tests/test_exception_handling.py @@ -14,12 +14,12 @@ # limitations under the License. import pandas as pd -from zipline.test_algorithms import ( +from catalyst.test_algorithms import ( ExceptionAlgorithm, DivByZeroAlgorithm, SetPortfolioAlgorithm, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithDataPortal, WithSimParams, ZiplineTestCase, diff --git a/tests/test_execution_styles.py b/tests/test_execution_styles.py index 7d606463d..08ab1bfd3 100644 --- a/tests/test_execution_styles.py +++ b/tests/test_execution_styles.py @@ -15,14 +15,14 @@ from nose_parameterized import parameterized from six.moves import range -from zipline.errors import BadOrderParameters -from zipline.finance.execution import ( +from catalyst.errors import BadOrderParameters +from catalyst.finance.execution import ( LimitOrder, MarketOrder, StopLimitOrder, StopOrder, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithLogger, ZiplineTestCase, ) @@ -30,7 +30,7 @@ class ExecutionStyleTestCase(WithLogger, ZiplineTestCase): """ - Tests for zipline ExecutionStyle classes. + Tests for catalyst ExecutionStyle classes. """ epsilon = .000001 diff --git a/tests/test_fetcher.py b/tests/test_fetcher.py index 973309783..419d13224 100644 --- a/tests/test_fetcher.py +++ b/tests/test_fetcher.py @@ -18,12 +18,12 @@ import numpy as np from mock import patch -from zipline import TradingAlgorithm -from zipline.errors import UnsupportedOrderParameters -from zipline.sources.requests_csv import mask_requests_args -from zipline.utils import factory -from zipline.testing import FetcherDataPortal -from zipline.testing.fixtures import ( +from catalyst import TradingAlgorithm +from catalyst.errors import UnsupportedOrderParameters +from catalyst.sources.requests_csv import mask_requests_args +from catalyst.utils import factory +from catalyst.testing import FetcherDataPortal +from catalyst.testing.fixtures import ( WithResponses, WithSimParams, ZiplineTestCase, @@ -130,7 +130,7 @@ def test_minutely_fetcher(self): test_algo = TradingAlgorithm( script=""" -from zipline.api import fetch_csv, record, sid +from catalyst.api import fetch_csv, record, sid def initialize(context): fetch_csv('https://fake.urls.com/aapl_minute_csv_data.csv') @@ -184,7 +184,7 @@ def test_fetch_csv_with_multi_symbols(self): results = self.run_algo( """ -from zipline.api import fetch_csv, record, sid +from catalyst.api import fetch_csv, record, sid def initialize(context): fetch_csv('https://fake.urls.com/multi_signal_csv_data.csv') @@ -208,7 +208,7 @@ def test_fetch_csv_with_pure_signal_file(self): results = self.run_algo( """ -from zipline.api import fetch_csv, sid, record +from catalyst.api import fetch_csv, sid, record def clean(df): return df.rename(columns={'Value':'cpi', 'Date':'date'}) @@ -240,7 +240,7 @@ def test_algo_fetch_csv(self): results = self.run_algo( """ -from zipline.api import fetch_csv, record, sid +from catalyst.api import fetch_csv, record, sid def normalize(df): df['scaled'] = df['signal'] * 10 @@ -272,7 +272,7 @@ def test_algo_fetch_csv_with_extra_symbols(self): results = self.run_algo( """ -from zipline.api import fetch_csv, record, sid +from catalyst.api import fetch_csv, record, sid def normalize(df): df['scaled'] = df['signal'] * 10 @@ -308,7 +308,7 @@ def test_usecols(self, testname, usecols): ) code = """ -from zipline.api import fetch_csv, sid, record +from catalyst.api import fetch_csv, sid, record def clean(df): return df.rename(columns={{'Value':'cpi'}}) @@ -342,11 +342,11 @@ def capture_kwargs(zelf, url, **kwargs): # Patching fetch_url instead of using responses in this test so that we # can intercept the requests keyword arguments and confirm that they're # correct. - with patch('zipline.sources.requests_csv.PandasRequestsCSV.fetch_url', + with patch('catalyst.sources.requests_csv.PandasRequestsCSV.fetch_url', new=capture_kwargs): results = self.run_algo( """ -from zipline.api import fetch_csv, record, sid +from catalyst.api import fetch_csv, record, sid def rename_col(df): df = df.rename(columns={'New York 15:00': 'price'}) @@ -386,7 +386,7 @@ def test_fetcher_universe(self, name, data, column_name): # easier given the paramaterization, and (b) there are enough tests # using responses that the fetch_url code is getting a good workout so # we don't have to use it in every test. - with patch('zipline.sources.requests_csv.PandasRequestsCSV.fetch_url', + with patch('catalyst.sources.requests_csv.PandasRequestsCSV.fetch_url', new=lambda *a, **k: data): sim_params = factory.create_simulation_parameters( start=pd.Timestamp("2006-01-09", tz='UTC'), @@ -396,7 +396,7 @@ def test_fetcher_universe(self, name, data, column_name): algocode = """ from pandas import Timestamp from pandas.tseries.tools import normalize_date -from zipline.api import fetch_csv, record, sid, get_datetime +from catalyst.api import fetch_csv, record, sid, get_datetime def initialize(context): fetch_csv( @@ -450,7 +450,7 @@ def test_fetcher_universe_non_security_return(self): self.run_algo( """ -from zipline.api import fetch_csv +from catalyst.api import fetch_csv def initialize(context): fetch_csv( @@ -475,7 +475,7 @@ def test_order_against_data(self): with self.assertRaises(UnsupportedOrderParameters): self.run_algo(""" -from zipline.api import fetch_csv, order, sid +from catalyst.api import fetch_csv, order, sid def rename_col(df): return df.rename(columns={'New York 15:00': 'price'}) @@ -510,7 +510,7 @@ def test_fetcher_universe_minute(self): results = self.run_algo( """ from pandas import Timestamp -from zipline.api import fetch_csv, record, get_datetime +from catalyst.api import fetch_csv, record, get_datetime def initialize(context): fetch_csv( @@ -557,7 +557,7 @@ def test_fetcher_in_before_trading_start(self): ) results = self.run_algo(""" -from zipline.api import fetch_csv, record, symbol +from catalyst.api import fetch_csv, record, symbol def initialize(context): fetch_csv('https://fake.urls.com/fetcher_nflx_data.csv', @@ -592,7 +592,7 @@ def test_fetcher_bad_data(self): ) results = self.run_algo(""" -from zipline.api import fetch_csv, symbol +from catalyst.api import fetch_csv, symbol import numpy as np def initialize(context): diff --git a/tests/test_finance.py b/tests/test_finance.py index 42c5b8729..fb6aea37d 100644 --- a/tests/test_finance.py +++ b/tests/test_finance.py @@ -14,7 +14,7 @@ # limitations under the License. """ -Tests for the zipline.finance package +Tests for the catalyst.finance package """ from datetime import datetime, timedelta import os @@ -27,29 +27,29 @@ from six.moves import range from testfixtures import TempDirectory -from zipline.assets.synthetic import make_simple_equity_info -from zipline.finance.blotter import Blotter -from zipline.finance.execution import MarketOrder, LimitOrder -from zipline.finance.performance import PerformanceTracker -from zipline.finance.trading import SimulationParameters -from zipline.data.us_equity_pricing import BcolzDailyBarReader -from zipline.data.minute_bars import BcolzMinuteBarReader -from zipline.data.data_portal import DataPortal -from zipline.data.us_equity_pricing import BcolzDailyBarWriter -from zipline.finance.slippage import FixedSlippage -from zipline.finance.asset_restrictions import NoRestrictions -from zipline.protocol import BarData -from zipline.testing import ( +from catalyst.assets.synthetic import make_simple_equity_info +from catalyst.finance.blotter import Blotter +from catalyst.finance.execution import MarketOrder, LimitOrder +from catalyst.finance.performance import PerformanceTracker +from catalyst.finance.trading import SimulationParameters +from catalyst.data.us_equity_pricing import BcolzDailyBarReader +from catalyst.data.minute_bars import BcolzMinuteBarReader +from catalyst.data.data_portal import DataPortal +from catalyst.data.us_equity_pricing import BcolzDailyBarWriter +from catalyst.finance.slippage import FixedSlippage +from catalyst.finance.asset_restrictions import NoRestrictions +from catalyst.protocol import BarData +from catalyst.testing import ( tmp_trading_env, write_bcolz_minute_data, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithLogger, WithTradingEnvironment, ZiplineTestCase, ) -import zipline.utils.factory as factory +import catalyst.utils.factory as factory DEFAULT_TIMEOUT = 15 # seconds EXTENDED_TIMEOUT = 90 @@ -66,7 +66,7 @@ class FinanceTestCase(WithLogger, def init_instance_fixtures(self): super(FinanceTestCase, self).init_instance_fixtures() - self.zipline_test_config = {'sid': 133} + self.catalyst_test_config = {'sid': 133} # TODO: write tests for short sales # TODO: write a test to do massive buying or shorting. @@ -405,7 +405,7 @@ class TradingEnvironmentTestCase(WithLogger, WithTradingEnvironment, ZiplineTestCase): """ - Tests for date management utilities in zipline.finance.trading. + Tests for date management utilities in catalyst.finance.trading. """ def test_simulation_parameters(self): sp = SimulationParameters( diff --git a/tests/test_history.py b/tests/test_history.py index cdc36d02d..4d5328c11 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -20,21 +20,21 @@ import pandas as pd from six import iteritems -from zipline import TradingAlgorithm -from zipline._protocol import handle_non_market_minutes, BarData -from zipline.assets import Asset, Equity -from zipline.errors import ( +from catalyst import TradingAlgorithm +from catalyst._protocol import handle_non_market_minutes, BarData +from catalyst.assets import Asset, Equity +from catalyst.errors import ( HistoryInInitialize, HistoryWindowStartsBeforeData, ) -from zipline.finance.trading import SimulationParameters -from zipline.finance.asset_restrictions import NoRestrictions -from zipline.testing import ( +from catalyst.finance.trading import SimulationParameters +from catalyst.finance.asset_restrictions import NoRestrictions +from catalyst.testing import ( create_minute_df_for_asset, str_to_seconds, MockDailyBarReader, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithCreateBarData, WithDataPortal, ZiplineTestCase, @@ -609,7 +609,7 @@ def make_equity_minute_bar_data(cls): def test_history_in_initialize(self): algo_text = dedent( """\ - from zipline.api import history + from catalyst.api import history def initialize(context): history([1], 10, '1d', 'price') diff --git a/tests/test_labelarray.py b/tests/test_labelarray.py index fc6673c9f..d68e8045c 100644 --- a/tests/test_labelarray.py +++ b/tests/test_labelarray.py @@ -5,10 +5,10 @@ import numpy as np from toolz import take -from zipline.lib.labelarray import LabelArray -from zipline.testing import check_arrays, parameter_space, ZiplineTestCase -from zipline.testing.predicates import assert_equal -from zipline.utils.compat import unicode +from catalyst.lib.labelarray import LabelArray +from catalyst.testing import check_arrays, parameter_space, ZiplineTestCase +from catalyst.testing.predicates import assert_equal +from catalyst.utils.compat import unicode def rotN(l, N): diff --git a/tests/test_memoize.py b/tests/test_memoize.py index c1621249b..8f17a5d77 100644 --- a/tests/test_memoize.py +++ b/tests/test_memoize.py @@ -1,11 +1,11 @@ """ -Tests for zipline.utils.memoize. +Tests for catalyst.utils.memoize. """ from collections import defaultdict import gc from unittest import TestCase -from zipline.utils.memoize import remember_last +from catalyst.utils.memoize import remember_last class TestRememberLast(TestCase): diff --git a/tests/test_panel_bar_reader.py b/tests/test_panel_bar_reader.py index 1a9c43776..6427a3bfc 100644 --- a/tests/test_panel_bar_reader.py +++ b/tests/test_panel_bar_reader.py @@ -18,13 +18,13 @@ import numpy as np import pandas as pd -from zipline.data.us_equity_pricing import PanelBarReader -from zipline.testing import ExplodingObject -from zipline.testing.fixtures import ( +from catalyst.data.us_equity_pricing import PanelBarReader +from catalyst.testing import ExplodingObject +from catalyst.testing.fixtures import ( WithAssetFinder, ZiplineTestCase, ) -from zipline.utils.calendars import get_calendar +from catalyst.utils.calendars import get_calendar class WithPanelBarReader(WithAssetFinder): diff --git a/tests/test_perf_tracking.py b/tests/test_perf_tracking.py index ebc068eef..f0acfad57 100644 --- a/tests/test_perf_tracking.py +++ b/tests/test_perf_tracking.py @@ -29,37 +29,37 @@ import numpy as np from six.moves import range, zip -from zipline.assets import Asset -from zipline.assets.synthetic import make_simple_equity_info -from zipline.data.us_equity_pricing import ( +from catalyst.assets import Asset +from catalyst.assets.synthetic import make_simple_equity_info +from catalyst.data.us_equity_pricing import ( SQLiteAdjustmentWriter, SQLiteAdjustmentReader, ) -import zipline.utils.factory as factory -import zipline.finance.performance as perf -from zipline.finance.transaction import create_transaction -import zipline.utils.math_utils as zp_math - -from zipline.finance.blotter import Order -from zipline.finance.performance.position import Position -from zipline.utils.factory import create_simulation_parameters -from zipline.utils.serialization_utils import ( +import catalyst.utils.factory as factory +import catalyst.finance.performance as perf +from catalyst.finance.transaction import create_transaction +import catalyst.utils.math_utils as zp_math + +from catalyst.finance.blotter import Order +from catalyst.finance.performance.position import Position +from catalyst.utils.factory import create_simulation_parameters +from catalyst.utils.serialization_utils import ( loads_with_persistent_ids, dumps_with_persistent_ids ) -from zipline.testing import ( +from catalyst.testing import ( MockDailyBarReader, create_data_portal_from_trade_history, create_empty_splits_mergers_frame, tmp_trading_env, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithInstanceTmpDir, WithSimParams, WithTmpDir, WithTradingEnvironment, ZiplineTestCase, ) -from zipline.utils.calendars import get_calendar +from catalyst.utils.calendars import get_calendar logger = logging.getLogger('Test Perf Tracking') diff --git a/tests/test_restrictions.py b/tests/test_restrictions.py index 72c1297d4..194857b7b 100644 --- a/tests/test_restrictions.py +++ b/tests/test_restrictions.py @@ -5,7 +5,7 @@ from toolz import groupby -from zipline.finance.asset_restrictions import ( +from catalyst.finance.asset_restrictions import ( RESTRICTION_STATES, Restriction, HistoricalRestrictions, @@ -15,8 +15,8 @@ _UnionRestrictions, ) -from zipline.testing import parameter_space -from zipline.testing.fixtures import ( +from catalyst.testing import parameter_space +from catalyst.testing.fixtures import ( WithDataPortal, ZiplineTestCase, ) @@ -221,7 +221,7 @@ def test_static_restrictions(self): def test_security_list_restrictions(self): """ Test single- and multi-asset queries on restrictions defined by - zipline.utils.security_list.SecurityList + catalyst.utils.security_list.SecurityList """ # A mock SecurityList object filled with fake data diff --git a/tests/test_security_list.py b/tests/test_security_list.py index ac7b99fe5..16ee8a236 100644 --- a/tests/test_security_list.py +++ b/tests/test_security_list.py @@ -4,22 +4,22 @@ from testfixtures import TempDirectory from nose_parameterized import parameterized -from zipline.algorithm import TradingAlgorithm -from zipline.errors import TradingControlViolation -from zipline.testing import ( +from catalyst.algorithm import TradingAlgorithm +from catalyst.errors import TradingControlViolation +from catalyst.testing import ( add_security_data, create_data_portal, security_list_copy, tmp_trading_env, tmp_dir, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithLogger, WithTradingEnvironment, ZiplineTestCase, ) -from zipline.utils import factory -from zipline.utils.security_list import ( +from catalyst.utils import factory +from catalyst.utils.security_list import ( SecurityListSet, load_from_directory, ) diff --git a/tests/test_testing.py b/tests/test_testing.py index dacba1508..5099cc89b 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -6,23 +6,23 @@ from numpy import array, empty -from zipline._protocol import BarData -from zipline.finance.asset_restrictions import NoRestrictions -from zipline.finance.order import Order +from catalyst._protocol import BarData +from catalyst.finance.asset_restrictions import NoRestrictions +from catalyst.finance.order import Order -from zipline.testing import ( +from catalyst.testing import ( check_arrays, make_alternating_boolean_array, make_cascading_boolean_array, parameter_space, ) -from zipline.testing.fixtures import ( +from catalyst.testing.fixtures import ( WithConstantEquityMinuteBarData, WithDataPortal, ZiplineTestCase, ) -from zipline.testing.slippage import TestingSlippage -from zipline.utils.numpy_utils import bool_dtype +from catalyst.testing.slippage import TestingSlippage +from catalyst.utils.numpy_utils import bool_dtype class TestParameterSpace(TestCase): diff --git a/tests/test_tradesimulation.py b/tests/test_tradesimulation.py index a7dc8e694..2927015e1 100644 --- a/tests/test_tradesimulation.py +++ b/tests/test_tradesimulation.py @@ -19,23 +19,23 @@ from nose_parameterized import parameterized from six.moves import range -from zipline import TradingAlgorithm -from zipline.gens.sim_engine import BEFORE_TRADING_START_BAR - -from zipline.finance.performance import PerformanceTracker -from zipline.finance.asset_restrictions import NoRestrictions -from zipline.gens.tradesimulation import AlgorithmSimulator -from zipline.sources.benchmark_source import BenchmarkSource -from zipline.test_algorithms import NoopAlgorithm -from zipline.testing.fixtures import ( +from catalyst import TradingAlgorithm +from catalyst.gens.sim_engine import BEFORE_TRADING_START_BAR + +from catalyst.finance.performance import PerformanceTracker +from catalyst.finance.asset_restrictions import NoRestrictions +from catalyst.gens.tradesimulation import AlgorithmSimulator +from catalyst.sources.benchmark_source import BenchmarkSource +from catalyst.test_algorithms import NoopAlgorithm +from catalyst.testing.fixtures import ( WithDataPortal, WithSimParams, WithTradingEnvironment, ZiplineTestCase, ) -from zipline.utils import factory -from zipline.testing.core import FakeDataPortal -from zipline.utils.calendars.trading_calendar import days_at_time +from catalyst.utils import factory +from catalyst.testing.core import FakeDataPortal +from catalyst.utils.calendars.trading_calendar import days_at_time class BeforeTradingAlgorithm(TradingAlgorithm): diff --git a/tests/utils/daily_bar_writer.py b/tests/utils/daily_bar_writer.py index df69c55c9..724cf517e 100644 --- a/tests/utils/daily_bar_writer.py +++ b/tests/utils/daily_bar_writer.py @@ -5,7 +5,7 @@ ) from bcolz import ctable -from zipline.data.us_equity_pricing import ( +from catalyst.data.us_equity_pricing import ( BcolzDailyBarWriter, OHLC, UINT32_MAX diff --git a/tests/utils/test_argcheck.py b/tests/utils/test_argcheck.py index c357518c1..737a730e0 100644 --- a/tests/utils/test_argcheck.py +++ b/tests/utils/test_argcheck.py @@ -14,7 +14,7 @@ # limitations under the License. from unittest import TestCase -from zipline.utils.argcheck import ( +from catalyst.utils.argcheck import ( verify_callable_argspec, Argument, NoStarargs, diff --git a/tests/utils/test_cache.py b/tests/utils/test_cache.py index 19c4af882..9df433de4 100644 --- a/tests/utils/test_cache.py +++ b/tests/utils/test_cache.py @@ -2,7 +2,7 @@ from pandas import Timestamp, Timedelta -from zipline.utils.cache import CachedObject, Expired, ExpiringCache +from catalyst.utils.cache import CachedObject, Expired, ExpiringCache class CachedObjectTestCase(TestCase): diff --git a/tests/utils/test_date_utils.py b/tests/utils/test_date_utils.py index 67ac141a2..912b976f5 100644 --- a/tests/utils/test_date_utils.py +++ b/tests/utils/test_date_utils.py @@ -1,9 +1,9 @@ from pandas import Timestamp from nose_parameterized import parameterized -from zipline.testing import ZiplineTestCase -from zipline.utils.calendars import get_calendar -from zipline.utils.date_utils import compute_date_range_chunks +from catalyst.testing import ZiplineTestCase +from catalyst.utils.calendars import get_calendar +from catalyst.utils.date_utils import compute_date_range_chunks def T(s): diff --git a/tests/utils/test_final.py b/tests/utils/test_final.py index 22aff7e0a..a8d2b22d5 100644 --- a/tests/utils/test_final.py +++ b/tests/utils/test_final.py @@ -3,11 +3,11 @@ from six import with_metaclass -from zipline.utils.final import ( +from catalyst.utils.final import ( FinalMeta, final, ) -from zipline.utils.metautils import compose_types +from catalyst.utils.metautils import compose_types class FinalMetaTestCase(TestCase): diff --git a/tests/utils/test_math_utils.py b/tests/utils/test_math_utils.py index e111c2bf3..f296e8c2c 100644 --- a/tests/utils/test_math_utils.py +++ b/tests/utils/test_math_utils.py @@ -1,7 +1,7 @@ from unittest import TestCase -from zipline.utils.math_utils import number_of_decimal_places +from catalyst.utils.math_utils import number_of_decimal_places class MathUtilsTestCase(TestCase): diff --git a/tests/utils/test_metautils.py b/tests/utils/test_metautils.py index ad864d9ec..9214caa64 100644 --- a/tests/utils/test_metautils.py +++ b/tests/utils/test_metautils.py @@ -1,12 +1,12 @@ -from zipline.testing.fixtures import ZiplineTestCase -from zipline.testing.predicates import ( +from catalyst.testing.fixtures import ZiplineTestCase +from catalyst.testing.predicates import ( assert_equal, assert_is, assert_is_instance, assert_is_subclass, assert_true, ) -from zipline.utils.metautils import compose_types, with_metaclasses +from catalyst.utils.metautils import compose_types, with_metaclasses class C(object): diff --git a/tests/utils/test_numpy_utils.py b/tests/utils/test_numpy_utils.py index 6d7fe65e9..e43754086 100644 --- a/tests/utils/test_numpy_utils.py +++ b/tests/utils/test_numpy_utils.py @@ -1,5 +1,5 @@ """ -Tests for zipline.utils.numpy_utils. +Tests for catalyst.utils.numpy_utils. """ from datetime import datetime from six import itervalues @@ -19,8 +19,8 @@ from toolz import curry from toolz.curried.operator import ne -from zipline.utils.functional import mapall as lazy_mapall -from zipline.utils.numpy_utils import ( +from catalyst.utils.functional import mapall as lazy_mapall +from catalyst.utils.numpy_utils import ( is_float, is_int, is_datetime, diff --git a/tests/utils/test_pandas_utils.py b/tests/utils/test_pandas_utils.py index 68d1efb89..c62db421f 100644 --- a/tests/utils/test_pandas_utils.py +++ b/tests/utils/test_pandas_utils.py @@ -1,11 +1,11 @@ """ -Tests for zipline/utils/pandas_utils.py +Tests for catalyst/utils/pandas_utils.py """ import pandas as pd -from zipline.testing import parameter_space, ZiplineTestCase -from zipline.testing.predicates import assert_equal -from zipline.utils.pandas_utils import ( +from catalyst.testing import parameter_space, ZiplineTestCase +from catalyst.testing.predicates import assert_equal +from catalyst.utils.pandas_utils import ( categorical_df_concat, nearest_unequal_elements ) diff --git a/tests/utils/test_preprocess.py b/tests/utils/test_preprocess.py index a1f2676fb..60a0e7d29 100644 --- a/tests/utils/test_preprocess.py +++ b/tests/utils/test_preprocess.py @@ -1,5 +1,5 @@ """ -Tests for zipline.utils.validate. +Tests for catalyst.utils.validate. """ from operator import attrgetter from types import FunctionType @@ -10,8 +10,8 @@ import pytz from six import PY3 -from zipline.utils.preprocess import call, preprocess -from zipline.utils.input_validation import ( +from catalyst.utils.preprocess import call, preprocess +from catalyst.utils.input_validation import ( expect_dimensions, ensure_timezone, expect_element, diff --git a/tests/utils/test_sentinel.py b/tests/utils/test_sentinel.py index dea22cf83..cf7b65686 100644 --- a/tests/utils/test_sentinel.py +++ b/tests/utils/test_sentinel.py @@ -3,7 +3,7 @@ from unittest import TestCase from weakref import ref -from zipline.utils.sentinel import sentinel +from catalyst.utils.sentinel import sentinel class SentinelTestCase(TestCase): diff --git a/tests/utils/test_sharedoc.py b/tests/utils/test_sharedoc.py index bed1cef93..d73b13e38 100644 --- a/tests/utils/test_sharedoc.py +++ b/tests/utils/test_sharedoc.py @@ -1,5 +1,5 @@ -from zipline.testing import ZiplineTestCase -from zipline.utils.sharedoc import copydoc +from catalyst.testing import ZiplineTestCase +from catalyst.utils.sharedoc import copydoc class TestSharedoc(ZiplineTestCase):