Skip to content

SymbolPropertiesDatabase

QuantConnect.Securities.SymbolPropertiesDatabase

SymbolPropertiesDatabase(file: str)

Bases: BaseSecurityDatabase[QuantConnect_Securities_SymbolPropertiesDatabase, SymbolProperties]

Provides access to specific properties for various symbols

Initialize a new instance of SymbolPropertiesDatabase using the given file

This codeEntityType is protected.

Parameters:

Name Type Description Default
file str

File to read from

required

data_folder_database

data_folder_database: (
    QuantConnect_Securities_BaseSecurityDatabase_T
)

The database instance loaded from the data folder

This codeEntityType is protected.

DATA_FOLDER_DATABASE_LOCK

DATA_FOLDER_DATABASE_LOCK: Object = ...

Lock object for the data folder database

This codeEntityType is protected.

entries

entries: Dictionary[
    SecurityDatabaseKey,
    QuantConnect_Securities_BaseSecurityDatabase_TEntry,
]

The database entries

This codeEntityType is protected.

custom_entries

custom_entries: HashSet[SecurityDatabaseKey]

Custom entries set by the user.

This codeEntityType is protected.

get_symbol_properties_list

get_symbol_properties_list(
    market: str, security_type: SecurityType
) -> Iterable[
    KeyValuePair[SecurityDatabaseKey, SymbolProperties]
]
get_symbol_properties_list(
    market: str,
) -> Iterable[
    KeyValuePair[SecurityDatabaseKey, SymbolProperties]
]

Signature descriptions:

  • Gets a list of symbol properties for the specified market/security-type

  • Gets a list of symbol properties for the specified market

Parameters:

Name Type Description Default
market str

The market the exchange resides in, i.e, 'usa', 'fxcm', ect...

required
security_type Optional[SecurityType]

The security type of the symbol

None

Returns:

Type Description
Iterable[KeyValuePair[SecurityDatabaseKey, SymbolProperties]]

Depends on the signature used. Case 1: [An IEnumerable of symbol properties matching the specified market/security-type.]; Case 2: [An IEnumerable of symbol properties matching the specified market.]

from_csv_line

from_csv_line(
    line: str, key: Optional[SecurityDatabaseKey]
) -> Tuple[SymbolProperties, SecurityDatabaseKey]

Creates a new instance of SymbolProperties from the specified csv line

This codeEntityType is protected.

Parameters:

Name Type Description Default
line str

The csv line to be parsed

required
key Optional[SecurityDatabaseKey]

The key used to uniquely identify this security

required

Returns:

Type Description
Tuple[SymbolProperties, SecurityDatabaseKey]

A new SymbolProperties for the specified csv line.

from_data_folder

from_data_folder() -> SymbolPropertiesDatabase

Gets the instance of the SymbolPropertiesDatabase class produced by reading in the symbol properties data found in /Data/symbol-properties/

Returns:

Type Description
SymbolPropertiesDatabase

A SymbolPropertiesDatabase class that represents the data in the symbol-properties folder.

get_symbol_properties

get_symbol_properties(
    market: str,
    symbol: Union[Symbol, str, BaseContract],
    security_type: SecurityType,
    default_quote_currency: str,
) -> SymbolProperties

Gets the symbol properties for the specified market/symbol/security-type

Parameters:

Name Type Description Default
market str

The market the exchange resides in, i.e, 'usa', 'fxcm', ect...

required
symbol Union[Symbol, str, BaseContract]

The particular symbol being traded (Symbol class)

required
security_type SecurityType

The security type of the symbol

required
default_quote_currency str

Specifies the quote currency to be used when returning a default instance of an entry is not found in the database

required

Returns:

Type Description
SymbolProperties

The symbol properties matching the specified market/symbol/security-type or null if not found.

set_entry

set_entry(
    market: str,
    symbol: str,
    security_type: SecurityType,
    properties: SymbolProperties,
) -> bool

Set SymbolProperties entry for a particular market, symbol and security type.

Parameters:

Name Type Description Default
market str

Market of the entry

required
symbol str

Symbol of the entry

required
security_type SecurityType

Type of security for the entry

required
properties SymbolProperties

The new symbol properties to store

required

Returns:

Type Description
bool

True if successful.

try_get_market

try_get_market(
    symbol: str,
    security_type: SecurityType,
    market: Optional[str],
) -> Tuple[bool, str]

Tries to get the market for the provided symbol/security type

Parameters:

Name Type Description Default
symbol str

The particular symbol being traded

required
security_type SecurityType

The security type of the symbol

required
market Optional[str]

The market the exchange resides in Market

required

Returns:

Type Description
Tuple[bool, str]

True if market was retrieved, false otherwise.

contains_key

contains_key(key: SecurityDatabaseKey) -> bool
contains_key(
    market: str, symbol: str, security_type: SecurityType
) -> bool
contains_key(
    market: str,
    symbol: Union[Symbol, str, BaseContract],
    security_type: SecurityType,
) -> bool

Signature descriptions:

  • Determines if the database contains the specified key

  • Check whether an entry exists for the specified market/symbol/security-type

Parameters:

Name Type Description Default
key Optional[SecurityDatabaseKey]

The key to search for

None
market Optional[str]

The market the exchange resides in, i.e, 'usa', 'fxcm', ect...

None
symbol Optional[str | Union[Symbol, str, BaseContract]]

The particular symbol being traded

None
security_type Optional[SecurityType]

The security type of the symbol

None

Returns:

Type Description
bool

True if an entry is found, otherwise false.

get_database_symbol_key

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

Gets the correct string symbol to use as a database key

Parameters:

Name Type Description Default
symbol Union[Symbol, str, BaseContract]

The symbol

required

Returns:

Type Description
str

The symbol string used in the database ke.

reset

reset() -> None

Resets the database, forcing a reload when reused. Called in tests where multiple algorithms are run sequentially, and we need to guarantee that every test starts with the same environment.