Cross-Venue Liquidity
The same prediction can trade on Polymarket, Kalshi, and other platforms at different prices. Horizon’s liquidity aggregation module merges orderbooks from multiple venues into a unified view, routes orders to the best venue, and enables cross-venue market making. All aggregation math is in Rust.Overview
Book Aggregation
hz.aggregate_books() merges bid/ask levels from multiple venues.Smart Routing
hz.smart_route() picks the best venue for a given order.Best Venue
hz.best_venue() returns the venue with the best price for a side.Cross-Venue MM
hz.cross_venue_mm() market-makes using the aggregated book.Core Functions
hz.aggregate_books
Merge bid/ask levels from multiple venues into a unified orderbook.| Parameter | Type | Description |
|---|---|---|
bids | list[tuple[str, float, float]] | (venue, price, size) tuples |
asks | list[tuple[str, float, float]] | (venue, price, size) tuples |
AggregatedBook with fields: bids, asks, best_bid, best_ask, mid_price, total_bid_size, total_ask_size.
hz.smart_route
Route an order to the venue(s) offering best execution.| Parameter | Type | Description |
|---|---|---|
book | AggregatedBook | Aggregated orderbook |
side | str | "buy" or "sell" |
size | float | Order size |
hz.best_venue
Return the venue with the best price for a given side.hz.merged_mid_price
Compute the size-weighted mid price across venues.Pipeline Functions
hz.aggregate_book
Aggregate orderbooks from multiple venue feeds each cycle.| Parameter | Type | Description |
|---|---|---|
venue_feeds | dict[str, dict[str, str]] | venue to {"bid_feed": feed_name} mapping |
hz.smart_route_pipeline
Smart order routing each cycle.hz.cross_venue_mm
Market-make using the aggregated book. Quotes around the merged mid price.| Parameter | Type | Default | Description |
|---|---|---|---|
venue_feeds | dict[str, dict] | required | Venue feed configuration |
spread_markup | float | 0.01 | Spread around mid |
size | float | 50.0 | Quote size per side |