Skip to content

DefaultOrderBook

QuantConnect.Brokerages.DefaultOrderBook

DefaultOrderBook(symbol: Union[Symbol, str, BaseContract])

Bases: Object, IOrderBookUpdater[float, float]

Represents a full order book for a security. It contains prices and order sizes for each bid and ask level. The best bid and ask prices are also kept up to date.

Initializes a new instance of the DefaultOrderBook class

Parameters:

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

The symbol for the order book

required

bids

bids: SortedDictionary[float, float]

Represents bid prices and sizes

This codeEntityType is protected.

asks

asks: SortedDictionary[float, float]

Represents ask prices and sizes

This codeEntityType is protected.

symbol

symbol: Symbol

Represents a unique security identifier of current Order Book

best_bid_ask_updated

best_bid_ask_updated: _EventContainer[
    Callable[[Object, BestBidAskUpdatedEventArgs], Any], Any
]

Event fired each time best_bid_price or best_ask_price are changed

best_bid_price

best_bid_price: float

The best bid price

best_bid_size

best_bid_size: float

The best bid size

best_ask_price

best_ask_price: float

The best ask price

best_ask_size

best_ask_size: float

The best ask size

clear

clear() -> None

Clears all bid/ask levels and prices.

remove_ask_row

remove_ask_row(price: float) -> None

Removes an ask price level from the order book

Parameters:

Name Type Description Default
price float

The ask price level to be removed

required

remove_bid_row

remove_bid_row(price: float) -> None

Removes a bid price level from the order book

Parameters:

Name Type Description Default
price float

The bid price level to be removed

required

remove_price_level

remove_price_level(price_level: float) -> None

Common price level removal method

Parameters:

Name Type Description Default
price_level float
required

update_ask_row

update_ask_row(price: float, size: float) -> None

Updates or inserts an ask price level in the order book

Parameters:

Name Type Description Default
price float

The ask price level to be inserted or updated

required
size float

The new size at the ask price level

required

update_bid_row

update_bid_row(price: float, size: float) -> None

Updates or inserts a bid price level in the order book

Parameters:

Name Type Description Default
price float

The bid price level to be inserted or updated

required
size float

The new size at the bid price level

required