Market Book¶
Level 2 order book (Depth of Market) data.
Models¶
BookEntry¶
BookEntry
¶
Bases: BaseModel
A single entry in the market depth (Depth of Market) for a symbol.
Wraps the raw BookInfo struct returned by mt5.market_book_get().
Each entry represents one price level in the order book, which may be
a limit order or a market order on either the buy or sell side.
| ATTRIBUTE | DESCRIPTION |
|---|---|
type |
Whether this entry is a buy or sell order, and whether it is a limit or market order.
TYPE:
|
price |
Price level of this order book entry.
TYPE:
|
volume |
Volume available at this price level (integer lots).
TYPE:
|
volume_real |
Volume available at this price level (fractional lots).
TYPE:
|
Service¶
MarketBookService¶
MarketBookService
¶
Manages market depth (DOM) subscriptions and snapshots for the MT5 terminal.
Wraps mt5.market_book_add(), mt5.market_book_get(), and
mt5.market_book_release() via call_mt5, parses raw
BookInfo structs into BookEntry models, and returns
Result[T].
Usage¶
# Subscribe to market book
add = mt5.market_book_add("EURUSD")
if add.success and add.data:
# Read the book
res = mt5.market_book_get("EURUSD")
if res.success:
for entry in res.data:
side = "BUY" if entry.is_buy else "SELL"
print(f"{side}: {entry.price} @ {entry.volume_real}")
# Release when done
mt5.market_book_release("EURUSD")