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.2.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.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pionex_py-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 50f061b7aeef923053b1e2d2338eaf8acf9e94761dfcc7060a7cf1e1ccb87bcb
MD5 96b5e0124b950f0e4eeda932d8136bfa
BLAKE2b-256 e1887b34d245875b3662c78cf808de516b360ef96f3214b98e9afbc1225fb642

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pionex_py-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 34becd36e649afac19d97305ca61e7fdf26c320504849993b2c5b802e2f3c459
MD5 6f1a9894094211861dcd23f77d40a1e7
BLAKE2b-256 6fdc7ae94be572b03ccf08460e8fce23f97dd0721e265e2c75095710820b440d

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