PyCryptoEx
[!CAUTION]
This project is currently in alpha version and may have critical changes
A Python library providing a clients for interacting with various APIs of cryptocurrency exchanges for trading and accessing market data.
Installation
pip install -U pycryptoex
Choose and install one or more supported crypto exchanges:
pycryptoex [names ...]
For example:
pycryptoex bybit kucoin
Install from Github main
pip install -U git+https://github.com/ren3104/pycryptoex@main
pycryptoex [names ...] --update --version main
Quick Start
import asyncio
from pycryptoex import KuCoin, Bybit
async def handler(json_data):
print(json_data)
async def main():
kucoin = KuCoin()
async with kucoin:
await kucoin.request(...)
bybit = Bybit(
api_key="YOUR_API_KEY",
secret="YOUR_API_SECRET"
)
async with bybit:
await bybit.request(..., signed=True)
kucoin_public_ws = await kucoin.create_websocket_stream()
await kucoin_public_ws.start()
topic = "/market/candles:BTC-USDT_1min"
await kucoin_public_ws.subscribe_callback(topic, handler)
await kucoin_public_ws.unsubscribe_callback(topic, handler)
await kucoin_public_ws.unsubscribe(topic)
await kucoin_public_ws.close()
kucoin_private_ws = await kucoin.create_websocket_stream(private=True)
await kucoin_private_ws.start()
await kucoin_private_ws.subscribe_callback("/account/balance", handler)
while not kucoin_public_ws.closed or not kucoin_private_ws.closed:
await asyncio.sleep(0.1)
Supported Crypto Exchanges
Exchange | Api Client | Websocket Stream Manager |
---|
Bybit | + | - |
KuCoin | + | + |