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
[Error::Configuration].
Implementations§
Source§impl<'a, T: Transport> Account<'a, T>
impl<'a, T: Transport> Account<'a, T>
Sourcepub async fn get_balance(
&self,
ccy: Option<&str>,
) -> Result<Vec<AccountBalance>, Error>
pub async fn get_balance( &self, ccy: Option<&str>, ) -> Result<Vec<AccountBalance>, Error>
Retrieve the trading-account balance.
GET /api/v5/account/balance. Authenticated. Pass ccy to filter to one
or more comma-separated currencies (e.g. Some("BTC,USDT")). The result
is a single AccountBalance.
§Errors
Returns [Error::Configuration] if no credentials are set,
[Error::Api] on a non-zero OKX code, or transport/decode errors.
Sourcepub async fn get_positions(
&self,
inst_type: Option<InstType>,
inst_id: Option<&str>,
) -> Result<Vec<Position>, Error>
pub async fn get_positions( &self, inst_type: Option<InstType>, inst_id: Option<&str>, ) -> Result<Vec<Position>, Error>
Retrieve open positions.
GET /api/v5/account/positions. Authenticated. Both filters are
optional; omit them to return all positions.
§Errors
See get_balance.
Sourcepub async fn get_position_risk(
&self,
inst_type: Option<InstType>,
) -> Result<Vec<PositionRisk>, Error>
pub async fn get_position_risk( &self, inst_type: Option<InstType>, ) -> Result<Vec<PositionRisk>, Error>
Retrieve account position risk.
GET /api/v5/account/account-position-risk. Authenticated.
§Errors
See get_balance.
Sourcepub async fn get_account_config(&self) -> Result<Vec<AccountConfig>, Error>
pub async fn get_account_config(&self) -> Result<Vec<AccountConfig>, Error>
Sourcepub async fn get_account_bills(
&self,
request: &BillsRequest,
) -> Result<Vec<AccountBill>, Error>
pub async fn get_account_bills( &self, request: &BillsRequest, ) -> Result<Vec<AccountBill>, Error>
Sourcepub async fn get_account_bills_archive(
&self,
request: &BillsArchiveRequest,
) -> Result<Vec<AccountBill>, Error>
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
See get_balance.
Sourcepub async fn set_position_mode(
&self,
pos_mode: &str,
) -> Result<Vec<SetPositionModeResult>, Error>
pub async fn set_position_mode( &self, pos_mode: &str, ) -> Result<Vec<SetPositionModeResult>, Error>
Set the account position mode.
POST /api/v5/account/set-position-mode. Authenticated.
§Errors
See get_balance.
Sourcepub async fn set_leverage(
&self,
request: &SetLeverageRequest,
) -> Result<Vec<LeverageInfo>, Error>
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
See get_balance.
Sourcepub async fn get_leverage(
&self,
request: &LeverageRequest,
) -> Result<Vec<LeverageInfo>, Error>
pub async fn get_leverage( &self, request: &LeverageRequest, ) -> Result<Vec<LeverageInfo>, Error>
Retrieve leverage settings.
GET /api/v5/account/leverage-info. Authenticated.
§Errors
See get_balance.
Sourcepub async fn get_max_order_size(
&self,
request: &MaxOrderSizeRequest,
) -> Result<Vec<MaxOrderSize>, Error>
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
See get_balance.
Sourcepub async fn get_max_avail_size(
&self,
request: &MaxAvailableSizeRequest,
) -> Result<Vec<MaxAvailableSize>, Error>
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
See get_balance.
Sourcepub async fn adjust_margin(
&self,
request: &AdjustMarginRequest,
) -> Result<Vec<AdjustMarginResult>, Error>
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
See get_balance.
Sourcepub async fn get_fee_rates(
&self,
request: &FeeRatesRequest,
) -> Result<Vec<FeeRate>, Error>
pub async fn get_fee_rates( &self, request: &FeeRatesRequest, ) -> Result<Vec<FeeRate>, Error>
Sourcepub async fn get_account_instruments(
&self,
request: &AccountInstrumentsRequest,
) -> Result<Vec<AccountInstrument>, Error>
pub async fn get_account_instruments( &self, request: &AccountInstrumentsRequest, ) -> Result<Vec<AccountInstrument>, Error>
Retrieve account-available instruments.
GET /api/v5/account/instruments. Authenticated.
§Errors
See get_balance.
Sourcepub async fn get_max_loan(
&self,
request: &MaxLoanRequest,
) -> Result<Vec<MaxLoan>, Error>
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
See get_balance.
Sourcepub async fn get_interest_accrued(
&self,
request: &InterestAccruedRequest,
) -> Result<Vec<InterestAccrued>, Error>
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
See get_balance.
Sourcepub async fn get_interest_rate(
&self,
ccy: Option<&str>,
) -> Result<Vec<InterestRate>, Error>
pub async fn get_interest_rate( &self, ccy: Option<&str>, ) -> Result<Vec<InterestRate>, Error>
Sourcepub async fn set_greeks(
&self,
greeks_type: &str,
) -> Result<Vec<SetGreeksResult>, Error>
pub async fn set_greeks( &self, greeks_type: &str, ) -> Result<Vec<SetGreeksResult>, Error>
Set the greeks display type.
POST /api/v5/account/set-greeks. Authenticated.
§Errors
See get_balance.
Sourcepub async fn set_isolated_mode(
&self,
iso_mode: &str,
mode_type: &str,
) -> Result<Vec<SetIsolatedModeResult>, Error>
pub async fn set_isolated_mode( &self, iso_mode: &str, mode_type: &str, ) -> Result<Vec<SetIsolatedModeResult>, Error>
Set isolated margin transfer mode.
POST /api/v5/account/set-isolated-mode. Authenticated.
§Errors
See get_balance.
Sourcepub async fn get_max_withdrawal(
&self,
ccy: Option<&str>,
) -> Result<Vec<MaxWithdrawal>, Error>
pub async fn get_max_withdrawal( &self, ccy: Option<&str>, ) -> Result<Vec<MaxWithdrawal>, Error>
Retrieve maximum withdrawal amounts.
GET /api/v5/account/max-withdrawal. Authenticated.
§Errors
See get_balance.
Sourcepub async fn get_interest_limits(
&self,
request: &InterestLimitsRequest,
) -> Result<Vec<InterestLimit>, Error>
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
See get_balance.
Sourcepub async fn get_simulated_margin(
&self,
request: &SimulatedMarginRequest,
) -> Result<Vec<SimulatedMargin>, Error>
pub async fn get_simulated_margin( &self, request: &SimulatedMarginRequest, ) -> Result<Vec<SimulatedMargin>, Error>
Calculate simulated margin information.
POST /api/v5/account/simulated_margin. Authenticated. This is separate
from OkxClientBuilder::demo_trading,
which only toggles the OKX simulated-trading header.
§Errors
See get_balance.
Sourcepub async fn get_positions_history(
&self,
request: &PositionsHistoryRequest,
) -> Result<Vec<PositionHistory>, Error>
pub async fn get_positions_history( &self, request: &PositionsHistoryRequest, ) -> Result<Vec<PositionHistory>, Error>
Retrieve position history.
GET /api/v5/account/positions-history. Authenticated.
§Errors
See get_balance.
Sourcepub async fn get_account_position_tiers(
&self,
request: &AccountPositionTiersRequest,
) -> Result<Vec<AccountPositionTier>, Error>
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
See get_balance.
Sourcepub async fn get_risk_state(&self) -> Result<Vec<RiskState>, Error>
pub async fn get_risk_state(&self) -> Result<Vec<RiskState>, Error>
Retrieve the account risk state.
GET /api/v5/account/risk-state. Authenticated.
§Errors
See get_balance.
Sourcepub async fn set_risk_offset_type(
&self,
risk_offset_type: &str,
) -> Result<Vec<SetRiskOffsetTypeResult>, Error>
pub async fn set_risk_offset_type( &self, risk_offset_type: &str, ) -> Result<Vec<SetRiskOffsetTypeResult>, Error>
Set account risk offset type.
POST /api/v5/account/set-riskOffset-type. Authenticated.
§Errors
See get_balance.
Sourcepub async fn set_auto_loan(
&self,
auto_loan: bool,
) -> Result<Vec<SetAutoLoanResult>, Error>
pub async fn set_auto_loan( &self, auto_loan: bool, ) -> Result<Vec<SetAutoLoanResult>, Error>
Set account auto-loan mode.
POST /api/v5/account/set-auto-loan. Authenticated.
§Errors
See get_balance.
Sourcepub async fn set_account_level(
&self,
acct_lv: &str,
) -> Result<Vec<SetAccountLevelResult>, Error>
pub async fn set_account_level( &self, acct_lv: &str, ) -> Result<Vec<SetAccountLevelResult>, Error>
Set the account level.
POST /api/v5/account/set-account-level. Authenticated.
§Errors
See get_balance.
Sourcepub async fn activate_option(&self) -> Result<Vec<ActivateOptionResult>, Error>
pub async fn activate_option(&self) -> Result<Vec<ActivateOptionResult>, Error>
Activate option trading.
POST /api/v5/account/activate-option. Authenticated.
§Errors
See get_balance.
Sourcepub async fn position_builder(
&self,
request: &PositionBuilderRequest,
) -> Result<Vec<PositionBuilderResult>, Error>
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
See get_balance.
Sourcepub async fn spot_manual_borrow_repay(
&self,
request: &SpotManualBorrowRepayRequest,
) -> Result<Vec<SpotBorrowRepayResult>, Error>
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
See get_balance.
Sourcepub async fn set_auto_repay(
&self,
request: &SetAutoRepayRequest,
) -> Result<Vec<SetAutoRepayResult>, Error>
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
See get_balance.
Sourcepub async fn get_spot_borrow_repay_history(
&self,
request: &SpotBorrowRepayHistoryRequest,
) -> Result<Vec<SpotBorrowRepayHistory>, Error>
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
See get_balance.
Sourcepub async fn set_auto_earn(
&self,
request: &SetAutoEarnRequest,
) -> Result<Vec<SetAutoEarnResult>, Error>
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
See get_balance.