Skip to main content

Connector library for Pionex REST and WS API with enhanced error handling and performance.

Project description

🚀 Pionex to Python

Easily interact with the Pionex API for both REST and WebSocket connections.

📦 Installation

pip install pionex_py

📝 Description

Pionex to Python is a connector library for Pionex's REST and WebSocket API.

  • Mirrors the official Pionex API documentation for intuitive implementation.
  • Supports both public and private API endpoints.
  • Clean, modular, and easy-to-extend codebase.

Check out the GitHub project for more details.

⚡ Features

  • Full REST API support (public and private endpoints)
  • Real-time WebSocket streaming
  • Handles multiple orders with ease
  • Error handling
  • Lightweight and fast

🚀 Quickstart

📌 REST API Examples

Public Endpoint

from pionex_py.restful.Common import Common

commonClient = Common()
market_data = commonClient.market_data()

print(market_data)

Private Endpoint

from pionex_py.restful.Orders import Orders

key, secret = 'X...X', 'X...X'

ordersClient = Orders(key, secret)

order = {
    'symbol': 'BTC_USDT',
    'side': 'BUY',
    'type': 'MARKET',
    'amount': '16',
}

response = ordersClient.new_order(order=order)
print(response)
📌 Multiple Order Template
from pionex_py.restful.Orders import Orders

key, secret = 'X...X', 'X...X'

ordersClient = Orders(key, secret)

orders = [
  {
    'side': 'BUY',
    'type': 'LIMIT',
    'price': '57200',
    'size': '0.0002'
  },
  {
    'side': 'SELL',
    'type': 'LIMIT',
    'price': '60000',
    'size': '0.0002'
  }
]

response = ordersClient.new_multiple_order(symbol='BTC_USDT', orders=orders)
print(response)

📡 WebSocket Example

from pionex_py.websocket.PublicStream import PublicStream
from time import sleep

# For private streams: stream = PrivateStream(key, secret)
stream = PublicStream()

def onMessage(msg):
    print(msg)

stream.subscribe(callback=onMessage, topic='TRADE', symbol='BTC_USDT')
stream.subscribe(callback=onMessage, topic='TRADE', symbol='ETH_USDT')

sleep(5)

stream.unsubscribe(topic='TRADE', symbol='BTC_USDT')
stream.unsubscribe(topic='TRADE', symbol='ETH_USDT')

🔧 TODOs & Future Enhancements

  • Reconnection handling for WebSockets
  • Improved error handling with retries
  • More endpoint coverage
  • CLI for quick trading actions

📬 Contributions

Pull requests are welcome! If you find a bug or want to propose an enhancement, feel free to open an issue.

🛠️ License

This project is licensed under the MIT License - see the LICENSE file for details.

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

pionex_py-1.0.3.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

pionex_py-1.0.3-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file pionex_py-1.0.3.tar.gz.

File metadata

  • Download URL: pionex_py-1.0.3.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for pionex_py-1.0.3.tar.gz
Algorithm Hash digest
SHA256 dbc941982725fc8e4ed7de8fedaad272466b3440076ad56784274e7099acf6aa
MD5 eb9b25b8c71099f00582d7bb192bd5fb
BLAKE2b-256 b40bd161581d795eb878f1aca67210dec2dd4ddbfa681beb521f26ce7d73a484

See more details on using hashes here.

File details

Details for the file pionex_py-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pionex_py-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for pionex_py-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f12907dbe458fcf4da1a0118e35a156b43f52e9cb1ac56ee4389f4d6db1cd858
MD5 94b3e823df931758db65c62ea5df3a78
BLAKE2b-256 5e908731498103ecf66310381045f47dc50728f2e725574d141d15a063cfa4d7

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