When backtesting, the most common mistake is to assume you can fill any size at the best bid/ask. Real markets don’t work that way — large orders walk the book and pay progressively worse prices. PolyData’sDocumentation Index
Fetch the complete documentation index at: https://docs.polydata.live/llms.txt
Use this file to discover all available pages before exploring further.
/v1/execution-price endpoint solves this by walking the historical orderbook to compute the volume-weighted average price for any order size.
How it works
Given:asset_id— which token’s orderbook to queryside— BUY (eat asks) or SELL (eat bids)amount— desired order sizetimestamp— when to simulate
- Finds the orderbook snapshot at or before
timestamp - Walks the price levels in order (asks ascending if BUY, bids descending if SELL)
- Fills as much as possible at each level until
amountis satisfied or depth runs out - Returns the volume-weighted average price + slippage breakdown
Example: small order
Example: large order
fully_filled: false means the orderbook ran out before your order completed. In a backtest, you’d treat this as a partial fill or reject the trade.
Practical use
Pre-trade analysis
Before committing to a trade size, check what slippage you’d realistically incur:Position sizing
Find the maximum size you can trade without exceeding a slippage threshold:Limitations
Slippage simulation uses orderbook snapshots, which means: if your order is larger than what’s visible at
timestamp, the actual fill in live trading might be different (other traders react, new liquidity appears, etc.).For HFT/large-size strategies, consider these results as a baseline — your live execution may be better (passive maker rebates) or worse (impact on followers).