pub struct BinanceFuturesWsTradingClient { /* private fields */ }Expand description
Binance Futures WebSocket Trading API client.
Provides order management via WebSocket with JSON responses, complementing the HTTP client with lower-latency order submission. Only available for USD-M Futures.
Implementations§
Source§impl BinanceFuturesWsTradingClient
impl BinanceFuturesWsTradingClient
Sourcepub fn new(
url: Option<String>,
api_key: String,
api_secret: String,
heartbeat: Option<u64>,
transport_backend: TransportBackend,
) -> Self
pub fn new( url: Option<String>, api_key: String, api_secret: String, heartbeat: Option<u64>, transport_backend: TransportBackend, ) -> Self
Creates a new BinanceFuturesWsTradingClient instance.
Sourcepub fn with_proxy(self, proxy_url: Option<String>) -> Self
pub fn with_proxy(self, proxy_url: Option<String>) -> Self
Configures the proxy used by the WebSocket connection.
Sourcepub fn with_socket_control(self, control: SocketControl) -> Self
pub fn with_socket_control(self, control: SocketControl) -> Self
Configures socket state reporting and reconnect control.
Sourcepub const fn with_recv_window(self, recv_window_ms: Option<u64>) -> Self
pub const fn with_recv_window(self, recv_window_ms: Option<u64>) -> Self
Configures the receive window added to signed WebSocket API requests.
pub fn next_request_id(&self) -> String
Sourcepub async fn connect(&mut self) -> BinanceFuturesWsApiResult<()>
pub async fn connect(&mut self) -> BinanceFuturesWsApiResult<()>
Sourcepub async fn disconnect(&mut self) -> BinanceFuturesWsApiResult<()>
pub async fn disconnect(&mut self) -> BinanceFuturesWsApiResult<()>
Disconnects from the WebSocket Trading API server.
§Errors
Returns an error if the handler task fails or does not stop after abort.
Sourcepub async fn place_order(
&self,
params: BinanceNewOrderParams,
) -> BinanceFuturesWsApiResult<String>
pub async fn place_order( &self, params: BinanceNewOrderParams, ) -> BinanceFuturesWsApiResult<String>
Places a new order via the WebSocket Trading API.
§Errors
Returns an error if the handler is unavailable.
Sourcepub async fn place_order_with_id(
&self,
id: String,
params: BinanceNewOrderParams,
) -> BinanceFuturesWsApiResult<()>
pub async fn place_order_with_id( &self, id: String, params: BinanceNewOrderParams, ) -> BinanceFuturesWsApiResult<()>
Places a new order via the WebSocket Trading API using a pre-generated request ID.
§Errors
Returns an error if the handler is unavailable.
Sourcepub async fn cancel_order(
&self,
params: BinanceCancelOrderParams,
) -> BinanceFuturesWsApiResult<String>
pub async fn cancel_order( &self, params: BinanceCancelOrderParams, ) -> BinanceFuturesWsApiResult<String>
Cancels an order via the WebSocket Trading API.
§Errors
Returns an error if the handler is unavailable.
Sourcepub async fn cancel_order_with_id(
&self,
id: String,
params: BinanceCancelOrderParams,
) -> BinanceFuturesWsApiResult<()>
pub async fn cancel_order_with_id( &self, id: String, params: BinanceCancelOrderParams, ) -> BinanceFuturesWsApiResult<()>
Cancels an order via the WebSocket Trading API using a pre-generated request ID.
§Errors
Returns an error if the handler is unavailable.
Sourcepub async fn modify_order(
&self,
params: BinanceModifyOrderParams,
) -> BinanceFuturesWsApiResult<String>
pub async fn modify_order( &self, params: BinanceModifyOrderParams, ) -> BinanceFuturesWsApiResult<String>
Modifies an order via the WebSocket Trading API (in-place amendment).
§Errors
Returns an error if the handler is unavailable.
Sourcepub async fn modify_order_with_id(
&self,
id: String,
params: BinanceModifyOrderParams,
) -> BinanceFuturesWsApiResult<()>
pub async fn modify_order_with_id( &self, id: String, params: BinanceModifyOrderParams, ) -> BinanceFuturesWsApiResult<()>
Modifies an order via the WebSocket Trading API using a pre-generated request ID.
§Errors
Returns an error if the handler is unavailable.
Sourcepub async fn recv(&self) -> Option<BinanceFuturesWsTradingMessage>
pub async fn recv(&self) -> Option<BinanceFuturesWsTradingMessage>
Receives the next message from the handler.
Returns None if the receiver is closed or not initialized.
Trait Implementations§
Source§impl Clone for BinanceFuturesWsTradingClient
impl Clone for BinanceFuturesWsTradingClient
Source§fn clone(&self) -> BinanceFuturesWsTradingClient
fn clone(&self) -> BinanceFuturesWsTradingClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for BinanceFuturesWsTradingClient
impl !RefUnwindSafe for BinanceFuturesWsTradingClient
impl !UnwindSafe for BinanceFuturesWsTradingClient
impl Send for BinanceFuturesWsTradingClient
impl Sync for BinanceFuturesWsTradingClient
impl Unpin for BinanceFuturesWsTradingClient
impl UnsafeUnpin for BinanceFuturesWsTradingClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more