Documentation Index
Fetch the complete documentation index at: https://mathematicalcompany.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Execution Intelligence provides a feedback loop: measure execution quality, identify problems, and automatically adjust strategy parameters to improve.
The Feedback Loop
Execute Order
Submit order to the exchange via the strategy pipeline.
Measure Quality
Track fill rate, slippage, adverse selection, and market impact.
Diagnose Issues
Identify root causes: spread too tight, size too large, bad timing.
Adjust Parameters
Auto-tune spread width, order size, and timing based on diagnostics.
Execute Again
Run the next cycle with improved parameters. Loop continues.
Most trading systems are open-loop: they execute and move on. Execution Intelligence closes the loop by feeding results back into the strategy.
Execution Quality Metrics
| Metric | What It Measures | Why It Matters |
|---|
| Fill rate | % of orders that get filled | Low fill rate = quoting too aggressively |
| Slippage | Difference between expected and actual fill price | High slippage = poor execution or thin books |
| Adverse selection | P&L immediately after fill | Negative = we’re getting picked off by informed traders |
| Market impact | Price movement caused by our orders | High impact = we’re too large for this market |
| Timing cost | Cost of delayed execution | Relevant for TWAP/VWAP algos |
# Measure execution quality
quality = execution_quality(
strategy="political_mm",
period_days=7,
)
# {
# "fill_rate": 0.73,
# "avg_slippage_bps": 12.5,
# "adverse_selection_5s": -0.003,
# "market_impact_bps": 8.2,
# }
Adaptive Execution
Based on quality metrics, automatically adjust strategy parameters.
Spread Auto-Tuning
High adverse selection --> widen spread
Low fill rate --> tighten spread
High market impact --> reduce order size
| Signal | Parameter | Direction |
|---|
| Adverse selection > threshold | spread_width | Increase by 10% |
| Fill rate < 50% | spread_width | Decrease by 5% |
| Market impact > 10bps | order_size | Decrease by 20% |
| Fill rate > 90% and low adverse selection | order_size | Increase by 10% |
Time-of-Day Patterns
Markets have liquidity patterns. Execution Intelligence learns when to be more/less aggressive:
# Analyze time-of-day patterns
patterns = execution_patterns(strategy="crypto_mm", group_by="hour")
# {
# "best_hours": [14, 15, 16], # UTC - US market hours
# "worst_hours": [3, 4, 5], # Low liquidity
# "recommendation": "Reduce size 50% during 03:00-06:00 UTC"
# }
Cross-Exchange Execution
When the same market exists on multiple exchanges, route to the best venue.
Smart Routing
| Factor | Weight | Description |
|---|
| Price | 40% | Best bid/ask across venues |
| Liquidity | 30% | Depth available at target price |
| Fees | 20% | Maker/taker fee structure |
| Latency | 10% | Historical fill time |
# Smart order routing
route = smart_route(
market="will-btc-100k",
side="buy",
size=100,
venues=["polymarket", "kalshi"],
)
# {"venue": "polymarket", "expected_price": 0.62, "expected_slippage": 0.001}
Exchange Health Monitoring
Detect degraded exchange performance and route around it:
- API latency spikes
- Increased error rates
- Orderbook thinning
- Fill rate drops
| Tool | Description |
|---|
execution_quality | Quality metrics for a strategy or the fund |
execution_patterns | Time-of-day and market-specific patterns |
route_analysis | Best venue analysis for a given trade |
exchange_health | Current health status of all connected exchanges |