Skip to content

Loader

QuantConnect.AlgorithmFactory.Loader

Loader()
Loader(
    debugging: bool,
    language: Language,
    loader_time_limit: timedelta,
    multiple_type_name_resolver_function: Callable[
        [List[str]], str
    ],
    worker_thread: WorkerThread = None,
)

Bases: MarshalByRefObject

Loader creates and manages the memory and exception space of the algorithm, ensuring if it explodes the Lean Engine is intact.

Signature descriptions:

  • Creates a new loader with a 10 second maximum load time that forces exactly one derived type to be found

  • Creates a new loader with the specified configuration

Parameters:

Name Type Description Default
debugging Optional[bool]

True if we are debugging

None
language Optional[Language]

Which language are we trying to load

None
loader_time_limit Optional[timedelta]

Used to limit how long it takes to create a new instance

None
multiple_type_name_resolver_function Optional[Callable[[List[str]], str]]

Used to resolve multiple type names found in assembly to a single type name, if null, defaults to names => names.SingleOrDefault()

None
worker_thread Optional[WorkerThread]

The worker thread instance the loader should use

None

app_domain

app_domain: AppDomain

Memory space of the user algorithm

get_extended_type_names

get_extended_type_names(assembly: Assembly) -> List[str]

Get a list of all the matching type names in this DLL assembly:

Parameters:

Name Type Description Default
assembly Assembly

Assembly dll we're loading.

required

Returns:

Type Description
List[str]

String list of types available.

try_create_algorithm_instance

try_create_algorithm_instance(
    assembly_path: str,
    algorithm_instance: Optional[IAlgorithm],
    error_message: Optional[str],
) -> Tuple[bool, IAlgorithm, str]

Creates a new instance of the specified class in the library, safely.

Parameters:

Name Type Description Default
assembly_path str

Location of the DLL

required
algorithm_instance Optional[IAlgorithm]

Output algorithm instance

required
error_message Optional[str]

Output error message on failure

required

Returns:

Type Description
Tuple[bool, IAlgorithm, str]

Bool true on successfully loading the class.

try_create_algorithm_instance_with_isolator

try_create_algorithm_instance_with_isolator(
    assembly_path: str,
    ram_limit: int,
    algorithm_instance: Optional[IAlgorithm],
    error_message: Optional[str],
) -> Tuple[bool, IAlgorithm, str]

Creates a new instance of the class in the library, safely.

Parameters:

Name Type Description Default
assembly_path str

Location of the DLL

required
ram_limit int

Limit of the RAM for this process

required
algorithm_instance Optional[IAlgorithm]

Output algorithm instance

required
error_message Optional[str]

Output error message on failure

required

Returns:

Type Description
Tuple[bool, IAlgorithm, str]

bool success.

unload

unload() -> None