Skip to main content

Module models

Module models 

Source

Structs§

CreateOrderRequest
Input for create_order.
CryptoPrice
DepthBuckets
Cumulative depth at 10/50/100 bps tiers from mid.
Event
A grouping of related markets — one Kalshi event_ticker or one Polymarket event slug.
Fill
A single fill (trade execution) from one of the caller’s orders.
FixedPrice
Fixed-point price representation. 1 tick = 0.0001 (scale factor 10,000). Eliminates f64 comparison issues (no PRICE_EPSILON), enables Ord (no NaN), and uses integer arithmetic (1-5ns vs 20-100ns for f64 ops).
LevelCount
Per-side resting-level counts.
Market
A prediction market on the unified surface. Prices are YES probabilities in [0, 1].
MarketLineage
A market plus its parent event and series.
MarketTrade
A public trade off the market tape.
MaxGap
Largest consecutive-level price gap per side.
Order
An order on the unified surface.
Orderbook
Full-depth L2 orderbook for one asset.
OrderbookImpact
Slippage curve at one requested size.
OrderbookMicrostructure
Microstructure signals for one orderbook.
OrderbookStats
Top-of-book snapshot stats for one asset.
Outcome
One outcome of a prediction market.
Position
An open position held by the caller.
PriceLevel
A single resting orderbook level.
PriceLevelChange
One price-level update; size > 0 sets the level, size == 0 removes it.
PublicTrade
RestPriceLevel
Series
A recurring family of events (e.g. a weekly inflation reading or sports season).
SettlementSource
Reference used by the exchange to settle a series.
SportResult
Real-time sports score/state from the Polymarket Sports WebSocket. Serializes as snake_case for end-users; aliases accept the upstream camelCase.

Enums§

CryptoPriceSource
LiquidityRole
Whether a fill provided liquidity (maker) or took it (taker).
MarketStatus
Market lifecycle state. Options: active, closed, resolved.
MarketType
Shape of a market’s outcomes. Options: binary, categorical, scalar.
OrderOutcome
Outcome targeted by an order. Options: yes, no, or label: "<name>" for categorical Polymarket markets.
OrderSide
Order direction. Options: buy, sell.
OrderStatus
Order lifecycle state. Options: pending, open, filled, partially_filled, cancelled, rejected.
OrderType
Time-in-force. Options: gtc (rests on book), ioc (fill-now-or-cancel-rest), fok (all-or-nothing).
PriceLevelSide
Side of an orderbook level. Options: bid, ask.

Functions§

apply_ask_level
See apply_bid_level. Same semantics, ascending ordering.
apply_bid_level
Apply a price-level delta to a bid-sorted list with replace-or-insert semantics (matches the behaviour of a sorted associative map):
insert_ask
Insert a price level into an ask-sorted (ascending) list. Binary-search + Vec::insert; same complexity profile as insert_bid.
insert_bid
Insert a price level into a bid-sorted (descending) list. Binary-search for the insert position (O(log n)), then Vec::insert (O(n) memcpy shift on average). Net O(log n + n) per op vs the old push+sort’s O(n log n). Equal-price entries go AFTER existing entries.
orderbook_impact
Slippage curve at a single requested size. Walks both sides of the book (asks ascending for buy, bids descending for sell) consuming levels until size is filled or the side exhausts.
orderbook_microstructure
Microstructure signals: cumulative depth at standard bps tiers, slope of cumulative size vs distance-from-mid, largest consecutive-level gap, and raw level counts per side.
orderbook_stats
Snapshot stats: top-of-book, weighted mid, imbalance, total depth. Pure function over the unified orderbook — no upstream calls.
sort_asks
Sort price levels in ascending order (lowest price first) – ask side ordering. Uses integer comparison via FixedPrice::Ord (no partial_cmp/NaN handling).
sort_bids
Sort price levels in descending order (highest price first) – bid side ordering. Uses integer comparison via FixedPrice::Ord (no partial_cmp/NaN handling).

Type Aliases§

ChangeVec
Stack-allocated change list. Kalshi = 1 change, Polymarket typically 1-3. Falls back to heap only if > 4 changes in a single update (rare).