Expand description
§wickra-exchange
Streaming-native crypto-exchange connectivity built on the Wickra core: one
typed, unified API over the ten largest exchanges (market data + signed order
execution). This crate is a thin facade that re-exports
wickra_exchange_core; depend on it for the stable public surface.
See the repository README for the supported exchanges, the language bindings (native Python/Node + a C ABI hub for C/C++/C#/Go/Java/R), and the streaming model.
Structs§
- Backoff
- An exponential-backoff policy.
- Balance
- A balance for a single asset.
- Binance
- A Binance client over an injected HTTP transport.
- Bitget
- A Bitget client over injected transports.
- Book
Delta - A depth diff to apply to a locally maintained order book.
- Book
Level - A single resting price level (exchange-precision
Decimal). - Breadth
Member - One symbol’s contribution to a market-breadth cross-section.
- Bybit
- A Bybit client over an injected HTTP transport.
- Candle
- Re-export of
wickra_core::Candle, the candle type returned byMarketData::klinesso market data feeds the indicator core directly. A single OHLCV bar. - Client
IdGenerator - A monotonic generator of unique client order ids of the form
"{prefix}-{counter}". - Coinbase
- A Coinbase Advanced Trade client over injected transports.
- Credentials
- API credentials for one account on one venue.
- Dead
Mans Switch - A heartbeat-driven deadline. Starts disarmed; the first
heartbeatarms it. - Derivatives
Tick Builder - Folds independent
DerivativesFeedchannels into a runningDerivativesTick. - Exchange
Options - Configuration for one exchange connection.
- Funding
Rate - A funding-rate update for a perpetual market.
- Gate
- A Gate.io client over injected transports.
- Health
- A snapshot of a connection’s health.
- Http
Request - An outbound HTTP request.
- Http
Response - An HTTP response.
- Htx
- An HTX client over injected transports.
- Instrument
- One tradable instrument and its metadata.
- Instrument
Cache - A cache of instrument metadata with a caller-driven refresh clock.
- Instrument
Filters - The order constraints for one instrument.
- Kraken
- A Kraken client over injected transports.
- KuCoin
- A KuCoin client over injected transports.
- Liquidation
- A forced liquidation print.
- Long
Short Ratio - A long/short positioning ratio update.
- Mark
Index - A mark/index price update.
- Mock
Http Transport - An
HttpTransportthat returns queued responses and records the requests it was given. Queue responses withMockHttpTransport::push_response/push_json/push_error; they are returned FIFO. - Mock
WsTransport - A
WsTransportwhose connections replay a scripted sequence of frames. - Nonce
Generator - A strictly-increasing nonce generator. The nonce tracks wall-clock milliseconds but is forced monotonic, so calls faster than millisecond resolution still strictly increase.
- OcoRequest
- A one-cancels-other (OCO) order: a take-profit limit leg paired with a stop leg, where a fill on one cancels the other. Used to bracket a position with a profit target and a protective stop in a single request.
- Okx
- An OKX client over injected transports.
- Open
Interest - An open-interest update: outstanding contracts / notional.
- Order
- An order as reported by the venue after placement or on query.
- Order
Book Builder - A local L2 book built from a snapshot and a stream of diffs.
- Order
Book Snapshot - A depth snapshot with exact levels, best-first on each side.
- Order
Request - A request to place an order. Built with the convenience constructors and
refined with the builder methods; quantities and prices are exact
Decimals. - Paper
Exchange - A deterministic, network-free exchange that simulates fills through an internal portfolio. The fill model is documented on the methods below.
- Position
- A net position in one derivatives market.
- Reconciliation
- The result of reconciling local belief against the venue’s open orders.
- Replay
Exchange - A network-free exchange that replays a recorded feed and fills against it. The replay model is documented on the methods below.
- Reqwest
Http Transport - A synchronous HTTP transport backed by
reqwest’s blocking client (rustls TLS). The blocking client keeps the public surface synchronous with no tokio runtime for callers to manage. - Server
Clock - Tracks the offset between the local clock and a venue’s server clock.
- Symbol
- A canonical, venue-neutral market: a base asset against a quote asset.
- Throttled
Transport - A rate-limiting, retrying decorator over another
HttpTransport. - Ticker
- A point-in-time price summary for a market.
- Token
Ttl - The lifetime of a short-lived token (a per-request JWT).
- Trade
Print - A single executed public trade.
- Tungstenite
WsTransport - A pull-based WebSocket transport backed by tokio-tungstenite.
- Upbit
- An Upbit client over injected transports.
- Weighted
Rate Limiter - A windowed, weight-based rate limiter with venue cool-off support.
Enums§
- Acquire
- The result of asking the limiter for budget.
- Book
Update - The outcome of applying a
BookDelta. - Derivatives
Channel - A derivatives channel a venue can push over its WebSocket.
- Derivatives
Feed - One channel of the derivatives microstructure feed.
- Error
- A unified connectivity / execution error.
- Event
- An item yielded by a pull-based stream.
- Http
Method - An HTTP method.
- Margin
Mode - Margin mode for derivatives accounts.
- Market
Type - Which market of a venue to connect to.
- Order
Side - The side of an order.
- Order
Status - The lifecycle state of an order.
- Order
Type - The type of an order.
- Position
Mode - Position mode for derivatives accounts.
- Position
Side - The direction of a position.
- Self
Trade Prevention - Self-trade-prevention (STP) policy: what a venue does when an order would match against another order from the same account.
- Time
InForce - How long an order remains active.
Constants§
- VERSION
- The crate version, sourced from
Cargo.toml.
Traits§
- Advanced
Orders - Advanced order operations beyond single placement: amend-in-place, batched placement and cancellation, and one-cancels-other (OCO) brackets. Implemented per venue where the underlying API supports each operation; venues document any operation they cannot express natively.
- Derivatives
- Derivatives (perpetual / futures) account operations: positions, leverage and
margin mode. Implemented only by venues that offer derivatives markets and
meaningful only on a derivatives
MarketType; spot-only venues (Coinbase, Upbit) do not implement it. - Derivatives
Stream - The derivatives microstructure channels, for a futures client.
- Exchange
- A full exchange connection: market data and execution behind one typed API.
- Execution
- Signed order execution and account access.
- Http
Transport - A synchronous HTTP transport. The public surface stays blocking; a real adapter drives an async client internally, a mock returns canned responses.
- Market
Data - Read-only market data: REST snapshots plus pull-based streaming.
- WsConnection
- A single WebSocket connection.
recvreturnsOk(None)when the peer closed the connection cleanly. - WsExecution
- Order placement and cancellation over a venue’s WebSocket API (
ws-api), where a signed request frame is sent on a dedicated connection and the matching response frame is read back. Lower-latency than REST; implemented by venues that expose a WebSocket order API. - WsTransport
- A WebSocket transport: opens connections to stream URLs.
- WsUser
Data - Private user-data streaming: subscribe to the account’s own order and balance
updates so
poll_eventssurfacesEvent::OrderUpdateandEvent::BalanceUpdate. Implemented by venues that expose a private WebSocket stream (a listen-key / login handshake).
Functions§
- connect
- Build a real-socket, authenticated client for
name, ready to stream and trade. - connect_
advanced - Build a client for
nameas a boxedAdvancedOrderstrait object (amend / batch place-cancel / OCO). Available on the eight trading venues; the spot-only venues (coinbase,upbit) returnError::UnsupportedExchange. - connect_
derivatives - Build a derivatives client for
nameas a boxedDerivativestrait object (positions / leverage / margin mode / reduce-only close). - connect_
user_ data - Build a real-socket client that streams the account’s own order and balance
updates over a private WebSocket. After
subscribe_user_data, the client’spoll_eventssurfaces the user’s ownOrderUpdate/BalanceUpdateevents. - connect_
ws_ execution - Build a real-socket client that places and cancels orders over a venue’s WebSocket order API.
- cross_
section - Convert a universe of
BreadthMembers into the coreCrossSectionconsumed by the breadth indicator family. - format_
decimal - Format a
Decimalfor the wire: no scientific notation, trailing zeros stripped (1.2300becomes1.23,5.0becomes5). - hmac_
sha256_ base64 - HMAC-SHA256 of
messageundersecret, standard base64 (OKX, Bitget, KuCoin). - hmac_
sha256_ hex - HMAC-SHA256 of
messageundersecret, lower-case hex (Binance, Bybit, …). - hmac_
sha512_ base64 - HMAC-SHA512 of
messageundersecret, standard base64 (Kraken’s outer step). - hmac_
sha512_ base64_ with_ b64_ secret - HMAC-SHA512 of
messageunder a base64-decodedsecret, standard base64. Kraken supplies its private key base64-encoded; this decodes it first. - hmac_
sha512_ bytes - The raw HMAC-SHA512 digest of
messageundersecret(Upbit’s JWT HS512). - hmac_
sha512_ hex - HMAC-SHA512 of
messageundersecret, lower-case hex (Gate.io). - order_
book_ from_ snapshot - Convert a depth
OrderBookSnapshotinto the coreOrderBookconsumed by the order-book imbalance / order-flow indicators. - parse_
decimal - Parse a venue-supplied decimal string into an exact
Decimal. - parse_
opt_ decimal - Parse an optional decimal:
None/empty/"null"map toNone. - reconcile_
orders - Reconcile the order ids the client believed were open against the venue’s current open orders. Output vectors are sorted for determinism.
- redact
- Replace every occurrence of
secretintextwith"<redacted>". An empty secret is ignored (it would otherwise match everywhere), so this is safe to call unconditionally before logging. - sha256
- The raw SHA-256 digest of
data(Kraken hashesnonce + bodybefore the HMAC). - sha512_
hex - SHA-512 of
data, lower-case hex (Gate.io hashes the request body). - trade_
from_ print - Convert a public
TradePrintinto the coreTradevalue consumed by the microstructure indicator family.
Type Aliases§
- Result
- The crate-wide result type.