SymbolCache
QuantConnect.SymbolCache
Bases: Object
Provides a string->Symbol mapping to allow for user defined strings to be lifted into a Symbol This is mainly used via the Symbol implicit operator, but also functions that create securities should also call Set to add new mappings
try_remove
try_remove(
symbol: Union[Symbol, str, BaseContract],
) -> bool
try_remove(ticker: str) -> bool
Removes the mapping for the specified symbol from the cache
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Optional[Union[Symbol, str, BaseContract]]
|
The symbol whose mappings are to be removed |
None
|
ticker
|
Optional[str]
|
The ticker whose mappings are to be removed |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the symbol mapping were removed from the cache. |
clear
clear() -> None
Clears the current caches
get_symbol
get_symbol(ticker: str) -> Symbol
Gets the Symbol object that is mapped to the specified string ticker symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
The string ticker symbol |
required |
Returns:
| Type | Description |
|---|---|
Symbol
|
The symbol object that maps to the specified string ticker symbol. |
get_ticker
get_ticker(symbol: Union[Symbol, str, BaseContract]) -> str
Gets the string ticker symbol that is mapped to the specified Symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol object |
required |
Returns:
| Type | Description |
|---|---|
str
|
The string ticker symbol that maps to the specified symbol object. |
set
set(
ticker: str, symbol: Union[Symbol, str, BaseContract]
) -> None
Adds a mapping for the specified ticker
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
The string ticker symbol |
required |
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol object that maps to the string ticker symbol |
required |
try_get_symbol
try_get_symbol(
ticker: str,
symbol: Optional[Union[Symbol, str, BaseContract]],
) -> Tuple[bool, Union[Symbol, str, BaseContract]]
Gets the Symbol object that is mapped to the specified string ticker symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
The string ticker symbol |
required |
symbol
|
Optional[Union[Symbol, str, BaseContract]]
|
The output symbol object |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, Union[Symbol, str, BaseContract]]
|
The symbol object that maps to the specified string ticker symbol. |
try_get_ticker
try_get_ticker(
symbol: Union[Symbol, str, BaseContract],
ticker: Optional[str],
) -> Tuple[bool, str]
Gets the string ticker symbol that is mapped to the specified Symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol object |
required |
ticker
|
Optional[str]
|
The output string ticker symbol |
required |
Returns:
| Type | Description |
|---|---|
Tuple[bool, str]
|
The string ticker symbol that maps to the specified symbol object. |