Skip to main content

ExchangeClient

Struct ExchangeClient 

Source
pub struct ExchangeClient { /* private fields */ }
Expand description

Unified exchange client that wraps per-capability trait objects.

Created by super::VenueRegistry::create_exchange_client. Provides capability discovery and a convenience fetch_market_snapshot that fetches all available data in parallel.

Implementations§

Source§

impl ExchangeClient

Source

pub fn from_descriptor(desc: &VenueDescriptor) -> Self

👎Deprecated since 0.8.0:

pass the transport: use ExchangeClient::from_descriptor_with_http

Build an ExchangeClient from a VenueDescriptor.

Each capability that exists in the descriptor gets a ConfigurableExchangeClient implementation wired in.

Source

pub fn from_descriptor_with_http( desc: &VenueDescriptor, http: Arc<dyn HttpClient>, ) -> Self

Build an ExchangeClient from a VenueDescriptor whose requests go through http.

Source

pub fn venue_id(&self) -> &str

Venue ID (e.g., “binance”).

Source

pub fn venue_name(&self) -> &str

Venue display name (e.g., “Binance Spot”).

Source

pub fn venue_symbol(&self, pair: &Pair) -> String

The venue’s symbol for a pair; a pair with no quote uses the venue’s default quote.

Source

pub fn has_order_book(&self) -> bool

Whether this client supports order book fetching.

Source

pub fn has_ticker(&self) -> bool

Whether this client supports ticker fetching.

Source

pub fn has_trade_history(&self) -> bool

Whether this client supports trade history fetching.

Source

pub fn has_ohlc(&self) -> bool

Whether this client supports OHLC / kline data.

Source

pub async fn fetch_order_book(&self, pair: &str) -> Result<OrderBook>

Fetch order book (if supported).

Source

pub async fn fetch_ticker(&self, pair: &str) -> Result<Ticker>

Fetch ticker (if supported).

Source

pub async fn fetch_recent_trades( &self, pair: &str, limit: u32, ) -> Result<Vec<Trade>>

Fetch recent trades (if supported).

Source

pub fn lists_assets(&self) -> bool

Whether the venue lists its coins’ contracts (assets).

Source

pub async fn fetch_assets(&self) -> Option<Result<Vec<AssetInfo>>>

The venue’s coin list, or None when the venue has no assets capability.

Source

pub async fn fetch_token_addresses( &self, pair: &Pair, ) -> Option<Result<Vec<TokenAddress>>>

The token lines for pair from the venue’s coin list, or None when the venue has no assets capability.

Source

pub async fn fetch_ohlc( &self, pair: &str, interval: &str, limit: u32, ) -> Result<Vec<Candle>>

Fetch OHLC candlesticks (if supported).

Source

pub async fn fetch_market_snapshot( &self, pair: &str, trades_limit: u32, ) -> MarketSnapshot

Fetch all available market data for a pair in one call, with up to trades_limit recent trades.

Each capability is fetched independently; failures in one capability do not prevent others from succeeding (they just produce None).

Trait Implementations§

Source§

impl Debug for ExchangeClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more