Skip to content

OptionCache

QuantConnect.Securities.Option.OptionCache

Bases: SecurityCache

Option specific caching support

session

session: Session

Gets the trading session information

price

price: float

Gets the most recent price submitted to this cache

open

open: float

Gets the most recent open submitted to this cache

high

high: float

Gets the most recent high submitted to this cache

low

low: float

Gets the most recent low submitted to this cache

close

close: float

Gets the most recent close submitted to this cache

bid_price

bid_price: float

Gets the most recent bid submitted to this cache

ask_price

ask_price: float

Gets the most recent ask submitted to this cache

bid_size

bid_size: float

Gets the most recent bid size submitted to this cache

ask_size

ask_size: float

Gets the most recent ask size submitted to this cache

volume

volume: float

Gets the most recent volume submitted to this cache

open_interest

open_interest: int

Gets the most recent open interest submitted to this cache

properties

properties: Dictionary[str, Object]

Collection of keyed custom properties

get_data

get_data(py_type: Any) -> Any
get_data() -> BaseData

Signature descriptions:

  • Retrieves the last data packet of the specified Python type.

  • Get last data packet received for this security if any else null

Parameters:

Name Type Description Default
py_type Optional[Any]

The Python type to convert and match

None

Returns:

Type Description
Any | BaseData

Depends on the signature used. Case 1: [The last data packet as a PyObject, or null if not found.]; Case 2: [BaseData type of the security.]

add_data

add_data(data: BaseData) -> None

Add a new market data point to the local security cache for the current market price. Rules: Don't cache fill forward data. Always return the last observation. If two consecutive data has the same time stamp and one is Quotebars and the other Tradebar, prioritize the Quotebar.

add_data_list

add_data_list(
    data: Sequence[BaseData],
    data_type: Type,
    contains_fill_forward_data: Optional[bool] = None,
    is_internal_config: bool = False,
) -> None

Add a list of market data points to the local security cache for the current market price.

has_data

has_data(type: Type) -> bool

Gets whether or not this dynamic data instance has data stored for the specified type

process_data_point

process_data_point(
    data: BaseData, cache_by_type: bool
) -> None

Will consume the given data point updating the cache state and it's properties

This codeEntityType is protected.

Parameters:

Name Type Description Default
data BaseData

The data point to process

required
cache_by_type bool

True if this data point should be cached by type

required

reset

reset() -> None

Reset cache storage and free memory

set_local_time_keeper

set_local_time_keeper(
    local_time_keeper: LocalTimeKeeper,
) -> None

Sets the LocalTimeKeeper to be used for this SecurityCache. This is the source of this instance's time.

Parameters:

Name Type Description Default
local_time_keeper LocalTimeKeeper

The source of this Security's time.

required

share_type_cache_instance

share_type_cache_instance(
    source_to_share: SecurityCache,
    target_to_modify: SecurityCache,
) -> None

Helper method that modifies the target security cache instance to use the type cache of the source

Parameters:

Name Type Description Default
source_to_share SecurityCache

The source cache to use

required
target_to_modify SecurityCache

The target security cache that will be modified

required

store_data

store_data(
    data: Sequence[BaseData], data_type: Type
) -> None

Stores the specified data list in the cache WITHOUT updating any of the cache properties, such as Price

Parameters:

Name Type Description Default
data Sequence[BaseData]

The collection of data to store in this cache

required
data_type Type

The data type

required

try_get_value

try_get_value(
    type: Type, data: Optional[Sequence[BaseData]]
) -> Tuple[bool, Sequence[BaseData]]

Gets whether or not this dynamic data instance has data stored for the specified type