Repository: quantopian/zipline
File: zipline/errors.py (Python)

Code before:
    msg = "history() should only be called in handle_data()"


class OrderInBeforeTradingStart(ZiplineError):
    """
    Raised when an algorithm calls an order method in before_trading_start.
    """
    msg = "Cannot place orders inside before_trading_start."


class MultipleSymbolsFound(ZiplineError):
    """
    Raised when a symbol() call contains a symbol that changed over
    time and is thus not resolvable without additional information
    provided via as_of_date.
    """
    msg = """
Multiple symbols with the name '{symbol}' found. Use the
as_of_date' argument to to specify when the date symbol-lookup
should be valid.

Possible options: {options}
    """.strip()


class MultipleSymbolsFoundForFuzzySymbol(ZiplineError):
    """
    Raised when a fuzzy symbol lookup is not resolvable without additional
    information.
    """
    msg = dedent("""\
        Multiple symbols were found fuzzy matching the name '{symbol}'. Use
        the as_of_date and/or country_code arguments to to specify the date
        and country for the symbol-lookup.

        Possible options: {options}
    """)


class SameSymbolUsedAcrossCountries(ZiplineError):
    """
    Raised when a symbol() call contains a symbol that is used in more than
    one country and is thus not resolvable without a country_code.
    """
    msg = dedent("""\
        The symbol '{symbol}' is used in more than one country. Use the
        country_code' argument to to specify the country.

        Possible options: {options}
    """)


Review comment (suggestion):
Could a case be made for having this subclass `MultipleSymbolsFound`? I'm not sure from this PR what the motivation for separating these is.

Code after:
    msg = "history() should only be called in handle_data()"


class OrderInBeforeTradingStart(ZiplineError):
    """
    Raised when an algorithm calls an order method in before_trading_start.
    """
    msg = "Cannot place orders inside before_trading_start."


class MultipleSymbolsFound(ZiplineError):
    """
    Raised when a symbol() call contains a symbol that changed over
    time and is thus not resolvable without additional information
    provided via as_of_date.
    """
    msg = """
Multiple symbols with the name '{symbol}' found. Use the
as_of_date' argument to to specify when the date symbol-lookup
should be valid.

Possible options: {options}
    """.strip()


class MultipleSymbolsFoundForFuzzySymbol(MultipleSymbolsFound):
    """
    Raised when a fuzzy symbol lookup is not resolvable without additional
    information.
    """
    msg = dedent("""\
        Multiple symbols were found fuzzy matching the name '{symbol}'. Use
        the as_of_date and/or country_code arguments to to specify the date
        and country for the symbol-lookup.

        Possible options: {options}
    """)


class SameSymbolUsedAcrossCountries(MultipleSymbolsFound):
    """
    Raised when a symbol() call contains a symbol that is used in more than
    one country and is thus not resolvable without a country_code.
    """
    msg = dedent("""\
        The symbol '{symbol}' is used in more than one country. Use the
        country_code argument to to specify the country.

        Possible options by country: {options}
    """)