Skip to main content

BingX REST API Python implementation

Project description

Updated 1st Oct 2023

https://img.shields.io/pypi/v/py-bingx.svg https://img.shields.io/pypi/l/py-bingx.svg

py-bingx is an unofficial Python wrapper for the BingX Perpetual Swap API. I am not affiliated with BingX.

TODO

  • Add Response exception handling.

  • Implement the remaining less important endpoints.

Usage

Register an account on BingX.

Create an API and make sure you copy you Secret Key before leaving the page.

pip install py-bingx
from bingx.api import BingxAPI

...

API_KEY = '<api_public_key>'
SECRET_KEY = '<api_secret_key>'

# It is faster and more efficient to use local timestamps. If you are getting an error try using "server" timestamp.
bingx = BingxAPI(API_KEY, SECRET_KEY, timestamp="local")
order_data = bingx.open_market_order('FLOKI-USDT', 'LONG', 121220, tp="0.00001800", sl="0.00001700")

Functions

py-bingx was written with the goal of being user-friendly. Feel free to ask your questions and state any bugs/issues with the code.

You can find the list of py-bingx functions below:

Market Data Functions

  • get_all_contracts() - Gets a list of all contracts/trading pairs available on Bingx

  • get_latest_price(pair) - Gets the latest price for a trading pair

  • get_market_depth(pair, limit) - Gets the order book depth data for a trading pair

  • get_latest_trade(pair) - Gets recent trades for a trading pair

  • get_latest_funding(pair) - Gets latest funding rate for a trading pair

  • get_index_price(pair) - Gets index price for a trading pair

  • get_market_price(pair) - Gets market price for a trading pair

  • get_funding_history(pair) - Gets historical funding rate data for a trading pair

  • get_kline_data(pair, interval, start_time, end_time, limit) - Gets candlestick/kline data for a trading pair

  • get_open_positions(pair) - Gets open interest data for a trading pair

  • get_tiker(pair) - Gets ticker data including 24hr prices and volumes

  • get_current_optimal_price(pair) - Gets best bid and offer prices for a trading pair

Account Data Functions

  • get_perpetual_balance() - Get user account balance info

  • get_my_perpetual_swap_positions(pair) - Get user open positions for a trading pair

  • get_fee_rate() - Get fee rate for trading

Trading Functions

  • open_market_order() - Opens a market order to buy/sell a trading pair

  • close_market_order() - Closes an open market order

  • place_trigger_market_order() - Places a stop-trigger market order

  • open_limit_order() - Opens a limit order for a trading pair

  • close_limit_order() - Closes an open limit order

  • place_trigger_limit_order() - Places a stop-trigger limit order

  • place_trailing_stop_order() - Places a trailing stop order

  • place_test_order() - Places a test order that does not execute

  • close_all_positions() - Closes all open positions for user

  • cancel_order() - Cancels a pending order

  • cancel_all_orders_of_symbol() - Cancels all pending orders for a trading pair

  • cancel_batch_orders() - Cancels multiple pending orders

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-bingx-0.4.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

py_bingx-0.4-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file py-bingx-0.4.tar.gz.

File metadata

  • Download URL: py-bingx-0.4.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/41.2.0 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/2.7.18

File hashes

Hashes for py-bingx-0.4.tar.gz
Algorithm Hash digest
SHA256 cc637f814569c9bb90f4e5f45f7114e82faf2aadbda07763e8cd99befe8e6354
MD5 82d46784552d3cf2f02cec29e0114b70
BLAKE2b-256 726e8fb87ee015574c37d1b866f0a350593ad97a278e5da291620580160a5d47

See more details on using hashes here.

File details

Details for the file py_bingx-0.4-py3-none-any.whl.

File metadata

  • Download URL: py_bingx-0.4-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/41.2.0 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/2.7.18

File hashes

Hashes for py_bingx-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c3f7f08844771bfbff7ac98f6918864945e2c9adb8caa410b12602ad50023038
MD5 c8fb9c072c108bac34da47aaf88dc14b
BLAKE2b-256 67f00f894a6c003ffcc881c876aa7cd36f067e5369a323427a1d344ff2409f36

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page