Skip to main content

An open source, unofficial Python client for the BitUnix cryptocurrency exchange API

Project description

Bitunix Python Client

An unofficial opensource Python client for interacting with the Bitunix cryptocurrency exchange API.

Version 0.1.2 updates

  • add better documentation
  • add license
  • link to github for license and contributing

ToDo

  • add a WebSocket client
  • add technical indicators for Websocket Streams
  • add trading strategies

Installation

You can install the BitUnix Client package using pip:

pip install bitunix

Usage

from bitunix import BitunixClient

# Initialize the client with your API key and secret
client = BitunixClient(api_key, api_secret)
  
# Get latest price for BTC/USDT
latest_price = client.get_latest_price("BTCUSDT")
print(f"Latest BTC/USDT price: {latest_price}")
  
# Get depth data for ETH/USDT with precision 4
depth_data = client.get_depth_data("ETHUSDT", 4)
print(f"ETH/USDT depth data: {depth_data}")
  
# Get 1-hour K-line data for BNB/USDT
kline_data = client.get_kline_data("BNBUSDT", "60")
print(f"BNB/USDT 1-hour K-line data: {kline_data}")
  
# Get all trading pairs
trading_pairs = client.get_trading_pairs()
print(f"Trading pairs: {trading_pairs}")
  
# Get rate data
rate_data = client.get_rate_data()
print(f"Rate data: {rate_data}")
  
# Get token data
token_data = client.get_token_data()
print(f"Token data: {token_data}")
  
# Get account balance
account_balance = client.get_account_balance()
print(f"Account balance: {account_balance}")
  
# Place a market buy order, note that price is ignored. For buy side amount is in the denominated currency, ex for BTCUSDT a volume of 100 is 100 USDT worth of BTC
order = client.place_order(side=2, order_type=2, volume="100",price="0", symbol="BTCUSDT")
print(f"Placed order: {order}")

# Place a market sell order, note that price is ignored. For sell side volume is in the cryptocurrency to be traded, ex for BTCUSDTa volume of 0.5 is 0.5 BTC
order = client.place_order(side=1, order_type=2, volume="0.5",price="0", symbol="BTCUSDT")
print(f"Placed order: {order}")


# Place a limit buy order, note that volume is in the cryptocurrency to be traded, ex for BTCUSDT a volume of 0.001 is 0.001 BTC
order = client.place_order(side=2, order_type=1, volume="0.001",price="30000", symbol="BTCUSDT")
print(f"Placed order: {order}")


# Place a limit sell order, note that volume is in the cryptocurrency to be traded, ex for BTCUSDT a volume of 0.001 is 0.001 BTC
order = client.place_order(side=1, order_type=1, volume="0.001",price="30000", symbol="BTCUSDT")
print(f"Placed order: {order}")

# Place batch orders
batch_orders = client.place_batch_orders([
    {"side": 2, "type": 1, "volume": "0.001", "price": "30000", "symbol": "BTCUSDT"},
    {"side": 1, "type": 1, "volume": "0.1", "price": "2000", "symbol": "ETHUSDT"}
])
print(f"Placed batch orders: {batch_orders}")
  
# Cancel orders
cancel_result = client.cancel_orders([
    {"orderId": "123456", "symbol": "BTCUSDT"},
    {"orderId": "789012", "symbol": "ETHUSDT"}
])
print(f"Cancelled orders: {cancel_result}")
  
# Query matching orders
matching_orders = client.query_matching_orders(order_id="123456",symbol="BTCUSDT")
print(f"Matching orders: {matching_orders}")
  
# Query order history
order_history = client.query_order_history(symbol="BTCUSDT", page=1,page_size=10)
print(f"Order history: {order_history}")
  
# Query current orders
current_orders = client.query_current_orders(symbol="BTCUSDT")
print(f"Current orders: {current_orders}")
  

Documentation

For more details, please refer to the Bitunix API documentation.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contribution

Want to contribute to this project? Please read the CONTRIBUTING.md file for more details.

Support the author of this project project:

ETH:
0xefFC273c7452B6A7753B757333FCF7022785d44E

SOL:
3FdyCqV7rebU4zJXwQ6vfb9TVkPs25y64NDkAQdSLFf6

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

bitunix-0.1.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitunix-0.1.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file bitunix-0.1.2.tar.gz.

File metadata

  • Download URL: bitunix-0.1.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for bitunix-0.1.2.tar.gz
Algorithm Hash digest
SHA256 33e08de7ebe98f7e6c7c92556b32e4aebc9d37b4194194fb941a85a44a20d944
MD5 aba4bc783c26ed19e4a95218431bd97f
BLAKE2b-256 b7dee8f6e1e694a3a9ad86bb0188efb9ec0d138250c9d9d1c85cde6e8fbd0016

See more details on using hashes here.

File details

Details for the file bitunix-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: bitunix-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for bitunix-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 10a31a3c9ae4a70f5c2a91774722e89fbf8246057e0ad0ed023ac5a85e3a8e16
MD5 30e22edf917e54704cb8743bc919a187
BLAKE2b-256 73d8b66450a66e8e021fbb58972b9975a7678cde4e06ad18e7f9a76d5c2e2f3e

See more details on using hashes here.

Supported by

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