pub struct BitmexHttpInnerClient { /* private fields */ }
Expand description
Provides a lower-level HTTP client for connecting to the BitMEX REST API.
This client wraps the underlying HttpClient
to handle functionality
specific to BitMEX, such as request signing (for authenticated endpoints),
forming request URLs, and deserializing responses into specific data models.
§Connection Management
The client uses HTTP keep-alive for connection pooling with a 90-second idle timeout, which matches BitMEX’s server-side keep-alive timeout. Connections are automatically reused for subsequent requests to minimize latency.
§Rate Limiting
BitMEX enforces the following rate limits:
- 120 requests per minute for authenticated users (30 for unauthenticated).
- 10 requests per second burst limit for certain endpoints (order management).
The client automatically respects these limits through the configured quota.
Implementations§
Source§impl BitmexHttpInnerClient
impl BitmexHttpInnerClient
Sourcepub fn new(base_url: Option<String>, timeout_secs: Option<u64>) -> Self
pub fn new(base_url: Option<String>, timeout_secs: Option<u64>) -> Self
Creates a new BitmexHttpInnerClient
using the default BitMEX HTTP URL,
optionally overridden with a custom base URL.
This version of the client has no credentials, so it can only call publicly accessible endpoints.
Sourcepub fn with_credentials(
api_key: String,
api_secret: String,
base_url: String,
timeout_secs: Option<u64>,
) -> Self
pub fn with_credentials( api_key: String, api_secret: String, base_url: String, timeout_secs: Option<u64>, ) -> Self
Creates a new BitmexHttpInnerClient
configured with credentials
for authenticated requests, optionally using a custom base URL.
Sourcepub async fn http_get_instruments(
&self,
active_only: bool,
) -> Result<Vec<BitmexInstrument>, BitmexHttpError>
pub async fn http_get_instruments( &self, active_only: bool, ) -> Result<Vec<BitmexInstrument>, BitmexHttpError>
Get all instruments.
§Errors
Returns an error if the request fails, the response cannot be parsed, or the API returns an error.
Sourcepub async fn http_get_instrument(
&self,
symbol: &str,
) -> Result<BitmexInstrument, BitmexHttpError>
pub async fn http_get_instrument( &self, symbol: &str, ) -> Result<BitmexInstrument, BitmexHttpError>
Get instrument by symbol.
§Errors
Returns an error if the request fails, the response cannot be parsed, or the API returns an error.
Sourcepub async fn http_get_wallet(&self) -> Result<BitmexWallet, BitmexHttpError>
pub async fn http_get_wallet(&self) -> Result<BitmexWallet, BitmexHttpError>
Get user wallet information.
§Errors
Returns an error if credentials are missing, the request fails, or the API returns an error.
Sourcepub async fn http_get_margin(
&self,
currency: &str,
) -> Result<BitmexMargin, BitmexHttpError>
pub async fn http_get_margin( &self, currency: &str, ) -> Result<BitmexMargin, BitmexHttpError>
Get user margin information.
§Errors
Returns an error if credentials are missing, the request fails, or the API returns an error.
Sourcepub async fn http_get_trades(
&self,
params: GetTradeParams,
) -> Result<Vec<BitmexTrade>, BitmexHttpError>
pub async fn http_get_trades( &self, params: GetTradeParams, ) -> Result<Vec<BitmexTrade>, BitmexHttpError>
Sourcepub async fn http_get_orders(
&self,
params: GetOrderParams,
) -> Result<Vec<BitmexOrder>, BitmexHttpError>
pub async fn http_get_orders( &self, params: GetOrderParams, ) -> Result<Vec<BitmexOrder>, BitmexHttpError>
Sourcepub async fn http_place_order(
&self,
params: PostOrderParams,
) -> Result<Value, BitmexHttpError>
pub async fn http_place_order( &self, params: PostOrderParams, ) -> Result<Value, BitmexHttpError>
Sourcepub async fn http_cancel_orders(
&self,
params: DeleteOrderParams,
) -> Result<Value, BitmexHttpError>
pub async fn http_cancel_orders( &self, params: DeleteOrderParams, ) -> Result<Value, BitmexHttpError>
Sourcepub async fn http_amend_order(
&self,
params: PutOrderParams,
) -> Result<Value, BitmexHttpError>
pub async fn http_amend_order( &self, params: PutOrderParams, ) -> Result<Value, BitmexHttpError>
Sourcepub async fn http_cancel_all_orders(
&self,
params: DeleteAllOrdersParams,
) -> Result<Value, BitmexHttpError>
pub async fn http_cancel_all_orders( &self, params: DeleteAllOrdersParams, ) -> Result<Value, BitmexHttpError>
Cancel all orders.
§Errors
Returns an error if credentials are missing, the request fails, or the API returns an error.
§Panics
Panics if the parameters cannot be serialized (should never happen with valid builder-generated params).
§References
https://www.bitmex.com/api/explorer/#!/Order/Order_cancelAll
Sourcepub async fn http_get_executions(
&self,
params: GetExecutionParams,
) -> Result<Vec<BitmexExecution>, BitmexHttpError>
pub async fn http_get_executions( &self, params: GetExecutionParams, ) -> Result<Vec<BitmexExecution>, BitmexHttpError>
Sourcepub async fn http_get_positions(
&self,
params: GetPositionParams,
) -> Result<Vec<BitmexPosition>, BitmexHttpError>
pub async fn http_get_positions( &self, params: GetPositionParams, ) -> Result<Vec<BitmexPosition>, BitmexHttpError>
Sourcepub async fn http_place_orders_bulk(
&self,
params: PostOrderBulkParams,
) -> Result<Vec<BitmexOrder>, BitmexHttpError>
pub async fn http_place_orders_bulk( &self, params: PostOrderBulkParams, ) -> Result<Vec<BitmexOrder>, BitmexHttpError>
Sourcepub async fn http_amend_orders_bulk(
&self,
params: PutOrderBulkParams,
) -> Result<Vec<BitmexOrder>, BitmexHttpError>
pub async fn http_amend_orders_bulk( &self, params: PutOrderBulkParams, ) -> Result<Vec<BitmexOrder>, BitmexHttpError>
Sourcepub async fn http_update_position_leverage(
&self,
params: PostPositionLeverageParams,
) -> Result<BitmexPosition, BitmexHttpError>
pub async fn http_update_position_leverage( &self, params: PostPositionLeverageParams, ) -> Result<BitmexPosition, BitmexHttpError>
Trait Implementations§
Source§impl Clone for BitmexHttpInnerClient
impl Clone for BitmexHttpInnerClient
Source§fn clone(&self) -> BitmexHttpInnerClient
fn clone(&self) -> BitmexHttpInnerClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BitmexHttpInnerClient
impl Debug for BitmexHttpInnerClient
Auto Trait Implementations§
impl Freeze for BitmexHttpInnerClient
impl !RefUnwindSafe for BitmexHttpInnerClient
impl Send for BitmexHttpInnerClient
impl Sync for BitmexHttpInnerClient
impl Unpin for BitmexHttpInnerClient
impl !UnwindSafe for BitmexHttpInnerClient
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
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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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