Skip to main content

Account

Struct Account 

Source
pub struct Account<'a, T> { /* private fields */ }
Expand description

Accessor for the authenticated account endpoints.

Obtain one via OkxClient::account. All methods require credentials; calling them without credentials returns RestError::Configuration.

Implementations§

Source§

impl<'a, T: Transport> Account<'a, T>

Source

pub async fn get_balance( &self, request: BalanceRequest<'_>, ) -> Result<Vec<AccountBalance>, Error>

Retrieve the trading-account balance.

GET /api/v5/account/balance. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_positions( &self, request: &PositionsRequest<'_>, ) -> Result<Vec<Position>, Error>

Retrieve open positions.

GET /api/v5/account/positions. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_position_risk( &self, request: &PositionRiskRequest, ) -> Result<Vec<PositionRisk>, Error>

Retrieve account position risk.

GET /api/v5/account/account-position-risk. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_account_config(&self) -> Result<Vec<AccountConfig>, Error>

Retrieve account configuration.

GET /api/v5/account/config. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_account_bills( &self, request: &BillsRequest<'_>, ) -> Result<Vec<AccountBill>, Error>

Retrieve recent account bills.

GET /api/v5/account/bills. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_account_bills_archive( &self, request: &BillsArchiveRequest<'_>, ) -> Result<Vec<AccountBill>, Error>

Retrieve archived account bills.

GET /api/v5/account/bills-archive. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn apply_bills_history_archive( &self, request: &ApplyBillsHistoryArchiveRequest<'_>, ) -> Result<Vec<ApplyBillsHistoryArchiveResult>, Error>

Apply for historical account-bills archive generation.

POST /api/v5/account/bills-history-archive. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_bills_history_archive( &self, request: &BillsHistoryArchiveRequest<'_>, ) -> Result<Vec<BillsHistoryArchiveFile>, Error>

Retrieve historical account-bills archive download links.

GET /api/v5/account/bills-history-archive. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_bill_subtypes( &self, request: &BillSubtypesRequest<'_>, ) -> Result<Vec<BillSubtypeMapping>, Error>

Retrieve account bill types and subtype mappings.

GET /api/v5/account/subtypes. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_position_mode( &self, request: &SetPositionModeRequest<'_>, ) -> Result<Vec<SetPositionModeResult>, Error>

Set the account position mode.

POST /api/v5/account/set-position-mode. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_collateral_assets( &self, request: &SetCollateralAssetsRequest<'_>, ) -> Result<Vec<SetCollateralAssetsResult>, Error>

Set whether all or custom assets are used as collateral.

POST /api/v5/account/set-collateral-assets. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_leverage( &self, request: &SetLeverageRequest<'_>, ) -> Result<Vec<LeverageInfo>, Error>

Set leverage for an instrument or currency.

POST /api/v5/account/set-leverage. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_leverage( &self, request: &LeverageRequest<'_>, ) -> Result<Vec<LeverageInfo>, Error>

Retrieve leverage settings.

GET /api/v5/account/leverage-info. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_adjust_leverage_info( &self, request: &AdjustLeverageInfoRequest<'_>, ) -> Result<Vec<AdjustLeverageInfo>, Error>

Estimate account state after adjusting leverage.

GET /api/v5/account/adjust-leverage-info. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_max_order_size( &self, request: &MaxOrderSizeRequest<'_>, ) -> Result<Vec<MaxOrderSize>, Error>

Retrieve maximum tradable size for an instrument.

GET /api/v5/account/max-size. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_max_avail_size( &self, request: &MaxAvailableSizeRequest<'_>, ) -> Result<Vec<MaxAvailableSize>, Error>

Retrieve maximum available size for an instrument.

GET /api/v5/account/max-avail-size. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn adjust_margin( &self, request: &AdjustMarginRequest<'_>, ) -> Result<Vec<AdjustMarginResult>, Error>

Increase or decrease margin for a position.

POST /api/v5/account/position/margin-balance. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_fee_rates( &self, request: &FeeRatesRequest<'_>, ) -> Result<Vec<FeeRate>, Error>

Retrieve trade fee rates.

GET /api/v5/account/trade-fee. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_account_instruments( &self, request: &AccountInstrumentsRequest<'_>, ) -> Result<Vec<AccountInstrument>, Error>

Retrieve account-available instruments.

GET /api/v5/account/instruments. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_max_loan( &self, request: &MaxLoanRequest<'_>, ) -> Result<Vec<MaxLoan>, Error>

Retrieve the maximum loan amount.

GET /api/v5/account/max-loan. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_interest_accrued( &self, request: &InterestAccruedRequest<'_>, ) -> Result<Vec<InterestAccrued>, Error>

Retrieve interest-accrued records.

GET /api/v5/account/interest-accrued. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_interest_rate( &self, request: BalanceRequest<'_>, ) -> Result<Vec<InterestRate>, Error>

Retrieve interest rates.

GET /api/v5/account/interest-rate. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_greeks( &self, request: &SetGreeksRequest<'_>, ) -> Result<Vec<SetGreeksResult>, Error>

Set the greeks display type.

POST /api/v5/account/set-greeks. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_isolated_mode( &self, request: &SetIsolatedModeRequest<'_>, ) -> Result<Vec<SetIsolatedModeResult>, Error>

Set isolated margin transfer mode.

POST /api/v5/account/set-isolated-mode. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_max_withdrawal( &self, request: BalanceRequest<'_>, ) -> Result<Vec<MaxWithdrawal>, Error>

Retrieve maximum withdrawal amounts.

GET /api/v5/account/max-withdrawal. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_interest_limits( &self, request: &InterestLimitsRequest<'_>, ) -> Result<Vec<InterestLimit>, Error>

Retrieve borrowing rate and limit information.

GET /api/v5/account/interest-limits. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_simulated_margin( &self, request: &SimulatedMarginRequest<'_>, ) -> Result<Vec<SimulatedMargin>, Error>

Calculate simulated margin information.

POST /api/v5/account/simulated_margin. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_greeks( &self, request: BalanceRequest<'_>, ) -> Result<Vec<Greek>, Error>

Retrieve greeks.

GET /api/v5/account/greeks. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_positions_history( &self, request: &PositionsHistoryRequest<'_>, ) -> Result<Vec<PositionHistory>, Error>

Retrieve position history.

GET /api/v5/account/positions-history. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_account_position_tiers( &self, request: &AccountPositionTiersRequest<'_>, ) -> Result<Vec<AccountPositionTier>, Error>

Retrieve account position tiers.

GET /api/v5/account/position-tiers. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_risk_state(&self) -> Result<Vec<RiskState>, Error>

Retrieve the account risk state.

GET /api/v5/account/risk-state. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_risk_offset_amount( &self, request: &SetRiskOffsetAmountRequest<'_>, ) -> Result<Vec<SetRiskOffsetAmountResult>, Error>

Set the spot risk offset amount.

POST /api/v5/account/set-riskOffset-amt. Authenticated.

Only applicable to Portfolio Margin Mode.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_auto_loan( &self, request: &SetAutoLoanRequest, ) -> Result<Vec<SetAutoLoanResult>, Error>

Set account auto-loan mode.

POST /api/v5/account/set-auto-loan. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_account_level( &self, request: &SetAccountLevelRequest<'_>, ) -> Result<Vec<SetAccountLevelResult>, Error>

Set the account level.

POST /api/v5/account/set-account-level. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn activate_option(&self) -> Result<Vec<ActivateOptionResult>, Error>

Activate option trading.

POST /api/v5/account/activate-option. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn position_builder( &self, request: &PositionBuilderRequest<'_>, ) -> Result<Vec<PositionBuilderResult>, Error>

Build simulated positions and equity.

POST /api/v5/account/position-builder. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn spot_manual_borrow_repay( &self, request: &SpotManualBorrowRepayRequest<'_>, ) -> Result<Vec<SpotBorrowRepayResult>, Error>

Manually borrow or repay spot liabilities.

POST /api/v5/account/spot-manual-borrow-repay. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_auto_repay( &self, request: &SetAutoRepayRequest, ) -> Result<Vec<SetAutoRepayResult>, Error>

Set automatic repayment for spot borrow/repay.

POST /api/v5/account/set-auto-repay. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn get_spot_borrow_repay_history( &self, request: &SpotBorrowRepayHistoryRequest<'_>, ) -> Result<Vec<SpotBorrowRepayHistory>, Error>

Retrieve spot borrow/repay history.

GET /api/v5/account/spot-borrow-repay-history. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Source

pub async fn set_auto_earn( &self, request: &SetAutoEarnRequest<'_>, ) -> Result<Vec<SetAutoEarnResult>, Error>

Set automatic earn for the account.

POST /api/v5/account/set-auto-earn. Authenticated.

§Errors

Returns RestError::Configuration if no credentials are set, RestError::Okx on a non-zero OKX code, or transport/decode errors.

Auto Trait Implementations§

§

impl<'a, T> Freeze for Account<'a, T>

§

impl<'a, T> RefUnwindSafe for Account<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Account<'a, T>
where T: Sync,

§

impl<'a, T> Sync for Account<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Account<'a, T>

§

impl<'a, T> UnsafeUnpin for Account<'a, T>

§

impl<'a, T> UnwindSafe for Account<'a, T>
where T: RefUnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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