mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 16:44:59 +08:00
Changed zipline -> catalyst import paths
* Updated cython build scripts * Updated setup.py to to install catalyst package * Updated momentum example to use catalyst package * catalyst executable now supports loading pipelines from multiple bundles
This commit is contained in:
+9
-9
@@ -1,11 +1,11 @@
|
||||
#
|
||||
# Dockerfile for an image with the currently checked out version of zipline installed. To build:
|
||||
# Dockerfile for an image with the currently checked out version of catalyst installed. To build:
|
||||
#
|
||||
# docker build -t quantopian/zipline .
|
||||
# docker build -t quantopian/catalyst .
|
||||
#
|
||||
# To run the container:
|
||||
#
|
||||
# docker run -v /path/to/your/notebooks:/projects -v ~/.zipline:/root/.zipline -p 8888:8888/tcp --name zipline -it quantopian/zipline
|
||||
# docker run -v /path/to/your/notebooks:/projects -v ~/.catalyst:/root/.catalyst -p 8888:8888/tcp --name catalyst -it quantopian/catalyst
|
||||
#
|
||||
# To access Jupyter when running docker locally (you may need to add NAT rules):
|
||||
#
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
# You can also run an algo using the docker exec command. For example:
|
||||
#
|
||||
# docker exec -it zipline zipline run -f /projects/my_algo.py --start 2015-1-1 --end 2016-1-1 /projects/result.pickle
|
||||
# docker exec -it catalyst catalyst run -f /projects/my_algo.py --start 2015-1-1 --end 2016-1-1 /projects/result.pickle
|
||||
#
|
||||
FROM python:3.5
|
||||
|
||||
@@ -48,7 +48,7 @@ RUN mkdir ${PROJECT_DIR} \
|
||||
&& curl -L https://downloads.sourceforge.net/project/ta-lib/ta-lib/0.4.0/ta-lib-0.4.0-src.tar.gz | tar xvz
|
||||
|
||||
#
|
||||
# build and install zipline from source. install TA-Lib after to ensure
|
||||
# build and install catalyst from source. install TA-Lib after to ensure
|
||||
# numpy is available.
|
||||
#
|
||||
|
||||
@@ -72,17 +72,17 @@ RUN pip install 'numpy>=1.11.1,<2.0.0' \
|
||||
ADD ./etc/docker_cmd.sh /
|
||||
|
||||
#
|
||||
# make port available. /zipline is made a volume
|
||||
# make port available. /catalyst is made a volume
|
||||
# for developer testing.
|
||||
#
|
||||
EXPOSE ${NOTEBOOK_PORT}
|
||||
|
||||
#
|
||||
# build and install the zipline package into the image
|
||||
# build and install the catalyst package into the image
|
||||
#
|
||||
|
||||
ADD . /zipline
|
||||
WORKDIR /zipline
|
||||
ADD . /catalyst
|
||||
WORKDIR /catalyst
|
||||
RUN pip install -e .
|
||||
|
||||
#
|
||||
|
||||
+8
-8
@@ -1,15 +1,15 @@
|
||||
#
|
||||
# Dockerfile for an image with the currently checked out version of zipline installed. To build:
|
||||
# Dockerfile for an image with the currently checked out version of catalyst installed. To build:
|
||||
#
|
||||
# docker build -t quantopian/ziplinedev -f Dockerfile-dev .
|
||||
# docker build -t quantopian/catalystdev -f Dockerfile-dev .
|
||||
#
|
||||
# Note: the dev build requires a quantopian/zipline image, which you can build as follows:
|
||||
# Note: the dev build requires a quantopian/catalyst image, which you can build as follows:
|
||||
#
|
||||
# docker build -t quantopian/zipline -f Dockerfile
|
||||
# docker build -t quantopian/catalyst -f Dockerfile
|
||||
#
|
||||
# To run the container:
|
||||
#
|
||||
# docker run -v /path/to/your/notebooks:/projects -v ~/.zipline:/root/.zipline -p 8888:8888/tcp --name ziplinedev -it quantopian/ziplinedev
|
||||
# docker run -v /path/to/your/notebooks:/projects -v ~/.catalyst:/root/.catalyst -p 8888:8888/tcp --name catalystdev -it quantopian/catalystdev
|
||||
#
|
||||
# To access Jupyter when running docker locally (you may need to add NAT rules):
|
||||
#
|
||||
@@ -23,11 +23,11 @@
|
||||
#
|
||||
# You can also run an algo using the docker exec command. For example:
|
||||
#
|
||||
# docker exec -it ziplinedev zipline run -f /projects/my_algo.py --start 2015-1-1 --end 2016-1-1 /projects/result.pickle
|
||||
# docker exec -it catalystdev catalyst run -f /projects/my_algo.py --start 2015-1-1 --end 2016-1-1 /projects/result.pickle
|
||||
#
|
||||
FROM quantopian/zipline
|
||||
FROM quantopian/catalyst
|
||||
|
||||
WORKDIR /zipline
|
||||
WORKDIR /catalyst
|
||||
|
||||
RUN pip install -r etc/requirements_dev.txt -r etc/requirements_blaze.txt
|
||||
# Clean out any cython assets. The pip install re-builds them.
|
||||
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
include LICENSE
|
||||
|
||||
include etc/requirements*.txt
|
||||
recursive-include zipline *.pyi
|
||||
recursive-include zipline *.pxi
|
||||
recursive-include catalyst *.pyi
|
||||
recursive-include catalyst *.pxi
|
||||
|
||||
recursive-include zipline/resources *.*
|
||||
recursive-include catalyst/resources *.*
|
||||
include versioneer.py
|
||||
include zipline/_version.py
|
||||
include catalyst/_version.py
|
||||
|
||||
+4
-4
@@ -83,8 +83,8 @@ install:
|
||||
- ps: copy .\ci\appveyor\vcvars64.bat "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"
|
||||
- "%CMD_IN_ENV% python .\\ci\\make_conda_packages.py"
|
||||
|
||||
# test that we can conda install zipline in a new env
|
||||
- conda create -n installenv --yes -q --use-local python=%PYTHON_VERSION% numpy=%NUMPY_VERSION% zipline -c quantopian -c https://conda.anaconda.org/quantopian/label/ci
|
||||
# test that we can conda install catalyst in a new env
|
||||
- conda create -n installenv --yes -q --use-local python=%PYTHON_VERSION% numpy=%NUMPY_VERSION% catalyst -c quantopian -c https://conda.anaconda.org/quantopian/label/ci
|
||||
|
||||
- ps: $env:BCOLZ_VERSION=(sls "bcolz==(.*)" .\etc\requirements.txt -ca).matches.groups[1].value
|
||||
- ps: $env:NUMEXPR_VERSION=(sls "numexpr==(.*)" .\etc\requirements.txt -ca).matches.groups[1].value
|
||||
@@ -101,8 +101,8 @@ install:
|
||||
- pip freeze | sort
|
||||
|
||||
test_script:
|
||||
- nosetests -e zipline.utils.numpy_utils
|
||||
- flake8 zipline tests
|
||||
- nosetests -e catalyst.utils.numpy_utils
|
||||
- flake8 catalyst tests
|
||||
|
||||
branches:
|
||||
only:
|
||||
|
||||
@@ -30,14 +30,14 @@ from . algorithm import TradingAlgorithm
|
||||
from . import api
|
||||
|
||||
|
||||
# PERF: Fire a warning if calendars were instantiated during zipline import.
|
||||
# Having calendars doesn't break anything per-se, but it makes zipline imports
|
||||
# PERF: Fire a warning if calendars were instantiated during catalyst import.
|
||||
# Having calendars doesn't break anything per-se, but it makes catalyst imports
|
||||
# noticeably slower, which becomes particularly noticeable in the Zipline CLI.
|
||||
from zipline.utils.calendars.calendar_utils import global_calendar_dispatcher
|
||||
from catalyst.utils.calendars.calendar_utils import global_calendar_dispatcher
|
||||
if global_calendar_dispatcher._calendars:
|
||||
import warnings
|
||||
warnings.warn(
|
||||
"Found TradingCalendar instances after zipline import.\n"
|
||||
"Found TradingCalendar instances after catalyst import.\n"
|
||||
"Zipline startup will be much slower until this is fixed!",
|
||||
)
|
||||
del warnings
|
||||
@@ -49,8 +49,8 @@ del get_versions
|
||||
|
||||
|
||||
def load_ipython_extension(ipython):
|
||||
from .__main__ import zipline_magic
|
||||
ipython.register_magic_function(zipline_magic, 'line_cell', 'zipline')
|
||||
from .__main__ import catalyst_magic
|
||||
ipython.register_magic_function(catalyst_magic, 'line_cell', 'catalyst')
|
||||
|
||||
|
||||
if os.name == 'nt':
|
||||
@@ -7,9 +7,9 @@ import logbook
|
||||
import pandas as pd
|
||||
from six import text_type
|
||||
|
||||
from zipline.data import bundles as bundles_module
|
||||
from zipline.utils.cli import Date, Timestamp
|
||||
from zipline.utils.run_algo import _run, load_extensions
|
||||
from catalyst.data import bundles as bundles_module
|
||||
from catalyst.utils.cli import Date, Timestamp
|
||||
from catalyst.utils.run_algo import _run, load_extensions
|
||||
|
||||
try:
|
||||
__IPYTHON__
|
||||
@@ -22,12 +22,12 @@ except NameError:
|
||||
'-e',
|
||||
'--extension',
|
||||
multiple=True,
|
||||
help='File or module path to a zipline extension to load.',
|
||||
help='File or module path to a catalyst extension to load.',
|
||||
)
|
||||
@click.option(
|
||||
'--strict-extensions/--non-strict-extensions',
|
||||
is_flag=True,
|
||||
help='If --strict-extensions is passed then zipline will not run if it'
|
||||
help='If --strict-extensions is passed then catalyst will not run if it'
|
||||
' cannot load all of the specified extensions. If this is not passed or'
|
||||
' --non-strict-extensions is passed then the failure will be logged but'
|
||||
' execution will continue.',
|
||||
@@ -36,10 +36,10 @@ except NameError:
|
||||
'--default-extension/--no-default-extension',
|
||||
is_flag=True,
|
||||
default=True,
|
||||
help="Don't load the default zipline extension.py file in $ZIPLINE_HOME.",
|
||||
help="Don't load the default catalyst extension.py file in $ZIPLINE_HOME.",
|
||||
)
|
||||
def main(extension, strict_extensions, default_extension):
|
||||
"""Top level zipline entry point.
|
||||
"""Top level catalyst entry point.
|
||||
"""
|
||||
# install a logbook handler before performing any other operations
|
||||
logbook.StderrHandler().push_application()
|
||||
@@ -242,14 +242,14 @@ def run(ctx,
|
||||
|
||||
if output == '-':
|
||||
click.echo(str(perf))
|
||||
elif output != os.devnull: # make the zipline magic not write any data
|
||||
elif output != os.devnull: # make the catalyst magic not write any data
|
||||
perf.to_pickle(output)
|
||||
|
||||
return perf
|
||||
|
||||
|
||||
def zipline_magic(line, cell=None):
|
||||
"""The zipline IPython cell magic.
|
||||
def catalyst_magic(line, cell=None):
|
||||
"""The catalyst IPython cell magic.
|
||||
"""
|
||||
load_extensions(
|
||||
default=True,
|
||||
@@ -270,7 +270,7 @@ def zipline_magic(line, cell=None):
|
||||
'--algotext', '',
|
||||
'--local-namespace',
|
||||
] if cell is None else []) + line.split(),
|
||||
'%s%%zipline' % ((cell or '') and '%'),
|
||||
'%s%%catalyst' % ((cell or '') and '%'),
|
||||
# don't use system exit and propogate errors to the caller
|
||||
standalone_mode=False,
|
||||
)
|
||||
@@ -24,12 +24,12 @@ from six import iteritems, PY2, string_types
|
||||
from cpython cimport bool
|
||||
from collections import Iterable
|
||||
|
||||
from zipline.assets import (Asset,
|
||||
from catalyst.assets import (Asset,
|
||||
AssetConvertible,
|
||||
PricingDataAssociable,
|
||||
Future)
|
||||
from zipline.assets.continuous_futures import ContinuousFuture
|
||||
from zipline.zipline_warnings import ZiplineDeprecationWarning
|
||||
from catalyst.assets.continuous_futures import ContinuousFuture
|
||||
from catalyst.catalyst_warnings import ZiplineDeprecationWarning
|
||||
|
||||
|
||||
cdef bool _is_iterable(obj):
|
||||
@@ -149,7 +149,7 @@ cdef class BarData:
|
||||
data_frequency : {'minute', 'daily'}
|
||||
The frequency of the bar data; i.e. whether the data is
|
||||
daily or minute bars
|
||||
restrictions : zipline.finance.asset_restrictions.Restrictions
|
||||
restrictions : catalyst.finance.asset_restrictions.Restrictions
|
||||
Object that combines and returns restricted list information from
|
||||
multiple sources
|
||||
universe_func : callable, optional
|
||||
@@ -37,8 +37,8 @@ def get_config():
|
||||
cfg.VCS = "git"
|
||||
cfg.style = "pep440"
|
||||
cfg.tag_prefix = ""
|
||||
cfg.parentdir_prefix = "zipline-"
|
||||
cfg.versionfile_source = "zipline/_version.py"
|
||||
cfg.parentdir_prefix = "catalyst-"
|
||||
cfg.versionfile_source = "catalyst/_version.py"
|
||||
cfg.verbose = False
|
||||
return cfg
|
||||
|
||||
@@ -35,11 +35,11 @@ from six import (
|
||||
viewkeys,
|
||||
)
|
||||
|
||||
from zipline._protocol import handle_non_market_minutes
|
||||
from zipline.assets.synthetic import make_simple_equity_info
|
||||
from zipline.data.data_portal import DataPortal
|
||||
from zipline.data.us_equity_pricing import PanelBarReader
|
||||
from zipline.errors import (
|
||||
from catalyst._protocol import handle_non_market_minutes
|
||||
from catalyst.assets.synthetic import make_simple_equity_info
|
||||
from catalyst.data.data_portal import DataPortal
|
||||
from catalyst.data.us_equity_pricing import PanelBarReader
|
||||
from catalyst.errors import (
|
||||
AttachPipelineAfterInitialize,
|
||||
CannotOrderDelistedAsset,
|
||||
HistoryInInitialize,
|
||||
@@ -60,9 +60,9 @@ from zipline.errors import (
|
||||
UnsupportedDatetimeFormat,
|
||||
UnsupportedOrderParameters,
|
||||
)
|
||||
from zipline.finance.trading import TradingEnvironment
|
||||
from zipline.finance.blotter import Blotter
|
||||
from zipline.finance.controls import (
|
||||
from catalyst.finance.trading import TradingEnvironment
|
||||
from catalyst.finance.blotter import Blotter
|
||||
from catalyst.finance.controls import (
|
||||
LongOnly,
|
||||
MaxOrderCount,
|
||||
MaxOrderSize,
|
||||
@@ -70,34 +70,34 @@ from zipline.finance.controls import (
|
||||
MaxLeverage,
|
||||
RestrictedListOrder
|
||||
)
|
||||
from zipline.finance.execution import (
|
||||
from catalyst.finance.execution import (
|
||||
LimitOrder,
|
||||
MarketOrder,
|
||||
StopLimitOrder,
|
||||
StopOrder,
|
||||
)
|
||||
from zipline.finance.performance import PerformanceTracker
|
||||
from zipline.finance.asset_restrictions import Restrictions
|
||||
from zipline.finance.cancel_policy import NeverCancel, CancelPolicy
|
||||
from zipline.finance.asset_restrictions import (
|
||||
from catalyst.finance.performance import PerformanceTracker
|
||||
from catalyst.finance.asset_restrictions import Restrictions
|
||||
from catalyst.finance.cancel_policy import NeverCancel, CancelPolicy
|
||||
from catalyst.finance.asset_restrictions import (
|
||||
NoRestrictions,
|
||||
StaticRestrictions,
|
||||
SecurityListRestrictions,
|
||||
)
|
||||
from zipline.assets import Asset, Equity, Future
|
||||
from zipline.gens.tradesimulation import AlgorithmSimulator
|
||||
from zipline.pipeline import Pipeline
|
||||
from zipline.pipeline.engine import (
|
||||
from catalyst.assets import Asset, Equity, Future
|
||||
from catalyst.gens.tradesimulation import AlgorithmSimulator
|
||||
from catalyst.pipeline import Pipeline
|
||||
from catalyst.pipeline.engine import (
|
||||
ExplodingPipelineEngine,
|
||||
SimplePipelineEngine,
|
||||
)
|
||||
from zipline.utils.api_support import (
|
||||
from catalyst.utils.api_support import (
|
||||
api_method,
|
||||
require_initialized,
|
||||
require_not_initialized,
|
||||
ZiplineAPI,
|
||||
disallowed_in_before_trading_start)
|
||||
from zipline.utils.input_validation import (
|
||||
from catalyst.utils.input_validation import (
|
||||
coerce_string,
|
||||
ensure_upper_case,
|
||||
error_keywords,
|
||||
@@ -105,14 +105,14 @@ from zipline.utils.input_validation import (
|
||||
expect_types,
|
||||
optional,
|
||||
)
|
||||
from zipline.utils.numpy_utils import int64_dtype
|
||||
from zipline.utils.calendars.trading_calendar import days_at_time
|
||||
from zipline.utils.cache import CachedObject, Expired
|
||||
from zipline.utils.calendars import get_calendar
|
||||
from zipline.utils.compat import exc_clear
|
||||
from catalyst.utils.numpy_utils import int64_dtype
|
||||
from catalyst.utils.calendars.trading_calendar import days_at_time
|
||||
from catalyst.utils.cache import CachedObject, Expired
|
||||
from catalyst.utils.calendars import get_calendar
|
||||
from catalyst.utils.compat import exc_clear
|
||||
|
||||
import zipline.utils.events
|
||||
from zipline.utils.events import (
|
||||
import catalyst.utils.events
|
||||
from catalyst.utils.events import (
|
||||
EventManager,
|
||||
make_eventrule,
|
||||
date_rules,
|
||||
@@ -121,21 +121,21 @@ from zipline.utils.events import (
|
||||
AfterOpen,
|
||||
BeforeClose
|
||||
)
|
||||
from zipline.utils.factory import create_simulation_parameters
|
||||
from zipline.utils.math_utils import (
|
||||
from catalyst.utils.factory import create_simulation_parameters
|
||||
from catalyst.utils.math_utils import (
|
||||
tolerant_equals,
|
||||
round_if_near_integer,
|
||||
)
|
||||
from zipline.utils.pandas_utils import clear_dataframe_indexer_caches
|
||||
from zipline.utils.preprocess import preprocess
|
||||
from zipline.utils.security_list import SecurityList
|
||||
from catalyst.utils.pandas_utils import clear_dataframe_indexer_caches
|
||||
from catalyst.utils.preprocess import preprocess
|
||||
from catalyst.utils.security_list import SecurityList
|
||||
|
||||
import zipline.protocol
|
||||
from zipline.sources.requests_csv import PandasRequestsCSV
|
||||
import catalyst.protocol
|
||||
from catalyst.sources.requests_csv import PandasRequestsCSV
|
||||
|
||||
from zipline.gens.sim_engine import MinuteSimulationClock
|
||||
from zipline.sources.benchmark_source import BenchmarkSource
|
||||
from zipline.zipline_warnings import ZiplineDeprecationWarning
|
||||
from catalyst.gens.sim_engine import MinuteSimulationClock
|
||||
from catalyst.sources.benchmark_source import BenchmarkSource
|
||||
from catalyst.catalyst_warnings import ZiplineDeprecationWarning
|
||||
|
||||
|
||||
log = logbook.Logger("ZiplineLog")
|
||||
@@ -206,7 +206,7 @@ class TradingAlgorithm(object):
|
||||
The platform the simulation is running on. This can be queried for
|
||||
in the simulation with ``get_environment``. This allows algorithms
|
||||
to conditionally execute code based on platform it is running on.
|
||||
default: 'zipline'
|
||||
default: 'catalyst'
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -260,7 +260,7 @@ class TradingAlgorithm(object):
|
||||
self._recorded_vars = {}
|
||||
self.namespace = kwargs.pop('namespace', {})
|
||||
|
||||
self._platform = kwargs.pop('platform', 'zipline')
|
||||
self._platform = kwargs.pop('platform', 'catalyst')
|
||||
|
||||
self.logger = None
|
||||
|
||||
@@ -316,7 +316,7 @@ class TradingAlgorithm(object):
|
||||
if not self.blotter:
|
||||
self.blotter = Blotter(
|
||||
data_frequency=self.data_frequency,
|
||||
# Default to NeverCancel in zipline
|
||||
# Default to NeverCancel in catalyst
|
||||
cancel_policy=self.cancel_policy,
|
||||
)
|
||||
|
||||
@@ -389,8 +389,8 @@ class TradingAlgorithm(object):
|
||||
self._analyze = kwargs.pop('analyze', None)
|
||||
|
||||
self.event_manager.add_event(
|
||||
zipline.utils.events.Event(
|
||||
zipline.utils.events.Always(),
|
||||
catalyst.utils.events.Event(
|
||||
catalyst.utils.events.Always(),
|
||||
# We pass handle_data.__func__ to get the unbound method.
|
||||
# We will explicitly pass the algorithm to bind it again.
|
||||
self.handle_data.__func__,
|
||||
@@ -702,7 +702,7 @@ class TradingAlgorithm(object):
|
||||
# this is a repeat run of the algorithm.
|
||||
self.perf_tracker = None
|
||||
|
||||
# Create zipline and loop through simulated_trading.
|
||||
# Create catalyst and loop through simulated_trading.
|
||||
# Each iteration returns a perf dictionary
|
||||
try:
|
||||
perfs = []
|
||||
@@ -937,7 +937,7 @@ class TradingAlgorithm(object):
|
||||
The starting capital for the simulation.
|
||||
platform : str
|
||||
The platform that the code is running on. By default this
|
||||
will be the string 'zipline'. This can allow algorithms to
|
||||
will be the string 'catalyst'. This can allow algorithms to
|
||||
know if they are running on the Quantopian platform instead.
|
||||
* : dict[str -> any]
|
||||
Returns all of the fields in a dictionary.
|
||||
@@ -1022,7 +1022,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
Returns
|
||||
-------
|
||||
csv_data_source : zipline.sources.requests_csv.PandasRequestsCSV
|
||||
csv_data_source : catalyst.sources.requests_csv.PandasRequestsCSV
|
||||
A requests source that will pull data from the url specified.
|
||||
"""
|
||||
|
||||
@@ -1063,7 +1063,7 @@ class TradingAlgorithm(object):
|
||||
The function to execute when the rule is triggered.
|
||||
"""
|
||||
self.event_manager.add_event(
|
||||
zipline.utils.events.Event(rule, callback),
|
||||
catalyst.utils.events.Event(rule, callback),
|
||||
)
|
||||
|
||||
@api_method
|
||||
@@ -1090,8 +1090,8 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.api.date_rules`
|
||||
:class:`zipline.api.time_rules`
|
||||
:class:`catalyst.api.date_rules`
|
||||
:class:`catalyst.api.time_rules`
|
||||
"""
|
||||
|
||||
# When the user calls schedule_function(func, <time_rule>), assume that
|
||||
@@ -1146,7 +1146,7 @@ class TradingAlgorithm(object):
|
||||
-----
|
||||
These values will appear in the performance packets and the performance
|
||||
dataframe passed to ``analyze`` and returned from
|
||||
:func:`~zipline.run_algorithm`.
|
||||
:func:`~catalyst.run_algorithm`.
|
||||
"""
|
||||
# Make 2 objects both referencing the same iterator
|
||||
args = [iter(args)] * 2
|
||||
@@ -1201,7 +1201,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:func:`zipline.api.set_symbol_lookup_date`
|
||||
:func:`catalyst.api.set_symbol_lookup_date`
|
||||
"""
|
||||
# If the user has not set the symbol lookup date,
|
||||
# use the end_session as the date for sybmol->sid resolution.
|
||||
@@ -1273,7 +1273,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:func:`zipline.api.set_symbol_lookup_date`
|
||||
:func:`catalyst.api.set_symbol_lookup_date`
|
||||
"""
|
||||
return [self.symbol(identifier) for identifier in args]
|
||||
|
||||
@@ -1433,9 +1433,9 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order_value`
|
||||
:func:`zipline.api.order_percent`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order_value`
|
||||
:func:`catalyst.api.order_percent`
|
||||
"""
|
||||
if not self._can_order_asset(asset):
|
||||
return None
|
||||
@@ -1567,14 +1567,14 @@ class TradingAlgorithm(object):
|
||||
|
||||
Notes
|
||||
-----
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_percent`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_percent`
|
||||
"""
|
||||
if not self._can_order_asset(asset):
|
||||
return None
|
||||
@@ -1673,7 +1673,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.slippage.SlippageModel`
|
||||
:class:`catalyst.finance.slippage.SlippageModel`
|
||||
"""
|
||||
if self.initialized:
|
||||
raise SetSlippagePostInit()
|
||||
@@ -1709,9 +1709,9 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.commission.PerShare`
|
||||
:class:`zipline.finance.commission.PerTrade`
|
||||
:class:`zipline.finance.commission.PerDollar`
|
||||
:class:`catalyst.finance.commission.PerShare`
|
||||
:class:`catalyst.finance.commission.PerTrade`
|
||||
:class:`catalyst.finance.commission.PerDollar`
|
||||
"""
|
||||
if self.initialized:
|
||||
raise SetCommissionPostInit()
|
||||
@@ -1745,8 +1745,8 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.api.EODCancel`
|
||||
:class:`zipline.api.NeverCancel`
|
||||
:class:`catalyst.api.EODCancel`
|
||||
:class:`catalyst.api.NeverCancel`
|
||||
"""
|
||||
if not isinstance(cancel_policy, CancelPolicy):
|
||||
raise UnsupportedCancelPolicy()
|
||||
@@ -1815,14 +1815,14 @@ class TradingAlgorithm(object):
|
||||
|
||||
Notes
|
||||
-----
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_value`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_value`
|
||||
"""
|
||||
if not self._can_order_asset(asset):
|
||||
return None
|
||||
@@ -1884,15 +1884,15 @@ class TradingAlgorithm(object):
|
||||
call to ``order_target`` will not have been filled when the second
|
||||
``order_target`` call is made.
|
||||
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_target_percent`
|
||||
:func:`zipline.api.order_target_value`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_target_percent`
|
||||
:func:`catalyst.api.order_target_value`
|
||||
"""
|
||||
if not self._can_order_asset(asset):
|
||||
return None
|
||||
@@ -1958,15 +1958,15 @@ class TradingAlgorithm(object):
|
||||
call to ``order_target_value`` will not have been filled when the
|
||||
second ``order_target_value`` call is made.
|
||||
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_target`
|
||||
:func:`zipline.api.order_target_percent`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_target`
|
||||
:func:`catalyst.api.order_target_percent`
|
||||
"""
|
||||
if not self._can_order_asset(asset):
|
||||
return None
|
||||
@@ -2022,15 +2022,15 @@ class TradingAlgorithm(object):
|
||||
because the first call to ``order_target_percent`` will not have been
|
||||
filled when the second ``order_target_percent`` call is made.
|
||||
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_target`
|
||||
:func:`zipline.api.order_target_value`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_target`
|
||||
:func:`catalyst.api.order_target_value`
|
||||
"""
|
||||
if not self._can_order_asset(asset):
|
||||
return None
|
||||
@@ -2128,7 +2128,7 @@ class TradingAlgorithm(object):
|
||||
The order_id or order object to cancel.
|
||||
"""
|
||||
order_id = order_param
|
||||
if isinstance(order_param, zipline.protocol.Order):
|
||||
if isinstance(order_param, catalyst.protocol.Order):
|
||||
order_id = order_param.id
|
||||
|
||||
self.blotter.cancel(order_id)
|
||||
@@ -2333,7 +2333,7 @@ class TradingAlgorithm(object):
|
||||
else:
|
||||
warnings.warn(
|
||||
"`set_do_not_order_list(container_of_assets)` is deprecated. "
|
||||
"Create a zipline.finance.asset_restrictions."
|
||||
"Create a catalyst.finance.asset_restrictions."
|
||||
"StaticRestrictions object with a container of assets and use "
|
||||
"`set_asset_restrictions(StaticRestrictions("
|
||||
"container_of_assets))` instead.",
|
||||
@@ -2359,7 +2359,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.finance.asset_restrictions.Restrictions
|
||||
catalyst.finance.asset_restrictions.Restrictions
|
||||
"""
|
||||
control = RestrictedListOrder(on_error, restrictions)
|
||||
self.register_trading_control(control)
|
||||
@@ -2404,7 +2404,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:func:`zipline.api.pipeline_output`
|
||||
:func:`catalyst.api.pipeline_output`
|
||||
"""
|
||||
if self._pipelines:
|
||||
raise NotImplementedError("Multiple pipelines are not supported.")
|
||||
@@ -2444,8 +2444,8 @@ class TradingAlgorithm(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:func:`zipline.api.attach_pipeline`
|
||||
:meth:`zipline.pipeline.engine.PipelineEngine.run_pipeline`
|
||||
:func:`catalyst.api.attach_pipeline`
|
||||
:meth:`catalyst.pipeline.engine.PipelineEngine.run_pipeline`
|
||||
"""
|
||||
# NOTE: We don't currently support multiple pipelines, but we plan to
|
||||
# in the future.
|
||||
@@ -1,12 +1,12 @@
|
||||
import collections
|
||||
from zipline.assets import Asset, Equity, Future
|
||||
from zipline.assets.futures import FutureChain
|
||||
from zipline.finance.asset_restrictions import Restrictions
|
||||
from zipline.finance.cancel_policy import CancelPolicy
|
||||
from zipline.pipeline import Pipeline
|
||||
from zipline.protocol import Order
|
||||
from zipline.utils.events import EventRule
|
||||
from zipline.utils.security_list import SecurityList
|
||||
from catalyst.assets import Asset, Equity, Future
|
||||
from catalyst.assets.futures import FutureChain
|
||||
from catalyst.finance.asset_restrictions import Restrictions
|
||||
from catalyst.finance.cancel_policy import CancelPolicy
|
||||
from catalyst.pipeline import Pipeline
|
||||
from catalyst.protocol import Order
|
||||
from catalyst.utils.events import EventRule
|
||||
from catalyst.utils.security_list import SecurityList
|
||||
|
||||
|
||||
def attach_pipeline(pipeline, name, chunks=None):
|
||||
@@ -31,7 +31,7 @@ def attach_pipeline(pipeline, name, chunks=None):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:func:`zipline.api.pipeline_output`
|
||||
:func:`catalyst.api.pipeline_output`
|
||||
"""
|
||||
|
||||
def batch_market_order(share_counts):
|
||||
@@ -121,7 +121,7 @@ def fetch_csv(url, pre_func=None, post_func=None, date_column='date', date_forma
|
||||
|
||||
Returns
|
||||
-------
|
||||
csv_data_source : zipline.sources.requests_csv.PandasRequestsCSV
|
||||
csv_data_source : catalyst.sources.requests_csv.PandasRequestsCSV
|
||||
A requests source that will pull data from the url specified.
|
||||
"""
|
||||
|
||||
@@ -182,7 +182,7 @@ def get_environment(field='platform'):
|
||||
The starting capital for the simulation.
|
||||
platform : str
|
||||
The platform that the code is running on. By default this
|
||||
will be the string 'zipline'. This can allow algorithms to
|
||||
will be the string 'catalyst'. This can allow algorithms to
|
||||
know if they are running on the Quantopian platform instead.
|
||||
* : dict[str -> any]
|
||||
Returns all of the fields in a dictionary.
|
||||
@@ -253,9 +253,9 @@ def order(asset, amount, limit_price=None, stop_price=None, style=None):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order_value`
|
||||
:func:`zipline.api.order_percent`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order_value`
|
||||
:func:`catalyst.api.order_percent`
|
||||
"""
|
||||
|
||||
def order_percent(asset, percent, limit_price=None, stop_price=None, style=None):
|
||||
@@ -283,14 +283,14 @@ def order_percent(asset, percent, limit_price=None, stop_price=None, style=None)
|
||||
|
||||
Notes
|
||||
-----
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_value`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_value`
|
||||
"""
|
||||
|
||||
def order_target(asset, target, limit_price=None, stop_price=None, style=None):
|
||||
@@ -333,15 +333,15 @@ def order_target(asset, target, limit_price=None, stop_price=None, style=None):
|
||||
call to ``order_target`` will not have been filled when the second
|
||||
``order_target`` call is made.
|
||||
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_target_percent`
|
||||
:func:`zipline.api.order_target_value`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_target_percent`
|
||||
:func:`catalyst.api.order_target_value`
|
||||
"""
|
||||
|
||||
def order_target_percent(asset, target, limit_price=None, stop_price=None, style=None):
|
||||
@@ -385,15 +385,15 @@ def order_target_percent(asset, target, limit_price=None, stop_price=None, style
|
||||
because the first call to ``order_target_percent`` will not have been
|
||||
filled when the second ``order_target_percent`` call is made.
|
||||
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_target`
|
||||
:func:`zipline.api.order_target_value`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_target`
|
||||
:func:`catalyst.api.order_target_value`
|
||||
"""
|
||||
|
||||
def order_target_value(asset, target, limit_price=None, stop_price=None, style=None):
|
||||
@@ -437,15 +437,15 @@ def order_target_value(asset, target, limit_price=None, stop_price=None, style=N
|
||||
call to ``order_target_value`` will not have been filled when the
|
||||
second ``order_target_value`` call is made.
|
||||
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_target`
|
||||
:func:`zipline.api.order_target_percent`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_target`
|
||||
:func:`catalyst.api.order_target_percent`
|
||||
"""
|
||||
|
||||
def order_value(asset, value, limit_price=None, stop_price=None, style=None):
|
||||
@@ -478,14 +478,14 @@ def order_value(asset, value, limit_price=None, stop_price=None, style=None):
|
||||
|
||||
Notes
|
||||
-----
|
||||
See :func:`zipline.api.order` for more information about
|
||||
See :func:`catalyst.api.order` for more information about
|
||||
``limit_price``, ``stop_price``, and ``style``
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.execution.ExecutionStyle`
|
||||
:func:`zipline.api.order`
|
||||
:func:`zipline.api.order_percent`
|
||||
:class:`catalyst.finance.execution.ExecutionStyle`
|
||||
:func:`catalyst.api.order`
|
||||
:func:`catalyst.api.order_percent`
|
||||
"""
|
||||
|
||||
def pipeline_output(name):
|
||||
@@ -510,8 +510,8 @@ def pipeline_output(name):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:func:`zipline.api.attach_pipeline`
|
||||
:meth:`zipline.pipeline.engine.PipelineEngine.run_pipeline`
|
||||
:func:`catalyst.api.attach_pipeline`
|
||||
:meth:`catalyst.pipeline.engine.PipelineEngine.run_pipeline`
|
||||
"""
|
||||
|
||||
def record(*args, **kwargs):
|
||||
@@ -526,7 +526,7 @@ def record(*args, **kwargs):
|
||||
-----
|
||||
These values will appear in the performance packets and the performance
|
||||
dataframe passed to ``analyze`` and returned from
|
||||
:func:`~zipline.run_algorithm`.
|
||||
:func:`~catalyst.run_algorithm`.
|
||||
"""
|
||||
|
||||
def schedule_function(func, date_rule=None, time_rule=None, half_days=True, calendar=None):
|
||||
@@ -545,8 +545,8 @@ def schedule_function(func, date_rule=None, time_rule=None, half_days=True, cale
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.api.date_rules`
|
||||
:class:`zipline.api.time_rules`
|
||||
:class:`catalyst.api.date_rules`
|
||||
:class:`catalyst.api.time_rules`
|
||||
"""
|
||||
|
||||
def set_asset_restrictions(restrictions, on_error='fail'):
|
||||
@@ -559,7 +559,7 @@ def set_asset_restrictions(restrictions, on_error='fail'):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.finance.asset_restrictions.Restrictions
|
||||
catalyst.finance.asset_restrictions.Restrictions
|
||||
"""
|
||||
|
||||
def set_benchmark(benchmark):
|
||||
@@ -586,8 +586,8 @@ def set_cancel_policy(cancel_policy):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.api.EODCancel`
|
||||
:class:`zipline.api.NeverCancel`
|
||||
:class:`catalyst.api.EODCancel`
|
||||
:class:`catalyst.api.NeverCancel`
|
||||
"""
|
||||
|
||||
def set_commission(commission):
|
||||
@@ -600,9 +600,9 @@ def set_commission(commission):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.commission.PerShare`
|
||||
:class:`zipline.finance.commission.PerTrade`
|
||||
:class:`zipline.finance.commission.PerDollar`
|
||||
:class:`catalyst.finance.commission.PerShare`
|
||||
:class:`catalyst.finance.commission.PerTrade`
|
||||
:class:`catalyst.finance.commission.PerDollar`
|
||||
"""
|
||||
|
||||
def set_do_not_order_list(restricted_list, on_error='fail'):
|
||||
@@ -691,7 +691,7 @@ def set_slippage(slippage):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.finance.slippage.SlippageModel`
|
||||
:class:`catalyst.finance.slippage.SlippageModel`
|
||||
"""
|
||||
|
||||
def set_symbol_lookup_date(dt):
|
||||
@@ -745,7 +745,7 @@ def symbol(symbol_str):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:func:`zipline.api.set_symbol_lookup_date`
|
||||
:func:`catalyst.api.set_symbol_lookup_date`
|
||||
"""
|
||||
|
||||
def symbols(*args):
|
||||
@@ -770,6 +770,6 @@ def symbols(*args):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:func:`zipline.api.set_symbol_lookup_date`
|
||||
:func:`catalyst.api.set_symbol_lookup_date`
|
||||
"""
|
||||
|
||||
@@ -34,7 +34,7 @@ from numpy cimport int64_t
|
||||
import warnings
|
||||
cimport numpy as np
|
||||
|
||||
from zipline.utils.calendars import get_calendar
|
||||
from catalyst.utils.calendars import get_calendar
|
||||
|
||||
|
||||
# IMPORTANT NOTE: You must change this template if you change
|
||||
@@ -5,10 +5,10 @@ from alembic.operations import Operations
|
||||
import sqlalchemy as sa
|
||||
from toolz.curried import do, operator as op
|
||||
|
||||
from zipline.assets.asset_writer import write_version_info
|
||||
from zipline.errors import AssetDBImpossibleDowngrade
|
||||
from zipline.utils.preprocess import preprocess
|
||||
from zipline.utils.sqlite_utils import coerce_string_to_eng
|
||||
from catalyst.assets.asset_writer import write_version_info
|
||||
from catalyst.errors import AssetDBImpossibleDowngrade
|
||||
from catalyst.utils.preprocess import preprocess
|
||||
from catalyst.utils.sqlite_utils import coerce_string_to_eng
|
||||
|
||||
|
||||
@preprocess(engine=coerce_string_to_eng)
|
||||
@@ -21,8 +21,8 @@ import pandas as pd
|
||||
import sqlalchemy as sa
|
||||
from toolz import first
|
||||
|
||||
from zipline.errors import AssetDBVersionError
|
||||
from zipline.assets.asset_db_schema import (
|
||||
from catalyst.errors import AssetDBVersionError
|
||||
from catalyst.assets.asset_db_schema import (
|
||||
ASSET_DB_VERSION,
|
||||
asset_db_table_names,
|
||||
asset_router,
|
||||
@@ -36,9 +36,9 @@ from zipline.assets.asset_db_schema import (
|
||||
version_info,
|
||||
)
|
||||
|
||||
from zipline.utils.preprocess import preprocess
|
||||
from zipline.utils.range import from_tuple, intersecting_ranges
|
||||
from zipline.utils.sqlite_utils import coerce_string_to_eng
|
||||
from catalyst.utils.preprocess import preprocess
|
||||
from catalyst.utils.range import from_tuple, intersecting_ranges
|
||||
from catalyst.utils.sqlite_utils import coerce_string_to_eng
|
||||
|
||||
# Define a namedtuple for use with the load_data and _load_data methods
|
||||
AssetData = namedtuple(
|
||||
@@ -455,7 +455,7 @@ class AssetDBWriter(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.assets.asset_finder
|
||||
catalyst.assets.asset_finder
|
||||
"""
|
||||
with self.engine.begin() as conn:
|
||||
# Create SQL tables if they do not exist.
|
||||
@@ -39,7 +39,7 @@ from toolz import (
|
||||
)
|
||||
from toolz.curried import operator as op
|
||||
|
||||
from zipline.errors import (
|
||||
from catalyst.errors import (
|
||||
EquitiesNotFound,
|
||||
FutureContractsNotFound,
|
||||
MapAssetIdentifierIndexError,
|
||||
@@ -70,11 +70,11 @@ from .asset_writer import (
|
||||
from .asset_db_schema import (
|
||||
ASSET_DB_VERSION
|
||||
)
|
||||
from zipline.utils.control_flow import invert
|
||||
from zipline.utils.memoize import lazyval
|
||||
from zipline.utils.numpy_utils import as_column
|
||||
from zipline.utils.preprocess import preprocess
|
||||
from zipline.utils.sqlite_utils import group_into_chunks, coerce_string_to_eng
|
||||
from catalyst.utils.control_flow import invert
|
||||
from catalyst.utils.memoize import lazyval
|
||||
from catalyst.utils.numpy_utils import as_column
|
||||
from catalyst.utils.preprocess import preprocess
|
||||
from catalyst.utils.sqlite_utils import group_into_chunks, coerce_string_to_eng
|
||||
|
||||
log = Logger('assets.py')
|
||||
|
||||
@@ -260,7 +260,7 @@ class AssetFinder(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.assets.AssetDBWriter`
|
||||
:class:`catalyst.assets.AssetDBWriter`
|
||||
"""
|
||||
# Token used as a substitute for pickling objects that contain a
|
||||
# reference to an AssetFinder.
|
||||
@@ -1316,7 +1316,7 @@ class AssetFinder(object):
|
||||
See Also
|
||||
--------
|
||||
numpy.putmask
|
||||
zipline.pipeline.engine.SimplePipelineEngine._compute_root_mask
|
||||
catalyst.pipeline.engine.SimplePipelineEngine._compute_root_mask
|
||||
"""
|
||||
# This is a less than ideal place to do this, because if someone adds
|
||||
# assets to the finder after we've touched lifetimes we won't have
|
||||
@@ -36,7 +36,7 @@ from numpy cimport long_t, int64_t
|
||||
from pandas import Timestamp
|
||||
import warnings
|
||||
|
||||
from zipline.utils.calendars import get_calendar
|
||||
from catalyst.utils.calendars import get_calendar
|
||||
|
||||
|
||||
def delivery_predicate(codes, contract):
|
||||
@@ -187,7 +187,7 @@ def make_future_info(first_sid,
|
||||
month_codes : dict[str -> [1..12]], optional
|
||||
Dictionary of month codes for which to create contracts. Entries
|
||||
should be strings mapped to values from 1 (January) to 12 (December).
|
||||
Default is zipline.futures.CME_CODE_TO_MONTH
|
||||
Default is catalyst.futures.CME_CODE_TO_MONTH
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -29,11 +29,11 @@ ctypedef object Timestamp_t
|
||||
ctypedef object DatetimeIndex_t
|
||||
ctypedef object Int64Index_t
|
||||
|
||||
from zipline.lib.adjustment import Float64Multiply
|
||||
from zipline.assets.asset_writer import (
|
||||
from catalyst.lib.adjustment import Float64Multiply
|
||||
from catalyst.assets.asset_writer import (
|
||||
SQLITE_MAX_VARIABLE_NUMBER as SQLITE_MAX_IN_STATEMENT,
|
||||
)
|
||||
from zipline.utils.pandas_utils import timedelta_to_integral_seconds
|
||||
from catalyst.utils.pandas_utils import timedelta_to_integral_seconds
|
||||
|
||||
|
||||
_SID_QUERY_TEMPLATE = """
|
||||
@@ -71,7 +71,7 @@ class BarReader(with_metaclass(ABCMeta, object)):
|
||||
@abstractproperty
|
||||
def trading_calendar(self):
|
||||
"""
|
||||
Returns the zipline.utils.calendar.trading_calendar used to read
|
||||
Returns the catalyst.utils.calendar.trading_calendar used to read
|
||||
the data. Can be None (if the writer didn't specify it).
|
||||
"""
|
||||
pass
|
||||
@@ -124,7 +124,7 @@ class BarReader(with_metaclass(ABCMeta, object)):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
asset : zipline.asset.Asset
|
||||
asset : catalyst.asset.Asset
|
||||
The asset for which to get the last traded minute.
|
||||
dt : pd.Timestamp
|
||||
The minute at which to start searching for the last traded minute.
|
||||
@@ -1,6 +1,5 @@
|
||||
# These imports are necessary to force module-scope register calls to happen.
|
||||
from . import quandl # noqa
|
||||
from . import catalyst
|
||||
from .core import (
|
||||
UnknownBundle,
|
||||
bundles,
|
||||
@@ -15,8 +14,6 @@ from .core import (
|
||||
)
|
||||
from .yahoo import yahoo_equities
|
||||
|
||||
|
||||
|
||||
__all__ = [
|
||||
'UnknownBundle',
|
||||
'bundles',
|
||||
@@ -19,18 +19,18 @@ from ..minute_bars import (
|
||||
BcolzMinuteBarReader,
|
||||
BcolzMinuteBarWriter,
|
||||
)
|
||||
from zipline.assets import AssetDBWriter, AssetFinder, ASSET_DB_VERSION
|
||||
from zipline.assets.asset_db_migrations import downgrade
|
||||
from zipline.utils.cache import (
|
||||
from catalyst.assets import AssetDBWriter, AssetFinder, ASSET_DB_VERSION
|
||||
from catalyst.assets.asset_db_migrations import downgrade
|
||||
from catalyst.utils.cache import (
|
||||
dataframe_cache,
|
||||
working_dir,
|
||||
working_file,
|
||||
)
|
||||
from zipline.utils.compat import mappingproxy
|
||||
from zipline.utils.input_validation import ensure_timestamp, optionally
|
||||
import zipline.utils.paths as pth
|
||||
from zipline.utils.preprocess import preprocess
|
||||
from zipline.utils.calendars import get_calendar
|
||||
from catalyst.utils.compat import mappingproxy
|
||||
from catalyst.utils.input_validation import ensure_timestamp, optionally
|
||||
import catalyst.utils.paths as pth
|
||||
from catalyst.utils.preprocess import preprocess
|
||||
from catalyst.utils.calendars import get_calendar
|
||||
|
||||
|
||||
def asset_db_path(bundle_name, timestr, environ=None, db_version=None):
|
||||
@@ -248,7 +248,7 @@ def _make_bundle_core():
|
||||
The daily bar writer to write into.
|
||||
adjustment_writer : SQLiteAdjustmentWriter
|
||||
The adjustment db writer to write into.
|
||||
calendar : zipline.utils.calendars.TradingCalendar
|
||||
calendar : catalyst.utils.calendars.TradingCalendar
|
||||
The trading calendar to ingest for.
|
||||
start_session : pd.Timestamp
|
||||
The first session of data to ingest.
|
||||
@@ -291,7 +291,7 @@ def _make_bundle_core():
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.data.bundles.bundles
|
||||
catalyst.data.bundles.bundles
|
||||
"""
|
||||
if name in bundles:
|
||||
warnings.warn(
|
||||
@@ -300,9 +300,9 @@ def _make_bundle_core():
|
||||
)
|
||||
|
||||
# NOTE: We don't eagerly compute calendar values here because
|
||||
# `register` is called at module scope in zipline, and creating a
|
||||
# `register` is called at module scope in catalyst, and creating a
|
||||
# calendar currently takes between 0.5 and 1 seconds, which causes a
|
||||
# noticeable delay on the zipline CLI.
|
||||
# noticeable delay on the catalyst CLI.
|
||||
_bundles[name] = RegisteredBundle(
|
||||
calendar_name=calendar_name,
|
||||
start_session=start_session,
|
||||
@@ -328,7 +328,7 @@ def _make_bundle_core():
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.data.bundles.bundles
|
||||
catalyst.data.bundles.bundles
|
||||
"""
|
||||
try:
|
||||
del _bundles[name]
|
||||
@@ -470,7 +470,7 @@ def _make_bundle_core():
|
||||
timestamp : datetime
|
||||
The timestamp to begin searching on or before.
|
||||
environ : dict, optional
|
||||
An environment dict to forward to zipline_root.
|
||||
An environment dict to forward to catalyst_root.
|
||||
"""
|
||||
if bundle_name not in bundles:
|
||||
raise UnknownBundle(bundle_name)
|
||||
@@ -492,7 +492,7 @@ def _make_bundle_core():
|
||||
raise
|
||||
raise ValueError(
|
||||
'no data for bundle {bundle!r} on or before {timestamp}\n'
|
||||
'maybe you need to run: $ zipline ingest -b {bundle}'.format(
|
||||
'maybe you need to run: $ catalyst ingest -b {bundle}'.format(
|
||||
bundle=bundle_name,
|
||||
timestamp=timestamp,
|
||||
),
|
||||
@@ -544,7 +544,7 @@ def _make_bundle_core():
|
||||
keep_last=None,
|
||||
environ=os.environ):
|
||||
"""Clean up data that was created with ``ingest`` or
|
||||
``$ python -m zipline ingest``
|
||||
``$ python -m catalyst ingest``
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -12,8 +12,8 @@ import pandas as pd
|
||||
import requests
|
||||
from six.moves.urllib.parse import urlencode
|
||||
|
||||
from zipline.utils.calendars import register_calendar_alias
|
||||
from zipline.utils.cli import maybe_show_progress
|
||||
from catalyst.utils.calendars import register_calendar_alias
|
||||
from catalyst.utils.cli import maybe_show_progress
|
||||
|
||||
from . import core as bundles
|
||||
|
||||
@@ -87,7 +87,7 @@ def fetch_symbol_metadata_frame(api_key,
|
||||
retries : int, optional
|
||||
The number of times to retry each request before failing.
|
||||
environ : mapping[str -> str], optional
|
||||
The environment to use to find the zipline home. By default this
|
||||
The environment to use to find the catalyst home. By default this
|
||||
is ``os.environ``.
|
||||
show_progress : bool, optional
|
||||
Show a progress bar for the download of this data.
|
||||
@@ -286,7 +286,7 @@ def quandl_bundle(environ,
|
||||
cache,
|
||||
show_progress,
|
||||
output_dir):
|
||||
"""Build a zipline data bundle from the Quandl WIKI dataset.
|
||||
"""Build a catalyst data bundle from the Quandl WIKI dataset.
|
||||
"""
|
||||
api_key = environ.get('QUANDL_API_KEY')
|
||||
metadata = fetch_symbol_metadata_frame(
|
||||
@@ -407,3 +407,38 @@ def quantopian_quandl_bundle(environ,
|
||||
|
||||
|
||||
register_calendar_alias("QUANDL", "NYSE")
|
||||
|
||||
CATALYST_URL = (
|
||||
'https://s3.amazonaws.com/quantopian-public-zipline-data/quandl'
|
||||
)
|
||||
|
||||
@bundles.register(
|
||||
'catalyst',
|
||||
calendar_name='NYSE',
|
||||
minutes_per_day=390,
|
||||
create_writers=False,
|
||||
)
|
||||
def catalyst_bundle(environ,
|
||||
asset_db_writer,
|
||||
minute_bar_writer,
|
||||
daily_bar_writer,
|
||||
adjustment_writer,
|
||||
calendar,
|
||||
start_session,
|
||||
end_session,
|
||||
cache,
|
||||
show_progress,
|
||||
output_dir):
|
||||
if show_progress:
|
||||
data = download_with_progress(
|
||||
CATALYST_URL,
|
||||
chunk_size=ONE_MEGABYTE,
|
||||
label="Downloading Bundle: catalyst",
|
||||
)
|
||||
else:
|
||||
data = download_without_progress(CATALYST_URL)
|
||||
|
||||
with tarfile.open('r', fileobj=data) as tar:
|
||||
if show_progress:
|
||||
print("Writing data to %s." % output_dir)
|
||||
tar.extractall(output_dir)
|
||||
@@ -5,8 +5,8 @@ import pandas as pd
|
||||
from pandas_datareader.data import DataReader
|
||||
import requests
|
||||
|
||||
from zipline.utils.calendars import register_calendar_alias
|
||||
from zipline.utils.cli import maybe_show_progress
|
||||
from catalyst.utils.calendars import register_calendar_alias
|
||||
from catalyst.utils.cli import maybe_show_progress
|
||||
from .core import register
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@ def yahoo_equities(symbols, start=None, end=None):
|
||||
|
||||
Examples
|
||||
--------
|
||||
This code should be added to ~/.zipline/extension.py
|
||||
This code should be added to ~/.catalyst/extension.py
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from zipline.data.bundles import yahoo_equities, register
|
||||
from catalyst.data.bundles import yahoo_equities, register
|
||||
|
||||
symbols = (
|
||||
'AAPL',
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from zipline.data.session_bars import SessionBarReader
|
||||
from catalyst.data.session_bars import SessionBarReader
|
||||
|
||||
|
||||
class ContinuousFutureSessionBarReader(SessionBarReader):
|
||||
@@ -93,7 +93,7 @@ class ContinuousFutureSessionBarReader(SessionBarReader):
|
||||
@property
|
||||
def trading_calendar(self):
|
||||
"""
|
||||
Returns the zipline.utils.calendar.trading_calendar used to read
|
||||
Returns the catalyst.utils.calendar.trading_calendar used to read
|
||||
the data. Can be None (if the writer didn't specify it).
|
||||
"""
|
||||
return self._bar_reader.trading_calendar
|
||||
@@ -148,7 +148,7 @@ class ContinuousFutureSessionBarReader(SessionBarReader):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
asset : zipline.asset.Asset
|
||||
asset : catalyst.asset.Asset
|
||||
The asset for which to get the last traded minute.
|
||||
dt : pd.Timestamp
|
||||
The minute at which to start searching for the last traded minute.
|
||||
@@ -279,7 +279,7 @@ class ContinuousFutureMinuteBarReader(SessionBarReader):
|
||||
@property
|
||||
def trading_calendar(self):
|
||||
"""
|
||||
Returns the zipline.utils.calendar.trading_calendar used to read
|
||||
Returns the catalyst.utils.calendar.trading_calendar used to read
|
||||
the data. Can be None (if the writer didn't specify it).
|
||||
"""
|
||||
return self._bar_reader.trading_calendar
|
||||
@@ -334,7 +334,7 @@ class ContinuousFutureMinuteBarReader(SessionBarReader):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
asset : zipline.asset.Asset
|
||||
asset : catalyst.asset.Asset
|
||||
The asset for which to get the last traded minute.
|
||||
dt : pd.Timestamp
|
||||
The minute at which to start searching for the last traded minute.
|
||||
@@ -24,45 +24,45 @@ from pandas.tslib import normalize_date
|
||||
from six import iteritems
|
||||
from six.moves import reduce
|
||||
|
||||
from zipline.assets import (
|
||||
from catalyst.assets import (
|
||||
Asset,
|
||||
AssetConvertible,
|
||||
Equity,
|
||||
Future,
|
||||
PricingDataAssociable,
|
||||
)
|
||||
from zipline.assets.continuous_futures import ContinuousFuture
|
||||
from zipline.data.continuous_future_reader import (
|
||||
from catalyst.assets.continuous_futures import ContinuousFuture
|
||||
from catalyst.data.continuous_future_reader import (
|
||||
ContinuousFutureSessionBarReader,
|
||||
ContinuousFutureMinuteBarReader
|
||||
)
|
||||
from zipline.assets.roll_finder import (
|
||||
from catalyst.assets.roll_finder import (
|
||||
CalendarRollFinder,
|
||||
VolumeRollFinder
|
||||
)
|
||||
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 (
|
||||
DailyHistoryAggregator,
|
||||
ReindexMinuteBarReader,
|
||||
ReindexSessionBarReader,
|
||||
)
|
||||
from zipline.data.history_loader import (
|
||||
from catalyst.data.history_loader import (
|
||||
DailyHistoryLoader,
|
||||
MinuteHistoryLoader,
|
||||
)
|
||||
from zipline.data.us_equity_pricing import NoDataOnDate
|
||||
from catalyst.data.us_equity_pricing import NoDataOnDate
|
||||
|
||||
from zipline.utils.math_utils import (
|
||||
from catalyst.utils.math_utils import (
|
||||
nansum,
|
||||
nanmean,
|
||||
nanstd
|
||||
)
|
||||
from zipline.utils.memoize import remember_last, weak_lru_cache
|
||||
from zipline.utils.pandas_utils import timedelta_to_integral_minutes
|
||||
from zipline.errors import (
|
||||
from catalyst.utils.memoize import remember_last, weak_lru_cache
|
||||
from catalyst.utils.pandas_utils import timedelta_to_integral_minutes
|
||||
from catalyst.errors import (
|
||||
NoTradeDataAvailableTooEarly,
|
||||
NoTradeDataAvailableTooLate,
|
||||
HistoryWindowStartsBeforeData,
|
||||
@@ -100,7 +100,7 @@ _DEF_D_HIST_PREFETCH = DEFAULT_DAILY_HISTORY_PREFETCH
|
||||
|
||||
|
||||
class DataPortal(object):
|
||||
"""Interface to all of the data that a zipline simulation needs.
|
||||
"""Interface to all of the data that a catalyst simulation needs.
|
||||
|
||||
This is used by the simulation runner to answer questions about the data,
|
||||
like getting the prices of assets on a given day or to service history
|
||||
@@ -108,9 +108,9 @@ class DataPortal(object):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
asset_finder : zipline.assets.assets.AssetFinder
|
||||
asset_finder : catalyst.assets.assets.AssetFinder
|
||||
The AssetFinder instance used to resolve assets.
|
||||
trading_calendar: zipline.utils.calendar.exchange_calendar.TradingCalendar
|
||||
trading_calendar: catalyst.utils.calendar.exchange_calendar.TradingCalendar
|
||||
The calendar instance used to provide minute->session information.
|
||||
first_trading_day : pd.Timestamp
|
||||
The first trading day for the simulation.
|
||||
@@ -154,8 +154,6 @@ class DataPortal(object):
|
||||
minute_history_prefetch_length=_DEF_M_HIST_PREFETCH,
|
||||
daily_history_prefetch_length=_DEF_D_HIST_PREFETCH):
|
||||
|
||||
print 'trading_calendar: {0}'.format(trading_calendar)
|
||||
|
||||
self.trading_calendar = trading_calendar
|
||||
self.asset_finder = asset_finder
|
||||
|
||||
@@ -879,7 +877,7 @@ class DataPortal(object):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
assets : list of zipline.data.Asset objects
|
||||
assets : list of catalyst.data.Asset objects
|
||||
The assets whose data is desired.
|
||||
|
||||
bar_count: int
|
||||
@@ -22,7 +22,7 @@ from numpy import (
|
||||
)
|
||||
from six import iteritems, with_metaclass
|
||||
|
||||
from zipline.utils.memoize import lazyval
|
||||
from catalyst.utils.memoize import lazyval
|
||||
|
||||
|
||||
class AssetDispatchBarReader(with_metaclass(ABCMeta)):
|
||||
@@ -30,8 +30,8 @@ class AssetDispatchBarReader(with_metaclass(ABCMeta)):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
- trading_calendar : zipline.utils.trading_calendar.TradingCalendar
|
||||
- asset_finder : zipline.assets.AssetFinder
|
||||
- trading_calendar : catalyst.utils.trading_calendar.TradingCalendar
|
||||
- asset_finder : catalyst.assets.AssetFinder
|
||||
- readers : dict
|
||||
A dict mapping Asset type to the corresponding
|
||||
[Minute|Session]BarReader
|
||||
@@ -26,16 +26,16 @@ from toolz import sliding_window
|
||||
|
||||
from six import with_metaclass
|
||||
|
||||
from zipline.assets import Equity, Future
|
||||
from zipline.assets.continuous_futures import ContinuousFuture
|
||||
from zipline.lib._int64window import AdjustedArrayWindow as Int64Window
|
||||
from zipline.lib._float64window import AdjustedArrayWindow as Float64Window
|
||||
from zipline.lib.adjustment import Float64Multiply, Float64Add
|
||||
from zipline.utils.cache import ExpiringCache
|
||||
from zipline.utils.math_utils import number_of_decimal_places
|
||||
from zipline.utils.memoize import lazyval
|
||||
from zipline.utils.numpy_utils import float64_dtype
|
||||
from zipline.utils.pandas_utils import find_in_sorted_index
|
||||
from catalyst.assets import Equity, Future
|
||||
from catalyst.assets.continuous_futures import ContinuousFuture
|
||||
from catalyst.lib._int64window import AdjustedArrayWindow as Int64Window
|
||||
from catalyst.lib._float64window import AdjustedArrayWindow as Float64Window
|
||||
from catalyst.lib.adjustment import Float64Multiply, Float64Add
|
||||
from catalyst.utils.cache import ExpiringCache
|
||||
from catalyst.utils.math_utils import number_of_decimal_places
|
||||
from catalyst.utils.memoize import lazyval
|
||||
from catalyst.utils.numpy_utils import float64_dtype
|
||||
from catalyst.utils.pandas_utils import find_in_sorted_index
|
||||
|
||||
# Default number of decimal places used for rounding asset prices.
|
||||
DEFAULT_ASSET_PRICE_DECIMALS = 3
|
||||
@@ -29,7 +29,7 @@ from ..utils.paths import (
|
||||
data_root,
|
||||
)
|
||||
from ..utils.deprecate import deprecated
|
||||
from zipline.utils.calendars import get_calendar
|
||||
from catalyst.utils.calendars import get_calendar
|
||||
|
||||
|
||||
logger = logbook.Logger('Loader')
|
||||
@@ -104,7 +104,7 @@ def load_market_data(trading_day=None, trading_days=None, bm_symbol='SPY',
|
||||
Bank of Canada is also available.
|
||||
|
||||
Results downloaded from the internet are cached in
|
||||
~/.zipline/data. Subsequent loads will attempt to read from the cached
|
||||
~/.catalyst/data. Subsequent loads will attempt to read from the cached
|
||||
files before falling back to redownload.
|
||||
|
||||
Parameters
|
||||
@@ -30,19 +30,19 @@ import tables
|
||||
from six import with_metaclass
|
||||
from toolz import keymap, valmap
|
||||
|
||||
from zipline.data._minute_bar_internal import (
|
||||
from catalyst.data._minute_bar_internal import (
|
||||
minute_value,
|
||||
find_position_of_minute,
|
||||
find_last_traded_position_internal
|
||||
)
|
||||
|
||||
from zipline.gens.sim_engine import NANOS_IN_MINUTE
|
||||
from catalyst.gens.sim_engine import NANOS_IN_MINUTE
|
||||
|
||||
from zipline.data.bar_reader import BarReader, NoDataOnDate
|
||||
from zipline.data.us_equity_pricing import check_uint32_safe
|
||||
from zipline.utils.calendars import get_calendar
|
||||
from zipline.utils.cli import maybe_show_progress
|
||||
from zipline.utils.memoize import lazyval
|
||||
from catalyst.data.bar_reader import BarReader, NoDataOnDate
|
||||
from catalyst.data.us_equity_pricing import check_uint32_safe
|
||||
from catalyst.utils.calendars import get_calendar
|
||||
from catalyst.utils.cli import maybe_show_progress
|
||||
from catalyst.utils.memoize import lazyval
|
||||
|
||||
|
||||
logger = logbook.Logger('MinuteBars')
|
||||
@@ -187,7 +187,7 @@ class BcolzMinuteBarMetadata(object):
|
||||
ohlc_ratio : int
|
||||
The factor by which the pricing data is multiplied so that the
|
||||
float data can be stored as an integer.
|
||||
calendar : zipline.utils.calendars.trading_calendar.TradingCalendar
|
||||
calendar : catalyst.utils.calendars.trading_calendar.TradingCalendar
|
||||
The TradingCalendar on which the minute bars are based.
|
||||
start_session : datetime
|
||||
The first trading session in the data set.
|
||||
@@ -358,7 +358,7 @@ class BcolzMinuteBarWriter(object):
|
||||
rootdir : string
|
||||
Path to the root directory into which to write the metadata and
|
||||
bcolz subdirectories.
|
||||
calendar : zipline.utils.calendars.trading_calendar.TradingCalendar
|
||||
calendar : catalyst.utils.calendars.trading_calendar.TradingCalendar
|
||||
The trading calendar on which to base the minute bars. Used to
|
||||
get the market opens used as a starting point for each periodic
|
||||
span of minutes in the index, and the market closes that
|
||||
@@ -436,7 +436,7 @@ class BcolzMinuteBarWriter(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.data.minute_bars.BcolzMinuteBarReader
|
||||
catalyst.data.minute_bars.BcolzMinuteBarReader
|
||||
"""
|
||||
COL_NAMES = ('open', 'high', 'low', 'close', 'volume')
|
||||
|
||||
@@ -895,7 +895,7 @@ class BcolzMinuteBarReader(MinuteBarReader):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.data.minute_bars.BcolzMinuteBarWriter
|
||||
catalyst.data.minute_bars.BcolzMinuteBarWriter
|
||||
"""
|
||||
FIELDS = ('open', 'high', 'low', 'close', 'volume')
|
||||
|
||||
@@ -18,17 +18,17 @@ import numpy as np
|
||||
import pandas as pd
|
||||
from six import with_metaclass
|
||||
|
||||
from zipline.data._resample import (
|
||||
from catalyst.data._resample import (
|
||||
_minute_to_session_open,
|
||||
_minute_to_session_high,
|
||||
_minute_to_session_low,
|
||||
_minute_to_session_close,
|
||||
_minute_to_session_volume,
|
||||
)
|
||||
from zipline.data.bar_reader import NoDataOnDate
|
||||
from zipline.data.minute_bars import MinuteBarReader
|
||||
from zipline.data.session_bars import SessionBarReader
|
||||
from zipline.utils.memoize import lazyval
|
||||
from catalyst.data.bar_reader import NoDataOnDate
|
||||
from catalyst.data.minute_bars import MinuteBarReader
|
||||
from catalyst.data.session_bars import SessionBarReader
|
||||
from catalyst.utils.memoize import lazyval
|
||||
|
||||
_MINUTE_TO_SESSION_OHCLV_HOW = OrderedDict((
|
||||
('open', 'first'),
|
||||
@@ -50,7 +50,7 @@ def minute_frame_to_session_frame(minute_frame, calendar):
|
||||
minute_frame : pd.DataFrame
|
||||
A DataFrame with the columns `open`, `high`, `low`, `close`, `volume`,
|
||||
and `dt` (minute dts)
|
||||
calendar : zipline.utils.calendars.trading_calendar.TradingCalendar
|
||||
calendar : catalyst.utils.calendars.trading_calendar.TradingCalendar
|
||||
A TradingCalendar on which session labels to resample from minute
|
||||
to session.
|
||||
|
||||
@@ -610,7 +610,7 @@ class ReindexBarReader(with_metaclass(ABCMeta)):
|
||||
Parameters
|
||||
----------
|
||||
|
||||
- trading_calendar : zipline.utils.trading_calendar.TradingCalendar
|
||||
- trading_calendar : catalyst.utils.trading_calendar.TradingCalendar
|
||||
The calendar to use when indexing results from the reader.
|
||||
- reader : MinuteBarReader|SessionBarReader
|
||||
The reader which has a calendar that is a subset of the desired
|
||||
@@ -13,7 +13,7 @@
|
||||
# limitations under the License.
|
||||
from abc import abstractproperty
|
||||
|
||||
from zipline.data.bar_reader import BarReader
|
||||
from catalyst.data.bar_reader import BarReader
|
||||
|
||||
|
||||
class SessionBarReader(BarReader):
|
||||
@@ -53,23 +53,23 @@ from six import (
|
||||
)
|
||||
from toolz import compose
|
||||
|
||||
from zipline.data.session_bars import SessionBarReader
|
||||
from zipline.data.bar_reader import (
|
||||
from catalyst.data.session_bars import SessionBarReader
|
||||
from catalyst.data.bar_reader import (
|
||||
NoDataAfterDate,
|
||||
NoDataBeforeDate,
|
||||
NoDataOnDate,
|
||||
)
|
||||
from zipline.utils.calendars import get_calendar
|
||||
from zipline.utils.functional import apply
|
||||
from zipline.utils.preprocess import call
|
||||
from zipline.utils.input_validation import (
|
||||
from catalyst.utils.calendars import get_calendar
|
||||
from catalyst.utils.functional import apply
|
||||
from catalyst.utils.preprocess import call
|
||||
from catalyst.utils.input_validation import (
|
||||
expect_element,
|
||||
preprocess,
|
||||
verify_indices_all_unique,
|
||||
)
|
||||
from zipline.utils.sqlite_utils import group_into_chunks, coerce_string_to_conn
|
||||
from zipline.utils.memoize import lazyval
|
||||
from zipline.utils.cli import maybe_show_progress
|
||||
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
|
||||
from ._adjustments import load_adjustments_from_sqlite
|
||||
|
||||
@@ -173,7 +173,7 @@ class BcolzDailyBarWriter(object):
|
||||
----------
|
||||
filename : str
|
||||
The location at which we should write our output.
|
||||
calendar : zipline.utils.calendar.trading_calendar
|
||||
calendar : catalyst.utils.calendar.trading_calendar
|
||||
Calendar to use to compute asset calendar offsets.
|
||||
start_session: pd.Timestamp
|
||||
Midnight UTC session label.
|
||||
@@ -182,7 +182,7 @@ class BcolzDailyBarWriter(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.data.us_equity_pricing.BcolzDailyBarReader
|
||||
catalyst.data.us_equity_pricing.BcolzDailyBarReader
|
||||
"""
|
||||
_csv_dtypes = {
|
||||
'open': float64,
|
||||
@@ -492,7 +492,7 @@ class BcolzDailyBarReader(SessionBarReader):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.data.us_equity_pricing.BcolzDailyBarWriter
|
||||
catalyst.data.us_equity_pricing.BcolzDailyBarWriter
|
||||
"""
|
||||
def __init__(self, table, read_all_threshold=3000):
|
||||
self._maybe_table_rootdir = table
|
||||
@@ -847,7 +847,7 @@ class PanelBarReader(SessionBarReader):
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
asset : zipline.asset.Asset
|
||||
asset : catalyst.asset.Asset
|
||||
The asset identifier.
|
||||
dt : datetime64-like
|
||||
Midnight of the day for which data is requested.
|
||||
@@ -883,7 +883,7 @@ class SQLiteAdjustmentWriter(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.data.us_equity_pricing.SQLiteAdjustmentReader
|
||||
catalyst.data.us_equity_pricing.SQLiteAdjustmentReader
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
@@ -1197,7 +1197,7 @@ class SQLiteAdjustmentWriter(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.data.us_equity_pricing.SQLiteAdjustmentReader
|
||||
catalyst.data.us_equity_pricing.SQLiteAdjustmentReader
|
||||
"""
|
||||
self.write_frame('splits', splits)
|
||||
self.write_frame('mergers', mergers)
|
||||
@@ -1277,7 +1277,7 @@ class SQLiteAdjustmentReader(object):
|
||||
|
||||
See Also
|
||||
--------
|
||||
:class:`zipline.data.us_equity_pricing.SQLiteAdjustmentWriter`
|
||||
:class:`catalyst.data.us_equity_pricing.SQLiteAdjustmentWriter`
|
||||
"""
|
||||
|
||||
@preprocess(conn=coerce_string_to_conn)
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License.
|
||||
from textwrap import dedent
|
||||
|
||||
from zipline.utils.memoize import lazyval
|
||||
from catalyst.utils.memoize import lazyval
|
||||
|
||||
|
||||
class ZiplineError(Exception):
|
||||
@@ -782,7 +782,7 @@ class UnsupportedPipelineOutput(ZiplineError):
|
||||
class NonSliceableTerm(ZiplineError):
|
||||
"""
|
||||
Raised when attempting to index into a non-sliceable term, e.g. instances
|
||||
of `zipline.pipeline.term.LoadableTerm`.
|
||||
of `catalyst.pipeline.term.LoadableTerm`.
|
||||
"""
|
||||
msg = "Taking slices of {term} is not currently supported."
|
||||
|
||||
@@ -3,11 +3,11 @@ import os
|
||||
|
||||
from toolz import merge
|
||||
|
||||
from zipline import run_algorithm
|
||||
from catalyst import run_algorithm
|
||||
|
||||
|
||||
# These are used by test_examples.py to discover the examples to run.
|
||||
from zipline.utils.calendars import register_calendar, get_calendar
|
||||
from catalyst.utils.calendars import register_calendar, get_calendar
|
||||
|
||||
EXAMPLE_MODULES = {}
|
||||
for f in os.listdir(os.path.dirname(__file__)):
|
||||
@@ -64,7 +64,7 @@ _cols_to_check = [
|
||||
|
||||
def run_example(example_name, environ):
|
||||
"""
|
||||
Run an example module from zipline.examples.
|
||||
Run an example module from catalyst.examples.
|
||||
"""
|
||||
mod = EXAMPLE_MODULES[example_name]
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from zipline.api import order, symbol
|
||||
from catalyst.api import order, symbol
|
||||
|
||||
stocks = ['AAPL', 'MSFT']
|
||||
|
||||
@@ -31,7 +31,7 @@ def handle_data(context, data):
|
||||
|
||||
|
||||
def _test_args():
|
||||
"""Extra arguments to use when zipline's automated tests run this example.
|
||||
"""Extra arguments to use when catalyst's automated tests run this example.
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%matplotlib inline\n",
|
||||
"%load_ext zipline"
|
||||
"%load_ext catalyst"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2170,9 +2170,9 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"%%zipline --start=2011-1-1 --end=2013-1-1\n",
|
||||
"%%catalyst --start=2011-1-1 --end=2013-1-1\n",
|
||||
"\n",
|
||||
"from zipline.api import order, record, symbol\n",
|
||||
"from catalyst.api import order, record, symbol\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"\n",
|
||||
"def initialize(context):\n",
|
||||
@@ -14,7 +14,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from zipline.api import order, record, symbol
|
||||
from catalyst.api import order, record, symbol
|
||||
|
||||
|
||||
def initialize(context):
|
||||
@@ -44,7 +44,7 @@ def analyze(context=None, results=None):
|
||||
|
||||
|
||||
def _test_args():
|
||||
"""Extra arguments to use when zipline's automated tests run this example.
|
||||
"""Extra arguments to use when catalyst's automated tests run this example.
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
@@ -24,7 +24,7 @@ momentum).
|
||||
|
||||
"""
|
||||
|
||||
from zipline.api import order, record, symbol
|
||||
from catalyst.api import order, record, symbol
|
||||
# Import exponential moving average from talib wrapper
|
||||
from talib import EMA
|
||||
|
||||
@@ -99,7 +99,7 @@ def analyze(context=None, results=None):
|
||||
|
||||
|
||||
def _test_args():
|
||||
"""Extra arguments to use when zipline's automated tests run this example.
|
||||
"""Extra arguments to use when catalyst's automated tests run this example.
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
@@ -22,7 +22,7 @@ its shares once the averages cross again (indicating downwards
|
||||
momentum).
|
||||
"""
|
||||
|
||||
from zipline.api import order_target, record, symbol
|
||||
from catalyst.api import order_target, record, symbol
|
||||
|
||||
|
||||
def initialize(context):
|
||||
@@ -98,7 +98,7 @@ def analyze(context=None, results=None):
|
||||
|
||||
|
||||
def _test_args():
|
||||
"""Extra arguments to use when zipline's automated tests run this example.
|
||||
"""Extra arguments to use when catalyst's automated tests run this example.
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
@@ -3,7 +3,7 @@ A simple Pipeline algorithm that longs the top 3 stocks by RSI and shorts
|
||||
the bottom 3 each day.
|
||||
"""
|
||||
from six import viewkeys
|
||||
from zipline.api import (
|
||||
from catalyst.api import (
|
||||
attach_pipeline,
|
||||
date_rules,
|
||||
order_target_percent,
|
||||
@@ -11,9 +11,9 @@ from zipline.api import (
|
||||
record,
|
||||
schedule_function,
|
||||
)
|
||||
from zipline.pipeline import Pipeline
|
||||
from zipline.pipeline.factors.crypto import RSI as cRSI
|
||||
from zipline.pipeline.factors.equity import RSI as eRSI
|
||||
from catalyst.pipeline import Pipeline
|
||||
from catalyst.pipeline.factors.crypto import RSI as cRSI
|
||||
from catalyst.pipeline.factors.equity import RSI as eRSI
|
||||
|
||||
|
||||
def make_pipeline():
|
||||
@@ -73,7 +73,7 @@ def before_trading_start(context, data):
|
||||
|
||||
def _test_args():
|
||||
"""
|
||||
Extra arguments to use when zipline's automated tests run this example.
|
||||
Extra arguments to use when catalyst's automated tests run this example.
|
||||
|
||||
Notes for testers:
|
||||
|
||||
@@ -2,14 +2,14 @@ import sys
|
||||
import logbook
|
||||
import numpy as np
|
||||
|
||||
from zipline.finance import commission
|
||||
from catalyst.finance import commission
|
||||
|
||||
zipline_logging = logbook.NestedSetup([
|
||||
catalyst_logging = logbook.NestedSetup([
|
||||
logbook.NullHandler(),
|
||||
logbook.StreamHandler(sys.stdout, level=logbook.INFO),
|
||||
logbook.StreamHandler(sys.stderr, level=logbook.ERROR),
|
||||
])
|
||||
zipline_logging.push_application()
|
||||
catalyst_logging.push_application()
|
||||
|
||||
STOCKS = ['AMD', 'CERN', 'COST', 'DELL', 'GPS', 'INTC', 'MMM']
|
||||
|
||||
@@ -157,7 +157,7 @@ def analyze(context=None, results=None):
|
||||
|
||||
|
||||
def _test_args():
|
||||
"""Extra arguments to use when zipline's automated tests run this example.
|
||||
"""Extra arguments to use when catalyst's automated tests run this example.
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
@@ -7,9 +7,9 @@ from six import with_metaclass, iteritems
|
||||
from collections import namedtuple
|
||||
from toolz import groupby
|
||||
|
||||
from zipline.utils.enum import enum
|
||||
from zipline.utils.numpy_utils import vectorized_is_element
|
||||
from zipline.assets import Asset
|
||||
from catalyst.utils.enum import enum
|
||||
from catalyst.utils.numpy_utils import vectorized_is_element
|
||||
from catalyst.assets import Asset
|
||||
|
||||
|
||||
Restriction = namedtuple(
|
||||
@@ -203,7 +203,7 @@ class SecurityListRestrictions(Restrictions):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
restrictions : zipline.utils.security_list.SecurityList
|
||||
restrictions : catalyst.utils.security_list.SecurityList
|
||||
The restrictions defined by a SecurityList
|
||||
"""
|
||||
|
||||
@@ -18,21 +18,21 @@ from copy import copy
|
||||
|
||||
from six import iteritems
|
||||
|
||||
from zipline.assets import Equity, Future, Asset
|
||||
from zipline.finance.order import Order
|
||||
from zipline.finance.slippage import (
|
||||
from catalyst.assets import Equity, Future, Asset
|
||||
from catalyst.finance.order import Order
|
||||
from catalyst.finance.slippage import (
|
||||
DEFAULT_FUTURE_VOLUME_SLIPPAGE_BAR_LIMIT,
|
||||
VolatilityVolumeShare,
|
||||
VolumeShareSlippage,
|
||||
)
|
||||
from zipline.finance.commission import (
|
||||
from catalyst.finance.commission import (
|
||||
DEFAULT_PER_CONTRACT_COST,
|
||||
FUTURE_EXCHANGE_FEES_BY_SYMBOL,
|
||||
PerContract,
|
||||
PerShare,
|
||||
)
|
||||
from zipline.finance.cancel_policy import NeverCancel
|
||||
from zipline.utils.input_validation import expect_types
|
||||
from catalyst.finance.cancel_policy import NeverCancel
|
||||
from catalyst.utils.input_validation import expect_types
|
||||
|
||||
log = Logger('Blotter')
|
||||
warning_logger = Logger('AlgoWarning')
|
||||
@@ -98,13 +98,13 @@ class Blotter(object):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
asset : zipline.assets.Asset
|
||||
asset : catalyst.assets.Asset
|
||||
The asset that this order is for.
|
||||
amount : int
|
||||
The amount of shares to order. If ``amount`` is positive, this is
|
||||
the number of shares to buy or cover. If ``amount`` is negative,
|
||||
this is the number of shares to sell or short.
|
||||
style : zipline.finance.execution.ExecutionStyle
|
||||
style : catalyst.finance.execution.ExecutionStyle
|
||||
The execution style for the order.
|
||||
order_id : str, optional
|
||||
The unique identifier for this order.
|
||||
@@ -332,7 +332,7 @@ class Blotter(object):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
bar_data: zipline._protocol.BarData
|
||||
bar_data: catalyst._protocol.BarData
|
||||
|
||||
Notes
|
||||
-----
|
||||
@@ -17,7 +17,7 @@ import abc
|
||||
from abc import abstractmethod
|
||||
from six import with_metaclass
|
||||
|
||||
from zipline.gens.sim_engine import SESSION_END
|
||||
from catalyst.gens.sim_engine import SESSION_END
|
||||
|
||||
|
||||
class CancelPolicy(with_metaclass(abc.ABCMeta)):
|
||||
@@ -32,10 +32,10 @@ class CancelPolicy(with_metaclass(abc.ABCMeta)):
|
||||
----------
|
||||
event : enum-value
|
||||
An event type, one of:
|
||||
- :data:`zipline.gens.sim_engine.BAR`
|
||||
- :data:`zipline.gens.sim_engine.DAY_START`
|
||||
- :data:`zipline.gens.sim_engine.DAY_END`
|
||||
- :data:`zipline.gens.sim_engine.MINUTE_END`
|
||||
- :data:`catalyst.gens.sim_engine.BAR`
|
||||
- :data:`catalyst.gens.sim_engine.DAY_START`
|
||||
- :data:`catalyst.gens.sim_engine.DAY_END`
|
||||
- :data:`catalyst.gens.sim_engine.MINUTE_END`
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -18,10 +18,10 @@ from collections import defaultdict
|
||||
from six import with_metaclass
|
||||
from toolz import merge
|
||||
|
||||
from zipline.assets import Equity, Future
|
||||
from zipline.finance.constants import FUTURE_EXCHANGE_FEES_BY_SYMBOL
|
||||
from zipline.finance.shared import AllowedAssetMarker, FinancialModelMeta
|
||||
from zipline.utils.dummy import DummyMapping
|
||||
from catalyst.assets import Equity, Future
|
||||
from catalyst.finance.constants import FUTURE_EXCHANGE_FEES_BY_SYMBOL
|
||||
from catalyst.finance.shared import AllowedAssetMarker, FinancialModelMeta
|
||||
from catalyst.utils.dummy import DummyMapping
|
||||
|
||||
DEFAULT_PER_SHARE_COST = 0.0075 # 0.75 cents per share
|
||||
DEFAULT_PER_CONTRACT_COST = 0.85 # $0.85 per future contract
|
||||
@@ -50,13 +50,13 @@ class CommissionModel(with_metaclass(FinancialModelMeta)):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
order : zipline.finance.order.Order
|
||||
order : catalyst.finance.order.Order
|
||||
The order being processed.
|
||||
|
||||
The ``commission`` field of ``order`` is a float indicating the
|
||||
amount of commission already charged on this order.
|
||||
|
||||
transaction : zipline.finance.transaction.Transaction
|
||||
transaction : catalyst.finance.transaction.Transaction
|
||||
The transaction being processed. A single order may generate
|
||||
multiple transactions if there isn't enough volume in a given bar
|
||||
to fill the full amount requested in the order.
|
||||
@@ -100,7 +100,7 @@ FUTURE_EXCHANGE_FEES_BY_SYMBOL = {
|
||||
'YS': 0.75, # Silver e-mini
|
||||
}
|
||||
|
||||
# See `zipline.finance.slippage.VolatilityVolumeShare` for more information on
|
||||
# See `catalyst.finance.slippage.VolatilityVolumeShare` for more information on
|
||||
# how these constants are used.
|
||||
DEFAULT_ETA = 0.049018143225019836
|
||||
ROOT_SYMBOL_TO_ETA = {
|
||||
@@ -19,7 +19,7 @@ import pandas as pd
|
||||
|
||||
from six import with_metaclass
|
||||
|
||||
from zipline.errors import (
|
||||
from catalyst.errors import (
|
||||
AccountControlViolation,
|
||||
TradingControlViolation,
|
||||
)
|
||||
@@ -137,7 +137,7 @@ class RestrictedListOrder(TradingControl):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
restrictions : zipline.finance.asset_restrictions.Restrictions
|
||||
restrictions : catalyst.finance.asset_restrictions.Restrictions
|
||||
Object representing restrictions of a group of assets.
|
||||
"""
|
||||
|
||||
@@ -19,11 +19,11 @@ from sys import float_info
|
||||
|
||||
from six import with_metaclass
|
||||
|
||||
import zipline.utils.math_utils as zp_math
|
||||
import catalyst.utils.math_utils as zp_math
|
||||
|
||||
from numpy import isfinite
|
||||
|
||||
from zipline.errors import BadOrderParameters
|
||||
from catalyst.errors import BadOrderParameters
|
||||
|
||||
|
||||
class ExecutionStyle(with_metaclass(abc.ABCMeta)):
|
||||
@@ -17,10 +17,10 @@ import uuid
|
||||
|
||||
from six import text_type
|
||||
|
||||
import zipline.protocol as zp
|
||||
from zipline.assets import Asset
|
||||
from zipline.utils.enum import enum
|
||||
from zipline.utils.input_validation import expect_types
|
||||
import catalyst.protocol as zp
|
||||
from catalyst.assets import Asset
|
||||
from catalyst.utils.enum import enum
|
||||
from catalyst.utils.input_validation import expect_types
|
||||
|
||||
ORDER_STATUS = enum(
|
||||
'OPEN',
|
||||
@@ -76,7 +76,7 @@ import logbook
|
||||
import numpy as np
|
||||
|
||||
from collections import namedtuple
|
||||
from zipline.assets import Future
|
||||
from catalyst.assets import Future
|
||||
|
||||
try:
|
||||
# optional cython based OrderedDict
|
||||
@@ -86,7 +86,7 @@ except ImportError:
|
||||
|
||||
from six import itervalues, iteritems
|
||||
|
||||
import zipline.protocol as zp
|
||||
import catalyst.protocol as zp
|
||||
|
||||
log = logbook.Logger('Performance')
|
||||
TRADE_TYPE = zp.DATASOURCE_TYPE.TRADE
|
||||
@@ -37,8 +37,8 @@ from collections import OrderedDict
|
||||
import numpy as np
|
||||
import logbook
|
||||
|
||||
from zipline.assets import Future, Asset
|
||||
from zipline.utils.input_validation import expect_types
|
||||
from catalyst.assets import Future, Asset
|
||||
from catalyst.utils.input_validation import expect_types
|
||||
|
||||
log = logbook.Logger('Performance')
|
||||
|
||||
@@ -153,11 +153,11 @@ class Position(object):
|
||||
@expect_types(asset=Asset)
|
||||
def adjust_commission_cost_basis(self, asset, cost):
|
||||
"""
|
||||
A note about cost-basis in zipline: all positions are considered
|
||||
A note about cost-basis in catalyst: all positions are considered
|
||||
to share a cost basis, even if they were executed in different
|
||||
transactions with different commission costs, different prices, etc.
|
||||
|
||||
Due to limitations about how zipline handles positions, zipline will
|
||||
Due to limitations about how catalyst handles positions, catalyst will
|
||||
currently spread an externally-delivered commission charge across
|
||||
all shares in a position.
|
||||
"""
|
||||
+5
-5
@@ -22,11 +22,11 @@ from math import isnan
|
||||
|
||||
from six import iteritems, itervalues
|
||||
|
||||
from zipline.finance.performance.position import Position
|
||||
from zipline.finance.transaction import Transaction
|
||||
from zipline.utils.input_validation import expect_types
|
||||
import zipline.protocol as zp
|
||||
from zipline.assets import (
|
||||
from catalyst.finance.performance.position import Position
|
||||
from catalyst.finance.transaction import Transaction
|
||||
from catalyst.utils.input_validation import expect_types
|
||||
import catalyst.protocol as zp
|
||||
from catalyst.assets import (
|
||||
Future,
|
||||
Asset
|
||||
)
|
||||
@@ -52,7 +52,7 @@ Performance Tracking
|
||||
| _metrics | calculated based on the positions aggregated |
|
||||
| | through all the events delivered to this tracker. |
|
||||
| | For details look at the comments for |
|
||||
| | :py:meth:`zipline.finance.risk.RiskMetrics.to_dict`|
|
||||
| | :py:meth:`catalyst.finance.risk.RiskMetrics.to_dict`|
|
||||
+-----------------+----------------------------------------------------+
|
||||
|
||||
"""
|
||||
@@ -64,9 +64,9 @@ import logbook
|
||||
import pandas as pd
|
||||
from pandas.tseries.tools import normalize_date
|
||||
|
||||
from zipline.finance.performance.period import PerformancePeriod
|
||||
from zipline.errors import NoFurtherDataError
|
||||
import zipline.finance.risk as risk
|
||||
from catalyst.finance.performance.period import PerformancePeriod
|
||||
from catalyst.errors import NoFurtherDataError
|
||||
import catalyst.finance.risk as risk
|
||||
|
||||
from . position_tracker import PositionTracker
|
||||
|
||||
@@ -22,13 +22,13 @@ from pandas import isnull
|
||||
from six import with_metaclass
|
||||
from toolz import merge
|
||||
|
||||
from zipline.assets import Equity, Future
|
||||
from zipline.errors import HistoryWindowStartsBeforeData
|
||||
from zipline.finance.constants import ROOT_SYMBOL_TO_ETA
|
||||
from zipline.finance.shared import AllowedAssetMarker, FinancialModelMeta
|
||||
from zipline.finance.transaction import create_transaction
|
||||
from zipline.utils.cache import ExpiringCache
|
||||
from zipline.utils.dummy import DummyMapping
|
||||
from catalyst.assets import Equity, Future
|
||||
from catalyst.errors import HistoryWindowStartsBeforeData
|
||||
from catalyst.finance.constants import ROOT_SYMBOL_TO_ETA
|
||||
from catalyst.finance.shared import AllowedAssetMarker, FinancialModelMeta
|
||||
from catalyst.finance.transaction import create_transaction
|
||||
from catalyst.utils.cache import ExpiringCache
|
||||
from catalyst.utils.dummy import DummyMapping
|
||||
|
||||
SELL = 1 << 0
|
||||
BUY = 1 << 1
|
||||
@@ -54,7 +54,7 @@ def fill_price_worse_than_limit_price(fill_price, order):
|
||||
fill_price: float
|
||||
The price to check.
|
||||
|
||||
order: zipline.finance.order.Order
|
||||
order: catalyst.finance.order.Order
|
||||
The order whose limit price to check.
|
||||
|
||||
Returns
|
||||
@@ -20,11 +20,11 @@ from pandas.tslib import normalize_date
|
||||
from six import string_types
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
from zipline.assets import AssetDBWriter, AssetFinder
|
||||
from zipline.assets.continuous_futures import CHAIN_PREDICATES
|
||||
from zipline.data.loader import load_market_data
|
||||
from zipline.utils.calendars import get_calendar
|
||||
from zipline.utils.memoize import remember_last
|
||||
from catalyst.assets import AssetDBWriter, AssetFinder
|
||||
from catalyst.assets.continuous_futures import CHAIN_PREDICATES
|
||||
from catalyst.data.loader import load_market_data
|
||||
from catalyst.utils.calendars import get_calendar
|
||||
from catalyst.utils.memoize import remember_last
|
||||
|
||||
log = logbook.Logger('Trading')
|
||||
|
||||
@@ -34,7 +34,7 @@ DEFAULT_CAPITAL_BASE = 1e5
|
||||
|
||||
class TradingEnvironment(object):
|
||||
"""
|
||||
The financial simulations in zipline depend on information
|
||||
The financial simulations in catalyst depend on information
|
||||
about the benchmark index and the risk free rates of return.
|
||||
The benchmark index defines the benchmark returns used in
|
||||
the calculation of performance metrics such as alpha/beta. Many
|
||||
@@ -49,7 +49,7 @@ class TradingEnvironment(object):
|
||||
ensure proper rollover through daylight savings and so on.
|
||||
|
||||
User code will not normally need to use TradingEnvironment
|
||||
directly. If you are extending zipline's core financial
|
||||
directly. If you are extending catalyst's core financial
|
||||
components and need to use the environment, you must import the module and
|
||||
build a new TradingEnvironment object, then pass that TradingEnvironment as
|
||||
the 'env' arg to your TradingAlgorithm.
|
||||
@@ -16,9 +16,9 @@ from __future__ import division
|
||||
|
||||
from copy import copy
|
||||
|
||||
from zipline.assets import Asset
|
||||
from zipline.protocol import DATASOURCE_TYPE
|
||||
from zipline.utils.input_validation import expect_types
|
||||
from catalyst.assets import Asset
|
||||
from catalyst.protocol import DATASOURCE_TYPE
|
||||
from catalyst.utils.input_validation import expect_types
|
||||
|
||||
|
||||
class Transaction(object):
|
||||
@@ -15,11 +15,11 @@
|
||||
from contextlib2 import ExitStack
|
||||
from logbook import Logger, Processor
|
||||
from pandas.tslib import normalize_date
|
||||
from zipline.protocol import BarData
|
||||
from zipline.utils.api_support import ZiplineAPI
|
||||
from catalyst.protocol import BarData
|
||||
from catalyst.utils.api_support import ZiplineAPI
|
||||
from six import viewkeys
|
||||
|
||||
from zipline.gens.sim_engine import (
|
||||
from catalyst.gens.sim_engine import (
|
||||
BAR,
|
||||
SESSION_START,
|
||||
SESSION_END,
|
||||
@@ -19,7 +19,7 @@ import numbers
|
||||
|
||||
from hashlib import md5
|
||||
from datetime import datetime
|
||||
from zipline.protocol import DATASOURCE_TYPE
|
||||
from catalyst.protocol import DATASOURCE_TYPE
|
||||
|
||||
from six import iteritems, b
|
||||
|
||||
@@ -5,7 +5,7 @@ from libc.math cimport log
|
||||
cimport numpy as np
|
||||
import numpy as np
|
||||
|
||||
from zipline.utils.numpy_utils import unsigned_int_dtype_with_size_in_bytes
|
||||
from catalyst.utils.numpy_utils import unsigned_int_dtype_with_size_in_bytes
|
||||
|
||||
np.import_array()
|
||||
|
||||
@@ -7,9 +7,9 @@ file that's defined a type symbol named `databuffer` that can be used like a
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.lib._floatwindow
|
||||
zipline.lib._intwindow
|
||||
zipline.lib._datewindow
|
||||
catalyst.lib._floatwindow
|
||||
catalyst.lib._intwindow
|
||||
catalyst.lib._datewindow
|
||||
"""
|
||||
from numpy cimport ndarray
|
||||
from numpy import asanyarray, dtype, issubdtype
|
||||
@@ -13,18 +13,18 @@ from numpy import (
|
||||
uint32,
|
||||
uint8,
|
||||
)
|
||||
from zipline.errors import (
|
||||
from catalyst.errors import (
|
||||
WindowLengthNotPositive,
|
||||
WindowLengthTooLong,
|
||||
)
|
||||
from zipline.lib.labelarray import LabelArray
|
||||
from zipline.utils.numpy_utils import (
|
||||
from catalyst.lib.labelarray import LabelArray
|
||||
from catalyst.utils.numpy_utils import (
|
||||
datetime64ns_dtype,
|
||||
float64_dtype,
|
||||
int64_dtype,
|
||||
uint8_dtype,
|
||||
)
|
||||
from zipline.utils.memoize import lazyval
|
||||
from catalyst.utils.memoize import lazyval
|
||||
|
||||
# These class names are all the same because of our bootleg templating system.
|
||||
from ._float64window import AdjustedArrayWindow as Float64Window
|
||||
@@ -274,7 +274,7 @@ def ensure_ndarray(ndarray_or_adjusted_array):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
ndarray_or_adjusted_array : numpy.ndarray | zipline.data.adjusted_array
|
||||
ndarray_or_adjusted_array : numpy.ndarray | catalyst.data.adjusted_array
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -5,7 +5,7 @@ from pandas import isnull, Timestamp
|
||||
from numpy cimport float64_t, uint8_t, int64_t
|
||||
from numpy import asarray, datetime64, float64, int64
|
||||
|
||||
from zipline.utils.compat import unicode
|
||||
from catalyst.utils.compat import unicode
|
||||
|
||||
# Purely for readability. There aren't C-level declarations for these types.
|
||||
ctypedef object Int64Index_t
|
||||
@@ -786,7 +786,7 @@ cdef class ObjectOverwrite(_ObjectAdjustment):
|
||||
|
||||
cpdef mutate(self, object data):
|
||||
# data is an object here because this is intended to be used with a
|
||||
# `zipline.lib.LabelArray`.
|
||||
# `catalyst.lib.LabelArray`.
|
||||
|
||||
# We don't do this in a loop because we only want to look up the label
|
||||
# code in the array's categories once.
|
||||
@@ -10,22 +10,22 @@ from numpy import ndarray
|
||||
import pandas as pd
|
||||
from toolz import compose
|
||||
|
||||
from zipline.utils.compat import unicode
|
||||
from zipline.utils.functional import instance
|
||||
from zipline.utils.preprocess import preprocess
|
||||
from zipline.utils.sentinel import sentinel
|
||||
from zipline.utils.input_validation import (
|
||||
from catalyst.utils.compat import unicode
|
||||
from catalyst.utils.functional import instance
|
||||
from catalyst.utils.preprocess import preprocess
|
||||
from catalyst.utils.sentinel import sentinel
|
||||
from catalyst.utils.input_validation import (
|
||||
coerce,
|
||||
expect_kinds,
|
||||
expect_types,
|
||||
optional,
|
||||
)
|
||||
from zipline.utils.numpy_utils import (
|
||||
from catalyst.utils.numpy_utils import (
|
||||
bool_dtype,
|
||||
unsigned_int_dtype_with_size_in_bytes,
|
||||
is_object,
|
||||
)
|
||||
from zipline.utils.pandas_utils import ignore_pandas_nan_categorical_warning
|
||||
from catalyst.utils.pandas_utils import ignore_pandas_nan_categorical_warning
|
||||
|
||||
from ._factorize import (
|
||||
factorize_strings,
|
||||
@@ -17,7 +17,7 @@ from numpy cimport (
|
||||
from numpy import apply_along_axis, float64, isnan, nan
|
||||
from scipy.stats import rankdata
|
||||
|
||||
from zipline.utils.numpy_utils import (
|
||||
from catalyst.utils.numpy_utils import (
|
||||
is_missing,
|
||||
float64_dtype,
|
||||
int64_dtype,
|
||||
@@ -1,5 +1,5 @@
|
||||
from __future__ import print_function
|
||||
from zipline.assets import AssetFinder
|
||||
from catalyst.assets import AssetFinder
|
||||
|
||||
from .classifiers import Classifier, CustomClassifier
|
||||
from .engine import SimplePipelineEngine
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Utilities for creating public APIs (e.g. argument validation decorators).
|
||||
"""
|
||||
from zipline.utils.input_validation import preprocess
|
||||
from catalyst.utils.input_validation import preprocess
|
||||
|
||||
|
||||
def restrict_to_dtype(dtype, message_template):
|
||||
@@ -10,7 +10,7 @@ def restrict_to_dtype(dtype, message_template):
|
||||
Terms with a specific dtype.
|
||||
|
||||
This is conceptually similar to
|
||||
zipline.utils.input_validation.expect_dtypes, but provides more flexibility
|
||||
catalyst.utils.input_validation.expect_dtypes, but provides more flexibility
|
||||
for providing error messages that are specifically targeting Term methods.
|
||||
|
||||
Parameters
|
||||
+16
-16
@@ -8,15 +8,15 @@ import re
|
||||
from numpy import where, isnan, nan, zeros
|
||||
import pandas as pd
|
||||
|
||||
from zipline.lib.labelarray import LabelArray
|
||||
from zipline.lib.quantiles import quantiles
|
||||
from zipline.pipeline.api_utils import restrict_to_dtype
|
||||
from zipline.pipeline.sentinels import NotSpecified
|
||||
from zipline.pipeline.term import ComputableTerm
|
||||
from zipline.utils.compat import unicode
|
||||
from zipline.utils.input_validation import expect_types, expect_dtypes
|
||||
from zipline.utils.memoize import classlazyval
|
||||
from zipline.utils.numpy_utils import (
|
||||
from catalyst.lib.labelarray import LabelArray
|
||||
from catalyst.lib.quantiles import quantiles
|
||||
from catalyst.pipeline.api_utils import restrict_to_dtype
|
||||
from catalyst.pipeline.sentinels import NotSpecified
|
||||
from catalyst.pipeline.term import ComputableTerm
|
||||
from catalyst.utils.compat import unicode
|
||||
from catalyst.utils.input_validation import expect_types, expect_dtypes
|
||||
from catalyst.utils.memoize import classlazyval
|
||||
from catalyst.utils.numpy_utils import (
|
||||
categorical_dtype,
|
||||
int64_dtype,
|
||||
vectorized_is_element,
|
||||
@@ -330,7 +330,7 @@ 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:`~zipline.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)
|
||||
@@ -409,7 +409,7 @@ class Relabel(SingleInputMixin, Classifier):
|
||||
|
||||
Parameters
|
||||
----------
|
||||
arg : zipline.pipeline.Classifier
|
||||
arg : catalyst.pipeline.Classifier
|
||||
Term produceing the input to be relabeled.
|
||||
relabel_func : function(LabelArray) -> LabelArray
|
||||
Function to apply to the result of `term`.
|
||||
@@ -455,8 +455,8 @@ class CustomClassifier(PositiveWindowLengthMixin,
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.pipeline.CustomFactor
|
||||
zipline.pipeline.CustomFilter
|
||||
catalyst.pipeline.CustomFactor
|
||||
catalyst.pipeline.CustomFilter
|
||||
"""
|
||||
def _allocate_output(self, windows, shape):
|
||||
"""
|
||||
@@ -481,9 +481,9 @@ class Latest(LatestMixin, CustomClassifier):
|
||||
|
||||
See Also
|
||||
--------
|
||||
zipline.pipeline.data.dataset.BoundColumn.latest
|
||||
zipline.pipeline.factors.factor.Latest
|
||||
zipline.pipeline.filters.filter.Latest
|
||||
catalyst.pipeline.data.dataset.BoundColumn.latest
|
||||
catalyst.pipeline.factors.factor.Latest
|
||||
catalyst.pipeline.filters.filter.Latest
|
||||
"""
|
||||
pass
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user