Generates a per-exchange error enum with the five variants every exchange
shares (Http, Api, RateLimited, AuthRequired, MarketNotFound),
plus any exchange-specific variants passed in the body.
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.
A concurrent rate limiter that enforces a global rate limit across multiple
concurrent streams. Uses a semaphore for concurrency control and an atomic
timestamp to ensure min_interval between ANY two requests globally.
Lock-free: uses AtomicU64 CAS loop instead of a mutex for the timestamp.
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).
Enum dispatch over all supported exchanges.
Direct match dispatch eliminates vtable indirection and allows the compiler to
monomorphize and inline each exchange method — no heap-allocated Pin<Box<dyn Future>>.
Insert a price level into a bid-sorted (descending) list.
Uses push + sort_unstable for prediction market books (typically < 100 levels).
sort_unstable avoids the allocation of a merge-sort buffer and is faster
on small, nearly-sorted arrays than Vec::insert’s O(n) memcpy shift.
Sort price levels in ascending order (lowest price first) – ask side ordering.
Uses integer comparison via FixedPrice::Ord (no partial_cmp/NaN handling).
Sort price levels in descending order (highest price first) – bid side ordering.
Uses integer comparison via FixedPrice::Ord (no partial_cmp/NaN handling).