Skip to content

ExtendedDictionary

QuantConnect.ExtendedDictionary

Bases: Generic[QuantConnect_ExtendedDictionary_TKey, QuantConnect_ExtendedDictionary_TValue], Object, IExtendedDictionary[QuantConnect_ExtendedDictionary_TKey, QuantConnect_ExtendedDictionary_TValue]

Provides a base class for types holding key value pairs with helper methods for easy usage in Python

count

count: int

Gets the number of elements contained in the dictionary

get_keys

get_keys: Iterable[QuantConnect_ExtendedDictionary_TKey]

Gets an System.Collections.Generic.ICollection1 containing the key objects of the System.Collections.Generic.IDictionary2.

This codeEntityType is protected.

get_values

get_values: Iterable[QuantConnect_ExtendedDictionary_TValue]

Gets an System.Collections.Generic.ICollection1 containing the values in the System.Collections.Generic.IDictionary2.

This codeEntityType is protected.

is_read_only

is_read_only: bool

Gets a value indicating whether the IDictionary object is read-only.

fromkeys

fromkeys(
    sequence: List[QuantConnect_ExtendedDictionary_TKey],
) -> Dict[Any, Any]
fromkeys(
    sequence: List[QuantConnect_ExtendedDictionary_TKey],
    value: QuantConnect_ExtendedDictionary_TValue,
) -> Dict[Any, Any]

Signature descriptions:

  • Creates a new dictionary from the given sequence of elements.

  • Creates a new dictionary from the given sequence of elements with a value provided by the user.

Parameters:

Name Type Description Default
sequence List[QuantConnect_ExtendedDictionary_TKey]

Sequence of elements which is to be used as keys for the new dictionary

required
value Optional[QuantConnect_ExtendedDictionary_TValue]

Value which is set to each each element of the dictionary

None

Returns:

Type Description
Dict[Any, Any]

Returns a new dictionary with the given sequence of elements as the keys of the dictionary.

get

get(
    key: QuantConnect_ExtendedDictionary_TKey,
) -> QuantConnect_ExtendedDictionary_TValue
get(
    key: QuantConnect_ExtendedDictionary_TKey,
    value: QuantConnect_ExtendedDictionary_TValue,
) -> QuantConnect_ExtendedDictionary_TValue

Returns the value for the specified key if key is in dictionary.

Parameters:

Name Type Description Default
key QuantConnect_ExtendedDictionary_TKey

key to be searched in the dictionary

required
value Optional[QuantConnect_ExtendedDictionary_TValue]

Value to be returned if the key is not found. The default value is null.

None

Returns:

Type Description
QuantConnect_ExtendedDictionary_TValue

The value for the specified key if key is in dictionary.

pop

pop(
    key: QuantConnect_ExtendedDictionary_TKey,
) -> QuantConnect_ExtendedDictionary_TValue
pop(
    key: QuantConnect_ExtendedDictionary_TKey,
    default_value: QuantConnect_ExtendedDictionary_TValue,
) -> QuantConnect_ExtendedDictionary_TValue

Removes and returns an element from a dictionary having the given key.

Parameters:

Name Type Description Default
key QuantConnect_ExtendedDictionary_TKey

Key which is to be searched for removal

required
default_value Optional[QuantConnect_ExtendedDictionary_TValue]

Value which is to be returned when the key is not in the dictionary

None

Returns:

Type Description
QuantConnect_ExtendedDictionary_TValue

If key is found - removed/popped element from the dictionary

setdefault

setdefault(
    key: QuantConnect_ExtendedDictionary_TKey,
) -> QuantConnect_ExtendedDictionary_TValue
setdefault(
    key: QuantConnect_ExtendedDictionary_TKey,
    default_value: QuantConnect_ExtendedDictionary_TValue,
) -> QuantConnect_ExtendedDictionary_TValue

Returns the value of a key (if the key is in dictionary). If not, it inserts key with a value to the dictionary.

Parameters:

Name Type Description Default
key QuantConnect_ExtendedDictionary_TKey

Key with null/None value is inserted to the dictionary if key is not in the dictionary.

required
default_value Optional[QuantConnect_ExtendedDictionary_TValue]

Default value

None

Returns:

Type Description
QuantConnect_ExtendedDictionary_TValue

The value of the key if it is in the dictionary

__contains__

__contains__(
    key: QuantConnect_ExtendedDictionary_TKey,
) -> bool

Checks if the dictionary contains the specified key.

Parameters:

Name Type Description Default
key QuantConnect_ExtendedDictionary_TKey

The key to locate in the dictionary

required

Returns:

Type Description
bool

true if the dictionary contains an element with the specified key; otherwise, false.

__getitem__

__getitem__(
    key: QuantConnect_ExtendedDictionary_TKey,
) -> QuantConnect_ExtendedDictionary_TValue

Indexer method for the base dictioanry to access the objects by their symbol.

Parameters:

Name Type Description Default
key QuantConnect_ExtendedDictionary_TKey

Key object indexer

required

Returns:

Type Description
QuantConnect_ExtendedDictionary_TValue

Object of t_value.

__len__

__len__() -> int

__setitem__

__setitem__(
    key: QuantConnect_ExtendedDictionary_TKey,
    value: QuantConnect_ExtendedDictionary_TValue,
) -> None

Indexer method for the base dictioanry to access the objects by their symbol.

Parameters:

Name Type Description Default
key QuantConnect_ExtendedDictionary_TKey

Key object indexer

required

Returns:

Type Description
None

Object of t_value.

check_for_implicitly_created_symbol

check_for_implicitly_created_symbol(
    symbol: Union[Symbol, str, BaseContract],
) -> None

Checks if the symbol is implicitly created from a string, in which case it is not in the symbol cache, and throws a KeyNotFoundException.

This codeEntityType is protected.

clear

clear() -> None

Removes all items from the System.Collections.Generic.ICollection`1.

contains_key

contains_key(
    key: QuantConnect_ExtendedDictionary_TKey,
) -> bool

Checks if the dictionary contains the specified key.

Parameters:

Name Type Description Default
key QuantConnect_ExtendedDictionary_TKey

The key to locate in the dictionary

required

Returns:

Type Description
bool

true if the dictionary contains an element with the specified key; otherwise, false.

copy

copy() -> Dict[Any, Any]

Creates a shallow copy of the IExtendedDictionary{TKey, TValue}.

Returns:

Type Description
Dict[Any, Any]

Returns a shallow copy of the dictionary. It doesn't modify the original dictionary.

get_items

get_items() -> Iterable[
    KeyValuePair[
        QuantConnect_ExtendedDictionary_TKey,
        QuantConnect_ExtendedDictionary_TValue,
    ]
]

Gets all the items in the dictionary

Returns:

Type Description
Iterable[KeyValuePair[QuantConnect_ExtendedDictionary_TKey, QuantConnect_ExtendedDictionary_TValue]]

All the items in the dictionary.

items

items() -> List[Any]

Returns a view object that displays a list of dictionary's (key, value) tuple pairs.

Returns:

Type Description
List[Any]

Returns a view object that displays a list of a given dictionary's (key, value) tuple pair.

keys

keys() -> List[Any]

Returns a view object that displays a list of all the key objects in the dictionary

Returns:

Type Description
List[Any]

Returns a view object that displays a list of all the key objects. When the dictionary is changed, the view object also reflect these changes.

popitem

popitem() -> Any

Returns and removes an arbitrary element (key, value) pair from the dictionary.

Returns:

Type Description
Any

Returns an arbitrary element (key, value) pair from the dictionary removes an arbitrary element(the same element which is returned) from the dictionary. Note: Arbitrary elements and random elements are not same.The popitem() doesn't return a random element.

remove

remove(key: QuantConnect_ExtendedDictionary_TKey) -> bool

Removes the value with the specified key

Parameters:

Name Type Description Default
key QuantConnect_ExtendedDictionary_TKey

The key object of the element to remove.

required

Returns:

Type Description
bool

true if the element is successfully found and removed; otherwise, false.

try_get_value

try_get_value(
    key: QuantConnect_ExtendedDictionary_TKey,
    value: Optional[QuantConnect_ExtendedDictionary_TValue],
) -> Tuple[bool, QuantConnect_ExtendedDictionary_TValue]

Gets the value associated with the specified key.

Parameters:

Name Type Description Default
key QuantConnect_ExtendedDictionary_TKey

The key whose value to get.

required
value Optional[QuantConnect_ExtendedDictionary_TValue]

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

required

Returns:

Type Description
Tuple[bool, QuantConnect_ExtendedDictionary_TValue]

true if the object that implements System.Collections.Generic.IDictionary`2 contains an element with the specified key; otherwise, false.

update

update(other: Any) -> None

Updates the dictionary with the elements from the another dictionary object or from an iterable of key/value pairs. The update() method adds element(s) to the dictionary if the key is not in the dictionary.If the key is in the dictionary, it updates the key with the new value.

Parameters:

Name Type Description Default
other Any

Takes either a dictionary or an iterable object of key/value pairs (generally tuples).

required

values

values() -> List[Any]

Returns a view object that displays a list of all the values in the dictionary.

Returns:

Type Description
List[Any]

Returns a view object that displays a list of all values in a given dictionary.