Skip to main content

Module models

Module models 

Source

Structs§

Candlestick
OHLCV candlestick, normalized across all exchanges. Prices are decimals (0.0 to 1.0). Timestamp is the period START (not end). Serialized over the wire as RFC3339 (DateTime) for API consistency.
CryptoPrice
Fill
A single fill (trade execution) from a user’s order.
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).
Market
Unified prediction market model.
MarketTrade
Normalized public market trade, suitable for “tape” UIs.
Order
Orderbook
OrderbookSnapshot
A point-in-time L2 orderbook snapshot, used for historical orderbook data.
OutcomeToken
Position
PriceLevel
PriceLevelChange
A single price level change. Absolute replacement semantics: size > 0 = set level to this size, size == 0 = remove level.
PricePoint
PublicTrade
RestPriceLevel
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
MarketStatus
Normalized market status across all exchanges.
MarketType
Market type classification.
OrderSide
OrderStatus
OrderType
Order time-in-force / execution type.
PriceHistoryInterval
PriceLevelSide
Bid or ask side. Serializes as “bid”/“ask” on the wire.

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 matching polyfill-rs’s BTreeMap behavior:
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.
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).