pub struct BybitRawHttpClient { /* private fields */ }Expand description
Raw HTTP client for low-level Bybit API operations.
This client handles request/response operations with the Bybit API, returning venue-specific response types. It does not parse to Nautilus domain types.
Implementations§
Source§impl BybitRawHttpClient
impl BybitRawHttpClient
Sourcepub fn cancel_all_requests(&self)
pub fn cancel_all_requests(&self)
Cancel all pending HTTP requests.
Sourcepub fn cancellation_token(&self) -> &CancellationToken
pub fn cancellation_token(&self) -> &CancellationToken
Get the cancellation token for this client.
Sourcepub fn new(
base_url: Option<String>,
timeout_secs: Option<u64>,
max_retries: Option<u32>,
retry_delay_ms: Option<u64>,
retry_delay_max_ms: Option<u64>,
recv_window_ms: Option<u64>,
proxy_url: Option<String>,
) -> Result<Self, BybitHttpError>
pub fn new( base_url: Option<String>, timeout_secs: Option<u64>, max_retries: Option<u32>, retry_delay_ms: Option<u64>, retry_delay_max_ms: Option<u64>, recv_window_ms: Option<u64>, proxy_url: Option<String>, ) -> Result<Self, BybitHttpError>
Creates a new BybitRawHttpClient using the default Bybit HTTP URL.
§Errors
Returns an error if the retry manager cannot be created.
Sourcepub fn with_credentials(
api_key: String,
api_secret: String,
base_url: Option<String>,
timeout_secs: Option<u64>,
max_retries: Option<u32>,
retry_delay_ms: Option<u64>,
retry_delay_max_ms: Option<u64>,
recv_window_ms: Option<u64>,
proxy_url: Option<String>,
) -> Result<Self, BybitHttpError>
pub fn with_credentials( api_key: String, api_secret: String, base_url: Option<String>, timeout_secs: Option<u64>, max_retries: Option<u32>, retry_delay_ms: Option<u64>, retry_delay_max_ms: Option<u64>, recv_window_ms: Option<u64>, proxy_url: Option<String>, ) -> Result<Self, BybitHttpError>
Creates a new BybitRawHttpClient configured with credentials.
§Errors
Returns an error if the HTTP client cannot be created.
Sourcepub async fn get_server_time(
&self,
) -> Result<BybitServerTimeResponse, BybitHttpError>
pub async fn get_server_time( &self, ) -> Result<BybitServerTimeResponse, BybitHttpError>
Sourcepub async fn get_instruments<T: DeserializeOwned>(
&self,
params: &BybitInstrumentsInfoParams,
) -> Result<T, BybitHttpError>
pub async fn get_instruments<T: DeserializeOwned>( &self, params: &BybitInstrumentsInfoParams, ) -> Result<T, BybitHttpError>
Sourcepub async fn get_instruments_spot(
&self,
params: &BybitInstrumentsInfoParams,
) -> Result<BybitInstrumentSpotResponse, BybitHttpError>
pub async fn get_instruments_spot( &self, params: &BybitInstrumentsInfoParams, ) -> Result<BybitInstrumentSpotResponse, BybitHttpError>
Sourcepub async fn get_instruments_linear(
&self,
params: &BybitInstrumentsInfoParams,
) -> Result<BybitInstrumentLinearResponse, BybitHttpError>
pub async fn get_instruments_linear( &self, params: &BybitInstrumentsInfoParams, ) -> Result<BybitInstrumentLinearResponse, BybitHttpError>
Sourcepub async fn get_instruments_inverse(
&self,
params: &BybitInstrumentsInfoParams,
) -> Result<BybitInstrumentInverseResponse, BybitHttpError>
pub async fn get_instruments_inverse( &self, params: &BybitInstrumentsInfoParams, ) -> Result<BybitInstrumentInverseResponse, BybitHttpError>
Sourcepub async fn get_instruments_option(
&self,
params: &BybitInstrumentsInfoParams,
) -> Result<BybitInstrumentOptionResponse, BybitHttpError>
pub async fn get_instruments_option( &self, params: &BybitInstrumentsInfoParams, ) -> Result<BybitInstrumentOptionResponse, BybitHttpError>
Sourcepub async fn get_klines(
&self,
params: &BybitKlinesParams,
) -> Result<BybitKlinesResponse, BybitHttpError>
pub async fn get_klines( &self, params: &BybitKlinesParams, ) -> Result<BybitKlinesResponse, BybitHttpError>
Sourcepub async fn get_recent_trades(
&self,
params: &BybitTradesParams,
) -> Result<BybitTradesResponse, BybitHttpError>
pub async fn get_recent_trades( &self, params: &BybitTradesParams, ) -> Result<BybitTradesResponse, BybitHttpError>
Sourcepub async fn get_open_orders(
&self,
category: BybitProductType,
symbol: Option<&str>,
) -> Result<BybitOpenOrdersResponse, BybitHttpError>
pub async fn get_open_orders( &self, category: BybitProductType, symbol: Option<&str>, ) -> Result<BybitOpenOrdersResponse, BybitHttpError>
Sourcepub async fn place_order(
&self,
request: &Value,
) -> Result<BybitPlaceOrderResponse, BybitHttpError>
pub async fn place_order( &self, request: &Value, ) -> Result<BybitPlaceOrderResponse, BybitHttpError>
Sourcepub async fn get_wallet_balance(
&self,
params: &BybitWalletBalanceParams,
) -> Result<BybitWalletBalanceResponse, BybitHttpError>
pub async fn get_wallet_balance( &self, params: &BybitWalletBalanceParams, ) -> Result<BybitWalletBalanceResponse, BybitHttpError>
Sourcepub async fn get_account_details(
&self,
) -> Result<BybitAccountDetailsResponse, BybitHttpError>
pub async fn get_account_details( &self, ) -> Result<BybitAccountDetailsResponse, BybitHttpError>
Sourcepub async fn get_fee_rate(
&self,
params: &BybitFeeRateParams,
) -> Result<BybitFeeRateResponse, BybitHttpError>
pub async fn get_fee_rate( &self, params: &BybitFeeRateParams, ) -> Result<BybitFeeRateResponse, BybitHttpError>
Sourcepub async fn set_margin_mode(
&self,
margin_mode: BybitMarginMode,
) -> Result<BybitSetMarginModeResponse, BybitHttpError>
pub async fn set_margin_mode( &self, margin_mode: BybitMarginMode, ) -> Result<BybitSetMarginModeResponse, BybitHttpError>
Sourcepub async fn set_leverage(
&self,
product_type: BybitProductType,
symbol: &str,
buy_leverage: &str,
sell_leverage: &str,
) -> Result<BybitSetLeverageResponse, BybitHttpError>
pub async fn set_leverage( &self, product_type: BybitProductType, symbol: &str, buy_leverage: &str, sell_leverage: &str, ) -> Result<BybitSetLeverageResponse, BybitHttpError>
Sourcepub async fn switch_mode(
&self,
product_type: BybitProductType,
mode: BybitPositionMode,
symbol: Option<String>,
coin: Option<String>,
) -> Result<BybitSwitchModeResponse, BybitHttpError>
pub async fn switch_mode( &self, product_type: BybitProductType, mode: BybitPositionMode, symbol: Option<String>, coin: Option<String>, ) -> Result<BybitSwitchModeResponse, BybitHttpError>
Sourcepub async fn set_trading_stop(
&self,
params: &BybitSetTradingStopParams,
) -> Result<BybitSetTradingStopResponse, BybitHttpError>
pub async fn set_trading_stop( &self, params: &BybitSetTradingStopParams, ) -> Result<BybitSetTradingStopResponse, BybitHttpError>
Sourcepub async fn borrow(
&self,
coin: &str,
amount: &str,
) -> Result<BybitBorrowResponse, BybitHttpError>
pub async fn borrow( &self, coin: &str, amount: &str, ) -> Result<BybitBorrowResponse, BybitHttpError>
Sourcepub async fn no_convert_repay(
&self,
coin: &str,
amount: Option<&str>,
) -> Result<BybitNoConvertRepayResponse, BybitHttpError>
pub async fn no_convert_repay( &self, coin: &str, amount: Option<&str>, ) -> Result<BybitNoConvertRepayResponse, BybitHttpError>
Manually repays borrowed coins without asset conversion.
§Errors
Returns an error if:
- Credentials are missing.
- The request fails.
- Called between 04:00-05:30 UTC (interest calculation window).
- Insufficient spot balance for repayment.
§Panics
Panics if the parameter builder fails (should never happen with valid inputs).
§References
Sourcepub async fn get_tickers<T: DeserializeOwned>(
&self,
params: &BybitTickersParams,
) -> Result<T, BybitHttpError>
pub async fn get_tickers<T: DeserializeOwned>( &self, params: &BybitTickersParams, ) -> Result<T, BybitHttpError>
Sourcepub async fn get_trade_history(
&self,
params: &BybitTradeHistoryParams,
) -> Result<BybitTradeHistoryResponse, BybitHttpError>
pub async fn get_trade_history( &self, params: &BybitTradeHistoryParams, ) -> Result<BybitTradeHistoryResponse, BybitHttpError>
Sourcepub async fn get_positions(
&self,
params: &BybitPositionListParams,
) -> Result<BybitPositionListResponse, BybitHttpError>
pub async fn get_positions( &self, params: &BybitPositionListParams, ) -> Result<BybitPositionListResponse, BybitHttpError>
Sourcepub fn recv_window_ms(&self) -> u64
pub fn recv_window_ms(&self) -> u64
Returns the configured receive window in milliseconds.
Sourcepub fn credential(&self) -> Option<&Credential>
pub fn credential(&self) -> Option<&Credential>
Returns the API credential if configured.
Trait Implementations§
Source§impl Debug for BybitRawHttpClient
impl Debug for BybitRawHttpClient
Auto Trait Implementations§
impl Freeze for BybitRawHttpClient
impl !RefUnwindSafe for BybitRawHttpClient
impl Send for BybitRawHttpClient
impl Sync for BybitRawHttpClient
impl Unpin for BybitRawHttpClient
impl !UnwindSafe for BybitRawHttpClient
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<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