py-bingx-d


Namepy-bingx-d JSON
Version 0.1 PyPI version JSON
download
home_pagehttps://github.com/rikhtehgaran/py-bingx-d
SummaryBingX REST API Python implementation Pluse
upload_time2024-03-04 13:34:59
maintainer
docs_urlNone
authorDanial Rikhteh Garan
requires_python
licenseMIT
keywords bingx api cryptocurrency trading btc eth rest exchange
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==================
This is py-bingx-d
==================

Updated 4 March 2024 โฐ

.. image:: https://img.shields.io/pypi/v/py-bingx.svg
    :target: https://pypi.python.org/pypi/py-bingx

.. image:: https://img.shields.io/pypi/l/py-bingx.svg 
    :target: https://pypi.python.org/pypi/py-bingx

.. image:: https://img.shields.io/github/stars/amirinsight/py-bingx.svg?style=social&label=Stars 
   :target: https://github.com/amirinsight/py-bingx
   :alt: Star This Project


py-bingx-d is developed (`py-bingx package <https://github.com/amirinsight/py-bingx>`_) an unofficial Python wrapper for the `BingX Perpetual Swap API <https://bingx-api.github.io/docs/swap/introduce.html>`_. You can use this package to create trading bots. Make sure to read my `disclaimer <https://github.com/rikhtehgaran/py-bingx#disclaimer>`_ and consider starring this project.

Usage
-----

Register an account on `BingX <https://bingx.com/en-us/register>`_. 

`Create an API <https://bingx.com/en-us/account/api>`_
and make sure you copy your Secret Key before leaving the page. ๐Ÿ—

.. code:: bash

    pip install py-bingx-d

.. code:: python

    from bingx.api import BingxAPI 

    ...

    # Please note that it is smarter to use environment variables than hard coding your keys into your code.
    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, demo=False, timestamp="local") # For use VST demo account set demo to True
    order_data = bingx.open_market_order('BTC-USDT', 'LONG', 0.01, tp="63277", sl="60658")

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 โŒ

TODO ๐Ÿ“
-------

This package is functional but the following list should be achieved pre release:

- Add Response exception handling. ๐Ÿ’ฅ
- Implement the remaining less important endpoints. ๐Ÿ”ง
- Leverage async/await (Use async methods and aiohttp to make requests asynchronously rather than blocking.) โšก
- Add proper logging. (Add a structured logger like loguru to log requests, errors etc.) ๐Ÿ“
- Write tests. (Add unit and integration tests using pytest) โœ…
- Refactor code to be more pythonic and modular. ๐Ÿ
- Add WS support to report order updates.

Disclaimer ๐Ÿ“œ
-------------

This open source code is provided "as is" without warranty of any kind. The author makes no representations or warranties about the accuracy, completeness, or suitability of this code for any purpose. Use of this code is at your own risk.

The author is not affiliated with BingX and is not liable for any damages arising from the use of this code. Cryptocurrency trading involves substantial risk of loss. You should not rely on this code as your sole method of trading. No promises or guarantees are made regarding the performance of any trades executed using this code. Always do your own research and due diligence before executing any trades.

This code is still under developement and may contain bugs and errors. Use at your own discretion.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rikhtehgaran/py-bingx-d",
    "name": "py-bingx-d",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "bingx api cryptocurrency trading btc eth rest exchange",
    "author": "Danial Rikhteh Garan",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/15/90/42c0520d4a534374c547fd3970765e2c69282e3f5a109b383f12a4c2e313/py-bingx-d-0.1.tar.gz",
    "platform": null,
    "description": "==================\nThis is py-bingx-d\n==================\n\nUpdated 4 March 2024 \u23f0\n\n.. image:: https://img.shields.io/pypi/v/py-bingx.svg\n    :target: https://pypi.python.org/pypi/py-bingx\n\n.. image:: https://img.shields.io/pypi/l/py-bingx.svg \n    :target: https://pypi.python.org/pypi/py-bingx\n\n.. image:: https://img.shields.io/github/stars/amirinsight/py-bingx.svg?style=social&label=Stars \n   :target: https://github.com/amirinsight/py-bingx\n   :alt: Star This Project\n\n\npy-bingx-d is developed (`py-bingx package <https://github.com/amirinsight/py-bingx>`_) an unofficial Python wrapper for the `BingX Perpetual Swap API <https://bingx-api.github.io/docs/swap/introduce.html>`_. You can use this package to create trading bots. Make sure to read my `disclaimer <https://github.com/rikhtehgaran/py-bingx#disclaimer>`_ and consider starring this project.\n\nUsage\n-----\n\nRegister an account on `BingX <https://bingx.com/en-us/register>`_. \n\n`Create an API <https://bingx.com/en-us/account/api>`_\nand make sure you copy your Secret Key before leaving the page. \ud83d\udddd\n\n.. code:: bash\n\n    pip install py-bingx-d\n\n.. code:: python\n\n    from bingx.api import BingxAPI \n\n    ...\n\n    # Please note that it is smarter to use environment variables than hard coding your keys into your code.\n    API_KEY = '<api_public_key>' \n    SECRET_KEY = '<api_secret_key>'\n\n    # It is faster and more efficient to use local timestamps. If you are getting an error try using \"server\" timestamp.\n    bingx = BingxAPI(API_KEY, SECRET_KEY, demo=False, timestamp=\"local\") # For use VST demo account set demo to True\n    order_data = bingx.open_market_order('BTC-USDT', 'LONG', 0.01, tp=\"63277\", sl=\"60658\")\n\nFunctions \ud83e\uddf0\n------------\n\npy-bingx was written with the goal of being user-friendly. Feel free to ask your questions and state any bugs/issues with the code.\n\nYou can find the list of py-bingx functions below: \n\nMarket Data Functions \ud83d\udcb9\n------------------------\n\n- ``get_all_contracts()`` - Gets a list of all contracts/trading pairs available on Bingx \n- ``get_latest_price(pair)`` - Gets the latest price for a trading pair \ud83d\udcb1\n- ``get_market_depth(pair, limit)`` - Gets the order book depth data for a trading pair \ud83d\udcca\n- ``get_latest_trade(pair)`` - Gets recent trades for a trading pair \ud83d\udcb8\n- ``get_latest_funding(pair)`` - Gets latest funding rate for a trading pair \ud83d\udcb5\n- ``get_index_price(pair)`` - Gets index price for a trading pair \ud83d\udcc8\n- ``get_market_price(pair)`` - Gets market price for a trading pair \ud83d\udcc9\n- ``get_funding_history(pair)`` - Gets historical funding rate data for a trading pair \ud83d\udcdc\n- ``get_kline_data(pair, interval, start_time, end_time, limit)`` - Gets candlestick/kline data for a trading pair \ud83d\udd6f\n- ``get_open_positions(pair)`` - Gets open interest data for a trading pair \ud83d\udc40\n- ``get_tiker(pair)`` - Gets ticker data including 24hr prices and volumes \ud83d\udce3\n- ``get_current_optimal_price(pair)`` - Gets best bid and offer prices for a trading pair \ud83d\udcb0\n\nAccount Data Functions  \ud83d\udc64\n--------------------------\n\n- ``get_perpetual_balance()`` - Get user account balance info \ud83d\udcb3\n- ``get_my_perpetual_swap_positions(pair)`` - Get user open positions for a trading pair \ud83d\udcc8\n- ``get_fee_rate()`` - Get fee rate for trading \ud83d\udcb8\n\nTrading Functions \ud83d\udcc8\n--------------------\n\n- ``open_market_order()`` - Opens a market order to buy/sell a trading pair \ud83d\udcb9\n- ``close_market_order()`` - Closes an open market order \u274c\n- ``place_trigger_market_order()`` - Places a stop-trigger market order \u23f1\n- ``open_limit_order()`` - Opens a limit order for a trading pair \ud83c\udfaf\n- ``close_limit_order()`` - Closes an open limit order \u274c\n- ``place_trigger_limit_order()`` - Places a stop-trigger limit order \u23f1\n- ``place_trailing_stop_order()`` - Places a trailing stop order \ud83d\udcc9\n- ``place_test_order()`` - Places a test order that does not execute \ud83e\uddea\n- ``close_all_positions()`` - Closes all open positions for user  \u274c\n- ``cancel_order()`` - Cancels a pending order \u274c\n- ``cancel_all_orders_of_symbol()`` - Cancels all pending orders for a trading pair \u274c\n- ``cancel_batch_orders()`` - Cancels multiple pending orders \u274c\n\nTODO \ud83d\udcdd\n-------\n\nThis package is functional but the following list should be achieved pre release:\n\n- Add Response exception handling. \ud83d\udca5\n- Implement the remaining less important endpoints. \ud83d\udd27\n- Leverage async/await (Use async methods and aiohttp to make requests asynchronously rather than blocking.) \u26a1\n- Add proper logging. (Add a structured logger like loguru to log requests, errors etc.) \ud83d\udcdd\n- Write tests. (Add unit and integration tests using pytest) \u2705\n- Refactor code to be more pythonic and modular. \ud83d\udc0d\n- Add WS support to report order updates.\n\nDisclaimer \ud83d\udcdc\n-------------\n\nThis open source code is provided \"as is\" without warranty of any kind. The author makes no representations or warranties about the accuracy, completeness, or suitability of this code for any purpose. Use of this code is at your own risk.\n\nThe author is not affiliated with BingX and is not liable for any damages arising from the use of this code. Cryptocurrency trading involves substantial risk of loss. You should not rely on this code as your sole method of trading. No promises or guarantees are made regarding the performance of any trades executed using this code. Always do your own research and due diligence before executing any trades.\n\nThis code is still under developement and may contain bugs and errors. Use at your own discretion.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "BingX REST API Python implementation Pluse",
    "version": "0.1",
    "project_urls": {
        "Homepage": "https://github.com/rikhtehgaran/py-bingx-d"
    },
    "split_keywords": [
        "bingx",
        "api",
        "cryptocurrency",
        "trading",
        "btc",
        "eth",
        "rest",
        "exchange"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73ee50c9e0da1185d08b2b078d8fb213f80a29e66a846aba8b1b39527a4c7851",
                "md5": "ef9ba9d13c7485dbdd577189cfc149b0",
                "sha256": "0a7d6c7ec96cbfe342a14053cf91d4535839bc0fd27f1d1da425c46bf428d70e"
            },
            "downloads": -1,
            "filename": "py_bingx_d-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ef9ba9d13c7485dbdd577189cfc149b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11102,
            "upload_time": "2024-03-04T13:34:57",
            "upload_time_iso_8601": "2024-03-04T13:34:57.801125Z",
            "url": "https://files.pythonhosted.org/packages/73/ee/50c9e0da1185d08b2b078d8fb213f80a29e66a846aba8b1b39527a4c7851/py_bingx_d-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "159042c0520d4a534374c547fd3970765e2c69282e3f5a109b383f12a4c2e313",
                "md5": "80ced03e1a99548706fd4b70c871c8e8",
                "sha256": "f9f80be52ce8df2ae31e1caf6ef7a47ea4a98603d9f3337ef01295d5c8e3912d"
            },
            "downloads": -1,
            "filename": "py-bingx-d-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "80ced03e1a99548706fd4b70c871c8e8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12621,
            "upload_time": "2024-03-04T13:34:59",
            "upload_time_iso_8601": "2024-03-04T13:34:59.383642Z",
            "url": "https://files.pythonhosted.org/packages/15/90/42c0520d4a534374c547fd3970765e2c69282e3f5a109b383f12a4c2e313/py-bingx-d-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-04 13:34:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rikhtehgaran",
    "github_project": "py-bingx-d",
    "github_not_found": true,
    "lcname": "py-bingx-d"
}
        
Elapsed time: 0.19389s