How to use the catalyst.errors.ZiplineError function in catalyst

To help you get started, we’ve selected a few catalyst examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enigmampc / catalyst / catalyst / errors.py View on Github external
The commission model '{given_model}' only supports {supported_asset_types}.
""".strip()


class UnsupportedCancelPolicy(ZiplineError):
    """
    Raised if a user script calls set_cancel_policy with an object that isn't
    a CancelPolicy.
    """
    msg = """
You attempted to set the cancel policy with an unsupported class.  Please use
an instance of CancelPolicy.
""".strip()


class SetCommissionPostInit(ZiplineError):
    """
    Raised if a users script calls set_commission magic
    after the initialize method has returned.
    """
    msg = """
You attempted to override commission outside of `initialize`. \
You may only call 'set_commission' in your initialize method.
""".strip()


class TransactionWithNoVolume(ZiplineError):
    """
    Raised if a transact call returns a transaction with zero volume.
    """
    msg = """
Transaction {txn} has a volume of zero.
github enigmampc / catalyst / catalyst / exchange / exchange_errors.py View on Github external
msg = ('Unable to find bundle data for exchange {exchange} and '
           'data frequency {data_frequency}.'
           'Please ingest some price data.'
           'See `catalyst ingest-exchange --help` for details.').strip()


class TempBundleNotFoundError(ZiplineError):
    msg = ('Temporary bundle not found in: {path}.').strip()


class EmptyValuesInBundleError(ZiplineError):
    msg = ('{name} with end minute {end_minute} has empty rows '
           'in ranges: {dates}').strip()


class PricingDataBeforeTradingError(ZiplineError):
    msg = ('Pricing data for trading pairs {symbols} on exchange {exchange} '
           'starts on {first_trading_day}, but you are either trying to trade '
           'or retrieve pricing data on {dt}. Adjust your dates accordingly.'
           ).strip()


class PricingDataNotLoadedError(ZiplineError):
    msg = ('Missing data for {exchange} {symbols} in date range '
           '[{start_dt} - {end_dt}]'
           '\nPlease run: `catalyst ingest-exchange -x {exchange} -f '
           '{data_frequency} -i {symbol_list}`. See catalyst documentation '
           'for details.').strip()


class PricingDataValueError(ZiplineError):
    msg = ('Unable to retrieve pricing data for {exchange} {symbol} '
github enigmampc / catalyst / catalyst / exchange / exchange_errors.py View on Github external
'Total {currency} amount on {exchange} is lower than the cash '
        'reserved for this algo: {free} < {cash}. While trades can be made on '
        'the exchange accounts outside of the algo, exchange must have enough '
        'free {currency} to cover the algo cash.'
    ).strip()


class LastCandleTooEarlyError(ZiplineError):
    msg = (
        'The trade date of the last candle {last_traded} is before the '
        'specified end date minus one candle {end_dt}. Please verify how '
        '{exchange} calculates the start date of OHLCV candles.'
    ).strip()


class TickerNotFoundError(ZiplineError):
    msg = (
        'Unable to fetch ticker for {symbol} on {exchange}.'
    ).strip()


class BalanceNotFoundError(ZiplineError):
    msg = (
        '{currency} not found in account balance on {exchange}: {balances}.'
    ).strip()


class BalanceTooLowError(ZiplineError):
    msg = (
        'Balance for {currency} on {exchange} too low: {free} < {amount}. '
        'Positions have likely been sold outside of this algorithm. Please '
github enigmampc / catalyst / catalyst / errors.py View on Github external
"Expected a list of strings as a class-level attribute for "
        "{termname}.params, but got {value} instead."
    )


class DTypeNotSpecified(ZiplineError):
    """
    Raised if a user attempts to construct a term without specifying dtype and
    that term does not have class-level default dtype.
    """
    msg = (
        "{termname} requires a dtype, but no dtype was passed."
    )


class NotDType(ZiplineError):
    """
    Raised when a pipeline Term is constructed with a dtype that isn't a numpy
    dtype object.
    """
    msg = (
        "{termname} expected a numpy dtype "
        "object for a dtype, but got {dtype} instead."
    )


class UnsupportedDType(ZiplineError):
    """
    Raised when a pipeline Term is constructed with a dtype that's not
    supported.
    """
    msg = (
github enigmampc / catalyst / catalyst / exchange / exchange_errors.py View on Github external
msg = (
        'Order type `{order_type}` not currency supported by Catalyst. '
        'Please use `limit` or `market` orders only.'
    ).strip()


class NotEnoughCapitalError(ZiplineError):
    msg = (
        'Not enough capital on exchange {exchange} for trading. Each '
        'exchange should contain at least as much {base_currency} '
        'as the specified `capital_base`. The current balance {balance} is '
        'lower than the `capital_base`: {capital_base}'
    ).strip()


class NotEnoughCashError(ZiplineError):
    msg = (
        'Total {currency} amount on {exchange} is lower than the cash '
        'reserved for this algo: {free} < {cash}. While trades can be made on '
        'the exchange accounts outside of the algo, exchange must have enough '
        'free {currency} to cover the algo cash.'
    ).strip()


class LastCandleTooEarlyError(ZiplineError):
    msg = (
        'The trade date of the last candle {last_traded} is before the '
        'specified end date minus one candle {end_dt}. Please verify how '
        '{exchange} calculates the start date of OHLCV candles.'
    ).strip()
github enigmampc / catalyst / catalyst / exchange / exchange_errors.py View on Github external
class UnsupportedHistoryFrequencyError(ZiplineError):
    msg = (
        '{exchange} does not support candle frequency {freq}, please choose '
        'from: {freqs}.'
    ).strip()


class InvalidHistoryTimeframeError(ZiplineError):
    msg = (
        'CCXT timeframe {timeframe} not supported by the exchange.'
    ).strip()


class MismatchingFrequencyError(ZiplineError):
    msg = (
        'Bar aggregate frequency {frequency} not compatible with '
        'data frequency {data_frequency}.'
    ).strip()


class InvalidSymbolError(ZiplineError):
    msg = (
        'Invalid trading pair symbol: {symbol}. '
        'Catalyst symbols must follow this convention: '
        '[Market Currency]_[Base Currency]. For example: eth_usd, btc_usd, '
        'neo_eth, ubq_btc. Error details: {error}'
    ).strip()


class InvalidOrderStyle(ZiplineError):
github enigmampc / catalyst / catalyst / errors.py View on Github external
msg = """
Transaction {txn} has an amount of zero.
""".strip()


class TransactionVolumeExceedsOrder(ZiplineError):
    """
    Raised if a transact call returns a transaction with a volume greater than
the corresponding order.
    """
    msg = """
Transaction volume of {txn} exceeds the order volume of {order}.
""".strip()


class UnsupportedOrderParameters(ZiplineError):
    """
    Raised if a set of mutually exclusive parameters are passed to an order
    call.
    """
    msg = "{msg}"


class CannotOrderDelistedAsset(ZiplineError):
    """
    Raised if an order is for a delisted asset.
    """
    msg = "{msg}"


class BadOrderParameters(ZiplineError):
    """
github enigmampc / catalyst / catalyst / utils / argcheck.py View on Github external
callable_, args, starargs, kwargs
        )

    # Empty argument that will not match with any actual arguments.
    missing_arg = Argument(object(), object())

    for expected, provided in zip_longest(expected_arg_list,
                                          args,
                                          fillvalue=missing_arg):
        if not expected.matches(provided):
            raise MismatchedArguments(
                callable_, args, starargs, kwargs
            )


class BadCallable(TypeError, AssertionError, ZiplineError):
    """
    The given callable is not structured in the expected way.
    """
    _lambda_name = (lambda: None).__name__

    def __init__(self, callable_, args, starargs, kwargs):
        self.callable_ = callable_
        self.args = args
        self.starargs = starargs
        self.kwargsname = kwargs

        self.kwargs = {}

    def format_callable(self):
        if self.callable_.__name__ == self._lambda_name:
            fmt = '%s %s'
github enigmampc / catalyst / catalyst / errors.py View on Github external
msg = (
        "Cannot add column {column_name!r} with term {term}. Adding slices or "
        "single-column-output terms as pipeline columns is not currently "
        "supported."
    )


class NonSliceableTerm(ZiplineError):
    """
    Raised when attempting to index into a non-sliceable term, e.g. instances
    of `catalyst.pipeline.term.LoadableTerm`.
    """
    msg = "Taking slices of {term} is not currently supported."


class IncompatibleTerms(ZiplineError):
    """
    Raised when trying to compute correlations/regressions between two 2D
    factors with different masks.
    """
    msg = (
        "{term_1} and {term_2} must have the same mask in order to compute "
        "correlations and regressions asset-wise."
github enigmampc / catalyst / catalyst / errors.py View on Github external
return "No future contracts found for sids: {sids}."
        return "No future contract found for sid: {sids[0]}."


class ConsumeAssetMetaDataError(ZiplineError):
    """
    Raised when AssetFinder.consume() is called on an invalid object.
    """
    msg = """
AssetFinder can not consume metadata of type {obj}. Metadata must be a dict, a
DataFrame, or a tables.Table. If the provided metadata is a Table, the rows
must contain both or one of 'sid' or 'symbol'.
""".strip()


class MapAssetIdentifierIndexError(ZiplineError):
    """
    Raised when AssetMetaData.map_identifier_index_to_sids() is called on an
    index of invalid objects.
    """
    msg = """
AssetFinder can not map an index with values of type {obj}. Asset indices of
DataFrames or Panels must be integer sids, string symbols, or Asset objects.
""".strip()


class SidAssignmentError(ZiplineError):
    """
    Raised when an AssetFinder tries to build an Asset that does not have a sid
    and that AssetFinder is not permitted to assign sids.
    """
    msg = """