Lean  $LEAN_TAG$
QuantConnect.Configuration.Config Class Reference

Configuration class loads the required external setup variables to launch the Lean engine. More...

Static Public Member Functions

static void SetConfigurationFile (string fileName)
 Set configuration file on-fly More...
 
static void MergeCommandLineArgumentsWithConfiguration (Dictionary< string, object > cliArguments)
 Merge CLI arguments with configuration file + load custom config file via CLI arg More...
 
static void Reset ()
 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. More...
 
static string GetEnvironment ()
 Gets the currently selected environment. If sub-environments are defined, they'll be returned as {env1}.{env2} More...
 
static string Get (string key, string defaultValue="")
 Get the matching config setting from the file searching for this key. More...
 
static JToken GetToken (string key)
 Gets the underlying JToken for the specified key More...
 
static void Set (string key, dynamic value)
 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 More...
 
static bool GetBool (string key, bool defaultValue=false)
 Get a boolean value configuration setting by a configuration key. More...
 
static int GetInt (string key, int defaultValue=0)
 Get the int value of a config string. More...
 
static double GetDouble (string key, double defaultValue=0.0)
 Get the double value of a config string. More...
 
static T GetValue< T > (string key, T defaultValue=default(T))
 Gets a value from configuration and converts it to the requested type, assigning a default if the configuration is null or empty More...
 
static bool TryGetValue< T > (string key, out T value)
 Tries to find the specified key and parse it as a T, using default(T) if unable to locate the key or unable to parse it More...
 
static bool TryGetValue< T > (string key, T defaultValue, out T value)
 Tries to find the specified key and parse it as a T, using defaultValue if unable to locate the key or unable to parse it More...
 
static void Write (string targetPath=null)
 Write the contents of the serialized configuration back to the disk. More...
 
static JObject Flatten (string overrideEnvironment)
 Flattens the jobject with respect to the selected environment and then removes the 'environments' node More...
 
static JObject Flatten (JObject config, string overrideEnvironment)
 Flattens the jobject with respect to the selected environment and then removes the 'environments' node More...
 

Detailed Description

Configuration class loads the required external setup variables to launch the Lean engine.

Definition at line 31 of file Config.cs.

Member Function Documentation

◆ SetConfigurationFile()

static void QuantConnect.Configuration.Config.SetConfigurationFile ( string  fileName)
static

Set configuration file on-fly

Parameters
fileName

Definition at line 40 of file Config.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MergeCommandLineArgumentsWithConfiguration()

static void QuantConnect.Configuration.Config.MergeCommandLineArgumentsWithConfiguration ( Dictionary< string, object >  cliArguments)
static

Merge CLI arguments with configuration file + load custom config file via CLI arg

Parameters
cliArguments

Definition at line 57 of file Config.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reset()

static void QuantConnect.Configuration.Config.Reset ( )
static

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.

Definition at line 78 of file Config.cs.

Here is the caller graph for this function:

◆ GetEnvironment()

static string QuantConnect.Configuration.Config.GetEnvironment ( )
static

Gets the currently selected environment. If sub-environments are defined, they'll be returned as {env1}.{env2}

Returns
The fully qualified currently selected environment

Definition at line 114 of file Config.cs.

Here is the caller graph for this function:

◆ Get()

static string QuantConnect.Configuration.Config.Get ( string  key,
string  defaultValue = "" 
)
static

Get the matching config setting from the file searching for this key.

Parameters
keyString key value we're seaching for in the config file.
defaultValue
Returns
String value of the configuration setting or empty string if nothing found.

Definition at line 141 of file Config.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetToken()

static JToken QuantConnect.Configuration.Config.GetToken ( string  key)
static

Gets the underlying JToken for the specified key

Definition at line 158 of file Config.cs.

Here is the caller graph for this function:

◆ Set()

static void QuantConnect.Configuration.Config.Set ( string  key,
dynamic  value 
)
static

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
keyThe key to be set
valueThe new value

Definition at line 169 of file Config.cs.

◆ GetBool()

static bool QuantConnect.Configuration.Config.GetBool ( string  key,
bool  defaultValue = false 
)
static

Get a boolean value configuration setting by a configuration key.

Parameters
keyString value of the configuration key.
defaultValueThe default value to use if not found in configuration
Returns
Boolean value of the config setting.

Definition at line 192 of file Config.cs.

Here is the caller graph for this function:

◆ GetInt()

static int QuantConnect.Configuration.Config.GetInt ( string  key,
int  defaultValue = 0 
)
static

Get the int value of a config string.

Parameters
keySearch key from the config file
defaultValueThe default value to use if not found in configuration
Returns
Int value of the config setting.

Definition at line 203 of file Config.cs.

Here is the caller graph for this function:

◆ GetDouble()

static double QuantConnect.Configuration.Config.GetDouble ( string  key,
double  defaultValue = 0.0 
)
static

Get the double value of a config string.

Parameters
keySearch key from the config file
defaultValueThe default value to use if not found in configuration
Returns
Double value of the config setting.

Definition at line 214 of file Config.cs.

Here is the caller graph for this function:

◆ GetValue< T >()

static T QuantConnect.Configuration.Config.GetValue< T > ( string  key,
defaultValue = default(T) 
)
static

Gets a value from configuration and converts it to the requested type, assigning a default if the configuration is null or empty

Template Parameters
TThe requested type
Parameters
keySearch key from the config file
defaultValueThe default value to use if not found in configuration
Returns
Converted value of the config setting.

Definition at line 227 of file Config.cs.

Here is the call graph for this function:

◆ TryGetValue< T >() [1/2]

static bool QuantConnect.Configuration.Config.TryGetValue< T > ( string  key,
out T  value 
)
static

Tries to find the specified key and parse it as a T, using default(T) if unable to locate the key or unable to parse it

Template Parameters
TThe desired output type
Parameters
keyThe configuration key
valueThe output value. If the key is found and parsed successfully, it will be the parsed value, else default(T).
Returns
True on successful parse or if they key is not found. False only when key is found but fails to parse.

Definition at line 303 of file Config.cs.

◆ TryGetValue< T >() [2/2]

static bool QuantConnect.Configuration.Config.TryGetValue< T > ( string  key,
defaultValue,
out T  value 
)
static

Tries to find the specified key and parse it as a T, using defaultValue if unable to locate the key or unable to parse it

Template Parameters
TThe desired output type
Parameters
keyThe configuration key
defaultValueThe default value to use on key not found or unsuccessful parse
valueThe output value. If the key is found and parsed successfully, it will be the parsed value, else defaultValue.
Returns
True on successful parse or if they key is not found and using defaultValue. False only when key is found but fails to parse.

Definition at line 317 of file Config.cs.

◆ Write()

static void QuantConnect.Configuration.Config.Write ( string  targetPath = null)
static

Write the contents of the serialized configuration back to the disk.

Definition at line 334 of file Config.cs.

◆ Flatten() [1/2]

static JObject QuantConnect.Configuration.Config.Flatten ( string  overrideEnvironment)
static

Flattens the jobject with respect to the selected environment and then removes the 'environments' node

Parameters
overrideEnvironmentThe environment to use
Returns
The flattened JObject

Definition at line 353 of file Config.cs.

◆ Flatten() [2/2]

static JObject QuantConnect.Configuration.Config.Flatten ( JObject  config,
string  overrideEnvironment 
)
static

Flattens the jobject with respect to the selected environment and then removes the 'environments' node

Parameters
configThe configuration represented as a JObject
overrideEnvironmentThe environment to use
Returns
The flattened JObject

Definition at line 365 of file Config.cs.


The documentation for this class was generated from the following file: