cexy 0.1.0-dev.16

Official Rust SDK for the CEXY.io exchange API (REST + WebSocket)
Documentation
//! The official Rust SDK for the [CEXY.io](https://cexy.io) exchange API: REST and WebSocket.
//!
//! - Typed models generated from the public OpenAPI spec (cexy-api-spec).
//! - Safe by default: retries with backoff, order placement designed to avoid duplicates (via
//!   `client_order_id`), a client-side rate limiter, and HTTP redirects are never followed.
//! - A WebSocket client with heartbeat, reconnect and a live order book.
//!
//! ```no_run
//! # async fn demo() -> Result<(), cexy::Error> {
//! let client = cexy::Client::new(cexy::ClientOptions::default())?;
//! let markets = client.markets().list().await?;
//! let now = client.time().await?;
//! println!("{} markets, server time {}", markets.len(), now.iso);
//! # Ok(()) }
//! ```
//!
//! Amounts are decimal strings ([`Amount`]), never floating point. API keys cannot withdraw or
//! transfer funds, whatever their scopes.

#[macro_use]
mod macros;

mod amount;
mod auth;
mod batch;
mod cancel_all;
mod client;
mod clock;
mod compat_futures_ids;
mod error;
mod limiter;
mod live_balances;
mod models_gen;
mod operations_gen;
mod orderbook;
mod pagination;
mod services;
mod signing;
mod tls;
mod transport;
mod ws;
mod ws_futures;

pub use amount::{Amount, BookLevel, levels};
pub use auth::{ApiKeyAuthenticator, AuthRequest, Authenticator};
pub use batch::{
    BatchCancelResult, BatchOrderInput, BatchOrderOutcome, BatchPlaceResult, CancelEntryOutcome,
    CancelOutcome, MAX_BATCH_ORDERS, MAX_CANCEL_ENTRIES, PlaceOutcome, new_client_order_id,
};
pub use cancel_all::{CancelAllOptions, CancelAllStop, CancelAllSummary, CancelAllTarget};
pub use client::{
    AuthScheme, CallOptions, Client, ClientOptions, DEFAULT_BASE_URL, DEFAULT_RPM_ANONYMOUS,
    DEFAULT_RPM_WITH_KEY, OnRetry, is_local_host,
};
#[allow(deprecated)]
pub use compat_futures_ids::{
    CandlesParams, FillsParams, FundingParams, OrderbookParams, TradesParams,
};
pub use error::{
    ApiError, ConnectionError, Error, ErrorBody, ErrorCategory, MAX_SERVER_WAIT,
    PAGING_CURSOR_REPEATED, PAGING_STALLED, Result, WsError,
};
pub use limiter::RateLimitState;
pub use live_balances::{
    BalanceSnapshotFn, BalancesEvent, LiveBalances, LiveBalancesOptions, OwnerIdFn,
};
pub use models_gen::*;
pub use operations_gen::*;
pub use orderbook::{BookSnapshot, LiveOrderBook, WS_BOOK_DEPTH};
pub use pagination::{ItemStream, Page};
pub use services::{
    Account, Assets, DEFAULT_MAX_BUSY_RETRIES, Exports, Fees, Futures, Markets, Networks,
    PlaceOrderResult, Pools, Trading, Wallet,
};
pub use signing::{HmacAuthenticator, MAX_CLOCK_OFFSET, SIGNING_SCHEME};
pub use transport::RetryInfo;
pub use ws::{
    AuthChange, AuthChangeReason, AuthResult, BookEvent, CloseInfo, DEFAULT_WEBSOCKET_URL,
    MAX_PING_INTERVAL, OrderBookUpdate, PRIVATE_CHANNELS, ResyncReason, SUPPORTED_PROTOCOL_VERSION,
    SequenceGap, SessionRevoked, SubscribeResult, WebSocket, Welcome, WsClock, WsEvent, WsEvents,
    WsFrame, WsOptions, WsTimer,
};
pub use ws_futures::{
    FUTURES_ACCOUNT_CHANNEL, FUTURES_INTERVALS, FuturesBookUpdate, FuturesCandleUpdate,
    FuturesChannel, FuturesMids, FuturesOrdersUpdate, FuturesPositionsUpdate, FuturesStatus,
    FuturesTradesUpdate,
};

/// SDK version.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

/// Default User-Agent product token: `cexy-rust/<VERSION>`.
pub const USER_AGENT: &str = concat!("cexy-rust/", env!("CARGO_PKG_VERSION"));

#[cfg(test)]
mod tests;

/// The README's examples, compiled by `cargo test --doc`.
#[cfg(doctest)]
#[doc = include_str!("../README.md")]
struct ReadmeDoctests;