Pionex to Python
Python connector for the Pionex API — REST, WebSocket, bots, dual investment and high-level portfolio helpers in one package. Tracks the official OpenAPI spec (pionex-official/pionex-open-api).
Installation
pip install pionex_py
What's included
| Module | Coverage | Auth |
|---|---|---|
Common |
Symbol metadata (/api/v1/common/symbols) |
no |
Markets |
Trades, depth, tickers, book tickers, klines (+ paging) | no |
Account |
Balances + per-coin / portfolio helpers | yes |
Orders |
Spot orders: new, mass, cancel, lookup, fills, market/limit helpers, wait_for_order |
yes |
Trade |
High-level façade: portfolio value/weights, daily rebalancer with dry-run | yes |
Bot |
Spot Grid, Futures Grid, Smart Copy, custom signal listener | yes |
EarnDual |
Dual Investment — products, prices, invest/revoke/collect | mixed |
PublicStream / PrivateStream |
Trade / Depth / Order / Fill / Balance WebSocket | mixed |
Implements every endpoint exposed by the official 1.x OpenAPI spec for the Trade, Bot, Earn-Dual and WebSocket APIs (Futures and Partner APIs are invite-only and not included).
30-second tour
from pionex_python import Common, Markets, Account, Orders, Trade, Bot, EarnDual
# Public
print(Markets().get_price('BTC_USDT'))
print(Common().list_symbols(market_type='SPOT')[:5])
# Authenticated trading
orders = Orders('KEY', 'SECRET')
orders.market_buy('BTC_USDT', amount=20) # spend 20 USDT
orders.limit_sell('BTC_USDT', price=80000, size=0.0002)
# Portfolio rebalance — what the daily rebalancer is built on
trade = Trade('KEY', 'SECRET', quote='USDT')
trade.execute_rebalance({'BTC': 0.5, 'ETH': 0.3, 'USDT': 0.2}, dry_run=True)
# Spot-grid bot
bot = Bot('KEY', 'SECRET')
print(bot.get_spot_grid_ai_strategy('BTC', 'USDT')) # AI suggestion
For a full walkthrough of every module — including bot creation, custom signal pushing, dual-investment subscriptions and a daily rebalancer skeleton — see EXAMPLES.md.
Daily portfolio rebalancer
from pionex_python import Trade
trade = Trade(api_key, api_secret, quote='USDT')
# 1. From your TA + sentiment pipeline
target = {'BTC': 0.50, 'ETH': 0.30, 'USDT': 0.20}
# 2. Compute the diff between current and target weights
plan = trade.compute_rebalance_orders(target, threshold=0.01)
# 3. Always preview first
print(trade.execute_rebalance(plan, dry_run=True))
# 4. When ready
# trade.execute_rebalance(plan, dry_run=False)
execute_rebalance automatically:
- sells overweight positions before buying underweight ones (so quote cash is available)
- rounds sizes/amounts to each symbol's
basePrecision/quotePrecision - skips orders below
minNotional/minTradeSize - supports
dry_run=Trueso you can iterate safely
API key
-
Create the key at https://www.pionex.com/en/apiKey.
-
For a rebalancer enable Read + Trade only — never Withdraw.
-
Restrict the key to your server's IP.
-
Export it:
export PIONEX_KEY=... export PIONEX_SECRET=...
Versioning
Tracks the published Pionex Open API spec. The library is in pionex_python.__version__.
TODO
- WebSocket auto-reconnect
- Retry/backoff on REST 5xx
- CLI for ad-hoc trading
- Futures REST coverage (gated by Pionex invite-only access)
Contributing
PRs welcome — issues and feature requests at https://github.com/alejandrorodm/pionex_py/issues.
License
MIT — see LICENSE.
Release files for pionex-py 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pionex_py-1.2.0.tar.gz | 20.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pionex_py-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:46.0 kB
Release files / pionex_py-1.2.0.tar.gz
| Download URL | pionex_py-1.2.0.tar.gz |
|---|---|
| Size | 20.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2c672dee9bbd947d25a14f87f47800647dc51be3181d5d3a764ec30c9c9d4ff
|
|
BLAKE2b-256 checksum How to use checksums |
06c324787b0f8ae107296a8edb7a497116f2f8b06a340e074e3d24ca98bc71ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / pionex_py-1.2.0-py3-none-any.whl
| Download URL | pionex_py-1.2.0-py3-none-any.whl |
|---|---|
| Size | 25.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53f22c5ea208d0f4b5185686868f60f2ccb68dd312c0ec4f482bd4b78a0d71bc
|
|
BLAKE2b-256 checksum How to use checksums |
2b0edd30c13b9259f7550ec626ed97e7015b197fadc377af2b5deb85ffa3accc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|