Skip to main content

Crate wickra_exchange

Crate wickra_exchange 

Source
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.
BookDelta
A depth diff to apply to a locally maintained order book.
BookLevel
A single resting price level (exchange-precision Decimal).
BreadthMember
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 by MarketData::klines so market data feeds the indicator core directly. A single OHLCV bar.
ClientIdGenerator
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.
DeadMansSwitch
A heartbeat-driven deadline. Starts disarmed; the first heartbeat arms it.
DerivativesTickBuilder
Folds independent DerivativesFeed channels into a running DerivativesTick.
ExchangeOptions
Configuration for one exchange connection.
FundingRate
A funding-rate update for a perpetual market.
Gate
A Gate.io client over injected transports.
Health
A snapshot of a connection’s health.
HttpRequest
An outbound HTTP request.
HttpResponse
An HTTP response.
Htx
An HTX client over injected transports.
Instrument
One tradable instrument and its metadata.
InstrumentCache
A cache of instrument metadata with a caller-driven refresh clock.
InstrumentFilters
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.
LongShortRatio
A long/short positioning ratio update.
MarkIndex
A mark/index price update.
MockHttpTransport
An HttpTransport that returns queued responses and records the requests it was given. Queue responses with MockHttpTransport::push_response / push_json / push_error; they are returned FIFO.
MockWsTransport
A WsTransport whose connections replay a scripted sequence of frames.
NonceGenerator
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.
OpenInterest
An open-interest update: outstanding contracts / notional.
Order
An order as reported by the venue after placement or on query.
OrderBookBuilder
A local L2 book built from a snapshot and a stream of diffs.
OrderBookSnapshot
A depth snapshot with exact levels, best-first on each side.
OrderRequest
A request to place an order. Built with the convenience constructors and refined with the builder methods; quantities and prices are exact Decimals.
PaperExchange
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.
ReplayExchange
A network-free exchange that replays a recorded feed and fills against it. The replay model is documented on the methods below.
ReqwestHttpTransport
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.
ServerClock
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.
ThrottledTransport
A rate-limiting, retrying decorator over another HttpTransport.
Ticker
A point-in-time price summary for a market.
TokenTtl
The lifetime of a short-lived token (a per-request JWT).
TradePrint
A single executed public trade.
TungsteniteWsTransport
A pull-based WebSocket transport backed by tokio-tungstenite.
Upbit
An Upbit client over injected transports.
WeightedRateLimiter
A windowed, weight-based rate limiter with venue cool-off support.

Enums§

Acquire
The result of asking the limiter for budget.
BookUpdate
The outcome of applying a BookDelta.
DerivativesChannel
A derivatives channel a venue can push over its WebSocket.
DerivativesFeed
One channel of the derivatives microstructure feed.
Error
A unified connectivity / execution error.
Event
An item yielded by a pull-based stream.
HttpMethod
An HTTP method.
MarginMode
Margin mode for derivatives accounts.
MarketType
Which market of a venue to connect to.
OrderSide
The side of an order.
OrderStatus
The lifecycle state of an order.
OrderType
The type of an order.
PositionMode
Position mode for derivatives accounts.
PositionSide
The direction of a position.
SelfTradePrevention
Self-trade-prevention (STP) policy: what a venue does when an order would match against another order from the same account.
TimeInForce
How long an order remains active.

Constants§

VERSION
The crate version, sourced from Cargo.toml.

Traits§

AdvancedOrders
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.
DerivativesStream
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.
HttpTransport
A synchronous HTTP transport. The public surface stays blocking; a real adapter drives an async client internally, a mock returns canned responses.
MarketData
Read-only market data: REST snapshots plus pull-based streaming.
WsConnection
A single WebSocket connection. recv returns Ok(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.
WsUserData
Private user-data streaming: subscribe to the account’s own order and balance updates so poll_events surfaces Event::OrderUpdate and Event::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 name as a boxed AdvancedOrders trait object (amend / batch place-cancel / OCO). Available on the eight trading venues; the spot-only venues (coinbase, upbit) return Error::UnsupportedExchange.
connect_derivatives
Build a derivatives client for name as a boxed Derivatives trait 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’s poll_events surfaces the user’s own OrderUpdate / BalanceUpdate events.
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 core CrossSection consumed by the breadth indicator family.
format_decimal
Format a Decimal for the wire: no scientific notation, trailing zeros stripped (1.2300 becomes 1.23, 5.0 becomes 5).
hmac_sha256_base64
HMAC-SHA256 of message under secret, standard base64 (OKX, Bitget, KuCoin).
hmac_sha256_hex
HMAC-SHA256 of message under secret, lower-case hex (Binance, Bybit, …).
hmac_sha512_base64
HMAC-SHA512 of message under secret, standard base64 (Kraken’s outer step).
hmac_sha512_base64_with_b64_secret
HMAC-SHA512 of message under a base64-decoded secret, standard base64. Kraken supplies its private key base64-encoded; this decodes it first.
hmac_sha512_bytes
The raw HMAC-SHA512 digest of message under secret (Upbit’s JWT HS512).
hmac_sha512_hex
HMAC-SHA512 of message under secret, lower-case hex (Gate.io).
order_book_from_snapshot
Convert a depth OrderBookSnapshot into the core OrderBook consumed 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 to None.
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 secret in text with "<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 hashes nonce + body before the HMAC).
sha512_hex
SHA-512 of data, lower-case hex (Gate.io hashes the request body).
trade_from_print
Convert a public TradePrint into the core Trade value consumed by the microstructure indicator family.

Type Aliases§

Result
The crate-wide result type.