Struct bybit::account::AccountManager

source ·
pub struct AccountManager<'a> {
    pub client: Client<'a>,
    pub recv_window: u16,
}

Fields§

§client: Client<'a>§recv_window: u16

Implementations§

source§

impl<'a> AccountManager<'_>

source

pub async fn get_wallet_balance( &self, account: &str, coin: Option<&str>, ) -> Result<WalletResponse, BybitError>

Fetches the wallet balance for a specific account and optional coin.

§Arguments
  • account - The account type.
  • coin - The optional coin.
§Returns

A result containing the wallet balance response or an error.

source

pub async fn upgrade_to_uta(&self) -> Result<UTAResponse, BybitError>

Upgrades the current account to UTA.

This function sends a POST request to the Bybit API to upgrade the current account to UTA (Unified Trading Account). It awaits the response and returns the result.

§Returns

A result containing the UTA response or an error.

source

pub async fn get_borrow_history<'b>( &self, req: BorrowHistoryRequest<'_>, ) -> Result<BorrowHistoryResponse, BybitError>

Retrieves the borrow history for the current account.

This function sends a signed GET request to the Bybit API to retrieve the borrow history for the current account. The request can be filtered by the coin and start_time parameters. The response is deserialized into the BorrowHistoryResponse struct. The await? operator awaits the response and returns an error if the request fails.

§Arguments
  • req - A BorrowHistoryRequest struct containing the parameters for the request.
§Returns

A result containing the borrow history response or an error.

source

pub async fn repay_liability( &self, coin: Option<&str>, ) -> Result<RepayLiabilityResponse, BybitError>

Repays liability for a specific coin.

§Arguments
  • coin - The coin for which to repay liability. If not specified, all coins are repaid.
§Returns

A result containing a response object or an error.

source

pub async fn set_collateral_coin( &self, coin: &str, switch: bool, ) -> Result<SetCollateralCoinResponse, BybitError>

Sets the collateral coin for a specific coin with the given switch value.

§Arguments
  • coin - The coin for which to set the collateral.
  • switch - The switch value indicating whether to turn collateral on or off.
§Returns

A result containing the set collateral response or an error.

source

pub async fn batch_set_collateral( &self, requests: Vec<(&str, bool)>, ) -> Result<BatchSetCollateralCoinResponse, BybitError>

Sets the collateral coin for multiple coins in a single request.

§Arguments
  • requests - A vector of tuples, where each tuple contains the coin and the switch value.
§Returns

A result containing the batch set collateral response or an error.

source

pub async fn get_collateral_info( &self, coin: Option<&str>, ) -> Result<CollateralInfoResponse, BybitError>

Retrieves the collateral information for a specific coin.

§Arguments
  • coin - The optional coin for which to retrieve the collateral information. If not specified, information for all coins is returned.
§Returns

A result containing the collateral information response or an error.

source

pub async fn get_fee_rate( &self, category: Category, symbol: Option<String>, ) -> Result<FeeRateResponse, BybitError>

Retrieves the fee rate for a given market category and symbol.

§Arguments
  • category - The market category to fetch the fee rate from.
  • symbol - The trading symbol to fetch the fee rate for. If not specified, the fee rate for all symbols in the category is returned.
§Returns

A result containing the fee rate response or an error.

source

pub async fn get_account_info(&self) -> Result<AccountInfoResponse, BybitError>

Retrieves the account information for the current account.

This function sends a signed GET request to the Bybit API to retrieve the account information. The response is deserialized into the AccountInfoResponse struct. The await? operator awaits the response and returns an error if the request fails.

§Returns

A result containing the account information response or an error.

source

pub async fn get_transaction_log<'b>( &self, req: TransactionLogRequest<'_>, ) -> Result<TransactionLogResponse, BybitError>

Retrieves the transaction log for the current account.

This function sends a signed GET request to the Bybit API to retrieve the transaction log. The request parameters are serialized into a JSON object and sent in the request body. The response is deserialized into the TransactionLogResponse struct. The await? operator awaits the response and returns an error if the request fails.

§Arguments
  • req - An instance of TransactionLogRequest containing the request parameters.
§Returns

A result containing the transaction log response or an error.

source

pub async fn get_smp_id(&self) -> Result<SmpResponse, BybitError>

Retrieves the Server-Market-Portfolio (SMP) group ID for the current user.

§Returns

A result containing the SMP response or an error.

source

pub async fn set_margin_mode( &self, margin_mode: &str, ) -> Result<SetMarginModeResponse, BybitError>

Sets the margin mode for the current account.

§Arguments
  • margin_mode - The desired margin mode to set. Can be “CROSS” or “FIXED”.
§Returns

A result containing the set margin mode response or an error.

source

pub async fn set_spot_hedging( &self, spot_hedging: bool, ) -> Result<SpotHedgingResponse, BybitError>

Sets the spot hedging mode for the current account.

§Arguments
  • spot_hedging - The desired spot hedging mode. true sets the mode to “ON”, false sets the mode to “OFF”.
§Returns

A result containing the set spot hedging mode response or an error.

Trait Implementations§

source§

impl<'a> Bybit<'a> for AccountManager<'a>

source§

fn new( api_key: Option<Cow<'_, str>>, secret_key: Option<Cow<'_, str>>, ) -> AccountManager<'a>

Creates a new instance of the module with default configuration. Read more
source§

fn new_with_config( config: &Config<'_>, api_key: Option<Cow<'_, str>>, secret_key: Option<Cow<'_, str>>, ) -> AccountManager<'a>

Creates a new instance of the module with custom configuration. Read more
source§

impl<'a> Clone for AccountManager<'a>

source§

fn clone(&self) -> AccountManager<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for AccountManager<'a>

§

impl<'a> !RefUnwindSafe for AccountManager<'a>

§

impl<'a> Send for AccountManager<'a>

§

impl<'a> Sync for AccountManager<'a>

§

impl<'a> Unpin for AccountManager<'a>

§

impl<'a> !UnwindSafe for AccountManager<'a>

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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