You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frombingximportBingXClient# Initialize the clientclient=BingXClient(
api_key="your_api_key_here",
api_secret="your_api_secret_here",
signature_encoding="base64"# or "hex"
)
Common Operations
1. Get Market Data
# Get current BTC priceprice=client.market().get_latest_price("BTC-USDT")
print(f"BTC Price: {price['data']['price']}")
# Get 24hr tickerticker=client.market().get_24hr_ticker("BTC-USDT")
# Get order bookdepth=client.market().get_depth("BTC-USDT", 20)
# Get candlesticksklines=client.market().get_klines("BTC-USDT", "1h", 100)
2. Account Information
# Get balancebalance=client.account().get_balance()
# Get positionspositions=client.account().get_positions()
# Set leverageclient.account().set_leverage("BTC-USDT", "BOTH", 10)
# Get open ordersopen_orders=client.trade().get_open_orders("BTC-USDT")
# Cancel orderclient.trade().cancel_order("BTC-USDT", "order_id")
# Cancel all ordersclient.trade().cancel_all_orders("BTC-USDT")