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. Edge cases: bids and asks each at least 1 level (price, size in base units, any order); side buy or sell; give exactly one of notional_usd or impact_budget_bps, both above zero. A book too thin for the size returns book_sufficient false and no VWAP. Not covered: a book that moves while you trade, hidden liquidity, your own fees, and any depth you did not supply (capacity_is_lower_bound says when the whole supplied book fit). 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).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"bids": "<bids>",
"asks": "<asks>",
"side": "<side>"
},
"name": "workflow.run_orderbook_impact"
}
}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. |