Skip to content

BaseSecurityDatabase

QuantConnect.Securities.BaseSecurityDatabase

BaseSecurityDatabase(
    entries: Dictionary[
        SecurityDatabaseKey,
        QuantConnect_Securities_BaseSecurityDatabase_TEntry,
    ],
    from_data_folder: Callable[
        [], QuantConnect_Securities_BaseSecurityDatabase_T
    ],
    update_entry: Callable[
        [
            QuantConnect_Securities_BaseSecurityDatabase_TEntry,
            QuantConnect_Securities_BaseSecurityDatabase_TEntry,
        ],
        Any,
    ],
)

Bases: Generic[QuantConnect_Securities_BaseSecurityDatabase_T, QuantConnect_Securities_BaseSecurityDatabase_TEntry], Object

Base class for security databases, including market hours and symbol properties.

Initializes a new instance of the BaseSecurityDatabase{T, TEntry} class

This codeEntityType is protected.

Parameters:

Name Type Description Default
entries Dictionary[SecurityDatabaseKey, QuantConnect_Securities_BaseSecurityDatabase_TEntry]

The full listing of exchange hours by key

required
from_data_folder Callable[[], QuantConnect_Securities_BaseSecurityDatabase_T]

Method to load the database form the data folder

required
update_entry Callable[[QuantConnect_Securities_BaseSecurityDatabase_TEntry, QuantConnect_Securities_BaseSecurityDatabase_TEntry], Any]

Method to update a database entry

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.

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.