Skip to main content

Connector library for Pionex REST and WS api.

Project description

Pionex to Python

pip install pionex_python

Description

Connector library for Pionex Restful and Websocket api. Closely resembles PionexAPI Docs for intuitive implementation. All function names are identical to the endpoints in the documentation.

Examples

rest public

from pionex_python.restful.Common import Common

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

print(market_data)

rest private

from pionex_python.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_python.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

from pionex_python.websocket.PublicStream import PublicStream
from time import sleep

#stream = PrivateStream(key, secret)
stream = PublicStream()

def onMessage(msg):
    print(msg)

stream.subscribe(onMessage=onMessage, topic='TRADE',symbol='BTC_USDT')
stream.subscribe(onMessage=onMessage, topic='TRADE',symbol='ETH_USDT')
sleep(5)
stream.unsubscribe(topic='TRADE',symbol='BTC_USDT')
stream.unsubscribe(topic='TRADE',symbol='ETH_USDT')

Demultiplexing Topic and Symbol

The websocket client demultiplexes multiple streams over a single connection. Each subscription to a unique (topic, symbol) pair can have its own callback function.

Contributing

Contributions are welcome! Anyone can fork the repository, make changes, and submit a pull request for review and merging.


Motivation

I initially developed this project to learn Python packaging, implement a WebSocket client, and gain experience with marketplace APIs.

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_python-1.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

pionex_python-1.1.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file pionex_python-1.1.1.tar.gz.

File metadata

  • Download URL: pionex_python-1.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Linux/6.6.107-1-MANJARO

File hashes

Hashes for pionex_python-1.1.1.tar.gz
Algorithm Hash digest
SHA256 158d5c73045e169f44ce2b9c26b3b6b5f9aa336683f3190ad995586f71ecc9c7
MD5 de2fdea24bc40ade998ad0d9808fbb20
BLAKE2b-256 9b7f73d300054267baadbb4ebd3c5264020b3fc07881cc1fa4e68d7781d6683c

See more details on using hashes here.

File details

Details for the file pionex_python-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: pionex_python-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Linux/6.6.107-1-MANJARO

File hashes

Hashes for pionex_python-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2dfa14ba9d5a0f85efca28d5f9b721f1a9889567368eb9c29396573e2137d040
MD5 e60092374109d3b8cd5cfa744108e96f
BLAKE2b-256 774da8c78b31d1a9384f6378963ff975f6b975af028b9b5c707392f9beaaa757

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