mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 18:04:12 +08:00
Fixed catalyst tests except example tests
This commit is contained in:
+3
-3
@@ -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)
|
||||
|
||||
@@ -1115,7 +1115,7 @@ class TradingAlgorithm(object):
|
||||
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 @@ class TradingAlgorithm(object):
|
||||
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]'
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -412,6 +412,7 @@ CATALYST_URL = (
|
||||
'https://s3.amazonaws.com/quantopian-public-zipline-data/quandl'
|
||||
)
|
||||
|
||||
|
||||
@bundles.register(
|
||||
'catalyst',
|
||||
calendar_name='NYSE',
|
||||
|
||||
@@ -67,7 +67,10 @@ from catalyst.utils.input_validation import (
|
||||
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
|
||||
|
||||
@@ -10,26 +10,23 @@ from catalyst.api import (
|
||||
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
|
||||
|
||||
@@ -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
|
||||
----------
|
||||
|
||||
@@ -330,7 +330,8 @@ class Classifier(RestrictedDTypeMixin, ComputableTerm):
|
||||
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -7,7 +7,10 @@ from six import (
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
from .statistical import (
|
||||
RollingPearson,
|
||||
RollingLinearRegression,
|
||||
RollingLinearRegressionOfReturns,
|
||||
RollingPearsonOfReturns,
|
||||
RollingSpearman,
|
||||
RollingSpearmanOfReturns,
|
||||
)
|
||||
from .technical import (
|
||||
|
||||
@@ -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 @@ class Factor(RestrictedDTypeMixin, ComputableTerm):
|
||||
: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 @@ class Factor(RestrictedDTypeMixin, ComputableTerm):
|
||||
: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 @@ class Factor(RestrictedDTypeMixin, ComputableTerm):
|
||||
:func:`scipy.stats.linregress`
|
||||
:class:`catalyst.pipeline.factors.RollingLinearRegressionOfReturns`
|
||||
"""
|
||||
from .statistical import RollingLinearRegression
|
||||
from .equity import RollingLinearRegression
|
||||
return RollingLinearRegression(
|
||||
dependent=self,
|
||||
independent=target,
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -130,6 +130,10 @@ class BlazeEstimatesLoader(PipelineLoader):
|
||||
mask,
|
||||
)
|
||||
|
||||
@property
|
||||
def columns(self):
|
||||
return self._columns
|
||||
|
||||
|
||||
class BlazeNextEstimatesLoader(BlazeEstimatesLoader):
|
||||
loader = NextEarningsEstimatesLoader
|
||||
|
||||
@@ -91,6 +91,8 @@ class BlazeEventsLoader(PipelineLoader):
|
||||
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 @@ class BlazeEventsLoader(PipelineLoader):
|
||||
assets,
|
||||
mask,
|
||||
)
|
||||
|
||||
@property
|
||||
def columns(self):
|
||||
return self._columns
|
||||
|
||||
@@ -16,10 +16,7 @@ from numpy import (
|
||||
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
|
||||
|
||||
@@ -162,6 +162,7 @@ class EarningsEstimatesLoader(PipelineLoader):
|
||||
}
|
||||
|
||||
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 @@ class EarningsEstimatesLoader(PipelineLoader):
|
||||
)
|
||||
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
|
||||
|
||||
@@ -95,7 +95,7 @@ class USEquityPricingLoader(PipelineLoader):
|
||||
c.missing_value,
|
||||
)
|
||||
return out
|
||||
|
||||
|
||||
@property
|
||||
def columns(self):
|
||||
return self._columns
|
||||
|
||||
@@ -115,6 +115,8 @@ class EventsLoader(PipelineLoader):
|
||||
# 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 @@ class EventsLoader(PipelineLoader):
|
||||
self.load_next_events(n, dates, sids, mask),
|
||||
self.load_previous_events(p, dates, sids, mask),
|
||||
)
|
||||
|
||||
@property
|
||||
def columns(self):
|
||||
return self._columns
|
||||
|
||||
@@ -64,6 +64,8 @@ class DataFrameLoader(PipelineLoader):
|
||||
self.dates = baseline.index
|
||||
self.assets = baseline.columns
|
||||
|
||||
self._columns = self.assets
|
||||
|
||||
if adjustments is None:
|
||||
adjustments = DataFrame(
|
||||
index=DatetimeIndex([]),
|
||||
@@ -174,3 +176,8 @@ class DataFrameLoader(PipelineLoader):
|
||||
missing_value=column.missing_value,
|
||||
),
|
||||
}
|
||||
|
||||
@property
|
||||
def columns(self):
|
||||
return self._columns
|
||||
|
||||
|
||||
@@ -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 @@ class PrecomputedLoader(PipelineLoader):
|
||||
)
|
||||
|
||||
self._loaders = loaders
|
||||
self._columns = set(columns)
|
||||
|
||||
def load_adjusted_array(self, columns, dates, assets, mask):
|
||||
"""
|
||||
@@ -91,6 +94,9 @@ class PrecomputedLoader(PipelineLoader):
|
||||
)
|
||||
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 @@ class SeededRandomLoader(PrecomputedLoader):
|
||||
bool_dtype: self._bool_values,
|
||||
object_dtype: self._object_values,
|
||||
}[dtype](shape)
|
||||
|
||||
@property
|
||||
def columns(self):
|
||||
return self._columns
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -512,8 +512,8 @@ class WithTradingEnvironment(WithAssetFinder,
|
||||
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 @@ class WithEquityPricingPipelineEngine(WithAdjustmentReader,
|
||||
loader = USEquityPricingLoader(
|
||||
cls.bcolz_equity_daily_bar_reader,
|
||||
SQLiteAdjustmentReader(cls.adjustments_db_path),
|
||||
USEquityPricing,
|
||||
)
|
||||
|
||||
def get_loader(column):
|
||||
|
||||
@@ -3,17 +3,15 @@ from catalyst.errors import (
|
||||
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,
|
||||
|
||||
@@ -15,7 +15,6 @@ class OpenExchangeCalendar(TradingCalendar):
|
||||
def tz(self):
|
||||
return timezone('US/Eastern')
|
||||
|
||||
|
||||
@property
|
||||
def open_time(self):
|
||||
return time(0)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -37,8 +37,8 @@ class ApplyAsyncResult(object):
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@ from catalyst.data.bundles.core import load
|
||||
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 _run(handle_data,
|
||||
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 _run(handle_data,
|
||||
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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -2,7 +2,7 @@ from unittest import TestCase
|
||||
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):
|
||||
|
||||
@@ -2,7 +2,7 @@ from unittest import TestCase
|
||||
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):
|
||||
|
||||
@@ -2,7 +2,7 @@ from unittest import TestCase
|
||||
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):
|
||||
|
||||
@@ -2,7 +2,9 @@ from unittest import TestCase
|
||||
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):
|
||||
|
||||
@@ -29,24 +29,24 @@ from pandas.util.testing import assert_index_equal
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -5,26 +5,26 @@ import pandas as pd
|
||||
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 @@ from zipline.testing.predicates import (
|
||||
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')
|
||||
|
||||
@@ -5,23 +5,23 @@ import pandas as pd
|
||||
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 @@ class QuandlBundleTestCase(ZiplineTestCase):
|
||||
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,
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ from six.moves.urllib.parse import urlparse, parse_qs
|
||||
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 @@ class YahooBundleTestCase(WithResponses, ZiplineTestCase):
|
||||
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)
|
||||
|
||||
@@ -15,18 +15,18 @@ from numpy import array, nan
|
||||
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,
|
||||
|
||||
@@ -35,8 +35,8 @@ from pandas import (
|
||||
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 @@ from zipline.data.minute_bars import (
|
||||
H5MinuteBarUpdateReader,
|
||||
)
|
||||
|
||||
from zipline.testing.fixtures import (
|
||||
from catalyst.testing.fixtures import (
|
||||
WithAssetFinder,
|
||||
WithInstanceTmpDir,
|
||||
WithTradingCalendars,
|
||||
|
||||
@@ -21,7 +21,7 @@ import pandas as pd
|
||||
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 @@ from zipline.data.resample import (
|
||||
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,
|
||||
|
||||
@@ -30,13 +30,13 @@ from pandas import (
|
||||
)
|
||||
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 @@ from zipline.pipeline.loaders.synthetic import (
|
||||
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')
|
||||
|
||||
@@ -23,9 +23,9 @@ import pandas as pd
|
||||
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 @@ class RuleTestCase(object):
|
||||
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
|
||||
|
||||
@@ -17,7 +17,7 @@ import pandas as pd
|
||||
|
||||
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):
|
||||
|
||||
@@ -17,10 +17,10 @@ from datetime import timedelta
|
||||
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
|
||||
|
||||
@@ -16,30 +16,30 @@ from nose_parameterized import parameterized
|
||||
|
||||
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,
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -4,10 +4,10 @@ from textwrap import dedent
|
||||
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 @@ from zipline.finance.commission import (
|
||||
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
|
||||
)
|
||||
|
||||
@@ -26,11 +26,11 @@ import numpy as np
|
||||
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 @@ from zipline.finance.slippage import (
|
||||
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')
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -17,8 +17,8 @@ import random
|
||||
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,
|
||||
|
||||
@@ -8,21 +8,21 @@ from numpy import arange, prod
|
||||
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 @@ class BasePipelineTestCase(WithTradingSessions,
|
||||
|
||||
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.
|
||||
|
||||
@@ -18,8 +18,8 @@ from numpy import (
|
||||
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 @@ from zipline.lib.adjustment import (
|
||||
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,
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -19,28 +19,28 @@ from pandas.util.testing import assert_frame_equal
|
||||
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')
|
||||
|
||||
@@ -4,12 +4,12 @@ from operator import or_
|
||||
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,
|
||||
)
|
||||
|
||||
@@ -7,11 +7,11 @@ from unittest import TestCase
|
||||
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):
|
||||
|
||||
@@ -4,22 +4,22 @@ Tests for Downsampled Filters/Factors/Classifiers
|
||||
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):
|
||||
|
||||
@@ -36,15 +36,15 @@ from pandas.util.testing import assert_frame_equal
|
||||
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 @@ from zipline.pipeline.factors import (
|
||||
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 @@ from zipline.testing import (
|
||||
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 @@ class SyntheticBcolzTestCase(WithAdjustmentReader,
|
||||
cls.pipeline_loader = USEquityPricingLoader(
|
||||
cls.bcolz_equity_daily_bar_reader,
|
||||
cls.adjustment_reader,
|
||||
USEquityPricing,
|
||||
)
|
||||
|
||||
def write_nans(self, df):
|
||||
|
||||
@@ -10,27 +10,27 @@ from nose_parameterized import parameterized
|
||||
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,
|
||||
|
||||
@@ -24,32 +24,32 @@ from numpy.random import randn, seed
|
||||
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
|
||||
|
||||
|
||||
@@ -26,21 +26,21 @@ from numpy import (
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -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 @@ from pandas import (
|
||||
Int64Index,
|
||||
)
|
||||
|
||||
from zipline.lib.adjustment import (
|
||||
from catalyst.lib.adjustment import (
|
||||
ADD,
|
||||
Float64Add,
|
||||
Float64Multiply,
|
||||
@@ -20,11 +20,11 @@ from zipline.lib.adjustment import (
|
||||
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 @@ class DataFrameLoaderTestCase(TestCase):
|
||||
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],
|
||||
|
||||
@@ -29,13 +29,13 @@ from pandas import (
|
||||
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):
|
||||
|
||||
@@ -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 @@ class PipelineTestCase(TestCase):
|
||||
)
|
||||
|
||||
patch_display_graph = patch(
|
||||
'zipline.pipeline.graph.display_graph',
|
||||
'catalyst.pipeline.graph.display_graph',
|
||||
mock_display_graph,
|
||||
)
|
||||
|
||||
|
||||
@@ -30,42 +30,42 @@ from pandas import (
|
||||
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 @@ class PipelineAlgorithmTestCase(WithBcolzEquityDailyBarReaderFromCSVs,
|
||||
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 @@ class PipelineAlgorithmTestCase(WithBcolzEquityDailyBarReaderFromCSVs,
|
||||
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')
|
||||
|
||||
@@ -12,23 +12,23 @@ from numpy.testing import assert_array_equal, assert_almost_equal
|
||||
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 @@ from zipline.pipeline.loaders.earnings_estimates import (
|
||||
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):
|
||||
|
||||
@@ -5,35 +5,35 @@ from numpy import where
|
||||
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):
|
||||
|
||||
@@ -17,21 +17,21 @@ from pandas import (
|
||||
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 @@ from zipline.testing import (
|
||||
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,
|
||||
|
||||
@@ -7,9 +7,9 @@ import pandas as pd
|
||||
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 @@ from zipline.pipeline.factors import (
|
||||
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
|
||||
|
||||
|
||||
|
||||
+13
-13
@@ -8,8 +8,8 @@ from unittest import TestCase
|
||||
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 @@ from zipline.errors import (
|
||||
UnsupportedDType,
|
||||
WindowLengthNotSpecified,
|
||||
)
|
||||
from zipline.pipeline import (
|
||||
from catalyst.pipeline import (
|
||||
Classifier,
|
||||
CustomClassifier,
|
||||
CustomFactor,
|
||||
@@ -27,21 +27,21 @@ from zipline.pipeline import (
|
||||
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,
|
||||
|
||||
@@ -36,24 +36,24 @@ from pandas import (
|
||||
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 @@ class USEquityPricingLoaderTestCase(WithAdjustmentReader,
|
||||
pricing_loader = USEquityPricingLoader(
|
||||
self.bcolz_equity_daily_bar_reader,
|
||||
adjustment_reader,
|
||||
USEquityPricing,
|
||||
)
|
||||
|
||||
results = pricing_loader.load_adjusted_array(
|
||||
@@ -550,6 +551,7 @@ class USEquityPricingLoaderTestCase(WithAdjustmentReader,
|
||||
pricing_loader = USEquityPricingLoader(
|
||||
self.bcolz_equity_daily_bar_reader,
|
||||
self.adjustment_reader,
|
||||
USEquityPricing,
|
||||
)
|
||||
|
||||
results = pricing_loader.load_adjusted_array(
|
||||
|
||||
@@ -8,8 +8,8 @@ import pandas as pd
|
||||
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):
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -18,13 +18,13 @@ import calendar
|
||||
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
|
||||
|
||||
+75
-75
@@ -34,26 +34,26 @@ import pandas as pd
|
||||
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 @@ from zipline.errors import (
|
||||
UnsupportedCancelPolicy,
|
||||
UnsupportedDatetimeFormat,
|
||||
)
|
||||
from zipline.api import (
|
||||
from catalyst.api import (
|
||||
order,
|
||||
order_value,
|
||||
order_percent,
|
||||
@@ -76,17 +76,17 @@ from zipline.api import (
|
||||
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 @@ from zipline.testing import (
|
||||
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 @@ from zipline.testing.fixtures import (
|
||||
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 @@ from zipline.test_algorithms import (
|
||||
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 @@ class TestMiscellaneousAPI(WithLogger,
|
||||
|
||||
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 handle_data(algo, data):
|
||||
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 handle_data(context, data):
|
||||
'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 handle_data(context, data):
|
||||
# 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 log_nyse_close(context, data):
|
||||
)
|
||||
|
||||
# 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 @@ class TestTransformAlgorithm(WithLogger,
|
||||
])
|
||||
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 before_trading_start(context, data):
|
||||
|
||||
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 @@ class TestBeforeTradingStart(WithDataPortal,
|
||||
|
||||
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 @@ class TestBeforeTradingStart(WithDataPortal,
|
||||
|
||||
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 @@ class TestBeforeTradingStart(WithDataPortal,
|
||||
|
||||
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 @@ class TestBeforeTradingStart(WithDataPortal,
|
||||
|
||||
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 @@ class TestBeforeTradingStart(WithDataPortal,
|
||||
|
||||
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 @@ class TestBeforeTradingStart(WithDataPortal,
|
||||
|
||||
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 @@ class TestAlgoScript(WithLogger,
|
||||
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 @@ class TestAlgoScript(WithLogger,
|
||||
# --------------
|
||||
test_algo = TradingAlgorithm(
|
||||
script="""
|
||||
from zipline.api import (slippage,
|
||||
from catalyst.api import (slippage,
|
||||
commission,
|
||||
set_slippage,
|
||||
set_commission,
|
||||
@@ -1780,7 +1780,7 @@ def handle_data(context, data):
|
||||
# --------------
|
||||
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 handle_data(context, data):
|
||||
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 handle_data(context, data):
|
||||
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 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):
|
||||
context.assets = [sid(0), sid(3)]
|
||||
@@ -2030,7 +2030,7 @@ def handle_data(context, data):
|
||||
# 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 handle_data(context, data):
|
||||
)
|
||||
|
||||
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 @@ class TestCapitalChanges(WithLogger,
|
||||
}
|
||||
|
||||
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 order_stuff(context, data):
|
||||
'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 order_stuff(context, data):
|
||||
'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 @@ class TestGetDatetime(WithLogger,
|
||||
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 @@ class TestFutureFlip(WithDataPortal, WithSimParams, ZiplineTestCase):
|
||||
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 @@ class TestFuturesAlgo(WithDataPortal, WithSimParams, ZiplineTestCase):
|
||||
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 @@ class TestFuturesAlgo(WithDataPortal, WithSimParams, ZiplineTestCase):
|
||||
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 @@ class TestOrderAfterDelist(WithTradingEnvironment, ZiplineTestCase):
|
||||
asset = self.asset_finder.retrieve_asset(sid)
|
||||
|
||||
algo_code = dedent("""
|
||||
from zipline.api import (
|
||||
from catalyst.api import (
|
||||
sid,
|
||||
order,
|
||||
order_value,
|
||||
|
||||
+14
-13
@@ -5,24 +5,24 @@ import numpy as np
|
||||
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 @@ class TestAPIShim(WithCreateBarData,
|
||||
"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 @@ class TestAPIShim(WithCreateBarData,
|
||||
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):
|
||||
"""
|
||||
|
||||
+11
-11
@@ -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 pandas.util.testing import assert_frame_equal
|
||||
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 zipline.assets.synthetic import (
|
||||
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 @@ from zipline.errors import (
|
||||
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
|
||||
|
||||
@@ -22,26 +22,26 @@ from numpy.testing import assert_almost_equal
|
||||
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"]
|
||||
|
||||
@@ -16,19 +16,19 @@ import numpy as np
|
||||
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,
|
||||
|
||||
+3
-3
@@ -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 @@ from zipline.gens.sim_engine import (
|
||||
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):
|
||||
|
||||
@@ -28,14 +28,14 @@ from numpy.testing import assert_almost_equal
|
||||
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 @@ class ContinuousFuturesTestCase(WithCreateBarData,
|
||||
|
||||
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,
|
||||
|
||||
@@ -19,21 +19,21 @@ from numpy.testing import assert_almost_equal
|
||||
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,
|
||||
|
||||
@@ -19,13 +19,13 @@ import matplotlib
|
||||
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 @@ class ExamplesTests(WithTmpDir, ZiplineTestCase):
|
||||
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'),
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 @@ from zipline.testing.fixtures import (
|
||||
|
||||
class ExecutionStyleTestCase(WithLogger, ZiplineTestCase):
|
||||
"""
|
||||
Tests for zipline ExecutionStyle classes.
|
||||
Tests for catalyst ExecutionStyle classes.
|
||||
"""
|
||||
|
||||
epsilon = .000001
|
||||
|
||||
+21
-21
@@ -18,12 +18,12 @@ import pandas as pd
|
||||
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 @@ class FetcherTestCase(WithResponses,
|
||||
|
||||
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 handle_data(context, data):
|
||||
|
||||
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 handle_data(context, data):
|
||||
|
||||
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 handle_data(context, data):
|
||||
|
||||
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 handle_data(context, data):
|
||||
|
||||
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 handle_data(context, data):
|
||||
)
|
||||
|
||||
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 handle_data(context, data):
|
||||
# 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 handle_data(context, data):
|
||||
# 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 handle_data(context, data):
|
||||
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 handle_data(context, data):
|
||||
|
||||
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 handle_data(context, data):
|
||||
|
||||
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 handle_data(context, data):
|
||||
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 handle_data(context, data):
|
||||
)
|
||||
|
||||
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 before_trading_start(context, data):
|
||||
)
|
||||
|
||||
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):
|
||||
|
||||
+18
-18
@@ -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 import iteritems
|
||||
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(
|
||||
|
||||
@@ -20,21 +20,21 @@ from numpy import nan
|
||||
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 @@ class MinuteEquityHistoryTestCase(WithHistory, ZiplineTestCase):
|
||||
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')
|
||||
|
||||
@@ -5,10 +5,10 @@ import warnings
|
||||
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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -18,13 +18,13 @@ from itertools import permutations, product
|
||||
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):
|
||||
|
||||
+14
-14
@@ -29,37 +29,37 @@ import pandas as pd
|
||||
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
|
||||
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 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 (
|
||||
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')
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from functools import partial
|
||||
|
||||
from toolz import groupby
|
||||
|
||||
from zipline.finance.asset_restrictions import (
|
||||
from catalyst.finance.asset_restrictions import (
|
||||
RESTRICTION_STATES,
|
||||
Restriction,
|
||||
HistoricalRestrictions,
|
||||
@@ -15,8 +15,8 @@ from zipline.finance.asset_restrictions import (
|
||||
_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 @@ class RestrictionsTestCase(WithDataPortal, ZiplineTestCase):
|
||||
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
|
||||
|
||||
@@ -4,22 +4,22 @@ import pandas as pd
|
||||
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,
|
||||
)
|
||||
|
||||
@@ -6,23 +6,23 @@ from unittest import TestCase
|
||||
|
||||
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):
|
||||
|
||||
@@ -19,23 +19,23 @@ from mock import patch
|
||||
|
||||
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 catalyst import TradingAlgorithm
|
||||
from catalyst.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.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):
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user