Orderbook Impact
workflow.run_orderbook_impactOrder-book "walk the book" impact/capacity: given order-book levels (price, size in base-asset units) and EITHER a target notional or an impact budget in bps, computes VWAP and price impact for that size, or (via bisection) the largest notional that stays inside the impact budget. Use when user asks "what's my price impact if I trade $X" or "how much can I trade before impact exceeds Y bps". side="buy" walks the asks, side="sell" walks the bids; impact is measured from the book's own mid ((best_bid+best_ask)/2) and is always a positive "cost in bps" number regardless of side. Returns: mid_price, spread_bps, vwap, impact_bps - both null when EITHER the loaded book doesn't cover the requested notional (book_sufficient=false flags this specific case) OR the notional involved is ~0 (book_sufficient stays true then; happens for a near-zero notional_usd, or in capacity mode when even an infinitesimal trade already exceeds impact_budget_bps, in which case max_notional itself resolves to 0) - and in capacity mode, max_notional plus capacity_is_lower_bound (true if the ENTIRE supplied book was consumed within budget, meaning true market capacity may exceed what was supplied - this tool only sees the levels given to it).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asks | Yes | Ask levels as [price, size_base] pairs, any order | |
| bids | Yes | Bid levels as [price, size_base] pairs, any order | |
| side | Yes | "buy" walks the asks, "sell" walks the bids | |
| notional_usd | No | Target notional to walk the book for. Provide this OR impact_budget_bps, not both. | |
| impact_budget_bps | No | Max acceptable impact in bps; solves for the largest notional within it. Provide this OR notional_usd, not both. |