Skip to content

PythonUtil

QuantConnect.Util.PythonUtil

Bases: Object

Collection of utils for python objects processing

exception_line_shift

exception_line_shift: int

The python exception stack trace line shift to use

convert_to_symbols

convert_to_symbols(input: Any) -> Iterable[Symbol]

Convert Python input to a list of Symbols

Parameters:

Name Type Description Default
input Any

Object with the desired property

required

Returns:

Type Description
Iterable[Symbol]

List of Symbols.

python_exception_message_parser

python_exception_message_parser(message: str) -> str

Parsers Exception.Message into a readable message

Parameters:

Name Type Description Default
message str

The python exception message

required

Returns:

Type Description
str

String with relevant part of the stacktrace.

python_exception_parser

python_exception_parser(python_exception: Any) -> str

Parsers PythonException into a readable message

Parameters:

Name Type Description Default
python_exception Any

The exception to parse

required

Returns:

Type Description
str

String with relevant part of the stacktrace.

python_exception_stack_parser

python_exception_stack_parser(value: str) -> str

Parsers PythonException.StackTrace into a readable message

Parameters:

Name Type Description Default
value str

String with the stacktrace information

required

Returns:

Type Description
str

String with relevant part of the stacktrace.

to_coarse_fundamental_selector

to_coarse_fundamental_selector(
    py_object: Any,
) -> Callable[
    [Iterable[CoarseFundamental]], Iterable[Symbol]
]

Encapsulates a python method in coarse fundamental universe selector.

Parameters:

Name Type Description Default
py_object Any

The python method

required

Returns:

Type Description
Callable[[Iterable[CoarseFundamental]], Iterable[Symbol]]

A Func{T, TResult} (parameter is IEnumerable{CoarseFundamental}, return value is IEnumerable{Symbol}) that encapsulates the python method.

to_fine_fundamental_selector

to_fine_fundamental_selector(
    py_object: Any,
) -> Callable[
    [Iterable[FineFundamental]], Iterable[Symbol]
]

Encapsulates a python method in fine fundamental universe selector.

Parameters:

Name Type Description Default
py_object Any

The python method

required

Returns:

Type Description
Callable[[Iterable[FineFundamental]], Iterable[Symbol]]

A Func{T, TResult} (parameter is IEnumerable{FineFundamental}, return value is IEnumerable{Symbol}) that encapsulates the python method.