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>
impl<'a, T: Transport> Account<'a, T>
Sourcepub async fn get_balance(
&self,
request: BalanceRequest<'_>,
) -> Result<Vec<AccountBalance>, Error>
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.
Sourcepub async fn get_positions(
&self,
request: &PositionsRequest<'_>,
) -> Result<Vec<Position>, Error>
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.
Sourcepub async fn get_position_risk(
&self,
request: &PositionRiskRequest,
) -> Result<Vec<PositionRisk>, Error>
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.
Sourcepub async fn get_account_config(&self) -> Result<Vec<AccountConfig>, Error>
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.
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>
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.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
Sourcepub async fn apply_bills_history_archive(
&self,
request: &ApplyBillsHistoryArchiveRequest<'_>,
) -> Result<Vec<ApplyBillsHistoryArchiveResult>, Error>
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.
Sourcepub async fn get_bills_history_archive(
&self,
request: &BillsHistoryArchiveRequest<'_>,
) -> Result<Vec<BillsHistoryArchiveFile>, Error>
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.
Sourcepub async fn get_bill_subtypes(
&self,
request: &BillSubtypesRequest<'_>,
) -> Result<Vec<BillSubtypeMapping>, Error>
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.
Sourcepub async fn set_position_mode(
&self,
request: &SetPositionModeRequest<'_>,
) -> Result<Vec<SetPositionModeResult>, Error>
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.
Sourcepub async fn set_collateral_assets(
&self,
request: &SetCollateralAssetsRequest<'_>,
) -> Result<Vec<SetCollateralAssetsResult>, Error>
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.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
Sourcepub async fn get_adjust_leverage_info(
&self,
request: &AdjustLeverageInfoRequest<'_>,
) -> Result<Vec<AdjustLeverageInfo>, Error>
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.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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>
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.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
Sourcepub async fn get_interest_rate(
&self,
request: BalanceRequest<'_>,
) -> Result<Vec<InterestRate>, Error>
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.
Sourcepub async fn set_greeks(
&self,
request: &SetGreeksRequest<'_>,
) -> Result<Vec<SetGreeksResult>, Error>
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.
Sourcepub async fn set_isolated_mode(
&self,
request: &SetIsolatedModeRequest<'_>,
) -> Result<Vec<SetIsolatedModeResult>, Error>
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.
Sourcepub async fn get_max_withdrawal(
&self,
request: BalanceRequest<'_>,
) -> Result<Vec<MaxWithdrawal>, Error>
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.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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.
§Errors
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
Sourcepub async fn get_greeks(
&self,
request: BalanceRequest<'_>,
) -> Result<Vec<Greek>, Error>
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.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
Sourcepub async fn set_risk_offset_amount(
&self,
request: &SetRiskOffsetAmountRequest<'_>,
) -> Result<Vec<SetRiskOffsetAmountResult>, Error>
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.
Sourcepub async fn set_auto_loan(
&self,
request: &SetAutoLoanRequest,
) -> Result<Vec<SetAutoLoanResult>, Error>
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.
Sourcepub async fn set_account_level(
&self,
request: &SetAccountLevelRequest<'_>,
) -> Result<Vec<SetAccountLevelResult>, Error>
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.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.
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
Returns RestError::Configuration if no credentials are set,
RestError::Okx on a non-zero OKX code, or transport/decode errors.