Skip to content

Account Service

Igor Sazonov edited this page Mar 9, 2026 · 1 revision

The AccountService is a important component of the BingX Python SDK, providing the functionality required to manage your trading account. This service allows you to retrieve your account balance, monitor your positions, and configure leverage and margin settings.

Accessing the Service

To begin using the AccountService, you must first access it through your BingXClient instance:

from bingx import BingXClient

client = BingXClient(api_key="YOUR_API_KEY", api_secret="YOUR_API_SECRET")
account_service = client.account()

Core Functionalities

The AccountService is organized into several logical groups of methods, each addressing a specific aspect of account management.

Balance and Positions

These methods provide real-time insights into your account's financial status and open positions.

Method Description
get_balance() Retrieves your current account balance.
get_positions(symbol) Retrieves your open positions. A specific symbol can be provided to filter the results.
get_account_info() Retrieves comprehensive information about your trading account.

Leverage and Margin

Properly managing leverage and margin is crucial for risk management. These methods provide the tools to do so effectively.

Method Description
get_leverage(symbol) Retrieves the current leverage for a specific symbol.
set_leverage(symbol, side, leverage) Sets the leverage for a symbol and position side (LONG, SHORT, or BOTH).
get_margin_mode(symbol) Retrieves the current margin mode (ISOLATED or CROSSED).
set_margin_mode(symbol, margin_type) Sets the margin mode for a specific symbol.
set_position_margin(symbol, ...) Adjusts the margin for a specific position.

Fees, Permissions, and History

This group of methods allows you to query your account's configuration, historical data, and fee structure.

Method Description
get_trading_fees(symbol) Retrieves the trading fees for a specific symbol.
get_account_permissions() Retrieves the permissions associated with your API key.
get_api_rate_limits() Retrieves the current API rate limits for your account.
get_balance_history(asset, ...) Retrieves the historical balance changes for a specific asset.
get_deposit_history(coin, ...) Retrieves your deposit history.
get_withdraw_history(coin, ...) Retrieves your withdrawal history.

Clone this wiki locally