Engine
StockMarketABM.Engine exposes a compact façade over the limit order book for consumers such as the matching engine or market simulation layers. Detailed discussion of the underlying data structures lives in docs/src/lob/orderbook.md; this article focuses on the thin wrapper that reuses that implementation. Rather than reimplementing logic, the module:
- Delegates
submit!andcancel!toOrderBookMod.add_order!andOrderBookMod.cancel_order!, so the same validation path is used everywhere. - Re-exports convenience queries (
best_bid,best_ask,is_crossed,get_depth,available_qty,consume!) by attaching documentation to the underlying order book functions. This keeps a single implementation while presenting an intuitive API surface to callers. - Ensures upstream modules can
using StockMarketABM.Engine(or rely on the top-level reexport) without knowing about the lower level modules.
Thanks to this façade, higher level code manipulates the order book through a stable interface, while the actual data-structure decisions remain encapsulated inside OrderBookMod and PriceLevelMod.
StockMarketABM.Engine.cancel! — Methodcancel!(ob, id) -> BoolCancel an existing order by identifier. Returns true if the order was found and removed.
StockMarketABM.Engine.submit! — Methodsubmit!(ob, spec)Add a new order to the book. This is a simple wrapper around add_order!.
StockMarketABM.OrderBookMod.available_qty — Functionavailable_qty(ob, side, price_limit; stop_at=zero(Qty)) -> QtyReturn executable quantity on the opposite side up to price_limit. The optional stop_at keyword lets callers short-circuit once the desired quantity is reached.
StockMarketABM.OrderBookMod.best_ask — Functionbest_ask(ob) -> Union{Price,Nothing}Return the lowest resting ask price. Internally this proxies to OrderBookMod.best_ask.
StockMarketABM.OrderBookMod.best_bid — Functionbest_bid(ob) -> Union{Price,Nothing}Return the highest resting bid price. Internally this proxies to OrderBookMod.best_bid on the shared order book.
StockMarketABM.OrderBookMod.consume! — Functionconsume!(ob, side, qty; price_limit=nothing)Consume liquidity from the opposite side while respecting an optional price limit, forwarding to OrderBookMod.consume!.
StockMarketABM.OrderBookMod.get_depth — Functionget_depth(ob, side; top=0)Return aggregated depth for side. Keyword arguments are forwarded to the underlying OrderBookMod.get_depth implementation.
StockMarketABM.OrderBookMod.is_crossed — Functionis_crossed(ob) -> BoolReturn true when the best bid is greater than or equal to the best ask.