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 fn new_with_env(
api_key: Option<String>,
api_secret: Option<String>,
base_url: Option<String>,
demo: bool,
testnet: bool,
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_with_env( api_key: Option<String>, api_secret: Option<String>, base_url: Option<String>, demo: bool, testnet: bool, 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 with environment variable credential resolution.
If api_key or api_secret are not provided, they will be loaded from
environment variables based on the environment flags:
- Demo:
BYBIT_DEMO_API_KEY,BYBIT_DEMO_API_SECRET - Testnet:
BYBIT_TESTNET_API_KEY,BYBIT_TESTNET_API_SECRET - Mainnet:
BYBIT_API_KEY,BYBIT_API_SECRET
§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 + BybitResponseCheck>(
&self,
params: &BybitInstrumentsInfoParams,
) -> Result<T, BybitHttpError>
pub async fn get_instruments<T: DeserializeOwned + BybitResponseCheck>( &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<String>,
base_coin: Option<String>,
settle_coin: Option<String>,
order_id: Option<String>,
order_link_id: Option<String>,
open_only: Option<BybitOpenOnly>,
order_filter: Option<BybitOrderFilter>,
limit: Option<u32>,
cursor: Option<String>,
) -> Result<BybitOpenOrdersResponse, BybitHttpError>
pub async fn get_open_orders( &self, category: BybitProductType, symbol: Option<String>, base_coin: Option<String>, settle_coin: Option<String>, order_id: Option<String>, order_link_id: Option<String>, open_only: Option<BybitOpenOnly>, order_filter: Option<BybitOrderFilter>, limit: Option<u32>, cursor: Option<String>, ) -> 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 + BybitResponseCheck>(
&self,
params: &BybitTickersParams,
) -> Result<T, BybitHttpError>
pub async fn get_tickers<T: DeserializeOwned + BybitResponseCheck>( &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.
Source§impl BybitRawHttpClient
impl BybitRawHttpClient
pub fn py_base_url(&self) -> &str
pub fn py_api_key(&self) -> Option<String>
pub fn py_recv_window_ms(&self) -> u64
Trait Implementations§
Source§impl Clone for BybitRawHttpClient
impl Clone for BybitRawHttpClient
Source§fn clone(&self) -> BybitRawHttpClient
fn clone(&self) -> BybitRawHttpClient
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BybitRawHttpClient
impl Debug for BybitRawHttpClient
Source§impl Default for BybitRawHttpClient
impl Default for BybitRawHttpClient
Source§impl<'py> IntoPyObject<'py> for BybitRawHttpClient
impl<'py> IntoPyObject<'py> for BybitRawHttpClient
Source§type Target = BybitRawHttpClient
type Target = BybitRawHttpClient
Source§type Output = Bound<'py, <BybitRawHttpClient as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <BybitRawHttpClient as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for BybitRawHttpClient
impl PyClass for BybitRawHttpClient
Source§impl PyClassImpl for BybitRawHttpClient
impl PyClassImpl for BybitRawHttpClient
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// 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.
const RAW_DOC: &'static CStr = /// 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.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<BybitRawHttpClient>
type ThreadChecker = SendablePyClass<BybitRawHttpClient>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for BybitRawHttpClient
impl PyClassNewTextSignature for BybitRawHttpClient
const TEXT_SIGNATURE: &'static str = "(api_key=None, api_secret=None, base_url=None, demo=False, testnet=False, timeout_secs=None, max_retries=None, retry_delay_ms=None, retry_delay_max_ms=None, recv_window_ms=None, proxy_url=None)"
Source§impl PyMethods<BybitRawHttpClient> for PyClassImplCollector<BybitRawHttpClient>
impl PyMethods<BybitRawHttpClient> for PyClassImplCollector<BybitRawHttpClient>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for BybitRawHttpClient
impl PyTypeInfo for BybitRawHttpClient
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl DerefToPyAny for BybitRawHttpClient
impl ExtractPyClassWithClone 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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)§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§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read moreSource§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
Source§fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more