Config
QuantConnect.Configuration.Config
Bases: Object
Configuration class loads the required external setup variables to launch the Lean engine.
flatten
flatten(config: Any, override_environment: str) -> Any
flatten(override_environment: str) -> Any
Flattens the jobject with respect to the selected environment and then removes the 'environments' node
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[Any]
|
The configuration represented as a JObject |
None
|
override_environment
|
str
|
The environment to use |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The flattened JObject. |
get
get(key: str, default_value: str = ...) -> str
Get the matching config setting from the file searching for this key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
String key value we're seaching for in the config file. |
required |
default_value
|
str
|
|
...
|
Returns:
| Type | Description |
|---|---|
str
|
String value of the configuration setting or empty string if nothing found. |
get_bool
get_bool(key: str, default_value: bool = False) -> bool
Get a boolean value configuration setting by a configuration key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
String value of the configuration key. |
required |
default_value
|
bool
|
The default value to use if not found in configuration |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
Boolean value of the config setting. |
get_double
get_double(key: str, default_value: float = 0.0) -> float
Get the double value of a config string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Search key from the config file |
required |
default_value
|
float
|
The default value to use if not found in configuration |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
Double value of the config setting. |
get_environment
get_environment() -> str
Gets the currently selected environment. If sub-environments are defined, they'll be returned as {env1}.{env2}
Returns:
| Type | Description |
|---|---|
str
|
The fully qualified currently selected environment. |
get_int
get_int(key: str, default_value: int = 0) -> int
Get the int value of a config string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Search key from the config file |
required |
default_value
|
int
|
The default value to use if not found in configuration |
0
|
Returns:
| Type | Description |
|---|---|
int
|
Int value of the config setting. |
get_token
get_token(key: str) -> Any
Gets the underlying JToken for the specified key
merge_command_line_arguments_with_configuration
merge_command_line_arguments_with_configuration(
cli_arguments: Dictionary[str, Object],
) -> None
Merge CLI arguments with configuration file + load custom config file via CLI arg
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cli_arguments
|
Dictionary[str, Object]
|
|
required |
reset
reset() -> None
Resets the config settings to their default values. Called in regression tests where multiple algorithms are run sequentially, and we need to guarantee that every test starts with the same configuration.
set
set(key: str, value: Any) -> None
Sets a configuration value. This is really only used to help testing. The key heye can be specified as {environment}.key to set a value on a specific environment
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to be set |
required |
value
|
Any
|
The new value |
required |
set_configuration_file
set_configuration_file(file_name: str) -> None
Set configuration file on-fly
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name
|
str
|
|
required |
write
write(target_path: str = None) -> None
Write the contents of the serialized configuration back to the disk.